Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

Avoid uninstantiated internal classes







Breaking Change


An instance of an assembly-level type is not created by code within the assembly. The following types are not examined by this rule:

  • Value types.

  • Abstract types.

  • Enumerations.

  • Delegates.

  • Compiler-emitted array types.

  • Uninstantiable types that define static methods only.

This rule tries to locate a call to one of the type's constructors, and reports a violation if no call is found.

To fix a violation of this rule, remove the type, or add the code that uses it. If the type contains only static methods, add one of the following to the type to prevent the compiler from emitting a default public instance constructor:

  • A private constructor (for types targeting .NET Framework versions 1.0 and 1.1).

  • The static modifier (for types targeting .NET Framework 2.0).

It is safe to exclude a warning from this rule, but there are no known scenarios where this is required.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.