Examples of errors detected by the V3025 diagnostic.


V3025. Incorrect format. Consider checking the N format items of the 'Foo' function.


SharpDevelop

V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 4. Present: 6. MonoSymbolTable.cs 235


public override string ToString ()
{
  return
    String.Format("[Line {0}:{1,2}-{3,4}:{5}]",
                  File, Row, Column, EndRow, EndColumn, Offset);
}

SharpDevelop

V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 2. Present: 3. Thread.cs 235


public override string ToString()
{
  return String.Format("Thread Name = {1} Suspended = {2}",
                       ID, Name, Suspended);
}

Microsoft Code Contracts

V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 3. Present: 2. VSServiceProvider.cs 515


void AskToReportError(Exception exn) {
  ....
  var emailBody = new StringBuilder();
  emailBody.AppendLine("Hi Code Contracts user,");
  emailBody.AppendLine();
  ....
  emailBody.AppendLine(
    String.Format(".... {0} {1} Visual Studio {2} Bug Report",
      typeof(VSServiceProvider).Assembly.GetName().Version,
#if DEBUG
                                                 "Debug"
#else
                                                 "Release"
#endif
                                           ));
  ....
}

Microsoft Code Contracts

V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 1. Present: 2. Output.cs 68


public override void WriteLine(string value)
{
  output.WriteLine(string.Format("{1}", DateTime.Now,
    value.Replace("{", "{{").Replace("}","}}")));
  //output.WriteLine(string.Format("[{0}] {1}",
    //DateTime.Now., value));
}

Similar errors can be found in some other places:

  • V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 6. Present: 7. CacheModelExtensions.cs 46
  • V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 1. Present: 2. CodeFixesInference.cs 1608
  • V3025 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 2. Present: 3. ExpressionManipulation.cs 442

MonoDevelop

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 3. Present: 4. MonoDevelop.Core ConditionParser.cs 254


ConditionExpression ParseReferenceExpression (string prefix)
{
  StringBuilder sb = new StringBuilder ();

  string ref_type = prefix [0] == '$' ?
                      "a property" : "an item list";
  int token_pos = tokenizer.Token.Position;
  IsAtToken (TokenType.LeftParen, String.Format (
             "Expected {0} at position {1} in condition \"{2}\".
             Missing opening parantheses after the '{3}'.",
             ref_type, token_pos, conditionStr, prefix));
  ....

  IsAtToken (TokenType.RightParen, String.Format (
             "Expected {0} at position {1} in condition \"{2}\".
              Missing closing parantheses'.",
              ref_type, token_pos, conditionStr, prefix));
  ....
}

Similar errors can be found in some other places:

  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 1. Present: 2. MonoDevelop.Xml XmlFormatterWriter.cs 1131;
  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 4. Present: 6. ICSharpCode.NRefactory.CSharp MonoSymbolTable.cs 235
  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 1. Present: 2. MonoDevelop.Ide HelpOperations.cs 212
  • And 2 additional diagnostic messages.

IronPython and IronRuby

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 1. Present: 2. ConversionWrappers.cs 235


public T Current {
  get {
    try {
      return (T)enumerable.Current;
    }
    catch (InvalidCastException iex) {
      throw new InvalidCastException(string.Format(
    "Error in IEnumeratorOfTWrapper. Could not cast: {0} in {0}",
    typeof(T).ToString(),
    enumerable.Current.GetType().ToString()),
    iex);
    }
  }
}

IronPython and IronRuby

V3025 Incorrect format. A different number of format items is expected while calling 'WriteLine' function. Expected: 2. Present: 3. Program.cs 268


private static void DumpGenericParameters(
  MetadataTableView genericParams,
  MetadataRecord owner) {
  foreach (GenericParamDef gp in genericParams) {
    _output.WriteLine("  generic parameter #{0}: {1}",
    gp.Index, gp.Name, gp.Attributes);
  ....
}

.NET Compiler Platform ("Roslyn")

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 2. Present: 3. CompilerServerLogger.cs 49


static CompilerServerLogger()
{
  ....
  loggingFileName = Path.Combine(loggingFileName,
    string.Format("server.{1}.{2}.log",
                  loggingFileName,
                  GetCurrentProcessId(),
                  Environment.TickCount));
  ....
}

.NET Compiler Platform ("Roslyn")

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 2. Present: 1. CompilerPackage.cs 105


private const string WriteFileExceptionMessage =
  @"{1}
  To reload the Roslyn compiler package, close Visual Studio and
  any MSBuild processes, then restart Visual Studio.";

private void WriteMSBuildFiles(....)
{
  ....
  catch (Exception e)
  {
    VsShellUtilities.ShowMessageBox(
      this,
      string.Format(WriteFileExceptionMessage, e.Message),
      null,
      OLEMSGICON.OLEMSGICON_WARNING,
      OLEMSGBUTTON.OLEMSGBUTTON_OK,
      OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
  }
}

.NET Compiler Platform ("Roslyn")

V3025 Incorrect format. A different number of format items is expected while calling 'WriteLine' function. Expected: 3. Present: 1. LoadingAttributes.cs 551

V3025 Incorrect format. A different number of format items is expected while calling 'WriteLine' function. Expected: 4. Present: 2. LoadingAttributes.cs 558


private void DumpAttributes(Symbol s)
{
  int i = 0;
  foreach (var sa in s.GetAttributes())
  {
    int j = 0;
    foreach (var pa in sa.CommonConstructorArguments)
    {
      Console.WriteLine("{0} {1} {2}", pa.ToString());
      j += 1;
    }
    j = 0;
    foreach (var na in sa.CommonNamedArguments)
    {
      Console.WriteLine("{0} {1} {2} = {3}",
                        na.Key, na.Value.ToString());
      j += 1;
    }
    i += 1;
  }
}

Xenko

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 4. Present: 3. SiliconStudio.Core.Mathematics Color3.cs 765


public string ToString(string format,
                                IFormatProvider formatProvider)
{
  if (format == null)
    return ToString(formatProvider);

  return string.Format(
                      formatProvider,
                      "Red:{1} Green:{2} Blue:{3}",
                      R.ToString(format, formatProvider),
                      G.ToString(format, formatProvider),
                      B.ToString(format, formatProvider));
}

Xenko

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Expected: 1. Present: 2. SiliconStudio.Core.Design NamingHelper.cs 56


public static bool IsValidNamespace(
                            string text, out string error)
{
  ....
  error = items.Where(s => !IsIdentifier(s))
               .Select(item =>
                            string.Format("[{0}]", item, text))
               .FirstOrDefault();
  ....
}

Unity3D

V3025 Incorrect format. A different number of format items is expected while calling 'WriteLine' function. Arguments not used: port. AssetBundleDemo AssetBundleServer.cs 59


public static void Main(string[] args)
{
  ....
  Console.WriteLine("Starting up asset bundle server.", port);
  ....
}

MSBuild

V3025 Incorrect format. A different number of format items is expected while calling 'WriteLine' function. Arguments not used: 1st. Scheduler.cs 2216


private void DumpSchedulerState()
{
  ...
  file.WriteLine("Scheduler state at timestamp {0}:",
    _schedulingData.EventTime.Ticks);
  file.WriteLine("--------------------------------------------",
    _schedulingData.EventTime.Ticks);  // <=
  ...
}

Similar errors can be found in some other places:

  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: resource. XmlUtil.cs 75
  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: resource. XmlUtil.cs 82
  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: resource. XmlUtil.cs 91
  • And 1 additional diagnostic messages.

Mono

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: url. corlib-net_4_x RemotingServices.cs 700


static IMessageSink GetClientChannelSinkChain(string url, ....)
{
  ....
  if (url != null)
  {
    string msg = String.Format (
      "Cannot create channel sink to connect to URL {0}.
       An appropriate channel has probably not been registered.",
      url);
    throw new RemotingException (msg);
  }
  else
  {
    string msg = String.Format (
      "Cannot create channel sink to connect
       to the remote object.
       An appropriate channel has probably not been registered.",
      url);
    throw new RemotingException (msg);
  }
  ....
}

Mono

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: text. System.Windows.Forms-net_4_x ListViewItem.cs 1287


public override string ToString ()
{
  return string.Format ("ListViewSubItem {{0}}", text);
}

Mono

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Format items not used: {2}. Arguments not used: 1st. System.ServiceModel-net_4_x WSTrustMessageConverters.cs 147


void ReadEntropy ()
{
  if (reader.IsEmptyElement)
    throw new XmlException (
      String.Format ("WS-Trust Entropy element is empty.{2}",
                      LineInfo ()));
  ....
}

GitExtensions

V3025 Incorrect format. A different number of format items is expected while calling 'WriteLine' function. Arguments not used: pluginFile.Name. GitUI LoadPlugins.cs 35


public static void Load()
{
  ....
  Debug.WriteLine("Loading plugin...", pluginFile.Name); // <=
  ....
}

Umbraco

V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Format items not used: {1}. Arguments not used: 1st. HtmlHelperRenderExtensions.cs 938


public static IHtmlString EnableCanvasDesigner(....)
{
  ....
  string noPreviewLinks = @"<link href=""{1}"" type=
    ""text/css"" rel=""stylesheet"
    " data-title=""canvasdesignerCss"" />";
  ....
  if (....)
    result = string.Format(noPreviewLinks, cssPath) +
             Environment.NewLine;
  ....
}

Similar errors can be found in some other places:

  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Format items not used: {1}. Arguments not used: 1st. HtmlHelperRenderExtensions.cs 946
  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: path. requestModule.cs 204
  • V3025 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: Alias.Replace(" ", ""). Template.cs 382
  • And 2 additional diagnostic messages.


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;