Skip to content

Commit cea0daa

Browse files
committed
Standardise on NuGet Trusted Publishing, align with XWiki.Api pattern, fix analyzer warnings
1 parent bf1557f commit cea0daa

17 files changed

Lines changed: 130 additions & 126 deletions

File tree

.editorConfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,25 @@ csharp_style_prefer_top_level_statements = true:silent
150150
dotnet_diagnostic.CA1050.severity = error
151151
#dotnet_naming_style.constant_field_style.required_prefix = _ NOPE.
152152

153+
# CA1848: Use the LoggerMessage delegates
154+
dotnet_diagnostic.CA1848.severity = none
155+
# CA1873: Avoid unnecessary string evaluation for logging
156+
dotnet_diagnostic.CA1873.severity = none
157+
# CA5350: SHA1 is required by SSH protocol (diffie-hellman-group1-sha1)
158+
dotnet_diagnostic.CA5350.severity = none
159+
# CA5351: MD5 is required for SSH fingerprint computation
160+
dotnet_diagnostic.CA5351.severity = none
161+
# CA5384: DSA is required for SSH DSS key support
162+
dotnet_diagnostic.CA5384.severity = none
163+
# CA1305: string.Format locale - SSH protocol messages are not user-facing
164+
dotnet_diagnostic.CA1305.severity = none
165+
# CA1051: Protected fields in abstract base classes are part of the library API
166+
dotnet_diagnostic.CA1051.severity = none
167+
# CA1001: Disposable ownership patterns are managed via CloseService/ForceClose
168+
dotnet_diagnostic.CA1001.severity = none
169+
# CA1711: CipherModeEx is an established name in the codebase
170+
dotnet_diagnostic.CA1711.severity = none
171+
153172
vsspell_section_id = 24bfe3a339004957ab34f7654481307f
154173
vsspell_spell_check_as_you_type = true
155174
vsspell_ignore_words_with_digits = true

.github/workflows/ci.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
tags: ['[0-9]*.[0-9]*.[0-9]*']
67
pull_request:
78
branches: [main]
89

910
jobs:
1011
build:
1112
runs-on: ubuntu-latest
13+
1214
steps:
1315
- uses: actions/checkout@v4
1416
with:
@@ -19,11 +21,46 @@ jobs:
1921
with:
2022
dotnet-version: '10.0.x'
2123

22-
- name: Restore dependencies
24+
- name: Restore
2325
run: dotnet restore
2426

2527
- name: Build
2628
run: dotnet build --no-restore --configuration Release
2729

28-
- name: Test
29-
run: dotnet test --no-build --configuration Release --verbosity normal
30+
- name: Pack
31+
run: dotnet pack PanoramicData.SshServer/PanoramicData.SshServer.csproj --no-build --configuration Release --output ./artifacts
32+
33+
- name: Upload NuGet artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: nuget
37+
path: |
38+
./artifacts/*.nupkg
39+
./artifacts/*.snupkg
40+
41+
publish:
42+
needs: build
43+
runs-on: ubuntu-latest
44+
if: startsWith(github.ref, 'refs/tags/')
45+
permissions:
46+
id-token: write
47+
48+
steps:
49+
- uses: actions/download-artifact@v4
50+
with:
51+
name: nuget
52+
path: ./artifacts
53+
54+
- name: Setup .NET
55+
uses: actions/setup-dotnet@v4
56+
with:
57+
dotnet-version: '10.0.x'
58+
59+
- name: NuGet login (Trusted Publishing)
60+
uses: NuGet/login@v1
61+
id: login
62+
with:
63+
user: david_n_m_bond
64+
65+
- name: Publish to NuGet
66+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

Directory.Build.props

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<Project>
22
<PropertyGroup>
3-
<Company>Panoramic Data Limited</Company>
43
<Authors>Panoramic Data Limited</Authors>
5-
<Copyright>Copyright © $([System.DateTime]::Now.Year) Panoramic Data Limited</Copyright>
6-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
4+
<Company>Panoramic Data Limited</Company>
5+
<Copyright>Copyright © Panoramic Data Limited $([System.DateTime]::Now.Year)</Copyright>
6+
<LangVersion>latest</LangVersion>
77
<Nullable>enable</Nullable>
8-
<NuGetAuditMode>All</NuGetAuditMode>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<AnalysisMode>All</AnalysisMode>
11+
<AnalysisLevel>latest-recommended</AnalysisLevel>
12+
<NuGetAuditMode>all</NuGetAuditMode>
913
<!-- Nullable warnings kept as warnings (not errors) for gradual adoption in existing codebase -->
1014
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8618;CS8619;CS8620;CS8622;CS8625;CS8631;CS8634;CS8714;CS8765;CS8767</WarningsNotAsErrors>
1115
</PropertyGroup>

PanoramicData.SshServer.Test/ExampleKeyManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
namespace ExampleApp;
1010

11-
internal class ExampleKeyManager : IKeyManager
11+
internal sealed class ExampleKeyManager : IKeyManager
1212
{
1313
public async Task<Dictionary<string, string>> GetHostKeysAsync(CancellationToken cancellationToken)
14-
=> new Dictionary<string, string>
14+
=> new()
1515
{
1616
{ "rsa-sha2-256", await GetPrivateKeyBase64Async("rsa-sha2-256", cancellationToken) },
1717
{ "ssh-dss", await GetPrivateKeyBase64Async("ssh-dss", cancellationToken) },

PanoramicData.SshServer.Test/ExampleSshApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System;
88

99
namespace ExampleApp;
10-
internal class ExampleSshApplication(
10+
internal sealed class ExampleSshApplication(
1111
IOptions<ExampleSshApplicationConfiguration> options,
1212
ILogger<Program> logger) : ISshApplication
1313
{

PanoramicData.SshServer.Test/ExampleSshApplicationConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace ExampleApp;
22

3-
internal class ExampleSshApplicationConfiguration
3+
internal sealed class ExampleSshApplicationConfiguration
44
{
55
/// <summary>
66
/// Whether to permit TCP forwarding.

PanoramicData.SshServer.Test/MiniTerm/Processes/Process.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal sealed class Process(Native.ProcessApi.STARTUPINFOEX startupInfo, Nativ
1414

1515
#region IDisposable Support
1616

17-
private bool _disposedValue = false; // To detect redundant calls
17+
private bool _disposedValue; // To detect redundant calls
1818

1919
void Dispose(bool disposing)
2020
{

PanoramicData.SshServer.Test/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace ExampleApp;
1414

15+
#pragma warning disable CA1852 // Partial Program class cannot be sealed
1516
partial class Program
1617
{
1718
static async Task Main()

PanoramicData.SshServer.Test/TcpForwardService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class TcpForwardService(
1212
{
1313
private readonly Socket _socket = new(SocketType.Stream, ProtocolType.Tcp);
1414
private readonly List<byte> _blocked = [];
15-
private bool _connected = false;
15+
private bool _connected;
1616

1717
public event EventHandler<byte[]> DataReceived;
1818
public event EventHandler CloseReceived;

PanoramicData.SshServer/Algorithms/CtrModeCryptoTransform.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,9 @@ public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int input
6565
return output;
6666
}
6767

68-
public void Dispose() => _transform.Dispose();
68+
public void Dispose()
69+
{
70+
_transform.Dispose();
71+
GC.SuppressFinalize(this);
72+
}
6973
}

0 commit comments

Comments
 (0)