ToStringWithoutOverrideAnalyzer 0.5.0

NET Compiler Platform ("Roslyn") analyzer to disallow calling object.ToString() on types lacking an override.

Imagine we have the following simple plain old CLR object for representing money:

   struct Money {
       public decimal amount;
       public string currency;
   }

Then we try to print out an instance of it:

   System.WriteLine("I need about {0}", new Money { amount = 3.50m, currency = "$" });

The statement will print `I need about Money`, which is not very useful. This came up a number of times on a team when writing code logging the state of objects for debugging purposes, leading to the creation of this analyzer.

After installing this analyzer the above `WriteLine` call will result in a compile-time error message `Expression of type 'Money' will be implicitly converted to a string, but does not override ToString()`.

Install-Package ToStringWithoutOverrideAnalyzer -Version 0.5.0
dotnet add package ToStringWithoutOverrideAnalyzer --version 0.5.0

Release Notes

Version 0.5.0.0

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
0.5.0 (current version) 389 7/7/2016
0.4.2 99 6/30/2016
0.4.1 128 5/27/2016