Skip to content

Commit

Permalink
Fix nullability annotation of IConnectionMultiplexer.RegisterProfiler (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
eerhardt authored Jun 28, 2023
1 parent f6171a1 commit 5e618dc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Current package versions:

## Unreleased

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

## 2.6.116

- 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))
Expand Down
4 changes: 2 additions & 2 deletions src/StackExchange.Redis/ConnectionMultiplexer.Profiling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace StackExchange.Redis;

public partial class ConnectionMultiplexer
{
private Func<ProfilingSession>? _profilingSessionProvider;
private Func<ProfilingSession?>? _profilingSessionProvider;

/// <summary>
/// Register a callback to provide an on-demand ambient session provider based on the
/// calling context; the implementing code is responsible for reliably resolving the same provider
/// based on ambient context, or returning null to not profile
/// </summary>
/// <param name="profilingSessionProvider">The session provider to register.</param>
public void RegisterProfiler(Func<ProfilingSession> profilingSessionProvider) => _profilingSessionProvider = profilingSessionProvider;
public void RegisterProfiler(Func<ProfilingSession?> profilingSessionProvider) => _profilingSessionProvider = profilingSessionProvider;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public interface IConnectionMultiplexer : IDisposable, IAsyncDisposable
/// based on ambient context, or returning null to not profile.
/// </summary>
/// <param name="profilingSessionProvider">The profiling session provider.</param>
void RegisterProfiler(Func<ProfilingSession> profilingSessionProvider);
void RegisterProfiler(Func<ProfilingSession?> profilingSessionProvider);

/// <summary>
/// Get summary statistics associates with this server.
Expand Down
4 changes: 2 additions & 2 deletions src/StackExchange.Redis/PublicAPI/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ StackExchange.Redis.ConnectionMultiplexer.PreserveAsyncOrder.set -> void
StackExchange.Redis.ConnectionMultiplexer.PublishReconfigure(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> long
StackExchange.Redis.ConnectionMultiplexer.PublishReconfigureAsync(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task<long>!
StackExchange.Redis.ConnectionMultiplexer.ReconfigureAsync(string! reason) -> System.Threading.Tasks.Task<bool>!
StackExchange.Redis.ConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession!>! profilingSessionProvider) -> void
StackExchange.Redis.ConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession?>! profilingSessionProvider) -> void
StackExchange.Redis.ConnectionMultiplexer.ResetStormLog() -> void
StackExchange.Redis.ConnectionMultiplexer.ServerMaintenanceEvent -> System.EventHandler<StackExchange.Redis.Maintenance.ServerMaintenanceEvent!>?
StackExchange.Redis.ConnectionMultiplexer.StormLogThreshold.get -> int
Expand Down Expand Up @@ -497,7 +497,7 @@ StackExchange.Redis.IConnectionMultiplexer.PreserveAsyncOrder.get -> bool
StackExchange.Redis.IConnectionMultiplexer.PreserveAsyncOrder.set -> void
StackExchange.Redis.IConnectionMultiplexer.PublishReconfigure(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> long
StackExchange.Redis.IConnectionMultiplexer.PublishReconfigureAsync(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task<long>!
StackExchange.Redis.IConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession!>! profilingSessionProvider) -> void
StackExchange.Redis.IConnectionMultiplexer.RegisterProfiler(System.Func<StackExchange.Redis.Profiling.ProfilingSession?>! profilingSessionProvider) -> void
StackExchange.Redis.IConnectionMultiplexer.ResetStormLog() -> void
StackExchange.Redis.IConnectionMultiplexer.ServerMaintenanceEvent -> System.EventHandler<StackExchange.Redis.Maintenance.ServerMaintenanceEvent!>!
StackExchange.Redis.IConnectionMultiplexer.StormLogThreshold.get -> int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public event EventHandler<ServerMaintenanceEvent> ServerMaintenanceEvent

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

public void RegisterProfiler(Func<ProfilingSession> profilingSessionProvider) => _inner.RegisterProfiler(profilingSessionProvider);
public void RegisterProfiler(Func<ProfilingSession?> profilingSessionProvider) => _inner.RegisterProfiler(profilingSessionProvider);

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

Expand Down

0 comments on commit 5e618dc

Please sign in to comment.