Subscribe to The Madman Scribblings        RSS Feed

String Format Diagnostic (v1.9.0.0)

Icon Leave Comment
String Format Diagnostic (v1.9.0.0)

I've been spending some time developing a Roslyn Code Diagnostic to analyse and validate formatting strings in both VB and C#.
Proud to say that succeeding in creating a proof of concept a few months back (link to blog post)
Over the intervening spare time I have been slowly improving it.
Attached Image
Currently it is capable of validating format string of 43 method overloads.
  • Format Args { ArgIndex , Alignment : Format } Note: Doesn't further valid the format is correct for the type of the supplied argument

    Available for the following methods
    • System.Diagnostics.Debug.WriteLine
    • System.Diagnostics.Trace.TraceError
    • System.Diagnostics.Trace.TraceInformation
    • System.Diagnostics.Trace.TraceWarning
    • System.IO.TextWriter.WriteLine
    • System.String.Format
    • System.Console,Write
    • System.Console.Writeline
    • System.Text.StringBuilder.AppendForma

  • .ToString( )
    Validate the format string of .ToString method of the following types

    • Numeric Type
      • Int16
      • Int32
      • Int64
      • UInt16
      • UInt32
      • UInt64
      • Byte
      • UByte
      • Double
      • Single
      • Decimal
      • Int64

    • Date / Time
      • DateTime
      • DateTimeOffset
      • TimeSpan

    • Enum
      • System.Enum

Future Directions

Validate more format strings like the .Parse and .TryParse methods.
Validate the format string of the format args against the type of the supplied argument.

Want to Try It Out?

Visual Studio Gallery: String.Format Diagnostic (Roslyn)

Want to contribute?
Bug Reports, Bug Fixes, more Analysers.
CodePlex: String.Format Diagnostic (Roslyn)

0 Comments On This Entry


Search My Blog

Recent Entries

Recent Comments