Skip to content
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

CA2254 should not apply when null coalescing expression is used #7291

Open
drewnoakes opened this issue Apr 15, 2024 · 0 comments
Open

CA2254 should not apply when null coalescing expression is used #7291

drewnoakes opened this issue Apr 15, 2024 · 0 comments
Labels
False_Positive A diagnostic is reported for non-problematic case

Comments

@drewnoakes
Copy link
Member

Analyzer

Diagnostic ID: CA2254: Template should be a static expression

Analyzer source

SDK: Built-in CA analyzers in .NET 5 SDK or later

Version: SDK 8.0.200

Describe the bug

My understanding is that the diagnostic aims to improve performance by allowing interpolation/concatenation to be avoided when the log message would be filtered out, and the result discarded.

In the case of ?? this seems excessive. While the ?? can be avoided, it's typically a very cheap operation and doesn't allocate (in this example at least);

image

@drewnoakes drewnoakes added the False_Positive A diagnostic is reported for non-problematic case label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False_Positive A diagnostic is reported for non-problematic case
Projects
None yet
Development

No branches or pull requests

1 participant