Closed jacobjmarks closed 1 week ago
adding @KathleenDollard to comment.
You shouldn't really use net8.0
for roslyn components (analyzers, codefixes, or generators).
The thing is that Visual Studio is still .NET Framework, while dotnet
CLI is .NET Core. So for a roslyn component to work in both, it must target netstandard2.0
.
In your case, it has possibly worked because you were in a .NET Core environment. If you tried that in Visual Studio, it shouldn't work.
And from C# Discord:
Thanks, that's all understandable. Though for the documentation here — at least on this page — to state that it just "will not work" is not very helpful to anyone; because depending on what you're doing, it can and will. Some additional context should be added.
Type of issue
Missing information
Description
When authoring a source generator, documentation states that "The source generator project needs to target the
netstandard2.0
TFM, otherwise it will not work.". However, in my testing I was able to create a basic source generator — following the current documentation — targetingnet8.0
with seemingly no issues at all; this using Visual Studio Code and the .NET CLI with SDK8.0.204
.Is this documentation out of date? Is it only applicable in certain scenarios? More information here would be very much appreciated.
Possible related issue: #40058
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/roslyn-sdk/source-generators-overview.md
Document Version Independent Id
f1ed9873-3e29-b4bd-2dbb-44dd9a05d790
Article author
@BillWagner
Metadata