Skip to content

Commit 75a7464

Browse files
Merge pull request #17 from atc-net/feature/maintenance
Ensure backgroundservice is reported as running before each invocation of DoWorkAsync
2 parents f3b07cd + 5496c61 commit 75a7464

17 files changed

+157
-222
lines changed

.editorconfig

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
2-
# Version: 1.0.0
3-
# Updated: 25-09-2023
2+
# Version: 1.0.1
3+
# Updated: 03-06-2024
44
# Location: Root
55
# Distribution: DotNet8
66
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
@@ -464,10 +464,46 @@ dotnet_diagnostic.MA0048.severity = error # https://github.com/atc-net
464464
dotnet_diagnostic.CA1014.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1014.md
465465
dotnet_diagnostic.CA1068.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md
466466
dotnet_diagnostic.CA1305.severity = error
467+
dotnet_diagnostic.CA1308.severity = suggestion # Normalize strings to uppercase
468+
dotnet_diagnostic.CA1510.severity = suggestion # Use ArgumentNullException throw helper
469+
dotnet_diagnostic.CA1511.severity = suggestion # Use ArgumentException throw helper
470+
dotnet_diagnostic.CA1512.severity = suggestion # Use ArgumentOutOfRangeException throw helper
471+
dotnet_diagnostic.CA1513.severity = suggestion # Use ObjectDisposedException throw helper
472+
dotnet_diagnostic.CA1514.severity = error # Avoid redundant length argument
467473
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
468474
dotnet_diagnostic.CA1812.severity = none
469475
dotnet_diagnostic.CA1822.severity = suggestion
476+
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
477+
dotnet_diagnostic.CA1854.severity = suggestion # Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
478+
dotnet_diagnostic.CA1855.severity = suggestion # Prefer 'Clear' over 'Fill'
479+
dotnet_diagnostic.CA1856.severity = error # Incorrect usage of ConstantExpected attribute
480+
dotnet_diagnostic.CA1857.severity = suggestion # A constant is expected for the parameter
481+
dotnet_diagnostic.CA1858.severity = suggestion # Use 'StartsWith' instead of 'IndexOf'
482+
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
483+
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
484+
dotnet_diagnostic.CA1861.severity = suggestion # Avoid constant arrays as arguments
485+
dotnet_diagnostic.CA1862.severity = error # Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
486+
dotnet_diagnostic.CA1863.severity = suggestion # Use 'CompositeFormat'
487+
dotnet_diagnostic.CA1864.severity = suggestion # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
488+
dotnet_diagnostic.CA1865.severity = suggestion # Use char overload
489+
dotnet_diagnostic.CA1866.severity = suggestion # Use char overload
490+
dotnet_diagnostic.CA1867.severity = suggestion # Use char overload
491+
dotnet_diagnostic.CA1868.severity = suggestion # Unnecessary call to 'Contains(item)'
492+
dotnet_diagnostic.CA1869.severity = suggestion # Cache and reuse 'JsonSerializerOptions' instances
493+
dotnet_diagnostic.CA1870.severity = suggestion # Use a cached 'SearchValues' instance
470494
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
495+
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
496+
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
497+
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
498+
dotnet_diagnostic.CA2021.severity = error # Don't call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
499+
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
500+
dotnet_diagnostic.CA2252.severity = suggestion # Opt-in to preview features should be used with caution
501+
dotnet_diagnostic.CA2253.severity = error # Named placeholders should not be numeric values
502+
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression
503+
dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attribute should not be used in libraries
504+
dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is only used with static fields
505+
dotnet_diagnostic.CA2260.severity = error # Implement generic math interfaces correctly
506+
dotnet_diagnostic.CA2261.severity = error # Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
471507
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
472508
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
473509

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
name: "Pre-Integration"
1+
name: Build and test
22

33
on:
4-
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
- reopened
4+
push:
95

106
jobs:
11-
dotnet-build:
7+
build:
128
strategy:
139
matrix:
1410
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -31,27 +27,6 @@ jobs:
3127
run: dotnet restore
3228

3329
- name: 🛠️ Building library in release mode
34-
run: dotnet build -c Release --no-restore
35-
36-
dotnet-test:
37-
runs-on: ubuntu-latest
38-
needs:
39-
- dotnet-build
40-
steps:
41-
- name: 🛒 Checkout repository
42-
uses: actions/checkout@v4
43-
with:
44-
fetch-depth: 0
45-
46-
- name: ⚙️ Setup dotnet 8.0.x
47-
uses: actions/setup-dotnet@v4
48-
with:
49-
dotnet-version: '8.0.x'
50-
51-
- name: 🔁 Restore packages
52-
run: dotnet restore
53-
54-
- name: 🛠️ Build
5530
run: dotnet build -c Release --no-restore /p:UseSourceLink=true
5631

5732
- name: 🧪 Run unit tests

.github/workflows/post-integration.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: release-please
13+
id: release
14+
uses: googleapis/release-please-action@v4
15+
with:
16+
token: ${{ secrets.RELEASE_PLEASE_PAT }}
17+
18+
- name: 🛒 Checkout repository
19+
if: ${{ steps.release.outputs.release_created }}
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
token: ${{ secrets.RELEASE_PLEASE_PAT }}
24+
25+
- name: ⚙️ Setup dotnet 8.0.x
26+
if: ${{ steps.release.outputs.release_created }}
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: '8.0.x'
30+
31+
- name: 🧹 Clean
32+
if: ${{ steps.release.outputs.release_created }}
33+
run: dotnet clean -c Release && dotnet nuget locals all --clear
34+
35+
- name: 🔁 Restore packages
36+
if: ${{ steps.release.outputs.release_created }}
37+
run: dotnet restore
38+
39+
- name: 🛠️ Building library in release mode
40+
if: ${{ steps.release.outputs.release_created }}
41+
run: dotnet build -c Release --no-restore /p:UseSourceLink=true
42+
43+
- name: 🗳️ Creating library package for release
44+
if: ${{ steps.release.outputs.release_created }}
45+
run: dotnet pack -c Release --no-restore -o ${GITHUB_WORKSPACE}/packages /p:PublicRelease=true
46+
47+
- name: 📦 Push packages to NuGet
48+
if: ${{ steps.release.outputs.release_created }}
49+
run: |
50+
dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols

.github/workflows/release.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.0.53"
3+
}

Directory.Build.props

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
<NeutralLanguage>en</NeutralLanguage>
1414
<DefaultLanguage>en-US</DefaultLanguage>
1515
</PropertyGroup>
16+
17+
<PropertyGroup Label="Versioning">
18+
<!-- The 'x-release-please-' comments are used to inform the release-please action that it should update the semver version here -->
19+
<!-- x-release-please-start-version -->
20+
<Version>1.0.53</Version>
21+
<!-- x-release-please-end -->
22+
<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>
23+
</PropertyGroup>
1624

1725
<PropertyGroup Label="Compile settings">
1826
<Nullable>enable</Nullable>
@@ -43,10 +51,10 @@
4351
<ItemGroup Label="Code Analyzers">
4452
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
4553
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
46-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.162" PrivateAssets="All" />
54+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.169" PrivateAssets="All" />
4755
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
4856
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
49-
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.30.0.95878" PrivateAssets="All" />
57+
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="All" />
5058
</ItemGroup>
5159

5260
</Project>

release-please-config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"release-type": "simple",
4+
"bootstrap-sha": "f3b07cd737f1930ba7e4f222d4fb90b3783f3ccc",
5+
"pull-request-title-pattern": "chore: release version ${version}",
6+
"pull-request-header": ":robot: Preparing to release next version",
7+
"pull-request-footer": "This pull request was generated by release-please.",
8+
"packages": {
9+
".": {
10+
}
11+
},
12+
"extra-files": [
13+
"Directory.Build.props"
14+
]
15+
}

src/Atc.Hosting/BackgroundServiceBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ await Task
192192
{
193193
try
194194
{
195+
healthService.SetRunningState(ServiceName, isRunning: true);
195196
await DoWorkAsync(stoppingToken).ConfigureAwait(false);
196197
healthService.SetRunningState(ServiceName, isRunning: true);
197198
}

src/Atc.Hosting/GlobalUsings.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
global using System.Collections.Concurrent;
22
global using System.Diagnostics.CodeAnalysis;
3-
43
global using Atc.Hosting.Internal;
5-
64
global using Cronos;
7-
85
global using Microsoft.Extensions.DependencyInjection;
96
global using Microsoft.Extensions.Hosting;
107
global using Microsoft.Extensions.Logging;

0 commit comments

Comments
 (0)