-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#471 Nested classes are not discovered by source generator #472
Conversation
|
}; | ||
|
||
public void Initialize(IncrementalGeneratorInitializationContext context) | ||
public void Initialize(IncrementalGeneratorInitializationContext context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you eliminate the one redundant space at the start, thanks 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
is this PR ok to be merged other than the space thing? |
The exclusion list got removed; the matching of derived classes is now based on searching for the interfaces including the @dj-nitehawk need your brain here; could that lead to any undesired side-effects I forgot about? |
yeah that should be alright. |
I have a project where I deliberately had to avoid "NuGet" in my namespaces, this will be perfect to see if I can now do that 😎 |
did some testing with this today and it was only discovering @nefarius if you find any issues in your project, do open up a new issue and we'll look in to it then. thanks a lot @ekspedycja for this 🙏 |
Works! namespace FastEndpoints
{
public static class DiscoveredTypes
{
public static readonly global::System.Type[] All = new global::System.Type[]
{
typeof(global::NuGetCachingProxy.Endpoints.CatchallEndpoint),
typeof(global::NuGetCachingProxy.Endpoints.PackageDownloadEndpoint),
};
}
} 👏 |
I'm glad I was able to help 🙂 One thing came to my mind but I had no chance to test it. Currently the list of available types includes FluetValidation.IValidator. I am not quite sure if this may be an issue if some externals packages implement their own Fluent Validators. In the other hand the generator is run on users code not on imported nugets so this should be fine - or maybe a good idea to test that. |
In current implementation of the Source Generator nested classes are not discovered properly. This may be an issue in case of some of Vertical Slices approaches where feature is a class that consists of multiple subclasses.
Its not an issue with Endpoint and its inheritance as when class is moved outside the top level class it is discovered properly.
The PR also simplifies the approach with discovering namespaces - IMO current approach is the way around.