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 e6ab73d0e2..c919aedacd 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -7,9 +7,14 @@ 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))
+- Fix analyzer [RCS1264](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1264) ([PR](https://github.com/dotnet/roslynator/pull/1604))
### Changed
diff --git a/src/Analyzers/CSharp/Analysis/UseVarOrExplicitTypeAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UseVarOrExplicitTypeAnalyzer.cs
index 39dac4c8a9..8f457167ce 100644
--- a/src/Analyzers/CSharp/Analysis/UseVarOrExplicitTypeAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analysis/UseVarOrExplicitTypeAnalyzer.cs
@@ -48,7 +48,7 @@ private static void AnalyzeVariableDeclaration(SyntaxNodeAnalysisContext context
}
else if (style == TypeStyle.Explicit)
{
- if (CSharpTypeAnalysis.IsImplicitThatCanBeExplicit(variableDeclaration, context.SemanticModel, TypeAppearance.Obvious, context.CancellationToken))
+ if (CSharpTypeAnalysis.IsImplicitThatCanBeExplicit(variableDeclaration, context.SemanticModel, context.CancellationToken))
ReportImplicitToExplicit(context, variableDeclaration.Type);
}
else if (style == TypeStyle.ImplicitWhenTypeIsObvious)
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/Tests/Analyzers.Tests/RCS1264UseVarOrExplicitTypeTests2.cs b/src/Tests/Analyzers.Tests/RCS1264UseVarOrExplicitTypeTests2.cs
index fbd34abda8..3c10ddb2b7 100644
--- a/src/Tests/Analyzers.Tests/RCS1264UseVarOrExplicitTypeTests2.cs
+++ b/src/Tests/Analyzers.Tests/RCS1264UseVarOrExplicitTypeTests2.cs
@@ -162,6 +162,36 @@ void M()
", options: Options.AddConfigOption(ConfigOptionKeys.UseVar, ConfigOptionValues.UseVar_Never));
}
+ [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseVarOrExplicitType)]
+ public async Task Test_NotObviousExpression()
+ {
+ await VerifyDiagnosticAndFixAsync(@"
+using System.Threading.Tasks;
+using System.Collections.Generic;
+
+class C
+{
+ void M()
+ {
+ [|var|] x1 = string.Empty;
+ [|var|] x2 = Task.FromResult(string.Empty);
+ }
+}
+", @"
+using System.Threading.Tasks;
+using System.Collections.Generic;
+
+class C
+{
+ void M()
+ {
+ string x1 = string.Empty;
+ Task x2 = Task.FromResult(string.Empty);
+ }
+}
+", options: Options.AddConfigOption(ConfigOptionKeys.UseVar, ConfigOptionValues.UseVar_Never));
+ }
+
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.UseVarOrExplicitType)]
public async Task TestNoDiagnostic_ForEach_DeclarationExpression()
{
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)