diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 267d14a..d9739aa 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -8,7 +8,11 @@
[
"ms-dotnettools.csdevkit",
"ue.alphabetical-sorter"
- ]
+ ],
+ "settings":
+ {
+ "remote.autoForwardPorts": false
+ }
}
},
"forwardPorts":
diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml
index 18dbd5e..22ed388 100644
--- a/.devcontainer/docker-compose.yml
+++ b/.devcontainer/docker-compose.yml
@@ -1,6 +1,6 @@
services:
devcontainer:
- image: mcr.microsoft.com/devcontainers/dotnet:8.0-bookworm
+ image: mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm
volumes:
- ..:/workspace:cached
command: sleep infinity
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..0a85bc9
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,26 @@
+[*.{cs,vb}]
+
+dotnet_diagnostic.severity = warning
+dotnet_diagnostic.CS1591.severity = none
+dotnet_diagnostic.IDE0001.severity = warning
+dotnet_diagnostic.IDE0007.severity = warning
+dotnet_diagnostic.IDE0008.severity = none
+dotnet_diagnostic.IDE0010.severity = none
+dotnet_diagnostic.IDE0028.severity = warning
+dotnet_diagnostic.IDE0055.severity = none
+dotnet_diagnostic.IDE0058.severity = none
+dotnet_diagnostic.IDE0090.severity = warning
+dotnet_diagnostic.IDE0160.severity = none
+dotnet_diagnostic.IDE0161.severity = warning
+dotnet_diagnostic.IDE0290.severity = warning
+dotnet_diagnostic.IDE0300.severity = warning
+dotnet_diagnostic.IDE0301.severity = warning
+dotnet_diagnostic.IDE0303.severity = warning
+dotnet_diagnostic.IDE0305.severity = warning
+
+csharp_space_between_square_brackets = true
+csharp_style_var_elsewhere = true:warning
+csharp_style_var_for_built_in_types = true:warning
+csharp_style_var_when_type_is_apparent = true:warning
+dotnet_style_namespace_match_folder = false
+dotnet_style_prefer_conditional_expression_over_return = false
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f95ec14..872bec3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,5 +10,5 @@ jobs:
- name: Test
uses: devcontainers/ci@v0.3
with:
- push: never
- runCmd: dotnet test
+ push: never
+ runCmd: dotnet test
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 5605d11..f6524d6 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -15,10 +15,10 @@ jobs:
- name: Test
uses: devcontainers/ci@v0.3
with:
- push: never
- runCmd: dotnet test
+ push: never
+ runCmd: dotnet test
- name: Publish
uses: devcontainers/ci@v0.3
with:
- push: never
- runCmd: dotnet build -c Release && dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_KEY }} -n -s https://api.nuget.org/v3/index.json --skip-duplicate
\ No newline at end of file
+ push: never
+ runCmd: dotnet build -c Release && dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_KEY }} -n -s https://api.nuget.org/v3/index.json --skip-duplicate
\ No newline at end of file
diff --git a/src/Configuration/ServiceCollectionExtensions.cs b/src/Configuration/ServiceCollectionExtensions.cs
index 42f4629..a3989b1 100644
--- a/src/Configuration/ServiceCollectionExtensions.cs
+++ b/src/Configuration/ServiceCollectionExtensions.cs
@@ -3,7 +3,6 @@
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Options;
using StackExchange.Redis;
-using System.Diagnostics.CodeAnalysis;
namespace Microsoft.Extensions.DependencyInjection;
@@ -16,7 +15,6 @@ public static class ServiceCollectionExtensions
/// Adds L1L2RedisCache distributed caching services to the specified IServiceCollection.
///
/// The IServiceCollection so that additional calls can be chained.
- [SuppressMessage("Performance", "CA1849")]
public static IServiceCollection AddL1L2RedisCache(
this IServiceCollection services,
Action setupAction)
diff --git a/src/L1L2RedisCache.cs b/src/L1L2RedisCache.cs
index 9ae1a77..22bc1d2 100644
--- a/src/L1L2RedisCache.cs
+++ b/src/L1L2RedisCache.cs
@@ -1,9 +1,9 @@
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using StackExchange.Redis;
-using System.Diagnostics.CodeAnalysis;
namespace L1L2RedisCache;
@@ -35,7 +35,8 @@ public L1L2RedisCache(
L2Cache = l2CacheAccessor?.Invoke() ??
throw new ArgumentNullException(
nameof(l2CacheAccessor));
- Logger = logger;
+ Logger = logger ??
+ NullLogger.Instance;
MessagePublisher = messagePublisher ??
throw new ArgumentNullException(
nameof(messagePublisher));
@@ -87,7 +88,7 @@ public L1L2RedisCache(
///
/// Optional. The logger.
///
- public ILogger? Logger { get; }
+ public ILogger Logger { get; }
///
/// The pub/sub publisher.
@@ -121,7 +122,6 @@ public void Dispose()
///
/// A string identifying the requested value.
/// The located value or null.
- [SuppressMessage("Reliability", "CA2000")]
public byte[]? Get(string key)
{
var value = L1Cache.Get(
@@ -245,7 +245,6 @@ await L2Cache
/// Removes the value with the given key.
///
/// A string identifying the requested value.
- [SuppressMessage("Reliability", "CA2000")]
public void Remove(string key)
{
var semaphore = GetOrCreateLock(key, null);
@@ -313,7 +312,6 @@ await MessagePublisher
/// A string identifying the requested value.
/// The value to set in the cache.
/// The cache options for the value.
- [SuppressMessage("Reliability", "CA2000")]
public void Set(
string key,
byte[] value,
@@ -456,7 +454,6 @@ private SemaphoreSlim GetOrCreateLock(
}
}
- [SuppressMessage("Reliability", "CA2000")]
private async Task GetOrCreateLockAsync(
string key,
DistributedCacheEntryOptions? distributedCacheEntryOptions,
@@ -547,7 +544,7 @@ private async Task SubscribeAsync(
cancellationToken)
.ConfigureAwait(false))
{
- Logger?.MessagingConfigurationInvalid(
+ Logger.MessagingConfigurationInvalid(
L1L2RedisCacheOptions.MessagingType);
}
@@ -560,7 +557,7 @@ await MessageSubscriber
}
catch (RedisConnectionException redisConnectionException)
{
- Logger?.SubscriberFailed(
+ Logger.SubscriberFailed(
L1L2RedisCacheOptions
.SubscriberRetryDelay,
redisConnectionException);
diff --git a/src/L1L2RedisCache.csproj b/src/L1L2RedisCache.csproj
index f926ac1..637ecfc 100644
--- a/src/L1L2RedisCache.csproj
+++ b/src/L1L2RedisCache.csproj
@@ -1,6 +1,6 @@
- latest-all
+ latest-recommended
true
true
true
@@ -17,10 +17,10 @@
-
-
-
-
+
+
+
+
diff --git a/tests/System/L1L2RedisCache.Tests.System.csproj b/tests/System/L1L2RedisCache.Tests.System.csproj
index dbf394d..1d820c2 100644
--- a/tests/System/L1L2RedisCache.Tests.System.csproj
+++ b/tests/System/L1L2RedisCache.Tests.System.csproj
@@ -1,11 +1,11 @@
- latest-all
+ latest-recommended
true
enable
false
enable
- net8.0
+ net9.0
@@ -16,13 +16,13 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
diff --git a/tests/Unit/L1L2RedisCache.Tests.Unit.csproj b/tests/Unit/L1L2RedisCache.Tests.Unit.csproj
index dfe6174..0a49c3d 100644
--- a/tests/Unit/L1L2RedisCache.Tests.Unit.csproj
+++ b/tests/Unit/L1L2RedisCache.Tests.Unit.csproj
@@ -1,11 +1,11 @@
- latest-all
+ latest-recommended
true
enable
false
enable
- net8.0
+ net9.0
@@ -13,8 +13,8 @@
-
-
-
+
+
+