RedLock.net
RedLock.net copied to clipboard
Non-idiomatic use of cancellation token parameters
The IDistributedLockFactory
interface uses a non-standard approach where a CancellationToken?
typed parameter is assigned null
.
https://github.com/samcook/RedLock.net/blob/dcfe373b3e288caac4f45b78c88b5943f8b47e42/RedLockNet.Abstractions/IDistributedLockFactory.cs#L39
The standard approach is CancellationToken cancellationToken = default
which is consistent with CancellationToken.None
- i.e. a token that will never cancel. It seems that the default RedLockFactory
implementation already is unncessarily implementing this logic by hand using a ??
null-coalescence operator, e.g.
https://github.com/samcook/RedLock.net/blob/dcfe373b3e288caac4f45b78c88b5943f8b47e42/RedLockNet.SERedis/RedLockFactory.cs#L130
Having this as part of the interface will poison-pill any other implementations of the interface as well as all call sites into this non-standard, non-idiomatic approach to cancellation tokens as well.
Just don't.