VSDiagnostics
VSDiagnostics copied to clipboard
Implement InstantiatedObjectNotUsed
When instantiating a new object we expect it to be assigned to something.
Show warnings in case of:
new StringBuilder();
Don't show warnings in case of:
return new StringBuilder();
throw new Exception();
This should only happen for locals that are not passed along as arguments. Take for example this usage of a factory pattern:
void Main()
{
Factory.Create(() => new string("test".ToCharArray())).Dump();
Factory.Create(() => new string("test 2".ToCharArray())).Dump();
}
public static class Factory
{
public static T Create<T>(Func<T> func)
{
return func();
}
}