-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-targeting strategy for Json and Logging Source Generators for 6.0 NuGet packages #58536
Comments
Tagging subscribers to this area: @Anipik, @safern, @ViktorHofer Issue DetailsBackgroundThis issue addresses the 3rd bullet point in #56702 (comment).
I have a proposal to add Roslyn component multi-targeting support to the .NET SDK here: dotnet/sdk#20355. And a couple prototypes of what it could look like in the SDK, and how our dotnet/runtime packages could be built. However, given where we are in the release cycle, I'm not confident getting a multi-targeting feature into the SDK in 6.0.100 is feasible at this point in time. This proposal is to define a plan for addressing the user experience of using the Json and Logging Source Generators when using an older version of Roslyn - specifically when using VS 2019 or an earlier version of the .NET SDK. With the latest
This is not a great user experience. Goals
ProposalTo address the current user experience on older Roslyn versions with our 6.0 packages, we can add the multi-targeting logic into our 2 NuGet packages. This is a stop-gap solution until the SDK can officially support multi-targeting Roslyn components. The proposal is to add MSBuild targets which:
Since the VS 2019 source generator API has performance issues, we will also include an MSBuild property that turns the Json and Logging source generators off. Developers can set the Alternative OptionsOther options for addressing the current user experience:
@ericstj @terrajobst @danmoseley @stephentoub @steveharter @layomia @maryamariyan - thoughts on this proposal? cc @chsienki @jaredpar @jmarolf @sharwell
|
If time is short: is an option to service the JSON package post GA to enable VS2019? Since it is only relevant to folks who consume the OOB, since VS2019 won't support targeting the 6.0 shared framework... Actually cutting the SG from the OOB scenario would be unfortunate. |
Closing as this work is now complete - and backported to the 6.0 branch. It will be available in 6.0-rc2. We chose to take Alternative Option (2) above. |
Background
This issue addresses the 3rd bullet point in #56702 (comment).
I have a proposal to add Roslyn component multi-targeting support to the .NET SDK here: dotnet/sdk#20355. And a couple prototypes of what it could look like in the SDK, and how our dotnet/runtime packages could be built.
However, given where we are in the release cycle, I'm not confident getting a multi-targeting feature into the SDK in 6.0.100 is feasible at this point in time.
This proposal is to define a plan for addressing the user experience of using the Json and Logging Source Generators when using an older version of Roslyn - specifically when using VS 2019 or an earlier version of the .NET SDK.
With the latest
6.0
NuGet packages, if a developer is using VS 2019 and upgrades their<PackageReference
to the6.0.0-rc1
versions, they start seeing build warnings:Warning CS8032 An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from C:\Users\eerhardt\.nuget\packages\system.text.json\6.0.0-rc1\analyzers\dotnet\cs\System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
This is not a great user experience.
Goals
Proposal
To address the current user experience on older Roslyn versions with our 6.0 packages, we can add the multi-targeting logic into our 2 NuGet packages. This is a stop-gap solution until the SDK can officially support multi-targeting Roslyn components.
The proposal is to add MSBuild targets which:
v3.9
when compilng with Roslyn< v4.0
v4.0
when compilng with Roslyn>= v4.0
net6.0
ref-packSince the VS 2019 source generator API has performance issues, we will also include an MSBuild property that turns the Json and Logging source generators off. Developers can set the
$(DisableSystemTextJsonSourceGenerator)
and$(DisableMicrosoftExtensionsLoggingSourceGenerator)
properties totrue
in their.csproj
to disable the source generators in the NuGet packages. Note that this only works in the NuGet package. These properties are not respected by the generators in the "ref-pack". The reason being is that the generators in the "ref-pack" have addressed the performance issues by moving to the incremental API.Alternative Options
Other options for addressing the current user experience:
>= 4.0
.v3.9
targeted generator when using VS 2019 or an earlier version of the .NET SDK@ericstj @terrajobst @danmoseley @stephentoub @steveharter @layomia @maryamariyan - thoughts on this proposal?
cc @chsienki @jaredpar @jmarolf @sharwell
The text was updated successfully, but these errors were encountered: