-
Notifications
You must be signed in to change notification settings - Fork 734
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
Re-add "legacy" Assert methods #4693
Comments
They are still there, just under a name ClassicAssert. And if you want that to use the Assert, you can actually change that yourself using an alias, ref Using global using aliases, either as a global alias in the GlobalUsings.cs file, or directly in the csproj file. global using Assert = NUnit.Framework.Legacy.ClassicAssert; or in the csproj <Using Include="NUnit.Framework.Legacy.ClassicAssert" Alias="Assert" /> You can then still use the That syntax if you like, in some cases. We have no intention of removing these, but I assume you have read that we can't evolve the classic asserts the way we can with the constraint aliases. |
Why rename them though and break everyone who upgrades? |
We had to move them into a separate project. If C# had allowed extension methods on static classes (which have been discussed for one, and also here ), we could have solved it that way. Also, this is a version 4, it does come with breaking changes, and that's also why we have a Migration Guide. |
According to the migration guide it states: "The analyzer code fix supports Batch Fixing:" But how is that done and can it be done from cli? I'm using Rider and can only do one line at a time, which is a problem, when you have 10k lines that needs to be converted to the new format. |
Within Visual Studio you can apply a CodeFix to either a Document, a Project or a Solution. An issue for Rider has been open for years. It might be that dotnet format work on the command line, but I haven't tried it. See dotnet/roslyn#48561 |
@renemadsen EDIT: Oops. I see the original comment had already been updated to reflect that
|
Perhaps this can fix these things for us: https://devblogs.microsoft.com/dotnet/dotnet-build-2024-announcements/#c-13 - Extension types. |
I know this is going to be controversial. However, I strongly recommend re-adding the "legacy" Assert/CollectionAssert/StringAssert methods (eg, Assert.Equal).
I believe Assert.That is objectively worse in every respect. In pre 4.0 versions, when you type Assert and then a dot, you get Intelliense for all the possible overloads (Equals, LessThan, etc). They are simple and straightforward to use. You do not need to go look up documentation.
Assert.That is the complete opposite. You have to "know" that the second argument requires a magical "Is" or "Does" construct. If you want to do something more complex you may have to chain multiple extremely undiscoverable method calls like Is.Not.... You are basically required to implicitly understand lots of extra-linguistic constructs that NUnit has added.
I understand that some people find the "That" syntax more pleasant to read. But I think it is way more difficult to write, way less discoverable, and a huge downgrade in usability for this library.
The main reason I and others have continued to prefer NUnit over XUnit is the superior simplicity and usability. Removing the easily discoverable methods we've all known and loved for decade(s) is a huge mistake, IMHO.
The text was updated successfully, but these errors were encountered: