Open martintmk opened 1 year ago
Hi👋I would like to help with this issue
@davidCett Thanks for volunteering! Feel free to open a pull request to tackle one of the disabled warnings. I suggest you tackle one or two per pull request to prevent the diffs getting too big to easily review.
💡 Tips for future contributors working on this issue:
Polly
and Polly.Specs
projects are still in scope for this issue. Other projects with analyzer suppressions are intentional (we've intentionally turned them off, rather than it being "let's fix it later") and represent cases where we specifically disable a rule for a project because it is not useful or code-level suppressions are too noisy (e.g. the Polly.Benchmarks project disables rules that are not compatible with BenchmarkDotNet's requirements for benchmark classes).PublicAPI.*.txt
file), then do not make the suggested change - instead, suppress the warning(s) on a case-by-case basis with a pair of #pragma warning {disable|restore} {AnalyzerId}
directives in the source file(s).For the warnings xUnit1031, it says blocking calls should not be used in a test method. The below mentioned code uses Task.WaitAll which is a blocking action.
Example :
#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
Task.WaitAll([firstExecution, secondExecution], testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
The essence of the above lines is to check if firstExecution and secondExecution tasks finishes before the specified timeout (testTimeoutToExposeDeadlocks). I want to confirm if the below mentioned non-blocking code can be a proper replacement for the above code.
var allTasksTask = Task.WhenAll(firstExecution, secondExecution);
var completedTask = await Task.WhenAny(allTasksTask, Task.Delay(testTimeoutToExposeDeadlocks));
(completedTask == allTasksTask).Should().BeTrue();
If I remember correctly, these tests are specifically testing synchronous code paths, so the suppressions should be left in place.
In the #1287 we enabled a full set of analyzers for these projects. Many of the rules are currently suppressed in each respective
csproj
file with the<NoWarn>
element.We can enable these rules one-be-one and cleanup the codebase.