FxCop giving a warning on private constructor CA1823 and CA1053

Posted by Luis Sánchez on Stack Overflow See other posts from Stack Overflow or by Luis Sánchez
Published on 2012-06-08T22:36:34Z Indexed on 2012/06/08 22:40 UTC
Read the original article Hit count: 318

I have a class that looks like the following:

Public Class Utilities
    Public Shared Function blah(userCode As String) As String
        'doing some stuff
    End Function
End Class

I'm running FxCop 10 on it and it says:

"Because type 'Utilities' contains only 'static' (
'Shared' in Visual Basic) members, add a default private 
constructor to prevent the compiler from adding a default 
public constructor."

Ok, you're right Mr. FxCop, I'll add a private constructor:

Private Utilities()

Now I'm having:

"It appears that field 'Utilities.Utilities' is 
never used or is only ever assigned to. Use this field 
or remove it."

Any ideas of what should I do to get rid of both warnings?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about visual-studio-2010