This project is read-only.

Static type definition

Topics: Metadata Model
Feb 16, 2011 at 5:40 AM
Edited Feb 16, 2011 at 12:45 PM


It looks like there is no such thing as a "static class" for the CLR. C# static classes are abstract sealed subclasses of System.Object with no instance constructor.

Even so ITypeDefinition has a IsStatic property that is supposed to be true if the condition above are met but that is not even consulted by PeWriter.

It's not a bug or a big problem but I find it's an inconsistency.

I wrote this just in case you didn't notice that. Otherwise please ignore this message.


What I meant is that, as I see it, being "static" is not a property of the metadata model of a type and IsStatic should not be a property of ITypeDefinition. If, as it seems, IsStatic has the only purpose to provide a quick way to check if a type is a "static class à la C#" there should be a TypeHelper.IsStaticClass(ITypeReference) method for the same purpose.


Feb 17, 2011 at 5:52 PM

This does seem inconsistent. I guess it just got overlooked during the evolution of the object model. However, removing it at this point seems more trouble than it is worth.