Giter Club home page Giter Club logo

Comments (2)

BlackWhiteYoshi avatar BlackWhiteYoshi commented on July 28, 2024

I did not consider the possibility for nested namespaces or nested using statements, thank you for pointing this out. I fixed it in the newest version.
But be aware that only fully-qualified using statements will work. In your case you could also write your using statement with just "Models":

namespace Thaum.Gw2Api.Clients
{
    using System.Threading;
    using System.Threading.Tasks;
    using AutoInterfaceAttributes;
    using Models; // refers to "Thaum.Gw2Api.Models", but generated code will refer to just "Models"

    [AutoInterface]
    public sealed class Gw2AccountApi : IGw2AccountApi
    {

But not fully-qualified using statements are dangerous, because they can be ambiguous. For example if you create somewhere in your project the namespace “Thaum.Gw2Api.Clients.Models”, all your nested “Models” usings inside the “Thaum.Gw2Api.Clients” namespace will suddenly refer to “Thaum.Gw2Api.Clients.Models” and you get compile errors all over the place. That’s why usually using statements are always full qualified and put at the top of a file.

I also left a note in README.md: #remark

from autointerface.

thaumanovic avatar thaumanovic commented on July 28, 2024

Thanks for the quick fix!

I'm aware of the caveats with using using declarations within a namespace, it's bitten me before - so I do keep them fully-qualified, I just prefer the structure of having them within the namespace because of other languages I've worked with, so I don't foresee any issues for me.

I do need more source-generator experience, so I may in the near future submit a PR to handle both cases (i.e. generate output to match the structure of inputs), if you'd accept one?

Thanks again!

from autointerface.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.