Skip to content

Commit 75d66ae

Browse files
dependabot[bot]HandyS11claude
authored
Bump SonarAnalyzer.CSharp from 10.29.0.143774 to 10.30.0.144632 (#71)
* Bump SonarAnalyzer.CSharp from 10.29.0.143774 to 10.30.0.144632 --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-version: 10.30.0.144632 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: satisfy new SonarAnalyzer 10.30 rules S8969 and S8949 SonarAnalyzer 10.30 adds S8969 (redundant null-forgiving operator) and S8949 (missing cancellation token). With TreatWarningsAsErrors both break the build. - Drop null-forgiving operators the compiler already knows are redundant, mostly after Assert.NotNull. - Swap `.Where(t => t is not null)` for `.OfType<Task>()` in the hosted services' StopAsync so the loop task is non-null by type instead of by assertion. - Thread the service token through the workspace heal paths and the pairing expiry write, and swallow the resulting cancellation on shutdown. - Pass CancellationToken.None explicitly to ConnectionSupervisor's gate waits: those run during teardown, after _shutdown is already cancelled. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: = <valentin-clergue@orange.fr> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent e203885 commit 75d66ae

29 files changed

Lines changed: 92 additions & 75 deletions

File tree

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="18.7.23" />
4747
<PackageVersion Include="Roslynator.Analyzers" Version="4.15.0" />
4848
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.15.0" />
49-
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.29.0.143774" />
49+
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.30.0.144632" />
5050
</ItemGroup>
5151
</Project>

src/RustPlusBot.Features.Alarms/Hosting/AlarmsHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
4949
foreach (var loop in new[]
5050
{
5151
_pairedLoop, _triggeredLoop, _statusLoop, _reachabilityLoop, _observedLoop, _wipedLoop
52-
}.Where(t => t is not null))
52+
}.OfType<Task>())
5353
{
5454
try
5555
{
5656
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
57-
await loop!.ConfigureAwait(false);
57+
await loop.ConfigureAwait(false);
5858
#pragma warning restore VSTHRD003
5959
}
6060
catch (OperationCanceledException)

src/RustPlusBot.Features.Connections/Supervisor/ConnectionSupervisor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ public async Task EnsureConnectionAsync(ulong guildId, Guid serverId, Cancellati
173173
/// <inheritdoc />
174174
public async Task StopAsync(ulong guildId, Guid serverId)
175175
{
176-
await _gate.WaitAsync().ConfigureAwait(false);
176+
// CancellationToken.None, not _shutdown.Token: teardown must still acquire the gate after
177+
// StopAllAsync has already cancelled _shutdown, otherwise the connection is never stopped.
178+
await _gate.WaitAsync(CancellationToken.None).ConfigureAwait(false);
177179
try
178180
{
179181
await StopConnectionAsync((guildId, serverId)).ConfigureAwait(false);
@@ -188,7 +190,8 @@ public async Task StopAsync(ulong guildId, Guid serverId)
188190
public async Task StopAllAsync()
189191
{
190192
await _shutdown.CancelAsync().ConfigureAwait(false);
191-
await _gate.WaitAsync().ConfigureAwait(false);
193+
// CancellationToken.None: _shutdown was just cancelled, so waiting on it would abandon shutdown.
194+
await _gate.WaitAsync(CancellationToken.None).ConfigureAwait(false);
192195
try
193196
{
194197
foreach (var key in _connections.Keys.ToList())

src/RustPlusBot.Features.Events/Hosting/EventsHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
6060
foreach (var loop in new[]
6161
{
6262
_relayLoop, _rigLoop, _tickLoop, _disconnectLoop
63-
}.Where(t => t is not null))
63+
}.OfType<Task>())
6464
{
6565
try
6666
{
6767
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
68-
await loop!.ConfigureAwait(false);
68+
await loop.ConfigureAwait(false);
6969
#pragma warning restore VSTHRD003
7070
}
7171
catch (OperationCanceledException)

src/RustPlusBot.Features.Map/Hosting/InfoMapHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
5858
foreach (var loop in new[]
5959
{
6060
_statusLoop, _tickLoop
61-
}.Where(t => t is not null))
61+
}.OfType<Task>())
6262
{
6363
try
6464
{
6565
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
66-
await loop!.ConfigureAwait(false);
66+
await loop.ConfigureAwait(false);
6767
#pragma warning restore VSTHRD003
6868
}
6969
catch (OperationCanceledException)

src/RustPlusBot.Features.Map/Hosting/MapHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
7979
foreach (var loop in new[]
8080
{
8181
_markerLoop, _settingsLoop, _statusLoop, _tickLoop
82-
}.Where(t => t is not null))
82+
}.OfType<Task>())
8383
{
8484
try
8585
{
8686
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
87-
await loop!.ConfigureAwait(false);
87+
await loop.ConfigureAwait(false);
8888
#pragma warning restore VSTHRD003
8989
}
9090
catch (OperationCanceledException)

src/RustPlusBot.Features.Pairing/Supervisor/PairingSupervisor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ private async Task MarkExpiredAsync((ulong Guild, ulong Owner) key, Guid registr
249249
await using (expireScope.ConfigureAwait(false))
250250
{
251251
var store = expireScope.ServiceProvider.GetRequiredService<IFcmRegistrationStore>();
252-
await store.SetStatusAsync(registrationId, FcmRegistrationStatus.Expired).ConfigureAwait(false);
252+
await store.SetStatusAsync(registrationId, FcmRegistrationStatus.Expired, _shutdown.Token)
253+
.ConfigureAwait(false);
253254
}
254255

255-
await notifier.NotifyCredentialsExpiredAsync(key.Guild, key.Owner).ConfigureAwait(false);
256+
await notifier.NotifyCredentialsExpiredAsync(key.Guild, key.Owner, _shutdown.Token).ConfigureAwait(false);
256257
}
257258

258259
private sealed class Handle : IAsyncDisposable

src/RustPlusBot.Features.StorageMonitors/Hosting/StorageMonitorsHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
4747
foreach (var loop in new[]
4848
{
4949
_pairedLoop, _triggeredLoop, _statusLoop, _reachabilityLoop, _wipedLoop
50-
}.Where(t => t is not null))
50+
}.OfType<Task>())
5151
{
5252
try
5353
{
5454
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
55-
await loop!.ConfigureAwait(false);
55+
await loop.ConfigureAwait(false);
5656
#pragma warning restore VSTHRD003
5757
}
5858
catch (OperationCanceledException)

src/RustPlusBot.Features.Switches/Hosting/SwitchesHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
4949
foreach (var loop in new[]
5050
{
5151
_pairedLoop, _stateLoop, _statusLoop, _deviceLoop, _reachabilityLoop, _wipedLoop
52-
}.Where(t => t is not null))
52+
}.OfType<Task>())
5353
{
5454
try
5555
{
5656
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
57-
await loop!.ConfigureAwait(false);
57+
await loop.ConfigureAwait(false);
5858
#pragma warning restore VSTHRD003
5959
}
6060
catch (OperationCanceledException)

src/RustPlusBot.Features.Wipes/Hosting/WipesHostedService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public async Task StopAsync(CancellationToken cancellationToken)
3939
foreach (var loop in new[]
4040
{
4141
_statusLoop, _wipedLoop
42-
}.Where(t => t is not null))
42+
}.OfType<Task>())
4343
{
4444
try
4545
{
4646
#pragma warning disable VSTHRD003 // Our own loop tasks, joined on stop.
47-
await loop!.ConfigureAwait(false);
47+
await loop.ConfigureAwait(false);
4848
#pragma warning restore VSTHRD003
4949
}
5050
catch (OperationCanceledException)

0 commit comments

Comments
 (0)