Convert RemoveUnusedMembersTests to the new test framework#41755
Convert RemoveUnusedMembersTests to the new test framework#41755sharwell merged 4 commits intodotnet:masterfrom
Conversation
| { | ||
| _field!.ToString(); | ||
| } | ||
| }", new TestParameters(retainNonFixableDiagnostics: true, parseOptions: new CSharpParseOptions(LanguageVersion.CSharp8))); |
There was a problem hiding this comment.
Does the test framework default to latest language version?
There was a problem hiding this comment.
➡️ The test framework defaults to LanguageVersion.Default, but we use this instead:
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Outdated
Show resolved
Hide resolved
| }, | ||
| FixedCode = source, | ||
| }.RunAsync(); | ||
| //var testParameters = new TestParameters(retainNonFixableDiagnostics: true); |
There was a problem hiding this comment.
Is message validation an unsupported scenario? Any case, this test needs to be fixed to remove the commented out code, and if required skipped with a tracking issue to unskip.
There was a problem hiding this comment.
Is message validation an unsupported scenario?
Messages are always validated for diagnostics in ExpectedDiagnostics, but ignored for diagnostics in markup.
There was a problem hiding this comment.
This test was not converted in the intended manner. I wrote the full-form skeleton, but left ExpectedDiagnostics empty intending to replace it with values found in an actual test failure. Unfortunately, the use of markup ended up causing the test to pass and I never went back to fill in the details. I will fix this.
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Outdated
Show resolved
Hide resolved
| await VerifyCS.VerifyCodeFixAsync( | ||
| @"class MyClass | ||
| { | ||
| private int [|_goo|] = 0, _bar = 0; |
There was a problem hiding this comment.
Interesting, so we cannot force the validation to a specific span within the document?
There was a problem hiding this comment.
No, and that's actually a desirable characteristic of the framework. The feature I have considered adding is the ability to run just one specific fix, as opposed to the iterative process used by default.
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Show resolved
Hide resolved
| string? [|_field|] = null; | ||
| void M() | ||
| string? _field = null; | ||
| public void M() |
There was a problem hiding this comment.
📝 A bunch of members were changed to public to avoid having them get marked as unused, which ends up cascading to everything in the class getting removed.
| private async Task TestDiagnosticMissingAsync(string initialMarkup) | ||
| => await VerifyCS.VerifyCodeFixAsync(initialMarkup, initialMarkup); |
There was a problem hiding this comment.
💡 This should really be removed to follow the patterns from other types.
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
Show resolved
Hide resolved
| }, | ||
| FixedCode = source, | ||
| }.RunAsync(); | ||
| //var testParameters = new TestParameters(retainNonFixableDiagnostics: true); |
There was a problem hiding this comment.
This test was not converted in the intended manner. I wrote the full-form skeleton, but left ExpectedDiagnostics empty intending to replace it with values found in an actual test failure. Unfortunately, the use of markup ended up causing the test to pass and I never went back to fill in the details. I will fix this.
No description provided.