Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrades for vs2022 and roslyn 4.3 and net6 and github actions #173

Merged
merged 20 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1 +1,87 @@
name: .NET Core Build and Publish

on:
push:
branches: master
pull_request:
branches: master

env:
NETCORE_VERSION: '6.0.x'
GIT_REPO_ROOT: src
MAJOR_MINOR_VERSION: 1.1.
SOLUTION_FILE: AgodaAnalyzers.Build.sln

jobs:
build:
name: Build Package
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK ${{ env.NETCORE_VERSION }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Restore
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet restore ${{ env.SOLUTION_FILE }}

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1

- name: Build
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Debug --no-restore

- name: Run Unit Tests and Generate Coverage
uses: glennawatson/coverlet-msbuild@v1
with:
project-files: '**/*Test.csproj'
no-build: true
output-format: cobertura
output: results
configuration: Debug

- name: Pack
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet pack ${{ env.SOLUTION_FILE }} --configuration Debug -o finalpackage -p:PackageVersion=${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}

- name: Publish artifact
uses: actions/upload-artifact@master
with:
name: nupkg
path: ${{ env.GIT_REPO_ROOT }}/finalpackage

- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: src/Agoda.Analyzers.Test/results.net6.cobertura.xml # optional
fail_ci_if_error: true # optional (default = false)

deploy:
needs: build
if: github.ref == 'refs/heads/main'
name: Deploy Packages
runs-on: ubuntu-latest
steps:
- name: Download Package artifact
uses: actions/download-artifact@master
with:
name: nupkg
path: ./nupkg

- name: Setup NuGet
uses: NuGet/[email protected]
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: latest

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Push to NuGet
run: dotnet nuget push nupkg/**/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org --skip-duplicate
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ To generate a jar file from this project for use with SonarQube we have prepared
## Contributing

[Please read the contributing guidelines](CONTRIBUTING.md)

## Dotnet Framework 4.x

[1.0.523](https://www.nuget.org/packages/Agoda.Analyzers/1.0.523) is our last version that supports dotnet framework, if you need to access the rules on a legacy project please use this version.
34 changes: 0 additions & 34 deletions appveyor.yml

This file was deleted.

10 changes: 5 additions & 5 deletions src/Agoda.Analyzers.CodeFixes/Agoda.Analyzers.CodeFixes.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
Expand Down Expand Up @@ -30,13 +30,13 @@
<ProjectReference Include="..\Agoda.Analyzers\Agoda.Analyzers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<None Include="Agoda.Analyzers.nuspec" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.Text;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Formatting;

namespace Agoda.Analyzers.CodeFixes.AgodaCustom
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using DocumentBasedFixAllProvider = Agoda.Analyzers.CodeFixes.Helpers.DocumentBasedFixAllProvider;

namespace Agoda.Analyzers.CodeFixes.StyleCop
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Editing;
using DocumentBasedFixAllProvider = Agoda.Analyzers.CodeFixes.Helpers.DocumentBasedFixAllProvider;

namespace Agoda.Analyzers.CodeFixes.StyleCop
{
Expand Down
46 changes: 24 additions & 22 deletions src/Agoda.Analyzers.Test/Agoda.Analyzers.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net6</TargetFrameworks>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
Expand Down Expand Up @@ -31,47 +31,49 @@
<ProjectReference Include="..\Agoda.Analyzers\Agoda.Analyzers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.3" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.3" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.NUnit" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.NUnit" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Testing.Verifiers.NUnit" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.Composition" Version="1.0.27" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NUnit" Version="3.6.0" />
<PackageReference Include="NUnit.Console" Version="3.6.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.6.0" />
<PackageReference Include="NUnit.Extension.NUnitProjectLoader" Version="3.5.0" />
<PackageReference Include="NUnit.Extension.NUnitV2Driver" Version="3.6.0" />
<PackageReference Include="NUnit.Extension.NUnitV2ResultWriter" Version="3.5.0" />
<PackageReference Include="NUnit.Extension.TeamCityEventListener" Version="1.0.2" />
<PackageReference Include="NUnit.Extension.VSProjectLoader" Version="3.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.6.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Selenium.WebDriver" Version="3.14.0" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Globalization" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.8.1" />
<PackageReference Include="System.Reflection.Metadata" Version="7.0.1" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web" />
</ItemGroup>
</Project>
</Project>
35 changes: 18 additions & 17 deletions src/Agoda.Analyzers.Test/AgodaCustom/AG0001UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@
using System.Web.Mvc;
using Agoda.Analyzers.AgodaCustom;
using Agoda.Analyzers.Test.Helpers;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Testing.Verifiers;
using NUnit.Framework;

namespace Agoda.Analyzers.Test.AgodaCustom
namespace Agoda.Analyzers.Test.AgodaCustom;

[TestFixture]
class AG0001UnitTests : DiagnosticVerifier
{
class AG0001UnitTests : DiagnosticVerifier
{
protected override DiagnosticAnalyzer DiagnosticAnalyzer => new AG0001DependencyResolverMustNotBeUsed();
protected override DiagnosticAnalyzer DiagnosticAnalyzer => new AG0001DependencyResolverMustNotBeUsed();

protected override string DiagnosticId => AG0001DependencyResolverMustNotBeUsed.DIAGNOSTIC_ID;
protected override string DiagnosticId => AG0001DependencyResolverMustNotBeUsed.DIAGNOSTIC_ID;

[Test]
public async Task TestDependencyResolverUsageAsync()
[Test]
public async Task TestDependencyResolverUsageAsync()
{
var code = new CodeDescriptor
{
var code = new CodeDescriptor
{
References = new[] {typeof(DependencyResolver).Assembly},
Code = @"
References = new[] {typeof(DependencyResolver).Assembly},
Code = @"
interface ISomething {
void DoSomething();
}
Expand All @@ -29,10 +32,8 @@ public void TestMethod() {
var instance = System.Web.Mvc.DependencyResolver.Current.GetService(typeof(ISomething));
}
}"
};

await VerifyDiagnosticsAsync(code, new DiagnosticLocation(8, 57));
}

};
await VerifyDiagnosticsAsync(code, new DiagnosticLocation(8, 57));
}
}

}
Loading