VSDiagnostics
VSDiagnostics copied to clipboard
Support StringFormatMethodAttribute for String.Format analyzer
JetBrains has free package with annotations. This package has useful attribute: StringFormatMethodAttribute (find it here).
It is better to support it in this package too, because:
- Some open source projects have reference to attributes (e.g. some methods are market with StringFormatMethodAttribute, which is stored in the separate package or in the internal attributes). For example, NLog does this.
- You can simply mark your method, that you will do string formatting. And then we can gain this diagnostic.
Additional:
- We should analyze all methods, which have attribute "StringFormatMethodAttribute" even if it has another namespace, even it is declared in the custom library
- String formatting argument can be second, third, etc. For example:
log.Debug(exception, "Action: {0}", action)
<--- second argument should be checked here
We can do this without this annotation. We already find calls to string.Format
for other analyzers, and that's all we need to do here to do the analyzing.