Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0] Fixing Analyzer issues, servicing, Part 1: Analyzer-test-infra refactoring. #13072

Open
wants to merge 22 commits into
base: release/9.0
Choose a base branch
from

Conversation

KlausLoeffelmann
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann commented Mar 4, 2025

Part 1 of servicing Analyzer back to .NET 9 rel.
This is JUST updating the test infrastructure; it does not change anything else.

Note:
The respective migration to .NET 10 is done here: #13112.

The touched files seem like a lot, but it's basically only file moves, and it does NOT effect the runtime itself, which makes it a low risk:

This is a compact visual guide, of how the folders moved:

image

In more words:
Projects which are the actual WinForms runtime, are not effected - except the Analyzer Projects themselves. And here, we just changed the folders where they lived, but we did not change anything in terms of file content. The reason to do this already in the context of the release fix was, that the changes which need to come after this for the actual Analyzer fixes (in 9REL) and then later for the add-ons (in 10Preview) bring Path length in many cases too close and (while testing) in 2 cases also OVER the maximum path length. That, and the fact that this PR does not change anything in the runtime, was one of the reasons, I decided to move the pure folder restructuring already to this PR, because bottom line, it will be actually safer to have the same Analyzer folder structure in the release branches and the upcoming versions, when we need to backport fixes.

You will note though, that some versions of a series of NuGet changed, which also are part of the release fix. And yes, those also might effect the runtime, but most of the changes again are either Analyzer-related or Test related. There was also one item we needed to change because its original version was flagged as having an security issue - which is documented in the versions file.
I decided to update the a series of the NuGets in addition, since they seem logical to update.

Updating the NuGet packages to the minimum versions which felt at least right and safe to have, required some minor, low-risk code changes, due to breaking changes. But again: Those changes are EXCLUSIVELY affecting the test code, and we have those changes for month in the .NET 10 branch, so also here, I feel really safe to apply them, and assess them as low risk.

Finally, there is a bigger picture of the TreeViews (left old, right new), which gives you more details about the moves, but which is visually more "demanding" 😸:

image

We're still considering, if we go for "Common" or "Generic" for the generic Analyzer Project, but that would just be a name change, and change nothing in principle.

Code, which this PR adds:

You see, that this PR adds a bit of new code. That is basically the foundation of the new Analyzer Test Infrastructure, so that the fixes we need to apply will have also new tests to back the fixes up, which will be compatible to the code, we are going forward with in .NET 10.

But again: This ONLY effects the unit tests. It does not make any changes necessary per se to the existing Analyzer code, let alone does it changes anything in the runtime. The files which get added here for supporting the new test infrastructure are all bundled here:

image

Microsoft Reviewers: Open in CodeFlow

@KlausLoeffelmann KlausLoeffelmann force-pushed the RefactorAnalyzerTests9.0Rel branch from 73b4f7c to 4d9825e Compare March 5, 2025 22:20
@KlausLoeffelmann KlausLoeffelmann changed the title Updates. Fixing a series of Analyzer issues, servicing to .NET 9, Part 1: Analyzer-test-infra refactoring. Mar 7, 2025
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.80108%. Comparing base (44f90e2) to head (fe3dd24).
Report is 20 commits behind head on release/9.0.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           release/9.0      #13072         +/-   ##
=====================================================
- Coverage     74.83821%   74.80108%   -0.03714%     
=====================================================
  Files             3022        2997         -25     
  Lines           630460      629261       -1199     
  Branches         46797       46742         -55     
=====================================================
- Hits            471825      470694       -1131     
+ Misses          155247      155204         -43     
+ Partials          3388        3363         -25     
Flag Coverage Δ
Debug 74.80108% <95.00000%> (+4.24962%) ⬆️
integration 18.02338% <ø> (+0.01277%) ⬆️
production 47.80523% <ø> (-0.06194%) ⬇️
test 96.99298% <95.00000%> (-0.04883%) ⬇️
unit 44.80666% <ø> (-0.07480%) ⬇️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KlausLoeffelmann KlausLoeffelmann requested a review from Copilot March 8, 2025 01:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR performs a refactoring of the analyzer test infrastructure in preparation for servicing to .NET 9, along with updates to the analyzer release documentation. The changes include updating shipped and unshipped analyzer release markdown files with new rule sets, adjusting test data type casts in binary format tests, and removing legacy analyzer and code fix test files.

Reviewed Changes

File Description
src/System.Windows.Forms.Analyzers/cs/src/Analyzers/AnalyzerReleases.Shipped.md Added new shipped analyzer release details for .NET 9 and updated rule documentation URLs.
src/System.Windows.Forms.Analyzers/cs/src/Analyzers/AnalyzerReleases.Unshipped.md Introduced a new unshipped analyzer release file with corresponding documentation link.
src/System.Private.Windows.Core/tests/BinaryFormatTests/FormatTests/FormattedObject/BinaryFormatWriterTests.cs Adjusted type casting for test data concatenations to address type inference issues.
src/System.Private.Windows.Core/tests/BinaryFormatTests/FormatTests/FormattedObject/HashTableTests.cs Updated construction of Point and PointF instances to use default values and adjusted pragma comment.
src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Shipped.md Updated shipped analyzer releases by switching documentation paths and rule order.
Various AssemblyInfo.cs and analyzer test files Removed legacy AssemblyInfo and legacy test files no longer needed with the updated test infrastructure.

Copilot reviewed 201 out of 201 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

src/System.Private.Windows.Core/tests/BinaryFormatTests/FormatTests/FormattedObject/HashTableTests.cs:236

  • Changing from 'new Point()' to 'default(Point)' could potentially affect behavior if any constructor initialization is expected; please verify that the default value is appropriate in this context.
{ "Foo", default(Point) }

src/System.Private.Windows.Core/tests/BinaryFormatTests/FormatTests/FormattedObject/HashTableTests.cs:240

  • Replacing 'new PointF()' with 'default(PointF)' may alter the initialization behavior; ensure that this change aligns with the intended default state for PointF.
{ "Foo", default(PointF) }

src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs:1

  • [nitpick] Confirm that the removal of this test file does not leave functionality untested and that equivalent coverage is provided elsewhere.
<entire file removed>

src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Analyzers/AvoidPassingTaskWithoutCancellationToken/AvoidPassingTaskWithoutCancellationTokenTest.cs:1

  • [nitpick] Ensure that the scenarios covered by the removed test are still validated through alternative tests to maintain comprehensive test coverage for task cancellation behavior.
<entire file removed>

@KlausLoeffelmann KlausLoeffelmann force-pushed the RefactorAnalyzerTests9.0Rel branch from 2ff2fe0 to b3c8d72 Compare March 10, 2025 23:25
@KlausLoeffelmann KlausLoeffelmann marked this pull request as ready for review March 11, 2025 21:30
@KlausLoeffelmann KlausLoeffelmann requested a review from a team as a code owner March 11, 2025 21:30
@KlausLoeffelmann
Copy link
Member Author

Note, that the Analyzer MD files have not changed, so, what Copilot reported there is just new from the new folder perspective.

@Tanya-Solyanik Tanya-Solyanik removed the draft draft PR label Mar 12, 2025
@Tanya-Solyanik
Copy link
Member

Tanya-Solyanik commented Mar 12, 2025

Please update

"SourceFile": ".\\src\\System.Windows.Forms.Analyzers\\src\\Resources\\xlf\\SR.xlf",
to point to the new paths for all 5 moved resx files and make sure to not add any whitespaces to that file. Even though the Loc pipelines are not enabled on the release branch, I'd rather have this file being correct.

Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

I was looking for the new test infra, i.e. where you load the test files, but I assume that test infra is coming next?

@KlausLoeffelmann
Copy link
Member Author

KlausLoeffelmann commented Mar 14, 2025

No, the actual new Test infra is in here.
That's why we have the additions.
The files with the new Test-Infra are these:

image

@KlausLoeffelmann KlausLoeffelmann changed the title Fixing a series of Analyzer issues, servicing to .NET 9, Part 1: Analyzer-test-infra refactoring. Fixing a couple of Analyzer issues, servicing to .NET 9, Part 1: Analyzer-test-infra refactoring. Mar 14, 2025
@Tanya-Solyanik Tanya-Solyanik changed the title Fixing a couple of Analyzer issues, servicing to .NET 9, Part 1: Analyzer-test-infra refactoring. [release/9.0] Fixing a couple of Analyzer issues, servicing to .NET 9, Part 1: Analyzer-test-infra refactoring. Mar 15, 2025
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

Added some comments.

@KlausLoeffelmann KlausLoeffelmann changed the title [release/9.0] Fixing a couple of Analyzer issues, servicing to .NET 9, Part 1: Analyzer-test-infra refactoring. [release/9.0] Fixing Analyzer issues, servicing, Part 1: Analyzer-test-infra refactoring. Mar 24, 2025
@KlausLoeffelmann KlausLoeffelmann force-pushed the RefactorAnalyzerTests9.0Rel branch from f61875f to 19e5925 Compare March 25, 2025 00:06
* Patch the LocProject.json file with the new file pathes and ...
* Add that file to the solution items for better discoverability.
* Remove redundant backup files.
@KlausLoeffelmann KlausLoeffelmann force-pushed the RefactorAnalyzerTests9.0Rel branch from 19e5925 to fe3dd24 Compare March 25, 2025 00:12
{
if (s_exactNetVersionLookup.TryGetValue(version, out (string tfm, string exactVersion) value))
{
var netRuntimePackage = new PackageIdentity(NetRuntimeIdentity, value.exactVersion);
Copy link
Member

Choose a reason for hiding this comment

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

I want to double-check that exactVersion is required

@KlausLoeffelmann KlausLoeffelmann added the 🚫 * NO-MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚫 * NO-MERGE * The PR is not ready for merge yet (see discussion for detailed reasons)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants