From 8c591b34a5a7673db09144a5695c79ed8015669a Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Wed, 1 Jan 2025 11:27:18 +0100 Subject: [PATCH] [CLI] Support .NET 9 (#1605) --- .github/workflows/build.yml | 3 +++ ChangeLog.md | 4 ++++ .../CommandLine.DocumentationGenerator.csproj | 2 +- src/CommandLine/CommandLine.csproj | 2 +- src/CommandLine/DelegateFactory.cs | 4 ++++ src/CommandLine/docs/NetCore/NuGetReadme.md | 2 +- src/Documentation/SymbolDefinitionDisplay.cs | 2 +- .../SortMemberDeclarationsRefactoring.cs | 2 +- src/Tools/CodeGeneration/Markdown/MarkdownGenerator.cs | 2 +- 9 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd2d8b3dc9..f3c90a08ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -261,6 +261,9 @@ jobs: working-directory: src/CommandLine steps: - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.101 - run: dotnet restore - run: dotnet build --no-restore - run: dotnet pack --no-build diff --git a/ChangeLog.md b/ChangeLog.md index d36f667f65..4e5f3db1cd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- [CLI] Add support for .NET 9 ([PR](https://github.com/dotnet/roslynator/pull/1605)) + ### Fixed - Fix refactoring 'Change accessibility' ([RR0186](https://josefpihrt.github.io/docs/roslynator/refactorings/RR0186)) ([PR](https://github.com/dotnet/roslynator/pull/1599)) diff --git a/src/CommandLine.DocumentationGenerator/CommandLine.DocumentationGenerator.csproj b/src/CommandLine.DocumentationGenerator/CommandLine.DocumentationGenerator.csproj index 8cf58f8bf1..642d1aecea 100644 --- a/src/CommandLine.DocumentationGenerator/CommandLine.DocumentationGenerator.csproj +++ b/src/CommandLine.DocumentationGenerator/CommandLine.DocumentationGenerator.csproj @@ -5,7 +5,7 @@ - net6.0;net7.0;net8.0 + net7.0;net8.0;net9.0 diff --git a/src/CommandLine/CommandLine.csproj b/src/CommandLine/CommandLine.csproj index de80181f19..cc3354cb0a 100644 --- a/src/CommandLine/CommandLine.csproj +++ b/src/CommandLine/CommandLine.csproj @@ -5,7 +5,7 @@ - net7.0;net8.0 + net7.0;net8.0;net9.0 diff --git a/src/CommandLine/DelegateFactory.cs b/src/CommandLine/DelegateFactory.cs index f21f5a86a3..df75f0741a 100644 --- a/src/CommandLine/DelegateFactory.cs +++ b/src/CommandLine/DelegateFactory.cs @@ -150,7 +150,11 @@ private static TDelegate CreateDelegate( if (method.IsStatic) { +#if NETFRAMEWORK return (TDelegate)method.CreateDelegate(typeof(TDelegate)); +#else + return method.CreateDelegate(); +#endif } else { diff --git a/src/CommandLine/docs/NetCore/NuGetReadme.md b/src/CommandLine/docs/NetCore/NuGetReadme.md index 727601c207..23936670be 100644 --- a/src/CommandLine/docs/NetCore/NuGetReadme.md +++ b/src/CommandLine/docs/NetCore/NuGetReadme.md @@ -4,7 +4,7 @@ ## Requirements -.NET Core SDK 6.0, 7.0 or 8.0. +.NET Core SDK 7, 8 or 9. ## Installation diff --git a/src/Documentation/SymbolDefinitionDisplay.cs b/src/Documentation/SymbolDefinitionDisplay.cs index ab586ef1e8..1e7411f759 100644 --- a/src/Documentation/SymbolDefinitionDisplay.cs +++ b/src/Documentation/SymbolDefinitionDisplay.cs @@ -955,7 +955,7 @@ private static void FormatParameters( private static int FindParameterListStart( ISymbol symbol, - IList parts) + ImmutableArray.Builder parts) { int parenthesesDepth = 0; int bracesDepth = 0; diff --git a/src/Refactorings/CSharp/Refactorings/SortMemberDeclarations/SortMemberDeclarationsRefactoring.cs b/src/Refactorings/CSharp/Refactorings/SortMemberDeclarations/SortMemberDeclarationsRefactoring.cs index 6a34cb20ef..62d301f652 100644 --- a/src/Refactorings/CSharp/Refactorings/SortMemberDeclarations/SortMemberDeclarationsRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/SortMemberDeclarations/SortMemberDeclarationsRefactoring.cs @@ -109,7 +109,7 @@ private static Task RefactorAsync( return document.ReplaceMembersAsync(info, newMembers, cancellationToken); } - private static SyntaxKind GetSingleKindOrDefault(IReadOnlyList members) + private static SyntaxKind GetSingleKindOrDefault(MemberDeclarationListSelection members) { SyntaxKind kind = members[0].Kind(); diff --git a/src/Tools/CodeGeneration/Markdown/MarkdownGenerator.cs b/src/Tools/CodeGeneration/Markdown/MarkdownGenerator.cs index 499ba4a85e..4cf346d3ef 100644 --- a/src/Tools/CodeGeneration/Markdown/MarkdownGenerator.cs +++ b/src/Tools/CodeGeneration/Markdown/MarkdownGenerator.cs @@ -158,7 +158,7 @@ public static string CreateAnalyzerMarkdown(AnalyzerMetadata analyzer, Immutable static IEnumerable CreateSamples(AnalyzerMetadata analyzer) { - IReadOnlyList samples = analyzer.Samples; + List samples = analyzer.Samples; LegacyAnalyzerOptionKind kind = analyzer.Kind; if (samples.Count > 0)