Obsolete Assert.Equals and add obsolete Assert.ReferenceEquals#5815
Obsolete Assert.Equals and add obsolete Assert.ReferenceEquals#5815Evangelink merged 16 commits intomainfrom
Conversation
…enceEquals Co-authored-by: Evangelink <[email protected]>
Co-authored-by: Evangelink <[email protected]>
Co-authored-by: Evangelink <[email protected]>
Assert.Equals, and add an obsolete ReferenceEquals
Evangelink
left a comment
There was a problem hiding this comment.
Please so the same job for StringAssert and CollectionAssert classes.
Co-authored-by: Evangelink <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…ollectionAssert Co-authored-by: Evangelink <[email protected]>
Done! Added obsolete Equals and ReferenceEquals methods to both StringAssert and CollectionAssert classes following the same pattern as Assert class - using constant string messages from FrameworkConstants and returning false to prevent silent failures. (b6650a9) Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
# Conflicts: # src/TestFramework/TestFramework/FrameworkConstants.cs # src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt
Evangelink
left a comment
There was a problem hiding this comment.
For all obsolete Equals and ReferenceEquals API, please instead of returning false ensuring we fail by calling the Assert.Fail API with a localized message.
…l with localized messages Co-authored-by: Evangelink <[email protected]>
Done! Changed all obsolete Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
# Conflicts: # src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt
# Conflicts: # src/TestFramework/TestFramework/Resources/FrameworkMessages.Designer.cs # src/TestFramework/TestFramework/Resources/FrameworkMessages.resx
Changes
Assert.Equalsfrom throwing an exception to being marked as obsolete, and adds a new obsoleteAssert.ReferenceEqualsmethod. This prevents silent failures that would occur if these methods were removed entirely.Problem
The original plan was to remove
Assert.Equalsin v4, but this would create a dangerous scenario:Solution
Instead of removal, both methods are now marked with
[Obsolete]attributes:Assert.Equals: Now obsolete instead of throwingAssert.Fail()Assert.ReferenceEquals: New obsolete method to prevent similar issuesBoth methods consistently return
falseand guide users to proper alternatives:Assert.Equals→ UseAssert.AreEqualand overloadsAssert.ReferenceEquals→ UseAssert.AreSameand overloadsImplementation Details
Assert.Equalswith[Obsolete]attributeAssert.ReferenceEqualswith[Obsolete]attributeDoNotUseAssertReferenceEqualsresource string with full localization (13 languages)PublicAPI.Unshipped.txtfor new methodTesting
This approach provides compile-time warnings while preventing the dangerous silent failure scenario.
Fixes #5758.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
5rqvsblobprodcus385.vsblob.vsassets.io/home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/testfx/testfx/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/testfx/testfx/artifacts/toolset/10.0.0-beta.25316.2.txt(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.