TypeName | StaticConstructorExceptionAnalyzer |
Check Id | CC0024 |
Category | Design |
Severity | Warning |
Static constructor are called before the first time a class is used but the caller doesn’t control when exactly. Exception thrown in this context force callers to use ‘try’ block around any useage of the class and should be avoided.
public class MyClass
{
static MyClass()
{
throw new System.Exception("error message");
}
}
A code fix will be presented to you that will transform the code:
public class MyClass
{
static MyClass()
{
}
}
None
TBD