546

Downloads

339

Downloads of v 0.5.0

1

Average downloads per day

2016-07-07

Last published

Share on Social Networks

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()`.

To install ToStringWithoutOverrideAnalyzer, run the following command in the Package Manager Console

Install-Package ToStringWithoutOverrideAnalyzer -Version 0.5.0

Release Notes

Version 0.5.0.0

Owners

Authors

Microsoft

Copyright

Microsoft

Tags

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
ToStringWithoutOv... 0.5.0 (this version) 339 Thursday, July 7, 2016
ToStringWithoutOv... 0.4.2 88 Thursday, June 30, 2016
ToStringWithoutOv... 0.4.1 119 Friday, May 27, 2016