Skip to content

Commit 5e618dc

Browse files
authored
Fix nullability annotation of IConnectionMultiplexer.RegisterProfiler (#2494)
RegisterProfiler allows for a null ProfilingSession to be returned - it is even documented with "or returning null to not profile". Fixing the nullable annotation to indicate that null is an acceptable result of the profilingSessionProvider function.
1 parent f6171a1 commit 5e618dc

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

docs/ReleaseNotes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Current package versions:
88

99
## Unreleased
1010

11+
- Fix: Fix nullability annotation of IConnectionMultiplexer.RegisterProfiler ([#2494 by eerhardt](https://github.com/StackExchange/StackExchange.Redis/pull/2494))
12+
1113
## 2.6.116
1214

1315
- Fix [#2479](https://github.com/StackExchange/StackExchange.Redis/issues/2479): Add `RedisChannel.UseImplicitAutoPattern` (global) and `RedisChannel.IsPattern` ([#2480 by mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/2480))

src/StackExchange.Redis/ConnectionMultiplexer.Profiling.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace StackExchange.Redis;
55

66
public partial class ConnectionMultiplexer
77
{
8-
private Func<ProfilingSession>? _profilingSessionProvider;
8+
private Func<ProfilingSession?>? _profilingSessionProvider;
99

1010
/// <summary>
1111
/// Register a callback to provide an on-demand ambient session provider based on the
1212
/// calling context; the implementing code is responsible for reliably resolving the same provider
1313
/// based on ambient context, or returning null to not profile
1414
/// </summary>
1515
/// <param name="profilingSessionProvider">The session provider to register.</param>
16-
public void RegisterProfiler(Func<ProfilingSession> profilingSessionProvider) => _profilingSessionProvider = profilingSessionProvider;
16+
public void RegisterProfiler(Func<ProfilingSession?> profilingSessionProvider) => _profilingSessionProvider = profilingSessionProvider;
1717
}

src/StackExchange.Redis/Interfaces/IConnectionMultiplexer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public interface IConnectionMultiplexer : IDisposable, IAsyncDisposable
7878
/// based on ambient context, or returning null to not profile.
7979
/// </summary>
8080
/// <param name="profilingSessionProvider">The profiling session provider.</param>
81-
void RegisterProfiler(Func<ProfilingSession> profilingSessionProvider);
81+
void RegisterProfiler(Func<ProfilingSession?> profilingSessionProvider);
8282

8383
/// <summary>
8484
/// Get summary statistics associates with this server.

src/StackExchange.Redis/PublicAPI/PublicAPI.Shipped.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ StackExchange.Redis.ConnectionMultiplexer.PreserveAsyncOrder.set -> void
359359
StackExchange.Redis.ConnectionMultiplexer.PublishReconfigure(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> long
360360
StackExchange.Redis.ConnectionMultiplexer.PublishReconfigureAsync(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task<long>!
361361
StackExchange.Redis.ConnectionMultiplexer.ReconfigureAsync(string! reason) -> System.Threading.Tasks.Task<bool>!
362-
StackExchange.Redis.ConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession!>! profilingSessionProvider) -> void
362+
StackExchange.Redis.ConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession?>! profilingSessionProvider) -> void
363363
StackExchange.Redis.ConnectionMultiplexer.ResetStormLog() -> void
364364
StackExchange.Redis.ConnectionMultiplexer.ServerMaintenanceEvent -> System.EventHandler<StackExchange.Redis.Maintenance.ServerMaintenanceEvent!>?
365365
StackExchange.Redis.ConnectionMultiplexer.StormLogThreshold.get -> int
@@ -497,7 +497,7 @@ StackExchange.Redis.IConnectionMultiplexer.PreserveAsyncOrder.get -> bool
497497
StackExchange.Redis.IConnectionMultiplexer.PreserveAsyncOrder.set -> void
498498
StackExchange.Redis.IConnectionMultiplexer.PublishReconfigure(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> long
499499
StackExchange.Redis.IConnectionMultiplexer.PublishReconfigureAsync(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task<long>!
500-
StackExchange.Redis.IConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession!>! profilingSessionProvider) -> void
500+
StackExchange.Redis.IConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession?>! profilingSessionProvider) -> void
501501
StackExchange.Redis.IConnectionMultiplexer.ResetStormLog() -> void
502502
StackExchange.Redis.IConnectionMultiplexer.ServerMaintenanceEvent -> System.EventHandler<StackExchange.Redis.Maintenance.ServerMaintenanceEvent!>!
503503
StackExchange.Redis.IConnectionMultiplexer.StormLogThreshold.get -> int

tests/StackExchange.Redis.Tests/Helpers/SharedConnectionFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public event EventHandler<ServerMaintenanceEvent> ServerMaintenanceEvent
169169

170170
public Task<long> PublishReconfigureAsync(CommandFlags flags = CommandFlags.None) => _inner.PublishReconfigureAsync(flags);
171171

172-
public void RegisterProfiler(Func<ProfilingSession> profilingSessionProvider) => _inner.RegisterProfiler(profilingSessionProvider);
172+
public void RegisterProfiler(Func<ProfilingSession?> profilingSessionProvider) => _inner.RegisterProfiler(profilingSessionProvider);
173173

174174
public void ResetStormLog() => _inner.ResetStormLog();
175175

0 commit comments

Comments
 (0)