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

There is a newer version of this package available.
See the version list below for details.
Install-Package ToStringWithoutOverrideAnalyzer -Version 0.5.0
dotnet add package ToStringWithoutOverrideAnalyzer --version 0.5.0
<PackageReference Include="ToStringWithoutOverrideAnalyzer" Version="0.5.0">
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ToStringWithoutOverrideAnalyzer --version 0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes



This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on ToStringWithoutOverrideAnalyzer:

Repository Stars
A static nuget feed generator for Azure Storage, AWS S3, and more.

Version History

Version Downloads Last updated
0.6.0 9,619 4/29/2018
0.5.0 3,105 7/7/2016
0.4.2 418 6/30/2016
0.4.1 405 5/27/2016