-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Validate existing suppressions and remove unnecessary suppressions when re-generating suppression files #32964
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
Conversation
|
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
66971d3 to
e84d7e0
Compare
197d65a to
7b0a2a0
Compare
7b0a2a0 to
196afa5
Compare
src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/SuppressionFileHelper.cs
Show resolved
Hide resolved
src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/CommonResources.resx
Outdated
Show resolved
Hide resolved
src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/ValidatePackageTask.cs
Outdated
Show resolved
Hide resolved
| /// <summary> | ||
| /// If true, validates that baseline suppressions aren't obsolete. | ||
| /// </summary> | ||
| public bool ValidateSuppressions { get; set; } = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the default to true here will be breaking. Make sure you raise that as a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every new rule in APICompat that is on by default is considered a breaking change. As well as infrastructure changes that enable more validation, i.e. #32930. I will group both changes together into one breaking change notice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true. Perhaps simply documenting the new validation is sufficient here.
src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Logging/SuppressionEngine.cs
Show resolved
Hide resolved
src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/ValidatePackageTask.cs
Outdated
Show resolved
Hide resolved
src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Logging/Suppression.cs
Outdated
Show resolved
Hide resolved
src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Logging/SuppressionEngine.cs
Outdated
Show resolved
Hide resolved
src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Logging/SuppressionEngine.cs
Outdated
Show resolved
Hide resolved
| engine.AddSuppression(newSuppression); | ||
| string filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName(), "DummyFile.xml"); | ||
| Assert.True(engine.WriteSuppressionsToFile(filePath)); | ||
| Assert.True(engine.WriteSuppressionsToFile(filePath, removeObsoleteSuppressions: false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add tests that cover the new behavior?
- Remove unnecessary suppressions in APICompat files. This is in preparation for dotnet/sdk#32964 which will validate the existing suppressions going forward. - Set the required APICompat properties for the future tooling support.
|
Just tried the changes out on runtime and submitted dotnet/runtime#87094 to remove the unnecessary suppressions and already set the required properties to opt-out of the new behavior for packable projects that also have a reference source project. |
* Remove unnecessary suppressions in APICompat files - Remove unnecessary suppressions in APICompat files. This is in preparation for dotnet/sdk#32964 which will validate the existing suppressions going forward. - Set the required APICompat properties for the future tooling support. * Add suppressions back for two CoreLib flavors * Fix CoreLib suppression because of API attribute difference
ericstj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Thank you for addressing. I didn't see tests yet so I imagine that's still pending.
I left one small observation now that we've aligned the properties.
|
@ericstj can you please take another look? I just pushed two more commits which add tests, refactor the existing ones. I also found one bug in the WriteSuppressionFilesToFile method which I fixed by creating a new HashSet based on the existing one for the suppressions. The tests were quite messy so I spent some time cleaning them up. |
ericstj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - modulo one nit on the tests. Thank you for adding them.
| Right = "lib/net6.0/tempValidation.dll" | ||
| })); | ||
| TestSuppressionEngine suppressionEngine = new(); | ||
| suppressionEngine.LoadSuppressions("NonExistentFile.xml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is loading a non-existent file essential to these test cases? That seems like a single test case rather than something we need to do in every one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's essential as it trigger loading the test suppression file content. See TestSuppressionEngine.cs which has an override to get the readable stream. Without calling the newly introduced LoadSuppressions method, the baseline suppressions won't get loaded.
|
Thank you :) |
Fixes #28070
Adds the following flags to the APICompat frontends:
dotnet/runtime will need to opt-out of these switches for packable projects which have a reference assembly as we do a two phase validation for these.
Note for reviewers: Hide whitespaces and exclude resx and xlf changes in the GH review pane.