Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StyleCop warning SA1126:PrefixCallsCorrectly on name of class

I've seen several answers regarding this warning (SA1126:PrefixCallsCorrectly) when using static fields/properties and others just not wanting to use this.. However I'm at a loss in my situation:

public class MyClass
{
    public string Name = nameof(MyClass);
}

this, base, etc. are not applicable. What should I be using? Or should I just keep ignoring the warning?

like image 588
UndeadBob Avatar asked May 12 '16 14:05

UndeadBob


1 Answers

There is a workaround:

public class MyClass
{
    public string Name = $"{nameof(MyClass)}";
}
like image 98
Ivan Zavyalov Avatar answered Oct 27 '22 04:10

Ivan Zavyalov