Skip to content

Add explicit type tests for AvoidOutParameterOnAssertIsInstanceOfTypeFixer - #9885

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/test-avoid-out-param-assert-isinstanceof
Jul 13, 2026
Merged

Add explicit type tests for AvoidOutParameterOnAssertIsInstanceOfTypeFixer#9885
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/test-avoid-out-param-assert-isinstanceof

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Fixes #9874

Summary

AvoidOutParameterOnAssertIsInstanceOfTypeFixer.FixIsInstanceOfTypeCallAsync has two distinct code paths:

  1. When the type is non-null (explicit type declaration like out string result) → creates a VariableDeclarationSyntax.
  2. When the type is null (existing variable like out result) → creates an AssignmentExpression.

The out var result case was covered, but the explicit type case (e.g., out string resultstring result = ...) was not tested.

Changes

Added two tests to AvoidOutParameterOnAssertIsInstanceOfTypeFixerTests.cs:

  • FixIsInstanceOfTypeWithExplicitType_ShouldProduceTypedVariableDeclarationout string resultstring result = Assert.IsInstanceOfType<string>(value) (with/without trivia, single and multi-instance).
  • FixIsInstanceOfTypeWithExplicitTypeAndMessage_ShouldProduceTypedVariableDeclaration — same with a message argument.

Verification

  • Build succeeded (0 warnings, 0 errors).
  • All 8 tests in the class pass (6 existing + 2 new) on net8.0.

…OfTypeFixer

Add two tests covering the untested code path where an explicit type is
used in the out parameter declaration (e.g., 'out string result' vs
'out var result'), producing a typed VariableDeclarationSyntax.

Fixes #9874

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 933245eb-b33b-4685-9afb-d50b0e1a82f3
Copilot AI review requested due to automatic review settings July 13, 2026 09:06

Copilot AI left a comment

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.

Pull request overview

Adds explicit-type coverage for the analyzer code fix that converts invalid out string result assertions into typed variable declarations.

Changes:

  • Tests conversion with and without message arguments.
  • Verifies trivia preservation and multiple occurrences.
Show a summary per file
File Description
test/UnitTests/MSTest.Analyzers.UnitTests/AvoidOutParameterOnAssertIsInstanceOfTypeFixerTests.cs Adds explicit-type code-fix tests.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9885

GradeTestNotes
A (90–100) new AvoidOutParameterOnAssertIsInstanceOfTypeFixerTests.
FixIsInstanceOfTypeWithExplicitTypeAndMessage_
ShouldProduceTypedVariableDeclaration
Clear AAA; VerifyCodeFixAsync strongly asserts the exact code transformation for the message-overload case.
B (80–89) new AvoidOutParameterOnAssertIsInstanceOfTypeFixerTests.
FixIsInstanceOfTypeWithExplicitType_
ShouldProduceTypedVariableDeclaration
Strong assertion via VerifyCodeFixAsync; body is ~50 lines due to two embedded code-literal fixtures — consider splitting into two focused tests (one per method in the fixture).

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 34.1 AIC · ⌖ 5.7 AIC · ⊞ 9.6K · [◷]( · )

@github-actions github-actions Bot left a comment

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.

LGTM — Clean, well-structured tests that fill a real coverage gap for the explicit-type code path in FixIsInstanceOfTypeCallAsync. The trivia preservation and multi-instance scenarios are good additions. No issues found.

@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 13, 2026
@Evangelink
Evangelink merged commit 3abb567 into main Jul 13, 2026
34 of 41 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/test-avoid-out-param-assert-isinstanceof branch July 13, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test-improver] Add explicit type tests for AvoidOutParameterOnAssertIsInstanceOfTypeFixer

3 participants