-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Write APICompat suppressions when baseline suppressions aren't empty #44965
Write APICompat suppressions when baseline suppressions aren't empty #44965
Conversation
When there aren't any suppressions but baseline suppressions exist, write to the suppression file to make it empty. Pass information back to the caller so that even if an empty collection of suppression are written to the file, still log a message to indicate that the suppression file got updated.
@ericstj when the With this change, we update the file and make it empty: <?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> |
src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompatibility/Logging/SuppressionEngine.cs
Outdated
Show resolved
Hide resolved
I think in our case we'd prefer to delete the file since we conditionally set it based on existence -- would that work in general? Suppose someone specified the file name - if we deleted that file would we handle a specified path to a non-existent file on run? Maybe not. I guess emitting an empty file is OK. If folks want to delete it, then can notice the empty file and delete it. |
The suppression engine file loader would throw a FileNotFoundException when sdk/src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompatibility/Logging/SuppressionEngine.cs Line 45 in 5ef57c8
I kind of lean towards deleting the empty suppression file. The switch name might confusing here though as it implies something getting generated, not deleted ( EDIT: Given this a second thought, not deleting is probably less breaking here and won't change a potential exisiting workflow. I.e. for runtime's ApiCompat.proj we want the suppression files emptied but not deleted. If they would get deleted we would see the FileNotFoundException. |
I'm fine either way, just test the behavior works in and doesn't introduce new errors for folks. |
|
||
Assert.True(suppressionFileUpdated); |
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.
Should we add a test case for the scenario where we had baselines and they are no longer needed -- ensure that the file is emptied and true is returned?
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.
I just noticed that we already have one that validates that: SuppressionEngine_WriteSuppressionsToFile_ReturnsEmptyWithAllUnnecessarySuppressions
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.
change looks ok, please consider adding a test for this scenario.
Yes, I will add a test for that scenario before merging. |
The SuppressionEngine_WriteSuppressionsToFile_ReturnsEmptyWithAllUnnecessarySuppressions test already validates the new behavior.
When there aren't any suppressions but baseline suppressions exist, write to the suppression file to make it empty.
Pass information back to the caller so that even if an empty collection of suppression are written to the file, still log a message to indicate that the suppression file got updated.