Skip navigation.

Color Blindness Simulator Now AvailableAll recent postsControl Freak

Fixes to Pipeline Generator

No, I’m not talking about power outages or oil pipelines. I’m talking about my online tool (see launch announcement) which generates templates of HttpModules, HttpHandlers, and HttpHandlerFactorys [sic]. Brad Greubel brought to my attention that the generator was producing incorrect code in VB.NET: CodeDOM was emitting code Inheriting interfaces, instead of Implementing them.

Normally, I would add the following code when a class implements a certain interface:

CodeTypeDeclaration cls = new CodeTypeDeclaration ([some class]);
...
cls.BaseTypes.Add ("IHttpHandler");

In VB.NET CodeDOM emits Inherits instead of Implements. An article by Paul Nichols, entitled CodeDOM: How to achieve code generation in .NET, suggests adding a CodeSnippetTypeMember as a workaround:

CodeTypeDeclaration cls = new  CodeTypeDeclaration ([some class]);
...
cls.Members.Add (
       new CodeSnippetTypeMember("Implements IHttpHandler"));

This seems to produce correct VB.NET code.

Another gotcha: methods should indicate they are implementations of the same interface methods, which requires this code appendix at each one of them:

CodeMemberProperty isReusableProp = new CodeMemberProperty ();
isReusableProp.Name = "IsReusable";
...
isReusableProp.ImplementationTypes.Add (
       new CodeTypeReference("IHttpHandler"));

The last line appends Implements IHttpHandler.IsReusable to the method in question and makes the VB.NET compiler happy.

I’m posting source code of the generator tool for your perusal. If anyone knows of a better way than the CodeSnippetTypeMember hack for the VB.NET code generator, please let me know.

If you, folks, notice other issues, please point them out.

Comments

No comments yet

Emails and Notifications

Would you like to be notified when somebody responds to this post? 

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):