tags:

views:

36

answers:

2

Is there a way to remove items in code generated in Codedom from VB code?

For example at the top of all the code I generate, it has:

'------------------------------------------------------------------------------
' 
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.1
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' 
'------------------------------------------------------------------------------
Option Strict Off 
Option Explicit On 

I'd like both of these to go away - the commented text and the both the Option xxx. I've tried toying around with CodeGeneratorOptions, but have not been able to remove the above from generated code.

+1  A: 

For #2, have you tried this?

CodeCompileUnit.UserData.Add("AllowLateBound", False) ' strict on
CodeCompileUnit.UserData.Add("RequireVariableDeclaration", False) ' explicit off

(where CodeCompileUnit is a variable of type CodeCompileUnit)

Dumb Guy
I have, unfortunately it doesn't remove them, either `False` or `True`.
Otaku
+2  A: 

No, that can't be removed. It is hard-coded into the VBCompiler. You can see this in system.dll in Reflector.

WinnerWinnerChickenDinner