Skip to content

Commit

Permalink
Remove VSIX (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Djoums authored Jul 13, 2024
1 parent 9704c88 commit dc1e351
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 217 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/01-versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ jobs:
tag: ${{ steps.versioning.outputs.tag }}
version: ${{ steps.versioning.outputs.version }} # same as tag but without the -betaN part at the end, if present
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0 # Necessary to fetch tags

- name: Install xmlstarlet
run: |
sudo apt-get update
sudo apt-get install -y xmlstarlet
- id: versioning
run: |
TAG=${GITHUB_REF#refs/tags/}
Expand All @@ -40,17 +43,10 @@ jobs:
echo "Error: Tag does not match the expected format 'X.Y.Z' or 'X.Y.Z-betaN'"
exit 1
fi
- name: Set Version in Directory.Build.props
run: xmlstarlet ed --inplace -u "/Project/PropertyGroup/Version" -v "${{ steps.versioning.outputs.version }}" Directory.Build.props
- name: Set Version in VSIX manifest
shell: pwsh
run: |
[xml]$manifest = Get-Content "src/EcoCode.Vsix/source.extension.vsixmanifest"
$identity = $manifest.SelectSingleNode("//*[local-name()='Identity']")
if ($identity -ne $null) {
$identity.Version = "${{ steps.versioning.outputs.version }}"
}
$manifest.Save("src/EcoCode.Vsix/source.extension.vsixmanifest")

- name: Cache updated sources
uses: actions/cache/save@v4
with:
Expand Down
31 changes: 10 additions & 21 deletions .github/workflows/02-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ jobs:
**/*
key: cache-${{ github.sha }}
enableCrossOsArchive: true

- uses: actions/setup-dotnet@v4

- run: dotnet restore NuGetOnly.slnf

- run: dotnet build NuGetOnly.slnf -c Release --no-restore

- run: dotnet pack NuGetOnly.slnf -c Release --no-build -o ./nupkg -p:Version=${{ inputs.tag }}

- uses: actions/cache/save@v4
with:
path: nupkg
Expand All @@ -40,33 +45,17 @@ jobs:
**/*
key: cache-${{ github.sha }}
enableCrossOsArchive: true

- uses: actions/setup-dotnet@v4

- run: dotnet restore ToolOnly.slnf

- run: dotnet build ToolOnly.slnf -c Release --no-restore

- run: dotnet pack ToolOnly.slnf -c Release --no-build -o ./tool -p:Version=${{ inputs.tag }}

- uses: actions/cache/save@v4
with:
path: tool
key: cache-${{ github.sha }}
enableCrossOsArchive: true

build-vsix:
runs-on: windows-latest
steps:
- name: Restore versioned sources
uses: actions/cache/restore@v4
with:
path: |
!**/.git
**/*
key: cache-${{ github.sha }}
enableCrossOsArchive: true
- uses: actions/setup-dotnet@v4
- run: dotnet restore VsixOnly.slnf
- uses: microsoft/setup-msbuild@v2
- run: msbuild VsixOnly.slnf "-p:OutputPath=..\..\vsix;Configuration=Release"
- uses: actions/cache/save@v4
with:
path: vsix
key: cache-${{ github.sha }}
enableCrossOsArchive: true
24 changes: 4 additions & 20 deletions .github/workflows/03-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ on:
tag:
required: true
type: string
version:
required: true
type: string
secrets:
nuget-api-key:
required: true
vsmarketplace-api-key:
required: true

jobs:
publish-nuget:
Expand All @@ -24,7 +19,9 @@ jobs:
path: nupkg
key: cache-${{ github.sha }}
enableCrossOsArchive: true

- run: echo "PACKAGE=$(find . -name 'EcoCode.${{ inputs.tag }}.nupkg' | head -n 1)" >> $GITHUB_ENV

- run: dotnet nuget push ${{ env.PACKAGE }} -k "${{ secrets.nuget-api-key }}" -s https://api.nuget.org/v3/index.json

publish-tool:
Expand All @@ -35,20 +32,7 @@ jobs:
path: tool
key: cache-${{ github.sha }}
enableCrossOsArchive: true

- run: echo "PACKAGE=$(find . -name 'EcoCode.Tool.${{ inputs.tag }}.nupkg' | head -n 1)" >> $GITHUB_ENV

- run: dotnet nuget push ${{ env.PACKAGE }} -k "${{ secrets.nuget-api-key }}" -s https://api.nuget.org/v3/index.json

publish-vsix:
if: ${{ inputs.tag == inputs.version }}
runs-on: windows-latest
steps:
- uses: actions/cache/restore@v4
with:
path: vsix
key: cache-${{ github.sha }}
enableCrossOsArchive: true
- uses: cezarypiatek/VsixPublisherAction@1.1
with:
extension-file: vsix/EcoCode.vsix
publish-manifest-file: vsix/publishManifest.json
personal-access-code: ${{ secrets.vsmarketplace-api-key }}
8 changes: 2 additions & 6 deletions .github/workflows/04-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ jobs:
path: nupkg
key: cache-${{ github.sha }}
enableCrossOsArchive: true

- uses: actions/cache/restore@v4
with:
path: tool
key: cache-${{ github.sha }}
enableCrossOsArchive: true
- uses: actions/cache/restore@v4
with:
path: vsix
key: cache-${{ github.sha }}
enableCrossOsArchive: true

- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
Expand All @@ -39,4 +36,3 @@ jobs:
files: |
nupkg/**/EcoCode.${{ inputs.tag }}.nupkg
tool/**/EcoCode.Tool.${{ inputs.tag }}.nupkg
vsix/EcoCode.vsix
9 changes: 8 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4

- run: dotnet restore TestsOnly.slnf

- run: dotnet build TestsOnly.slnf -c Release --no-restore

- run: dotnet test TestsOnly.slnf -c Release --no-build --logger "trx;LogFileName=test_results.trx" -p:CollectCoverage=true -p:Threshold=80 -p:CoverletOutputFormat='cobertura'

- uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: '/home/runner/work/ecoCode-csharp/ecoCode-csharp/src/EcoCode.Tests/coverage.cobertura.xml'
targetdir: 'CoverageReports'
historydir: 'CoverageHistory'
reporttypes: 'HtmlInline;Cobertura'
reporttypes: 'HtmlInline;Cobertura'

- uses: actions/upload-artifact@v4
if: always() # Ensure this step runs even if the test step fails
with:
name: Test Results
path: '**/test_results.trx'

- uses: actions/upload-artifact@v4
with:
name: Coverage reports
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/create-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ jobs:
uses: ./.github/workflows/03-publish.yml
with:
tag: ${{ needs.versioning.outputs.tag }}
version: ${{ needs.versioning.outputs.version }}
secrets:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
vsmarketplace-api-key: ${{ secrets.VSMARKETPLACE_API_KEY }}

release:
needs: publish
Expand Down
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>all</AnalysisMode>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<TreatWarningsAsErrors Condition="'$(Configuration)' != 'Debug'">true</TreatWarningsAsErrors>

Expand Down
3 changes: 1 addition & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.10.2185" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.4.3" />
<PackageVersion Include="MSTest.TestFramework" Version="3.4.3" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.4" />
Expand All @@ -30,4 +29,4 @@
<PackageVersion Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>
</Project>
</Project>
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ _ecoCode_ is based on evolving catalogs of [good practices](https://github.com/g
There are several ways you can use the ecoCode C# analyzers in your .Net projects:
1. As a [NuGet package](#nugetPackage)
2. As a [.NET tool](#dotnetTool)
3. As a [Visual Studio extension](#vsExtension)
4. Coming soon : as a VS Code extension.
5. As an [analyzer for SonarQube](#sonarQube).
3. As an [analyzer for SonarQube](#sonarQube).

<a name="nugetPackage"></a>🧩 NuGet package
-----------------
Expand All @@ -39,15 +37,7 @@ Once installed, you can launch an analyzis on an existing codebase like this :

The file to analyze can be a .sln, a .slnx or a .csproj. The report format depends on it's required extension, the following are currently supported : .html, .json and .csv.

Pre-requisite : .Net 8 SDK, with the goal of requiring the oldest .Net Core LTS from then on (ie. require .Net 10 in November 2026).

<a name="vsExtension"></a>🧩 Visual Studio extension
-----------------
The extension is available on the VS marketplace at this address : https://marketplace.visualstudio.com/items?itemName=greencodeinitiative.ecoCode, and can be installed in your Visual Studio instance like any extension, typically through the extension manager available in Visual Studio. Once installed, the ecoCode analyzers are automatically activated in your IDE/compilation process, and will list any applicable info/alert.

<a name="vsCodeExtension"></a>🧩 VS Code extension
-----------------
Not available yet, stay tuned.
Pre-requisite : .Net 8 SDK.

<a name="sonarQube"></a>🧩 Analyzer for SonarQube
-----------------
Expand All @@ -73,10 +63,10 @@ EcoCode C# can use [SonarScanner for .Net](https://docs.sonarsource.com/sonarqub
|[EC92](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC92/csharp/EC92.asciidoc)|Use `Length` to test empty `strings`|⚠️|✔️|
|[EC93](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC93/csharp/EC93.asciidoc)|Return `Task` directly|ℹ️|✔️|

🌿 Roslyn Rules
🌿 Customized Roslyn Rules
-------------------

EcoCode C# customizes the severity of the following Microsoft-produced Roslyn rules.
EcoCode C# customizes the severity of the following native Roslyn rules.

|Id|Description|Old Severity|New Severity|
|--|-----------|:----------:|:----------:|
Expand Down
9 changes: 0 additions & 9 deletions VsixOnly.slnf

This file was deleted.

21 changes: 14 additions & 7 deletions ecoCode-csharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Filters", "Filters", "{2750
NuGetOnly.slnf = NuGetOnly.slnf
TestsOnly.slnf = TestsOnly.slnf
ToolOnly.slnf = ToolOnly.slnf
VsixOnly.slnf = VsixOnly.slnf
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assets", "Assets", "{375CBD0D-5754-352F-9D9D-ED72E2F1B0ED}"
Expand Down Expand Up @@ -50,8 +49,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Tests", "src\EcoCod
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Tool", "src\EcoCode.Tool\EcoCode.Tool.csproj", "{DBF60DEC-9C46-6FC0-EEE0-892F31353788}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Vsix", "src\EcoCode.Vsix\EcoCode.Vsix.csproj", "{A9DB5FED-AAF1-F128-AF8E-738F916D065F}"
EndProject
Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F20F15FF-417E-42ED-962A-2CF00C3E4467}
Expand All @@ -77,10 +74,20 @@ Global
{DBF60DEC-9C46-6FC0-EEE0-892F31353788}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DBF60DEC-9C46-6FC0-EEE0-892F31353788}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DBF60DEC-9C46-6FC0-EEE0-892F31353788}.Release|Any CPU.Build.0 = Release|Any CPU
{A9DB5FED-AAF1-F128-AF8E-738F916D065F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9DB5FED-AAF1-F128-AF8E-738F916D065F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9DB5FED-AAF1-F128-AF8E-738F916D065F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9DB5FED-AAF1-F128-AF8E-738F916D065F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6B1DB35C-47E6-C62F-BA1D-5846AF2B77D4} = {089100B1-113F-4E66-888A-E83F3999EAFD}
{27501C7C-A65B-40A8-464F-F047BAFE6F81} = {089100B1-113F-4E66-888A-E83F3999EAFD}
{375CBD0D-5754-352F-9D9D-ED72E2F1B0ED} = {089100B1-113F-4E66-888A-E83F3999EAFD}
EndGlobalSection
EndGlobal
}
EndGlobalSection
EndGlobal
916D065F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static async Task<Document> ReplaceWithLengthCheckAsync(Document documen
{
var (left, right) = (binaryExpr.Left, binaryExpr.Right);
var stringExpr = left.IsEmptyStringLiteral() ? right : right.IsEmptyStringLiteral() ? left : null;
return stringExpr is null ? document : await document.WithUpdatedRoot(binaryExpr, UpdateBinaryExpression(binaryExpr, stringExpr));
return stringExpr is null ? document : await document.WithUpdatedRoot(binaryExpr, UpdateBinaryExpression(binaryExpr, stringExpr)).ConfigureAwait(false);

static BinaryExpressionSyntax UpdateBinaryExpression(BinaryExpressionSyntax binaryExpr, ExpressionSyntax stringExpr) =>
SyntaxFactory.BinaryExpression(binaryExpr.Kind(),
Expand Down
6 changes: 3 additions & 3 deletions src/EcoCode.Core/Analyzers/EC93.ReturnTaskDirectly.Fixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static async Task<Document> ReturnTaskDirectlyWithExpressionAsync(

return await document.WithUpdatedRoot(methodDecl, methodDecl
.WithModifiers(methodDecl.Modifiers.RemoveAt(asyncIndex))
.WithExpressionBody(newBody));
.WithExpressionBody(newBody)).ConfigureAwait(false);
}

private static async Task<Document> ReturnTaskDirectlyWithBodyAwaitAsync(
Expand All @@ -104,7 +104,7 @@ private static async Task<Document> ReturnTaskDirectlyWithBodyAwaitAsync(

return await document.WithUpdatedRoot(methodDecl, methodDecl
.WithModifiers(methodDecl.Modifiers.RemoveAt(asyncIndex))
.WithBody(newBody));
.WithBody(newBody)).ConfigureAwait(false);
}

private static async Task<Document> ReturnTaskDirectlyWithBodyReturnAwaitAsync(
Expand All @@ -123,6 +123,6 @@ private static async Task<Document> ReturnTaskDirectlyWithBodyReturnAwaitAsync(

return await document.WithUpdatedRoot(methodDecl, methodDecl
.WithModifiers(methodDecl.Modifiers.RemoveAt(asyncIndex))
.WithBody(newBody));
.WithBody(newBody)).ConfigureAwait(false);
}
}
2 changes: 2 additions & 0 deletions src/EcoCode.Core/EcoCode.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<Product>EcoCode.Core</Product>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>

<NoWarn>${NoWarn};CA1062</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/EcoCode.Tool/Commands/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, AnalyzeSett
using var workspace = MSBuildWorkspace.Create();
workspace.WorkspaceFailed += (sender, e) => Program.WriteLine(e.Diagnostic.Message, "red");

var analysisService = await AnalysisService.CreateAsync(settings.SeverityLevel);
var analysisService = await AnalysisService.CreateAsync(settings.SeverityLevel).ConfigureAwait(false);

var diagnostics = new List<DiagnosticInfo>();

Expand Down Expand Up @@ -68,7 +68,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, AnalyzeSett
await analysisService.AnalyzeProjectAsync(project, diagnostics).ConfigureAwait(false);
}

await ReportService.GenerateReportAsync(diagnostics, settings.Output, settings.OutputType);
await ReportService.GenerateReportAsync(diagnostics, settings.Output, settings.OutputType).ConfigureAwait(false);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EcoCode.Tool/Common/AdditionalFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public static async Task<AdditionalFile> LoadGlobalConfigAsync()
throw new FileNotFoundException($"Editor config file not found at {editorConfigPath}");

string fileContent = await File.ReadAllTextAsync(editorConfigPath).ConfigureAwait(false);
return new AdditionalFile(GlobalConfigFile, fileContent.Replace("is_global = true", string.Empty));
return new AdditionalFile(GlobalConfigFile, fileContent.Replace("is_global = true", string.Empty, StringComparison.OrdinalIgnoreCase));
}
}
Loading

0 comments on commit dc1e351

Please sign in to comment.