My code gets the CA1303
warning from Microsoft.Globalization
, "Do not pass literals as localized parameters", but my code is not actually passing a literal:
private void MyForm_Load(object sender, EventArgs e)
{
UpdateTitle();
}
private void UpdateTitle()
{
Version version = Assembly.GetExecutingAssembly().GetName().Version;
CultureInfo culture = CultureInfo.CurrentUICulture;
this.Text = String.Format(culture, "{0} v{1}.{2} Alpha r{3}", this.Text, version.Major, version.Minor, version.Build);
}
This code sets the title of the form to something like this, every time it is loaded:
MyFormNameAsSetInTheDesigner v0.1 Alpha r123
(version.build
actually contains the SVN revision, which is auto-updated at each commit, I do not use revision
because my versioning scheme uses only 3 numbers, major.minor.revision
)
But this triggers the aforementioned warning, because it thinks I'm setting the titlebar text from a string literal. In fact, I've set Localizable = True
in the designer, so that the string is fetched from a resource table.
I do not want to set the form's title statically because (especially in the alpha and beta stages) I want it to have dynamic version numbers.