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

Upgrade pipelines and coding-rules #12

Merged
merged 8 commits into from
Apr 9, 2024
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
22 changes: 16 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.9
# Updated: 31-03-2023
# Version: 1.0.0
# Updated: 25-09-2023
# Location: Root
# Distribution: DotNet7
# Distribution: DotNet8
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

##########################################
Expand Down Expand Up @@ -201,8 +201,8 @@ csharp_style_unused_value_assignment_preference = discard_variable

# Index and range preferences
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences
csharp_style_prefer_index_operator = true # IDE0056
csharp_style_prefer_range_operator = true # IDE0057
csharp_style_prefer_index_operator = true:suggestion # IDE0056
csharp_style_prefer_range_operator = true:suggestion # IDE0057

# Miscellaneous preferences
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences
Expand Down Expand Up @@ -450,18 +450,23 @@ dotnet_naming_rule.parameters_rule.severity = warning
dotnet_diagnostic.MA0003.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0003.md
dotnet_diagnostic.MA0004.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0004.md
dotnet_diagnostic.MA0006.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0006.md
dotnet_diagnostic.MA0011.severity = none # Duplicate of CA1305
dotnet_diagnostic.MA0016.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0016.md
dotnet_diagnostic.MA0025.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0025.md
dotnet_diagnostic.MA0026.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0026.md
dotnet_diagnostic.MA0028.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0028.md
dotnet_diagnostic.MA0038.severity = none # Duplicate of CA1822
dotnet_diagnostic.MA0048.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0048.md


# Microsoft - Code Analysis
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/
dotnet_diagnostic.CA1014.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1014.md
dotnet_diagnostic.CA1068.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md
dotnet_diagnostic.CA1305.severity = error
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
dotnet_diagnostic.CA1812.severity = none
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
Expand All @@ -488,6 +493,7 @@ dotnet_diagnostic.SA1202.severity = none # https://github.com/atc-net
dotnet_diagnostic.SA1204.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1204.md
dotnet_diagnostic.SA1413.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1413.md
dotnet_diagnostic.SA1600.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1600.md
dotnet_diagnostic.SA1601.severity = none
dotnet_diagnostic.SA1602.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1602.md
dotnet_diagnostic.SA1604.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1604.md
dotnet_diagnostic.SA1623.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1623.md
Expand All @@ -499,6 +505,10 @@ dotnet_diagnostic.SA1649.severity = error # https://github.com/atc-net
# SonarAnalyzer.CSharp
# https://rules.sonarsource.com/csharp
dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/SonarAnalyzerCSharp/S1135.md
dotnet_diagnostic.S2629.severity = none # Don't use string interpolation in logging message templates.
dotnet_diagnostic.S6602.severity = none # "Find" method should be used instead of the "FirstOrDefault"
dotnet_diagnostic.S6603.severity = none # The collection-specific "TrueForAll" method should be used instead of the "All"
dotnet_diagnostic.S6605.severity = none # Collection-specific "Exists" method should be used instead of the "Any"


##########################################
Expand All @@ -514,10 +524,10 @@ dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net
dotnet_diagnostic.SA1615.severity = none # Element return value should be documented

dotnet_diagnostic.CA1056.severity = none # URI properties should not be strings
dotnet_diagnostic.CA1812.severity = none # Internal class that is apparently never instantiated.
dotnet_diagnostic.CA2007.severity = none # Consider calling ConfigureAwait on the awaited task
dotnet_diagnostic.CA2227.severity = none # Collection properties should be read only

dotnet_diagnostic.MA0004.severity = none # Use Task.ConfigureAwait(false) as the current SynchronizationContext is not needed

dotnet_diagnostic.S1172.severity = suggestion # Temporary, due to false positive in latest version of the analyzer package
dotnet_diagnostic.S6672.severity = suggestion # Intended the logger is generic
8 changes: 4 additions & 4 deletions .github/workflows/post-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}
Expand All @@ -30,10 +30,10 @@ jobs:
with:
setAllVars: true

- name: ⚙️ Setup dotnet 7.0.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: ⚙️ Set up JDK 17
uses: actions/setup-java@v3
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pre-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 7.0.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear
Expand All @@ -39,14 +39,14 @@ jobs:
- dotnet-build
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 7.0.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: 🔁 Restore packages
run: dotnet restore
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}
Expand All @@ -27,10 +27,10 @@ jobs:
with:
setAllVars: true

- name: ⚙️ Setup dotnet 7.0.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<PropertyGroup Label="Compile settings">
<Nullable>enable</Nullable>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1573,1591,1712,CA1014,NU5104</NoWarn>

Expand All @@ -43,10 +43,10 @@
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.33" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146" PrivateAssets="All" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.23.1.88495" PrivateAssets="All" />
</ItemGroup>

</Project>
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The Atc.Hosting namespace serves as a toolbox for building scalable and reliable
- [Constructor dependency injection](#constructor-dependency-injection)
- [In your `StartAsync` and `StopAsync` methods, update the service's running state](#in-your-startasync-and-stopasync-methods-update-the-services-running-state)
- [Inside your worker method, you can set the running state of the service (to update latest timestamp)](#inside-your-worker-method-you-can-set-the-running-state-of-the-service-to-update-latest-timestamp)
- [Default implementation for `BackgroundServiceBase<>`](#default-implementation-for-backgroundservicebase)
- [Complete TimeFileWorker example](#complete-timefileworker-example)
- [Extensions for ServiceProvider](#extensions-for-serviceprovider)
- [Using GetHostedService`<T>`](#using-gethostedservicet)
Expand Down Expand Up @@ -185,8 +186,8 @@ The `BackgroundServiceBase<>` automatically uses the `IBackgroundServiceHealthSe
public TimeFileWorker(
//...other parameters
IBackgroundServiceHealthService healthService,
//...other parameters
)
//...other parameters
)
: base (healthService)
{
//...other initializations
Expand Down Expand Up @@ -313,7 +314,7 @@ public void DefineEndpoints(WebApplication app)

# Requirements

- [.NET 7 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
- [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)

# How to contribute

Expand Down
6 changes: 5 additions & 1 deletion atc-coding-rules-updater.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"projectTarget": "DotNet7",
"projectTarget": "DotNet8",
"useLatestMinorNugetVersion": true,
"useTemporarySuppressions": false,
"temporarySuppressionAsExcel": false,
"analyzerProviderCollectingMode": "LocalCache",
"mappings": {
"src": {
"paths": [
Expand Down
2 changes: 1 addition & 1 deletion atc-coding-rules-updater.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ atc-coding-rules-updater `
run `
-p $currentPath `
--optionsPath $currentPath'\atc-coding-rules-updater.json' `
-v
--verbose
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.9
# Updated: 31-03-2023
# Version: 1.0.0
# Updated: 25-09-2023
# Location: src
# Distribution: DotNet7
# Distribution: DotNet8
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

##########################################
Expand Down Expand Up @@ -48,4 +48,4 @@

dotnet_diagnostic.CA1002.severity = none # Do not expose generic lists

dotnet_diagnostic.MA0016.severity = none # Prefer returning collection abstraction instead of implementation
dotnet_diagnostic.MA0016.severity = none # Prefer returning collection abstraction instead of implementation
6 changes: 3 additions & 3 deletions src/Atc.Hosting/Atc.Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.349" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Atc" Version="2.0.465" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="All" />
</ItemGroup>

</Project>
7 changes: 4 additions & 3 deletions test/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.9
# Updated: 31-03-2023
# Version: 1.0.0
# Updated: 25-09-2023
# Location: test
# Distribution: DotNet7
# Distribution: DotNet8
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

##########################################
Expand All @@ -27,6 +27,7 @@ dotnet_diagnostic.MA0016.severity = none # https://github.com/atc-net
# Microsoft - Code Analysis
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/
dotnet_diagnostic.CA1068.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md
dotnet_diagnostic.CA1602.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1602.md
dotnet_diagnostic.CA1707.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
dotnet_diagnostic.CA2007.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md

Expand Down
16 changes: 8 additions & 8 deletions test/Atc.Hosting.Tests/Atc.Hosting.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc.Test" Version="1.0.72" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.16" PrivateAssets="All" />
<PackageReference Include="Atc.Test" Version="1.0.89" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down