Fix main build break: remove redundant DisplayName=nameof in dotnet.Tests (MSTEST0071)#54938
Merged
Evangelink merged 1 commit intoJun 23, 2026
Merged
Conversation
The testfx bump (#54765) elevated MSTEST0071 to an error under MSTestAnalysisMode=Recommended, breaking main: the dotnet.Tests New post-action tests set [TestMethod(DisplayName = nameof(Method))], which MSTEST0071 flags as redundant. Drop the DisplayName so the display name defaults to the method name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a dotnet.Tests build break on main caused by MSTest analyzers promoting MSTEST0071 (redundant DisplayName matching the method name) to an error under MSTestAnalysisMode=Recommended.
Changes:
- Removes redundant
[TestMethod(DisplayName = nameof(...))]usage where the display name equals the test method name. - Replaces those attributes with plain
[TestMethod]across the affecteddotnet newpost-action test files.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/New/DotnetAddPostActionTests.cs | Drops redundant DisplayName = nameof(...) from [TestMethod] attributes to satisfy MSTEST0071. |
| test/dotnet.Tests/CommandTests/New/DotnetRestorePostActionTests.cs | Same: removes redundant DisplayName from [TestMethod]. |
| test/dotnet.Tests/CommandTests/New/DotnetSlnPostActionTests.cs | Same: removes redundant DisplayName from [TestMethod] (including solution-related post-action tests). |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
0101
approved these changes
Jun 23, 2026
Member
Author
|
/ba-g test failures are unrelated to this PR. Merging to unblock main. |
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.
Problem
mainis currently failing to build (dotnet.Tests.csproj) with 48error MSTEST0071:Root cause
The testfx dependency bump (#54765) merged after the dotnet.Tests MSTest migration (#54905). Under
MSTestAnalysisMode=Recommended(set intest/Directory.Build.props), the analyzer now promotesMSTEST0071to an error. The migrated New post-action tests use[TestMethod(DisplayName = nameof(MethodName))], where the display name is identical to the method name — exactly whatMSTEST0071flags as redundant.This breaks the build for every PR that merges with current
main(e.g. observed while investigating #54904).Fix
Drop the redundant
DisplayName = nameof(...)from the 24 affected[TestMethod]attributes across:test/dotnet.Tests/CommandTests/New/DotnetAddPostActionTests.cstest/dotnet.Tests/CommandTests/New/DotnetRestorePostActionTests.cstest/dotnet.Tests/CommandTests/New/DotnetSlnPostActionTests.csThe display name now defaults to the method name — identical observable behavior, no test renames.
Scope notes
dotnet.Tests(an MSTest.Sdk project) is affected. The TemplateEngine unit-test projects also useDisplayName = nameof, but they are still xUnit (Microsoft.NET.Sdk), soMSTEST0071does not apply and they are intentionally left untouched.CS0104indotnet-new.IntegrationTests) per the same incremental-migration approach.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com