Add Message to suppressions and simplify ISuppressibleLog#45951
Add Message to suppressions and simplify ISuppressibleLog#45951ViktorHofer wants to merge 6 commits into
Conversation
|
cc @bitbonk |
|
Which SDK(s) will this end up in? We are current on the latest .NET 8 SDK. |
I'm currently targeting main but I don't see a reason why this can't go into .NET 9 (9.0.200) which is the next feature release. We won't be able to backport this back to .NET 8 which is servicing only at this point. Note that you can reference the Microsoft.DotNet.ApiCompat.Task NuGet package to consume features earlier. This change could be available in ~1-2 months on NuGet.org (I don't have the release schedule in front of me right now). Note that this is an experimental PR, not ready to go in. I first need agreement from other owners of this tool. |
ericstj
left a comment
There was a problem hiding this comment.
I'm supportive of adding the diagnostic message to the suppression file. I think it would help a lot. Some suggestions on how it's done.
| Description = "If true, enables rule to check that the parameter names between public methods do not change.", | ||
| Recursive = true | ||
| }; | ||
| CliOption<string> neutralLanguageOption = new("--neutral-language") |
There was a problem hiding this comment.
Naming: this was not intuitive to me. Consider something like --save-culture or similar. Ideally this setting won't affect other output of the application.
There was a problem hiding this comment.
The neutral language wording is based on the SDK option:
What about --neutral-language-for-compatibility-suppressions (lol)?
There was a problem hiding this comment.
I changed it to --suppression-culture / /p:ApiCompatSuppressionCulture.
| CultureInfo neutralLanguageCultureInfo = new(neutralLanguage); | ||
| Resources.Culture = neutralLanguageCultureInfo; | ||
| CommonResources.Culture = neutralLanguageCultureInfo; | ||
| PackageValidation.ResourceSingleton.ChangeCulture(neutralLanguageCultureInfo); |
There was a problem hiding this comment.
It might be better to delay resource lookup until we write/render a diagnostic/suppression -- that way we could have a different resource lookup behavior for serialization vs UI. It looks like Roslyn has a similar scenario and uses LocalizableResourceString for that.
I can see how this singleton solution approximates that -- if we can assume that all resources will be serialized. Is this Resource used exclusively for holding diagnostics? I see some other resources in there -- maybe if we want to take this static approach you can split the resource types into one resx that's only used for diagnostics and another that's used for UI and add comments about that rule?
|
Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label. |
Contributes to #45928
Suppression, simplifies theISuppressibleLoginterface and its implementations and updates testsen-US. The switches are/p:ApiCompatSuppressionCulture(msbuild tasks property) and--suppression-culture(cli tool).