-
Notifications
You must be signed in to change notification settings - Fork 482
Description
Analyzer
Diagnostic ID: CA2241
Describe the improvement
"CA2241: Provide correct arguments to formatting methods" has a hardcoded list of methods that accept a composite format string. But in .NET 7, the new StringSyntaxAttribute exists and includes a StringSyntaxAttribute.CompositeFormat, which has been used to annotate many string parameters that are expected to be passed a composite format string. CA2241 should ideally apply to any parameter that accepts such a format string, at least in terms of validating the correctness of the syntax of the string.
Describe suggestions on how to achieve the rule
For any method invocation, look at the parameters to see if any is attributed with [StringSyntax(StringSyntaxAttribute.CompositeFormat)]
, and if it is, validate that the argument being passed for that parameter is correctly formed (as it does today for the hardcoded list).