diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 45f68d7b17..c9e66ac8cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: dotnet-version: | 8.0.x 9.0.x + 10.0.x - run: dotnet tool install -g GitVersion.Tool --version 5.11.1 - name: Resolve version id: version @@ -126,6 +127,8 @@ jobs: - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn3.8 - run: dotnet restore --force /p:RoslynVersion=roslyn4.7 - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn4.7 + - run: dotnet restore --force /p:RoslynVersion=roslyn5.0 + - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn5.0 - run: dotnet pack --no-build - uses: actions/upload-artifact@v4 with: @@ -147,6 +150,8 @@ jobs: - run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn3.8 - run: dotnet restore --force /p:RoslynVersion=roslyn4.7 - run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn4.7 + - run: dotnet restore --force /p:RoslynVersion=roslyn5.0 + - run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn5.0 - run: dotnet pack --no-build - uses: actions/upload-artifact@v4 with: @@ -168,6 +173,8 @@ jobs: - run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn3.8 - run: dotnet restore --force /p:RoslynVersion=roslyn4.7 - run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn4.7 + - run: dotnet restore --force /p:RoslynVersion=roslyn5.0 + - run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn5.0 - run: dotnet pack --no-build - uses: actions/upload-artifact@v4 with: @@ -210,7 +217,7 @@ jobs: build_vs_code_extension: if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') - needs: [ pre_build, build_analyzers ] + needs: [ pre_build ] runs-on: ubuntu-24.04 env: Version: ${{ needs.pre_build.outputs.version }} @@ -222,7 +229,6 @@ jobs: - run: dotnet restore - run: dotnet build --no-restore - run: | - mkdir package/roslyn/analyzers mkdir package/roslyn/refactorings mkdir package/roslyn/fixes cp bin/Release/netstandard2.0/Roslynator.Core.dll package/roslyn/common @@ -231,10 +237,6 @@ jobs: cp bin/Release/netstandard2.0/Roslynator.Workspaces.Core.dll package/roslyn/common cp bin/Release/netstandard2.0/Roslynator.Workspaces.Common.dll package/roslyn/common cp bin/Release/netstandard2.0/Roslynator.CSharp.Workspaces.dll package/roslyn/common - cp bin/Release/netstandard2.0/Roslynator.CSharp.Analyzers.dll package/roslyn/analyzers - cp bin/Release/netstandard2.0/Roslynator.CSharp.Analyzers.CodeFixes.dll package/roslyn/analyzers - cp bin/Release/netstandard2.0/Roslynator.Formatting.Analyzers.dll package/roslyn/analyzers - cp bin/Release/netstandard2.0/Roslynator.Formatting.Analyzers.CodeFixes.dll package/roslyn/analyzers cp bin/Release/netstandard2.0/Roslynator.CSharp.Refactorings.dll package/roslyn/refactorings cp bin/Release/netstandard2.0/Roslynator.CSharp.CodeFixes.dll package/roslyn/fixes name: Copy DLLs to package diff --git a/CHANGELOG.md b/CHANGELOG.md index 476e6ca1f6..bde6f995fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `roslyn5.0` NuGet package flavor (`analyzers/dotnet/roslyn5.0/cs`) ([PR](https://github.com/dotnet/roslynator/pull/1787)) + +### Changed + +- Bump Roslyn to 5.0.0 ([PR](https://github.com/dotnet/roslynator/pull/1787)) + - CLI and testing library target Roslyn 5.0.0 + - Solution build and tests use Roslyn 5.0.0 by default +- Replace Visual Studio 2022 extension with **Roslynator 2026** for Visual Studio 2026 (`[18.0,19.0)`) ([PR](https://github.com/dotnet/roslynator/pull/1787)) + - Extension ships refactorings and compiler diagnostic code fixes; analyzers via NuGet + - [Roslynator 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) remains available as the last 4.x VSIX +- Visual Studio Code extension ships refactorings and compiler diagnostic code fixes only ([PR](https://github.com/dotnet/roslynator/pull/1787)) + - Analyzers require Roslynator NuGet packages + - Requires OmniSharp with Roslyn 5.x (C# extension 1.39.15+; set `dotnet.server.useOmnisharp` to `true`) + +### Removed + +- Remove bundled analyzers from Visual Studio extension ([PR](https://github.com/dotnet/roslynator/pull/1787)) + - Use [Roslynator.Analyzers](https://www.nuget.org/packages/roslynator.analyzers) NuGet package for diagnostics +- Remove bundled analyzers from Visual Studio Code extension ([PR](https://github.com/dotnet/roslynator/pull/1787)) + - Use Roslynator NuGet packages for diagnostics +- Remove `AnalyzersOptionsPage` from Visual Studio extension ([PR](https://github.com/dotnet/roslynator/pull/1787)) +- Drop support for Visual Studio 2022 VSIX ([PR](https://github.com/dotnet/roslynator/pull/1787)) + - Pin last 4.x release ([Roslynator 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022)) or use NuGet packages on Visual Studio 2022 + ## [4.16.1] - 2026-08-16 ### Fixed diff --git a/README.md b/README.md index 9636ab28e3..0cc2cad428 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ Roslynator is a set of code analysis tools for C#, powered by [Roslyn](https://github.com/dotnet/roslyn). -IMPORTANT: Analyzers will be removed from Roslynator IDE extensions in the next major release. -Use Roslynator NuGet packages instead (for example, [Roslynator.Analyzers](https://www.nuget.org/packages/roslynator.analyzers)). +Analyzers are not included in Roslynator IDE extensions. Use Roslynator NuGet packages (e.g. [Roslynator.Analyzers](https://www.nuget.org/packages/roslynator.analyzers)) for diagnostics. ## Tools - IDE extensions for: - - [Visual Studio](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) - - [VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) - - Requires OmniSharp. With C# Dev Kit, use NuGet packages for analyzers, refactorings, and code fixes. + - [Visual Studio 2026](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2026) (refactorings and compiler diagnostic fixes; analyzers via NuGet) + - [Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) (last 4.x release; pin or use NuGet packages) + - [VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) (refactorings and compiler diagnostic fixes; analyzers via NuGet) + - Requires legacy OmniSharp (`dotnet.server.useOmnisharp`: `true`). With C# Dev Kit, use NuGet packages instead. - [Open VSX](https://open-vsx.org/extension/josefpihrt-vscode/roslynator) - [NuGet packages](#nuget-packages) that contain a collection of analyzers - [Roslynator.Analyzers](https://www.nuget.org/packages/Roslynator.Analyzers) diff --git a/SECURITY.md b/SECURITY.md index 37dfc4e099..e3de92c390 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -7,19 +7,19 @@ Any vulnerabilities that affect older versions will be considered on a case-by-c | Version | Supported | | ------- |:------------------:| -| 4.x | :white_check_mark: | +| 5.x | :white_check_mark: | | CLI 0.x | :white_check_mark: | -| Extension for VS 2022 | :white_check_mark: | +| Extension for VS 2026 | :white_check_mark: | | Extension for VS Code | :white_check_mark: | ## Out of Support Versions | Version | Supported | | ------- |:---------:| -| < 4.0 | :x: | -| Extension for VS 2019 and older | :x: | +| < 5.0 | :x: | +| Extension for VS 2022 and older | :x: | ## Reporting a Vulnerability Please report (suspected) security vulnerabilities to GitHub [issues](https://github.com/dotnet/roslynator/issues/new). -Once confirmed, we will release a patch as soon as possible. \ No newline at end of file +Once confirmed, we will release a patch as soon as possible. diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitTypeInsteadOfVarCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitTypeInsteadOfVarCodeFixProvider.cs index 53de3c14a4..8ee7eebf73 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitTypeInsteadOfVarCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitTypeInsteadOfVarCodeFixProvider.cs @@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Roslynator.CodeFixes; +using Roslynator.CSharp; namespace Roslynator.CSharp.CodeFixes; @@ -75,7 +76,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) TypeSyntax type = declarationExpression.Type; - var localSymbol = semanticModel.GetDeclaredSymbol(declarationExpression.Designation, context.CancellationToken) as ILocalSymbol; + ILocalSymbol localSymbol = semanticModel.GetDeclaredLocalSymbol(declarationExpression.Designation, context.CancellationToken); ITypeSymbol typeSymbol = (localSymbol?.Type) ?? semanticModel.GetTypeSymbol(declarationExpression, context.CancellationToken); diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseVarOrExplicitTypeCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseVarOrExplicitTypeCodeFixProvider.cs index fc566b8e84..1299e771cc 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseVarOrExplicitTypeCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseVarOrExplicitTypeCodeFixProvider.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Roslynator.CodeFixes; +using Roslynator.CSharp; using static Roslynator.CSharp.CodeActionFactory; namespace Roslynator.CSharp.CodeFixes; @@ -126,7 +127,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) if (typeSymbol is null) { - var localSymbol = semanticModel.GetDeclaredSymbol(declarationExpression.Designation, context.CancellationToken) as ILocalSymbol; + ILocalSymbol localSymbol = semanticModel.GetDeclaredLocalSymbol(declarationExpression.Designation, context.CancellationToken); typeSymbol = (localSymbol?.Type) ?? semanticModel.GetTypeSymbol(declarationExpression, context.CancellationToken); } diff --git a/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec b/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec index 0224bf30f3..6b408b24fa 100644 --- a/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec +++ b/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec @@ -20,6 +20,7 @@ + diff --git a/src/Analyzers.CodeFixes/docs/NuGetReadme.md b/src/Analyzers.CodeFixes/docs/NuGetReadme.md index 460989b05f..5964ca6d3d 100644 --- a/src/Analyzers.CodeFixes/docs/NuGetReadme.md +++ b/src/Analyzers.CodeFixes/docs/NuGetReadme.md @@ -4,7 +4,7 @@ A collection of 200+ [analyzers](https://josefpihrt.github.io/docs/roslynator/an ## Requirements -* Visual Studio 2022 +* Visual Studio 2022 or 2026 * VS Code with [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) extension 1.21.13 or higher * Roslyn 3.8.0 or higher (when used directly, not as part of an IDE) @@ -24,6 +24,7 @@ A collection of 200+ [analyzers](https://josefpihrt.github.io/docs/roslynator/an ## Related Products +* [Roslynator for Visual Studio 2026](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2026) * [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) * [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) * [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli) diff --git a/src/Analyzers/Analyzers.csproj b/src/Analyzers/Analyzers.csproj index f676369d73..4b53c0d8eb 100644 --- a/src/Analyzers/Analyzers.csproj +++ b/src/Analyzers/Analyzers.csproj @@ -11,6 +11,7 @@ Analyzers false true + $(NoWarn);RS1038 diff --git a/src/CSharp.Workspaces/docs/NuGetReadme.md b/src/CSharp.Workspaces/docs/NuGetReadme.md index 7562e66cfe..42eb07389b 100644 --- a/src/CSharp.Workspaces/docs/NuGetReadme.md +++ b/src/CSharp.Workspaces/docs/NuGetReadme.md @@ -9,6 +9,7 @@ This package extends the functionality of the [Microsoft.CodeAnalysis.CSharp.Wor ## Related Products +* [Roslynator for Visual Studio 2026](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2026) * [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) * [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) * [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli) diff --git a/src/CSharp/CSharp/CSharpTypeAnalysis.cs b/src/CSharp/CSharp/CSharpTypeAnalysis.cs index 1fc6475a01..6e63b0e77d 100644 --- a/src/CSharp/CSharp/CSharpTypeAnalysis.cs +++ b/src/CSharp/CSharp/CSharpTypeAnalysis.cs @@ -489,7 +489,7 @@ public static bool IsImplicitThatCanBeExplicit( bool IsLocalThatSupportsExplicitDeclaration(VariableDesignationSyntax variableDesignation) { - if (semanticModel.GetDeclaredSymbol(variableDesignation, cancellationToken) is not ILocalSymbol localSymbol) + if (semanticModel.GetDeclaredLocalSymbol(variableDesignation, cancellationToken) is not ILocalSymbol localSymbol) return false; ITypeSymbol typeSymbol = localSymbol.Type; diff --git a/src/CSharp/CSharp/Extensions/CSharpExtensions.cs b/src/CSharp/CSharp/Extensions/CSharpExtensions.cs index f7b7eacef3..19b00d4f67 100644 --- a/src/CSharp/CSharp/Extensions/CSharpExtensions.cs +++ b/src/CSharp/CSharp/Extensions/CSharpExtensions.cs @@ -25,6 +25,17 @@ public static class CSharpExtensions return (IMethodSymbol?)ModelExtensions.GetDeclaredSymbol(semanticModel, localFunction, cancellationToken); } + internal static ILocalSymbol? GetDeclaredLocalSymbol( + this SemanticModel semanticModel, + VariableDesignationSyntax designation, + CancellationToken cancellationToken = default) + { + if (designation is SingleVariableDesignationSyntax singleVariableDesignation) + return (ILocalSymbol?)semanticModel.GetDeclaredSymbol(singleVariableDesignation, cancellationToken); + + return null; + } + /// /// Returns what symbol, if any, the specified attribute syntax bound to. /// diff --git a/src/CSharp/docs/NuGetReadme.md b/src/CSharp/docs/NuGetReadme.md index ecf746978d..a03987f2e6 100644 --- a/src/CSharp/docs/NuGetReadme.md +++ b/src/CSharp/docs/NuGetReadme.md @@ -9,6 +9,7 @@ This package extends the functionality of the [Microsoft.CodeAnalysis.CSharp](ht ## Related Products +* [Roslynator for Visual Studio 2026](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2026) * [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) * [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) * [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli) diff --git a/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec b/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec index ba50446927..074c20376f 100644 --- a/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec +++ b/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec @@ -22,6 +22,7 @@ + diff --git a/src/CodeAnalysis.Analyzers.CodeFixes/docs/NuGetReadme.md b/src/CodeAnalysis.Analyzers.CodeFixes/docs/NuGetReadme.md index 8493b2dce4..bca9175df9 100644 --- a/src/CodeAnalysis.Analyzers.CodeFixes/docs/NuGetReadme.md +++ b/src/CodeAnalysis.Analyzers.CodeFixes/docs/NuGetReadme.md @@ -6,7 +6,7 @@ Use this package for projects that reference Roslyn (`Microsoft.CodeAnalysis*`) ## Requirements -* Visual Studio 2022 +* Visual Studio 2022 or 2026 * VS Code with [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) extension 1.21.13 or higher * Roslyn 3.8.0 or higher (when used directly, not as part of an IDE) @@ -26,6 +26,7 @@ Use this package for projects that reference Roslyn (`Microsoft.CodeAnalysis*`) ## Related Products +* [Roslynator for Visual Studio 2026](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2026) * [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) * [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) * [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli) diff --git a/src/CodeFixes/Roslynator.CodeFixes.nuspec b/src/CodeFixes/Roslynator.CodeFixes.nuspec index 0e3dbfb468..c705b0b277 100644 --- a/src/CodeFixes/Roslynator.CodeFixes.nuspec +++ b/src/CodeFixes/Roslynator.CodeFixes.nuspec @@ -20,6 +20,7 @@ + diff --git a/src/CodeFixes/docs/NuGetReadme.md b/src/CodeFixes/docs/NuGetReadme.md index 086ced15d9..ce5bf786f8 100644 --- a/src/CodeFixes/docs/NuGetReadme.md +++ b/src/CodeFixes/docs/NuGetReadme.md @@ -7,7 +7,7 @@ Otherwise, use the IDE extension instead. ## Requirements -* Visual Studio 2022 +* Visual Studio 2022 or 2026 * VS Code with [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) extension 1.21.13 or higher * Roslyn 3.8.0 or higher (when used directly, not as part of an IDE) @@ -27,6 +27,7 @@ Otherwise, use the IDE extension instead. ## Related Products +* [Roslynator for Visual Studio 2026](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2026) * [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022) * [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator) * [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli) diff --git a/src/CommandLine/CommandLine.csproj b/src/CommandLine/CommandLine.csproj index d193044559..a50e0c8ed7 100644 --- a/src/CommandLine/CommandLine.csproj +++ b/src/CommandLine/CommandLine.csproj @@ -57,6 +57,8 @@ + + - 17.7.2 + 17.11.31 17.14.28 18.0.2