I have a utility class that only contains static methods. If I mark the class as static, is that a breaking binary change?
I've compared the IL for both, and besides the loss of the default constructor (that should never be used), I can see the following differences...
Class not marked as static:
.class public auto ansi beforefieldinit MyNamespace.MyClass
Class marked as static:
.class public auto ansi abstract sealed beforefieldinit MyNamespace.MyClass
I can't see why that would be a breaking change, but...?
It depends on the usage of your class by other code: potential usage of
static
classes is a lot more restricted than that of non-static ones.static
even though it hasn't been static at the time, the code is not going to break.Since in general you cannot guarantee that your non-static class is used in a certain way, making a formerly non-static class a static one should be considered a breaking change. If you have code outside your control that depends on your class, designate the old class obsolete, and make a new static class to be used instead of it.