by daeken · 11mo ago · 0 comments
Eventually I want to write a good baseline library to use for my source generators -- simplifying finding definitions with attributes, mapping types to System.Type, adding some basic pattern matching for structures -- but haven't found a way to do it that's general enough while being very useful.
I sometimes generate code from plain CLI projects (avoiding source generators altogether), as whole debugging and DX is so much better.
SourceGenerator.csproj:
<ProjectReference Include="..\Dependency.csproj" />
FinalProject.csproj: <ProjectReference Include="..\Dependency.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
And I also recommend to add "<LangVersion>latest</LangVersion>" to SourceGenerator.csproj to use new features like raw string literals.That isn't as cool as Aspire and AI features.
And the documentation is still pretty sparse.
> Eventually I want to write a good baseline library to use for my source generators -- simplifying finding definitions with attributes, mapping types to System.Type, adding some basic pattern matching for structures -- but haven't found a way to do it that's general enough while being very useful.
I'd use it in a heartbeat. The new ForAttributeWithMetadataName function has been a big help, but everything else feels like a totally different language to me.