From b07902486b45366830b7cf30a6ff9c409e0fe935 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Wed, 10 Jan 2024 23:26:22 +0100 Subject: [PATCH 1/6] update --- .github/workflows/build.yml | 44 ++++++++++++++++++- src/CodeFixes/CodeFixes.csproj | 9 +++- src/CodeFixes/Roslynator.CodeFixes.nuspec | 13 +++--- src/CodeFixes/docs/NuGetReadme.md | 30 +++++++++++++ src/Directory.Build.props | 8 ++++ src/Refactorings/Refactorings.csproj | 19 +++++--- .../Roslynator.Refactorings.nuspec | 27 ++++++++++++ src/Refactorings/docs/NuGetReadme.md | 30 +++++++++++++ 8 files changed, 165 insertions(+), 15 deletions(-) create mode 100644 src/CodeFixes/docs/NuGetReadme.md create mode 100644 src/Refactorings/Roslynator.Refactorings.nuspec create mode 100644 src/Refactorings/docs/NuGetReadme.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53f29f6464..a76dbbea85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,6 +119,48 @@ jobs: name: nuget_packages path: src/${{ matrix.component.name }}.CodeFixes/bin/Release/*.*nupkg + build_refactorings: + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') + needs: pre_build + runs-on: ubuntu-22.04 + env: + Version: ${{ needs.pre_build.outputs.version }} + defaults: + run: + working-directory: src/Refactorings + steps: + - uses: actions/checkout@v3 + - run: dotnet restore --force /p:RoslynVersion=roslyn3.8 + - 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 pack --no-build + - uses: actions/upload-artifact@v3 + with: + name: nuget_packages + path: src/Refactorings/bin/Release/*.*nupkg + + build_code_fixes: + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') + needs: pre_build + runs-on: ubuntu-22.04 + env: + Version: ${{ needs.pre_build.outputs.version }} + defaults: + run: + working-directory: src/CodeFixes + steps: + - uses: actions/checkout@v3 + - run: dotnet restore --force /p:RoslynVersion=roslyn3.8 + - 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 pack --no-build + - uses: actions/upload-artifact@v3 + with: + name: nuget_packages + path: src/CodeFixes/bin/Release/*.*nupkg + build_vs_extension: if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') needs: pre_build @@ -242,7 +284,7 @@ jobs: path: src/CommandLine/bin/Release/*.*nupkg publish_nuget_packages: - needs: [ build_core_and_testing, build_analyzers ] + needs: [ build_core_and_testing, build_analyzers, build_refactorings, build_code_fixes ] runs-on: ubuntu-22.04 if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') steps: diff --git a/src/CodeFixes/CodeFixes.csproj b/src/CodeFixes/CodeFixes.csproj index f99cb0d655..a12d091806 100644 --- a/src/CodeFixes/CodeFixes.csproj +++ b/src/CodeFixes/CodeFixes.csproj @@ -4,13 +4,18 @@ netstandard2.0 + + bin\$(RoslynVersion)\ + + $(RoslynatorVersion) Roslynator.CSharp.CodeFixes Roslynator.CSharp.CodeFixes Roslynator.CodeFixes.nuspec - configuration=$(Configuration) - false + configuration=$(Configuration);version=$(RoslynatorPackageVersion) + true + false diff --git a/src/CodeFixes/Roslynator.CodeFixes.nuspec b/src/CodeFixes/Roslynator.CodeFixes.nuspec index d9bf0c4a7f..0e3dbfb468 100644 --- a/src/CodeFixes/Roslynator.CodeFixes.nuspec +++ b/src/CodeFixes/Roslynator.CodeFixes.nuspec @@ -9,16 +9,19 @@ https://github.com/dotnet/roslynator icon.png false - A collection of code fixes for C# compiler diagnostics (CS....), powered by Roslyn. - A collection of code fixes for C# compiler diagnostics (CS....), powered by Roslyn. - Copyright (c) 2016-2023 Josef Pihrt - Roslyn Analyzer Refactoring Productivity CodeAnalysis C# CSharp + A collection of code fixes for C# compiler diagnostics, powered by Roslyn. + A collection of code fixes for C# compiler diagnostics, powered by Roslyn. + Copyright (c) 2016-2024 Josef Pihrt + Roslyn Refactoring Productivity CodeAnalysis C# CSharp true + docs\README.md - + + + \ No newline at end of file diff --git a/src/CodeFixes/docs/NuGetReadme.md b/src/CodeFixes/docs/NuGetReadme.md new file mode 100644 index 0000000000..948c51a487 --- /dev/null +++ b/src/CodeFixes/docs/NuGetReadme.md @@ -0,0 +1,30 @@ +# Roslynator.CodeFixes + +A collection [code fixes](https://josefpihrt.github.io/docs/roslynator/fixes) for C# compiler diagnostics, powered by [Roslyn](https://github.com/dotnet/roslyn). + +## Requirements + +* Visual Studio 2022 +* 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 a part of IDE) + +## Usage + +* Add package to your project: + ```shell + dotnet add package roslynator.codefixes + ``` + +* Use EditorConfig to [configure](https://josefpihrt.github.io/docs/roslynator/configuration) analyzers. + +## Feedback + +* File an issue on [GitHub](https://github.com/dotnet/roslynator/issues/new) +* Follow on [Twitter](https://twitter.com/roslynator) + +## Related Products + +* [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) +* [Roslynator Testing Framework](https://www.nuget.org/packages/Roslynator.Testing.CSharp.Xunit) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8d6ccc3c1b..efb8c06f49 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -62,6 +62,14 @@ Roslynator_Formatting_Analyzers_ + + Roslynator_Refactorings_ + + + + Roslynator_CodeFixes_ + + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Refactorings/Refactorings.csproj b/src/Refactorings/Refactorings.csproj index 71c67f7388..f2191372ac 100644 --- a/src/Refactorings/Refactorings.csproj +++ b/src/Refactorings/Refactorings.csproj @@ -4,17 +4,24 @@ netstandard2.0 + + bin\$(RoslynVersion)\ + + $(RoslynatorVersion) Roslynator.CSharp.Refactorings Roslynator.CSharp.Refactorings + Roslynator.Refactorings.nuspec + configuration=$(Configuration);version=$(RoslynatorPackageVersion) + true + false - - false - - - + + + + @@ -24,8 +31,6 @@ - - diff --git a/src/Refactorings/Roslynator.Refactorings.nuspec b/src/Refactorings/Roslynator.Refactorings.nuspec new file mode 100644 index 0000000000..7b546dbced --- /dev/null +++ b/src/Refactorings/Roslynator.Refactorings.nuspec @@ -0,0 +1,27 @@ + + + + Roslynator.Refactorings + $version$ + Josef Pihrt + Josef Pihrt + Apache-2.0 + https://github.com/dotnet/roslynator + icon.png + false + A collection of 200+ refactorings for C#, powered by Roslyn. + A collection of 200+ refactorings for C#, powered by Roslyn. + Copyright (c) 2016-2024 Josef Pihrt + Roslyn Refactoring Productivity CodeAnalysis C# CSharp + true + + docs\README.md + + + + + + + + + \ No newline at end of file diff --git a/src/Refactorings/docs/NuGetReadme.md b/src/Refactorings/docs/NuGetReadme.md new file mode 100644 index 0000000000..63ceca4e2e --- /dev/null +++ b/src/Refactorings/docs/NuGetReadme.md @@ -0,0 +1,30 @@ +# Roslynator.Refactorings + +A collection of 200+ [refactorings](https://josefpihrt.github.io/docs/roslynator/refactorings) for C#, powered by [Roslyn](https://github.com/dotnet/roslyn). + +## Requirements + +* Visual Studio 2022 +* 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 a part of IDE) + +## Usage + +* Add package to your project: + ```shell + dotnet add package roslynator.refactorings + ``` + +* Use EditorConfig to [configure](https://josefpihrt.github.io/docs/roslynator/configuration) analyzers. + +## Feedback + +* File an issue on [GitHub](https://github.com/dotnet/roslynator/issues/new) +* Follow on [Twitter](https://twitter.com/roslynator) + +## Related Products + +* [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) +* [Roslynator Testing Framework](https://www.nuget.org/packages/Roslynator.Testing.CSharp.Xunit) From 13f69906e9c91b43d42de5e59776575f9b3e05fc Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Wed, 10 Jan 2024 23:38:00 +0100 Subject: [PATCH 2/6] update --- src/Refactorings/tools/install.ps1 | 49 ++++++++++++++++++++++++ src/Refactorings/tools/uninstall.ps1 | 56 ++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/Refactorings/tools/install.ps1 create mode 100644 src/Refactorings/tools/uninstall.ps1 diff --git a/src/Refactorings/tools/install.ps1 b/src/Refactorings/tools/install.ps1 new file mode 100644 index 0000000000..8178834faf --- /dev/null +++ b/src/Refactorings/tools/install.ps1 @@ -0,0 +1,49 @@ +param($installPath, $toolsPath, $package, $project) + +$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve + +foreach($analyzersPath in $analyzersPaths) +{ + # Install the language agnostic analyzers. + if (Test-Path $analyzersPath) + { + foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll) + { + if($project.Object.AnalyzerReferences) + { + $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName) + } + } + } +} + +# $project.Type gives the language name like (C# or VB.NET) +$languageFolder = "" +if($project.Type -eq "C#") +{ + $languageFolder = "cs" +} +if($project.Type -eq "VB.NET") +{ + $languageFolder = "vb" +} +if($languageFolder -eq "") +{ + return +} + +foreach($analyzersPath in $analyzersPaths) +{ + # Install language specific analyzers. + $languageAnalyzersPath = join-path $analyzersPath $languageFolder + if (Test-Path $languageAnalyzersPath) + { + foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll) + { + if($project.Object.AnalyzerReferences) + { + $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName) + } + } + } +} \ No newline at end of file diff --git a/src/Refactorings/tools/uninstall.ps1 b/src/Refactorings/tools/uninstall.ps1 new file mode 100644 index 0000000000..9130bcb508 --- /dev/null +++ b/src/Refactorings/tools/uninstall.ps1 @@ -0,0 +1,56 @@ +param($installPath, $toolsPath, $package, $project) + +$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve + +foreach($analyzersPath in $analyzersPaths) +{ + # Uninstall the language agnostic analyzers. + if (Test-Path $analyzersPath) + { + foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll) + { + if($project.Object.AnalyzerReferences) + { + $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) + } + } + } +} + +# $project.Type gives the language name like (C# or VB.NET) +$languageFolder = "" +if($project.Type -eq "C#") +{ + $languageFolder = "cs" +} +if($project.Type -eq "VB.NET") +{ + $languageFolder = "vb" +} +if($languageFolder -eq "") +{ + return +} + +foreach($analyzersPath in $analyzersPaths) +{ + # Uninstall language specific analyzers. + $languageAnalyzersPath = join-path $analyzersPath $languageFolder + if (Test-Path $languageAnalyzersPath) + { + foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll) + { + if($project.Object.AnalyzerReferences) + { + try + { + $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) + } + catch + { + + } + } + } + } +} \ No newline at end of file From d29013529623ae7a58d2b1280bfc88f980fbd6d9 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Thu, 18 Jan 2024 11:49:57 +0100 Subject: [PATCH 3/6] update --- src/CodeFixes/docs/NuGetReadme.md | 3 +++ src/Refactorings/docs/NuGetReadme.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/CodeFixes/docs/NuGetReadme.md b/src/CodeFixes/docs/NuGetReadme.md index 948c51a487..6bafadde48 100644 --- a/src/CodeFixes/docs/NuGetReadme.md +++ b/src/CodeFixes/docs/NuGetReadme.md @@ -2,6 +2,9 @@ A collection [code fixes](https://josefpihrt.github.io/docs/roslynator/fixes) for C# compiler diagnostics, powered by [Roslyn](https://github.com/dotnet/roslyn). +This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. for VS Code with C# Dev Kit. +Otherwise, do not use this package and use IDE extension which has the same functionality. + ## Requirements * Visual Studio 2022 diff --git a/src/Refactorings/docs/NuGetReadme.md b/src/Refactorings/docs/NuGetReadme.md index 63ceca4e2e..f760c9fbed 100644 --- a/src/Refactorings/docs/NuGetReadme.md +++ b/src/Refactorings/docs/NuGetReadme.md @@ -2,6 +2,9 @@ A collection of 200+ [refactorings](https://josefpihrt.github.io/docs/roslynator/refactorings) for C#, powered by [Roslyn](https://github.com/dotnet/roslyn). +This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. for VS Code with C# Dev Kit. +Otherwise, do not use this package and use IDE extension which has the same functionality. + ## Requirements * Visual Studio 2022 From 240e5513038c4e2a038910341e09aaa81034e81f Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Thu, 18 Jan 2024 11:56:29 +0100 Subject: [PATCH 4/6] update --- ChangeLog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index dc6c547db3..a095415494 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Publish NuGet packages with [refactorings](https://www.nuget.org/packages/roslynator.refactorings) and [code fixes for compiler diagnostics](https://www.nuget.org/packages/roslynator.codefixes) ([PR](https://github.com/dotnet/roslynator/pull/1358)) + - These packages are recommended to be used in an environment where Roslynator IDE extension cannot be used, e.g. VS Code + C# Dev Kit (see related [issue](https://github.com/dotnet/vscode-csharp/issues/6790)) + ### Fixed - Fix analyzer [RCS1055](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1055) ([PR](https://github.com/dotnet/roslynator/pull/1361)) From 91a566cb63244b48445d6f66da51f54785265633 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Thu, 18 Jan 2024 11:59:49 +0100 Subject: [PATCH 5/6] update --- src/CodeFixes/docs/NuGetReadme.md | 2 +- src/Refactorings/docs/NuGetReadme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CodeFixes/docs/NuGetReadme.md b/src/CodeFixes/docs/NuGetReadme.md index 6bafadde48..298a1847f4 100644 --- a/src/CodeFixes/docs/NuGetReadme.md +++ b/src/CodeFixes/docs/NuGetReadme.md @@ -2,7 +2,7 @@ A collection [code fixes](https://josefpihrt.github.io/docs/roslynator/fixes) for C# compiler diagnostics, powered by [Roslyn](https://github.com/dotnet/roslyn). -This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. for VS Code with C# Dev Kit. +This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. VS Code + C# Dev Kit. Otherwise, do not use this package and use IDE extension which has the same functionality. ## Requirements diff --git a/src/Refactorings/docs/NuGetReadme.md b/src/Refactorings/docs/NuGetReadme.md index f760c9fbed..8b4ed9f403 100644 --- a/src/Refactorings/docs/NuGetReadme.md +++ b/src/Refactorings/docs/NuGetReadme.md @@ -2,7 +2,7 @@ A collection of 200+ [refactorings](https://josefpihrt.github.io/docs/roslynator/refactorings) for C#, powered by [Roslyn](https://github.com/dotnet/roslyn). -This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. for VS Code with C# Dev Kit. +This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. VS Code + C# Dev Kit. Otherwise, do not use this package and use IDE extension which has the same functionality. ## Requirements From 39e36968f7ff0fb7179840a048444460acb2543b Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Thu, 18 Jan 2024 20:19:45 +0100 Subject: [PATCH 6/6] update --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index a095415494..0c2d5fe434 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Publish NuGet packages with [refactorings](https://www.nuget.org/packages/roslynator.refactorings) and [code fixes for compiler diagnostics](https://www.nuget.org/packages/roslynator.codefixes) ([PR](https://github.com/dotnet/roslynator/pull/1358)) +- Publish NuGet packages that provide [refactorings](https://www.nuget.org/packages/roslynator.refactorings) and [code fixes for compiler diagnostics](https://www.nuget.org/packages/roslynator.codefixes) ([PR](https://github.com/dotnet/roslynator/pull/1358)) - These packages are recommended to be used in an environment where Roslynator IDE extension cannot be used, e.g. VS Code + C# Dev Kit (see related [issue](https://github.com/dotnet/vscode-csharp/issues/6790)) ### Fixed