CA1053 resolution question
-
Friday, May 05, 2006 2:56 PM
I have a VB class that has no constructor and all Shared methods. CA1053 says that this is a bad thing.
If I add an empty Public New() method, the message is still generated on the next analyze pass.
If I change New() to be Protected or Private, I get items in the task list for each place where I create an instance of the class (Private Sub New()' is not accessible in this context because it is 'Private').
What can I do to make CA1053 go away and still have my code build properly?
Thanks,
Mark
All Replies
-
Friday, May 05, 2006 3:18 PMModerator
Mark,
If you have a class that only has shared methods, why do you need to create an instance of it?
An example of a class with only shared methods, is the System.Math class. It has a private constructor, as it adds no benefit (and it makes no sense) for it to be createable.
By-the-way, if you specify no constructors, the VB compiler will generated a default public constructor.
Regards
David
-
Monday, May 08, 2006 3:34 PM
Excellent point.
I removed the instantiations and marked it as Uninheritable and all is well. Thanks!

