Skip to content

Use product targeting pack for analyzer tests and add compatibility tests - #15315

Merged
KlausLoeffelmann merged 2 commits into
dotnet:mainfrom
KlausLoeffelmann:fix/analyzer-test-harness-reliability
Oct 27, 2026
Merged

KlausLoeffelmann merged 2 commits into
dotnet:mainfrom
KlausLoeffelmann:fix/analyzer-test-harness-reliability

Conversation

@KlausLoeffelmann

@KlausLoeffelmann KlausLoeffelmann commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

This pull request refactors how the analyzer tests resolve and use .NET reference assemblies, simplifying the logic for determining the correct targeting pack and removing now-unnecessary code. The changes ensure that the analyzer tests always use the repository's configured targeting pack, and update the test coverage accordingly.

Reference assembly resolution improvements:

  • Refactored CurrentReferences to resolve the product's targeting pack directly from the test runtime configuration, removing dependency on the SDK's bundled pack and eliminating logic that searched for or validated the SDK version and available targeting packs. [1] [2] [3] [4]

Test updates and enhancements:

  • Removed tests related to the old targeting pack resolution logic, and introduced new tests to verify that the analyzer tests use the correct targeting pack and can compile with the resolved references for both C# and Visual Basic.

General cleanup:

  • Updated comments and documentation to clarify that the tests now use the repository's configured targeting pack, not the SDK's runtime reference pack.
Microsoft Reviewers: Open in CodeFlow

* Resolve analyzer references from the test runtime configuration, not the bootstrap SDK’s bundled pack.

* Add C# and Visual Basic compilation tests to verify compatibility.

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.

🟡 Changes recommended

The new compatibility test requires a WinForms build artifact without declaring the build prerequisite needed for independent clean runs.

1 open issue
What changed in this PR

This PR aligns analyzer-test reference assemblies with the repository’s product targeting pack rather than the bootstrap SDK’s bundled pack.

Changes:

  • Resolve the reference-pack version from the analyzer tests’ runtime configuration.
  • Remove SDK-version lookup and installed-pack validation.
  • Add runtime-configuration checks and C#/Visual Basic compilation compatibility tests.
File Description
src/​System.Windows.Forms.Analyzers/​tests/​UnitTests/​CurrentReferencesTests.cs Replaces SDK-pack tests with configuration and compilation compatibility checks.
src/​System.Windows.Forms.Analyzers/​tests/​UnitTests/​CurrentReferences.cs Uses test runtime metadata to select the product reference pack from NuGet.

Review effort: Balanced

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.84861%. Comparing base (c37f09d) to head (7cdd309).

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15315   +/-   ##
=============================================
  Coverage   37.84861%   37.84861%           
=============================================
  Files            246         246           
  Lines           9789        9789           
  Branches        1031        1031           
=============================================
  Hits            3705        3705           
  Misses          5920        5920           
  Partials         164         164           
Flag Coverage Δ
Debug 37.84861% <ø> (ø)
production 40.04608% <ø> (ø)
test 20.64923% <ø> (ø)
unit 40.04608% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SimonZhao888

Copy link
Copy Markdown
Member

Please resolve the copilot submission comment.

Declare the WinForms build-only prerequisite for compatibility tests and document product targeting-pack resolution.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 0816f1a5-b1f1-49b1-b60a-ca866b564c5b
@KlausLoeffelmann
KlausLoeffelmann merged commit d2737c7 into dotnet:main Oct 27, 2026
8 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 28, 2026
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.

5 participants