Reputation: 14787
I am generating a dynamic assembly using Reflection.Emit and everything works fine but the generated class is marked as internal sealed
due to the following code:
var typeBuilder = moduleBuilder.DefineType("MyNamespace.Program", TypeAttributes.Class | TypeAttributes.Sealed);
I don't see any of the TypeAttributes
members that would hint at static
. It does not seem to be just a compiler convenience as I can see manually written classes show up as static
in reflector tools.
How could I mark my own type as static?
Upvotes: 3
Views: 444
Reputation: 14787
Got it to work using:
var builderType = builderModule.DefineType("MyNamespace.Program", TypeAttributes.Class | TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.Abstract);
This gives internal static
which is what I wanted.
Upvotes: 4