Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install NUnit.Analyzers 4.1.0 and follow all suggested autofixes #203

Merged
merged 5 commits into from
Apr 7, 2024

Conversation

Bartleby2718
Copy link
Contributor

@Bartleby2718 Bartleby2718 commented Mar 31, 2024

This PR closes #202.

Steps taken:

  1. Install NUnit.Analyzers 4.1.0 through VS 2022's built-in NuGet Package Manager.
  2. Build the solution. This caused build warnings like:
  1. For each warning, click it to get to the code and implement the suggested automatic fix in the entire solution.
  2. If the automatic fix causes a build failure, fix it manually. (There were only a couple, I think: [bug] Code fix for NUnit2005 does not correctly fix Assert.AreEqual if named parameters are used in unexpected order nunit/nunit.analyzers#712, [bug] Code fix for NUnit2049 places the comma at a wrong place and messes up indentation nunit/nunit.analyzers#713)
  3. Tried updating nunit to the latest version 4.1.0 and noticed that there were some NUnit diagnostics whose severities were not warnings. (I didn't realize there were non-warning diagnostics, but in retrospect, I should've updated .editorconfig to set the severity to warning or above for all ClassicAssert-related diagnostics in https://docs.nunit.org/articles/nunit-analyzers/NUnit-Analyzers.html. Also, I didn't realize the CodeGen project had NUnit installed, so I installed NUnit.Analzyers there as well.)

<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="3.21.130" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
<PackageVersion Include="Oracle.ManagedDataAccess" Version="21.13.0" Condition="'$(TargetFramework)' == 'net462'"/>
<PackageVersion Include="Oracle.ManagedDataAccess" Version="21.13.0" Condition="'$(TargetFramework)' == 'net462'" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a missing space; fixed by VS 2022's NuGet Package Manager.

src/DistributedLock.Core/packages.lock.json Outdated Show resolved Hide resolved
src/DistributedLock.Tests/Tests/ApiTest.cs Outdated Show resolved Hide resolved
}

private async ValueTask<int> AddAsync(int a, int b, Thread startingThread, bool expectAsync)
private static async ValueTask<int> AddAsync(int a, int b, Thread startingThread, bool expectAsync)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS was showing the warning IDE0009, so I added this here and below.

src/DistributedLock.Tests/packages.lock.json Outdated Show resolved Hide resolved
@Bartleby2718 Bartleby2718 marked this pull request as ready for review March 31, 2024 17:28
@@ -110,7 +110,7 @@ public async Task TestAccessingHandleLostTokenWhileKeepaliveActiveDoesNotBlock()
handle.HandleLostToken.Register(() => { });
}
});
Assert.IsTrue(await accessHandleLostTokenTask.TryWaitAsync(TimeSpan.FromSeconds(5)));
Assert.That(await accessHandleLostTokenTask.TryWaitAsync(TimeSpan.FromSeconds(5)), Is.True);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drawing attention here.

Suggested change
Assert.That(await accessHandleLostTokenTask.TryWaitAsync(TimeSpan.FromSeconds(5)), Is.True);
Assert.That(await accessHandleLostTokenTask.TryWaitAsync(TimeSpan.FromSeconds(5)));

is also valid and is called the condensed form. For now, I went with the more verbose yet clearer form, but in some cases (e.g. https://github.com/madelson/DistributedLock/pull/203/files#diff-da270224eb19c911add476281ecc4508595b322d7a34c53254e4a82bcaee6e50R24), removing , Is.True can be more readable.

src/DistributedLock.Tests/Tests/ApiTest.cs Outdated Show resolved Hide resolved
src/DistributedLock.Tests/packages.lock.json Outdated Show resolved Hide resolved
@madelson madelson merged commit 97335aa into madelson:master Apr 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use NUnit.Analyzers to prepare for migration to NUnit 4
2 participants