issues with code generator
hi, im trying to make a basic codeanalysis project for a terraria mod im working on
id like to be able to ship the codeanalysis dll independently, rather than directly reference the codeanalysis project in each of my projects but whenever i reference the dll itself, the generators dont execute
i have made a minimum repro project below;
this is the basic generator i made:
and this is the csproj of the analyzer project:
10 Replies
and here is the testbench csproj im using to test the generators:
ive ensured the dll is in the build output and all, im really unsure of whats happening, if this is an actual issue or if im just a little dumb
ProjectReference is indeed the correct way to do that.
I don't think Reference works to load analyzers.
Why do you want to avoid ProjectReference anyhow? I'm not sure what you mean by "ship the codeanalysis dll independently"
I don't think Reference works to load analyzers.Correct, that will not work. You'd need to manually add it to the
Analyzers
list
I also do not understand why you'd be trying to avoid ProjectReference
and/or PackageReference
i wanted to put it over on nuget, but i wanted to make sure the dll actually worked first
Then just test with the nuget package, not with the raw dll
You can just put a nupkg in a folder, point your nuget.config at that folder, and use a
PackageReference
ic
wasnt aware you could test nuget packages locally, ty
nuget.config File Reference
NuGet.Config file reference including the config, bindingRedirects, packageRestore, solution, and packageSource sections.
apologies im p new to nuget stuff
im testing the nuget package, and the generators all work fine except for one that uses
Microsoft.Extensions.Primitives
You need to include that dll, just like you are with your analyzer dll
See https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.cookbook.md#use-functionality-from-nuget-packages
tyvm