-
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
Add Message to suppressions and simplify ISuppressibleLog #45951
base: main
Are you sure you want to change the base?
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. |
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'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.
@@ -84,6 +84,12 @@ static int Main(string[] args) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The neutral language wording is based on the SDK option:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateAssemblyInfo.targets
Lines 113 to 115 in 5826ca5
<AssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute" Condition="'$(NeutralLanguage)' != '' and '$(GenerateNeutralResourcesLanguageAttribute)' == 'true'"> | |
<_Parameter1>$(NeutralLanguage)</_Parameter1> | |
</AssemblyAttribute> |
What about --neutral-language-for-compatibility-suppressions
(lol)?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
Contributes to #45928
Suppression
, simplifies theISuppressibleLog
interface and its implementations and updates testsen-US
. The switches are/p:ApiCompatSuppressionCulture
(msbuild tasks property) and--suppression-culture
(cli tool).