-
Notifications
You must be signed in to change notification settings - Fork 7
Add support for the .NET 8 SDK #93
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
Conversation
Downgrading Microsoft.CodeAnalysis.CSharp from version 4.13.0 to 4.11.0 enables using Zomp.SyncMethodGenerator with the .NET 8 SDK at the very small price of using `nameof(Nullable<int>.*)` instead of `nameof(Nullable<>.*)` Currently, using Zomp.SyncMethodGenerator with the .NET 8 SDK fails with this error. > error CS9057: The analyzer assembly 'Zomp.SyncMethodGenerator.dll' references version '4.13.0.0' of the compiler, which is newer than the currently running version '4.11.0.0'.
| <PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" /> | ||
| <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" /> | ||
| <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" /> | ||
| <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.11.0]" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do the brackets mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means exact version match, see the NuGet Package versioning - Version ranges documentation. This ensures that version 4.11.0 will be resolved if another package depends on Microsoft.CodeAnalysis.CSharp.
|
I installed .NET SDK 8.0 on a VM and indeed there was a compilation error. When I rolled back to 4.11.0.0 everything worked. I don't think you need any changes other than the ones in Directory.Packages.props. Everything will compile into .NET Standard and the latest syntax to be used will be the latest C#. |
|
Yes that's true. But having a global.json file that forces to use the .NET 8 SDK makes it easy to ensure that If you prefer to use the .NET 9 SDK that's fine, the global.json file can be removed and the modifications from |
|
Do you have global.json in your consuming project? One concern that I have is if this project uses old assemblies, it will not be able to accommodate new language features in a timely manner. For example, C# 14 extensions require Microsoft.CodeAnalysis.CSharp version 5.*. If this library makes a commitment to support .NET 8 SDK, we'll have to be on that version until November 10, 2026 |
Actually the .NET 9 SDK is not even installed on the build machine.
I have removed the |
|
It does hold back upgrading to latest version of C#. This is a problem even your issue never came up. In #94 I must upgrade to 5.x in order to support latest C# 14 extensions, but that will fail everyone who doesn't have .NET 10 SDK on their build server. There are a few options here: One is to have 1-3 versions of the library at all times. They would be targeting SDKs which didn't reach end of support yet. I would definitely prefer a solution which can parse code without relying on the installed SDK. |
|
I don't think that a source generator should be a driver of which SDK to use, but just out of curiosity, why don't you have .NET 9 SDK on the build server? |
OK, I did not realise that you had to upgrade to I would suggest to release a new version using People can choose to use an older version if they want support for the .NET 8 SDK and use th newer version if they need support for the .NET 10 SDK. What do you think?
Hmmm, the source generator will always use the You can do this to see exactly what happens. var assembly = typeof(CSharpSyntaxRewriter).Assembly;
spc.AddSource(source.Path, SourceText.From(source.Content + $"// **DIAGNOSE** {assembly} at {assembly.Location}", Encoding.UTF8));Sure enough, by enabling
We use Long Term Support (LTS) releases and .NET 9 is under Standard Term Support (STS). 🤷🏻♂️ |
|
No problem going with this solution for now. I'll try to include |
Here be dragons. 🐉 Thanks for merging, another pull request is coming soon! 😉 |
Downgrading Microsoft.CodeAnalysis.CSharp from version 4.13.0 to 4.11.0 enables using Zomp.SyncMethodGenerator with the .NET 8 SDK at the very small price of using
nameof(Nullable<int>.*)instead ofnameof(Nullable<>.*)Currently, using Zomp.SyncMethodGenerator with the .NET 8 SDK fails with this error.