StackExchange.Redis.Analyzer

March 13, 2023 ยท View on GitHub

Build status Quality Gate Status codecov NuGet Visual Studio Marketplace

Roslyn-based analyzer for StackExchange.Redis library

SER001

Async methods on ITransaction type shouldn't be blocked

Noncompliant Code Example:

var transaction = db.CreateTransaction();
await transaction.StringSetAsync("key", "value").ConfigureAwait(false);

await transaction.ExecuteAsync().ConfigureAwait(false);

Compliant Solution:

var transaction = db.CreateTransaction();
transaction.StringSetAsync("key", "value").ConfigureAwait(false);

await transaction.ExecuteAsync().ConfigureAwait(false);

SER002

Sending commands in a loop can be slow, batch overload with array of keys instead

Noncompliant Code Example:

foreach (var key in new[] { "one", "two" })
{
    var value = db.StringGetAsync(key);
}

Compliant Solution:

var results = db.StringGetAsync(new[] { "one", "two" });