C
C#2mo ago
CaptainToTo

✅ Include Source Generator With Library

I created a source generator for a framework I'm making. I'm trying to make the include tree look like this:
Generator -> Framework -> Application
^ ^
Generator applied to
both framework & application
Generator -> Framework -> Application
^ ^
Generator applied to
both framework & application
I'm including each like this:
application csproj:
<ProjectReference Include="../Framework/Framework.csproj" />
application csproj:
<ProjectReference Include="../Framework/Framework.csproj" />
framework csproj:
<ProjectReference Include="../Generator/Generator.csproj" OutputItemType="analyzer" ReferenceOutputAssembly="false" />
framework csproj:
<ProjectReference Include="../Generator/Generator.csproj" OutputItemType="analyzer" ReferenceOutputAssembly="false" />
generator csproj:
<None Include="$(OutputPath)/netver/$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
generator csproj:
<None Include="$(OutputPath)/netver/$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
rn the generator is only being applied to the framework. I've been looking all over to figure out how to get it to also apply to the application, but I can't find anything that works. Any suggestions would be super helpful.
2 Replies
CaptainToTo
CaptainToToOP2mo ago
I've also tried to just include the generator in the application as a temporary solution, but that causes another issue where the generator executes twice, separately for both projects. In which case leads to a bunch of different questions: - can I guarantee the execution order? - can I determine if the generator is currently running on the framework? - how can I share state between the two runs?
jcotton42
jcotton422mo ago
1. No 3. Don’t/you can’t I would ask in #roslyn
Want results from more Discord servers?
Add your server