-
Notifications
You must be signed in to change notification settings - Fork 168
fix CA2254: Template should be a static expression #1048
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
base: main
Are you sure you want to change the base?
fix CA2254: Template should be a static expression #1048
Conversation
I've read the page at https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2254, which explains the rule and how to apply it. It fails, however, to explain the reasoning behind the rule or what benefit it provides. I could imagine a benefit if we were planning to localize, but since that's not on any roadmap, CA2254 seems pointless here. My objections are to the changes are twofold:
I'd love to hear any concrete benefits CA2254 would bring to this project, then we can make a decision based on the merit of those benefits when weighed with the points I listed above. |
I thought CA2254 only fires when methods of Microsoft.Extensions.Logging.LoggerExtensions are called with non-constant message templates. This code seems to be calling methods of Serilog.ILogger instead. How can it even get any CA2254 warnings? |
if you use interpolation, it means the logger cant tokenize the values. so for example
the logger treats it as single string but with
the |
here is an example tokenized log message in seq https://datalust.co/seq u can see that the Handler property is tokenized out. if that log message had instead used interpolation, you would not have Handler as an extracted property |
should i resolve the conflicts? |
src/Microsoft.Sbom.Api/Converters/ExternalReferenceInfoToPathConverter.cs
Show resolved
Hide resolved
src/Microsoft.Sbom.Api/PackageDetails/ComponentDetailsUtils/NugetUtils.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Sbom.Api/PackageDetails/ComponentDetailsUtils/RubyGemsUtils.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Sbom.Api/Workflows/Helpers/PackageArrayGenerator.cs
Outdated
Show resolved
Hide resolved
Yes, please resolve the conflicts when you can |
…-should-be-a-static-expression
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
…getUtils.cs Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
…byGemsUtils.cs Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
…onverter.cs Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
…er.cs Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
…venUtils.cs Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
Co-authored-by: Pragnya <59893188+pragnya17@users.noreply.github.com>
No description provided.