So I've been writing a source generator, got it working (apart from this issue) and then discovered this problem which I tried all evening to solve, and am now thinking maybe it's not possible.
I have a project like this:
- Project: MyProject
- Nuget Package: MySourceGenerator
- Project: ChildProject
Child project has a IMyInterface type, and because MyProject references ChildProject, it can also access IMyInterface.
MyProject is the uppermost project, and it's doing source generation based upon some method calls in Asp.Net startup, so I want to keep the reference to my source generator within this project.
My problem is this: During source generation I can find TypeSymbols for the interface, but I can't find InterfaceDeclarationSyntax's. If the interface is in the uppermost project it can find them, but if it's in a child project then it can't. Calling ISymbol.DeclarationSyntaxes returns 0 items.
I need this DeclarationSyntax because I need to view the available methods, so I can source generate a class that implements this interface.
I also can't move the interface to the parent project, because other child projects depend on this type.
Is it impossible? It's annoying as apart from this one issue, my source generator was working great. But this will make it unusable for a lot of projects!