Improve Assert.AreSame message for nulls#7426
Merged
Evangelink merged 1 commit intomainfrom Apr 13, 2026
Merged
Conversation
Evangelink
commented
Feb 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #7421 by improving MSTest Assert.AreSame/Assert.AreNotSame failure messages when null values are involved, making failures easier to understand without needing to infer nullness from the inputs.
Changes:
- Add localized resource strings for null-specific AreSame/AreNotSame failure cases.
- Update
Assert.AreSame/Assert.AreNotSamefailure construction to include null-specific wording. - Add unit tests asserting the updated message output across string and interpolated-string overloads.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreSame.cs | Adds test coverage for the new null-specific failure messages for AreSame and AreNotSame. |
| src/TestFramework/TestFramework/Assertions/Assert.AreSame.cs | Implements null-specific message formatting for AreSame (expected/actual null) and AreNotSame (both null), including interpolated-string handler paths. |
| src/TestFramework/TestFramework/Resources/FrameworkMessages.resx | Adds new resource entries used to format the null-specific assertion failure messages. |
| src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.*.xlf | Adds corresponding localization entries for the newly introduced resource keys across supported cultures. |
Copilot's findings
- Files reviewed: 16/16 changed files
- Comments generated: 0
Youssef1313
reviewed
Apr 13, 2026
Youssef1313
reviewed
Apr 13, 2026
Youssef1313
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #7421