Skip to content

Gendarme.Rules.Correctness.ProvideCorrectArgumentsToFormattingMethodsRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

ProvideCorrectArgumentsToFormattingMethodsRule

Assembly: Gendarme.Rules.Correctness
Version: git

Description

This rule checks that the format string used with String.Format matches the other parameters used with the method.

Examples

Bad examples:

string s1 = String.Format ("There is nothing to format here!");
// no argument to back {0}
string s2 = String.Format ("Hello {0}!");

Good examples:

string s1 = "There is nothing to format here!";
string s2 = String.Format ("Hello {0}!", name);

Notes

  • This rule is available since Gendarme 2.2

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally