Skip to content

Convert RemoveUnusedMembersTests to the new test framework#41755

Merged
sharwell merged 4 commits intodotnet:masterfrom
sharwell:unused-members
Feb 19, 2020
Merged

Convert RemoveUnusedMembersTests to the new test framework#41755
sharwell merged 4 commits intodotnet:masterfrom
sharwell:unused-members

Conversation

@sharwell
Copy link
Copy Markdown
Contributor

No description provided.

@sharwell sharwell requested a review from a team as a code owner February 18, 2020 19:47
{
_field!.ToString();
}
}", new TestParameters(retainNonFixableDiagnostics: true, parseOptions: new CSharpParseOptions(LanguageVersion.CSharp8)));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the test framework default to latest language version?

Copy link
Copy Markdown
Contributor Author

@sharwell sharwell Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ The test framework defaults to LanguageVersion.Default, but we use this instead:

/// <summary>
/// Gets or sets the language version to use for the test. The default value is
/// <see cref="LanguageVersion.CSharp8"/>.
/// </summary>
public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.CSharp8;

},
FixedCode = source,
}.RunAsync();
//var testParameters = new TestParameters(retainNonFixableDiagnostics: true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is message validation an unsupported scenario?

Messages are always validated for diagnostics in ExpectedDiagnostics, but ignored for diagnostics in markup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Fixed in cfbdcec

await VerifyCS.VerifyCodeFixAsync(
@"class MyClass
{
private int [|_goo|] = 0, _bar = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so we cannot force the validation to a specific span within the document?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

string? [|_field|] = null;
void M()
string? _field = null;
public void M()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 👍

Comment on lines +17 to +18
private async Task TestDiagnosticMissingAsync(string initialMarkup)
=> await VerifyCS.VerifyCodeFixAsync(initialMarkup, initialMarkup);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This should really be removed to follow the patterns from other types.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Fixed in 92fc348

},
FixedCode = source,
}.RunAsync();
//var testParameters = new TestParameters(retainNonFixableDiagnostics: true);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sharwell sharwell merged commit 5478577 into dotnet:master Feb 19, 2020
@sharwell sharwell deleted the unused-members branch February 19, 2020 17:14
@sharwell sharwell added this to the 16.6.P1 milestone Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants