Microsoft.CSharp.CSharpCodeGenerator.OutputTypeAttributes() does not write 'static class' when CodeTypeDefinition has "TypeAttributes.Abstract | TypeAttributes.Sealed" - by Fabio Pintos - MSFT

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 526505 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/22/2010 6:23:23 AM
Access Restriction Public


Microsoft.CSharp.CSharpCodeGenerator.OutputTypeAttributes() does not recognize the fact that a CodeTypeDefinition marked with 'typeDefinition.TypeAttributes = TypeAttributes.Abstract | TypeAttributes.Sealed' must be generated as 'static class' and generates 'sealed abstract class', which generates a compiler error.

This blocks code generation tools from creating static classes.

Optionally we could simply add a new TypeAttibutes.Static and deal with it explicitly.

Sign in to post a comment.
Posted by Microsoft on 2/1/2010 at 4:23 PM
Modules aren't exactly the same thing as static classes. For instance, C# allows nesting static classes, but VB doesn't allow nesting modules.

Mueez Siddiqui
Software development engineer - CLR Team
Posted by David A Nelson on 2/1/2010 at 4:09 PM
VB has modules which are essentially static classes. I don't see why the VB CodeDom provider couldn't generate modules for static classes.
Posted by Microsoft on 2/1/2010 at 12:28 PM
Thanks for reporting this. Unfortunately, it doesn't look like we can support static classes for CodeDom.

The reason is that one of the design goals of CodeDom is to be language-independent, so that any code generated for one language can easily be generated for a different language. While static classes are used often in C#, VB does not support them. Therefore, adding support for static classes will mean that some code that can compile for C# won't be compilable for VB, which goes against our goals.

While we can't act on this issue, we ask that you please continue to provide feedback in the future to help us improve.

Thank you,

Mueez Siddiqui
Software development engineer - CLR Team
Posted by Microsoft on 1/24/2010 at 5:43 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(