From ade7f82d2dd584720a14094eb0d498b9ab7c4e4d Mon Sep 17 00:00:00 2001 From: Benjamin Evenson <2031163+benjiro@users.noreply.github.com> Date: Tue, 19 Sep 2023 16:15:25 +1000 Subject: [PATCH] feat: Add dx to catch ConfigureAwait(false) - Enable dotnet anaylzers - Ignore rule in benchmarks/tests Signed-off-by: Benjamin Evenson <2031163+benjiro@users.noreply.github.com> --- .editorconfig | 3 +++ build/Common.props | 1 + test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs | 2 ++ test/OpenFeature.Tests/FeatureProviderTests.cs | 2 ++ test/OpenFeature.Tests/OpenFeatureClientTests.cs | 2 ++ test/OpenFeature.Tests/OpenFeatureHookTests.cs | 2 ++ 6 files changed, 12 insertions(+) diff --git a/.editorconfig b/.editorconfig index 19afa364..2682e4d6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -146,6 +146,9 @@ dotnet_diagnostic.IDE0005.severity = none # RS0041: Public members should not use oblivious types dotnet_diagnostic.RS0041.severity = suggestion +# CA2007: Do not directly await a Task +dotnet_diagnostic.CA2007.severity = error + [obj/**.cs] generated_code = true diff --git a/build/Common.props b/build/Common.props index 464ac37e..4af79a3c 100644 --- a/build/Common.props +++ b/build/Common.props @@ -2,6 +2,7 @@ 7.3 true + true diff --git a/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs b/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs index a17bfb8b..3adcb132 100644 --- a/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs +++ b/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs @@ -1,5 +1,6 @@ using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using AutoFixture; using BenchmarkDotNet.Attributes; @@ -12,6 +13,7 @@ namespace OpenFeature.Benchmark [SimpleJob(RuntimeMoniker.Net60, baseline: true)] [JsonExporterAttribute.Full] [JsonExporterAttribute.FullCompressed] + [SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")] public class OpenFeatureClientBenchmarks { private readonly string _clientName; diff --git a/test/OpenFeature.Tests/FeatureProviderTests.cs b/test/OpenFeature.Tests/FeatureProviderTests.cs index 9a355bbb..aa79cbf9 100644 --- a/test/OpenFeature.Tests/FeatureProviderTests.cs +++ b/test/OpenFeature.Tests/FeatureProviderTests.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using AutoFixture; using FluentAssertions; @@ -9,6 +10,7 @@ namespace OpenFeature.Tests { + [SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")] public class FeatureProviderTests : ClearOpenFeatureInstanceFixture { [Fact] diff --git a/test/OpenFeature.Tests/OpenFeatureClientTests.cs b/test/OpenFeature.Tests/OpenFeatureClientTests.cs index fef7403a..4995423e 100644 --- a/test/OpenFeature.Tests/OpenFeatureClientTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureClientTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; using AutoFixture; @@ -16,6 +17,7 @@ namespace OpenFeature.Tests { + [SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")] public class OpenFeatureClientTests : ClearOpenFeatureInstanceFixture { [Fact] diff --git a/test/OpenFeature.Tests/OpenFeatureHookTests.cs b/test/OpenFeature.Tests/OpenFeatureHookTests.cs index c814b15a..72e4a1d0 100644 --- a/test/OpenFeature.Tests/OpenFeatureHookTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureHookTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; using AutoFixture; @@ -14,6 +15,7 @@ namespace OpenFeature.Tests { + [SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")] public class OpenFeatureHookTests : ClearOpenFeatureInstanceFixture { [Fact]