-
Notifications
You must be signed in to change notification settings - Fork 275
Obsolete Assert.Equals and add obsolete Assert.ReferenceEquals #5815
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
Conversation
…enceEquals Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Assert.Equals
, and add an obsolete ReferenceEquals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please so the same job for StringAssert
and CollectionAssert
classes.
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
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 <11340282+Evangelink@users.noreply.github.com>
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <11340282+Evangelink@users.noreply.github.com>
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.Equals
from throwing an exception to being marked as obsolete, and adds a new obsoleteAssert.ReferenceEquals
method. This prevents silent failures that would occur if these methods were removed entirely.Problem
The original plan was to remove
Assert.Equals
in 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
false
and guide users to proper alternatives:Assert.Equals
→ UseAssert.AreEqual
and overloadsAssert.ReferenceEquals
→ UseAssert.AreSame
and overloadsImplementation Details
Assert.Equals
with[Obsolete]
attributeAssert.ReferenceEquals
with[Obsolete]
attributeDoNotUseAssertReferenceEquals
resource string with full localization (13 languages)PublicAPI.Unshipped.txt
for 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.