469,642 Members | 1,282 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

CodeDOM Help for Option Compare

Hi All,

I have been playing with the codedom and can't get it to output for
option compare Binary with a CodeCompileUnit. I have searched the web
and Don't now if it's possible. If it's not possible I just go with
CodeSnippetCompileUnit

Please email me a copy at:
programmer @ jenck . net (remove the extra spaces)

Thanks in advance,

Mike

<-------

Put the following code in a form with a textbox called txtResult
and a button

Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click
'Test()
Test2()
End Sub

------->

Option Strict On
Option Explicit On
Option Compare Binary

Imports System.IO
Imports System.CodeDom
Imports System.CodeDom.Compiler
Imports System.Text

Private Sub Test()
Dim strTemp As String
strTemp = "Option Strict On" & vbCrLf
strTemp += "Option Explicit On" & vbCrLf
strTemp += "Option Compare Binary" & vbCrLf

Dim myCU As New CodeSnippetCompileUnit(strTemp)
Dim cop As New CodeGeneratorOptions
Dim provider As New VBCodeProvider
Dim CodeGenerator As ICodeGenerator =
provider.CreateGenerator()

' Set cop properties
cop.IndentString = " "

Dim sbCode As StringBuilder = New StringBuilder
Dim sw As StringWriter = New StringWriter(sbCode)
CodeGenerator.GenerateCodeFromCompileUnit(myCU, sw, cop)

txtResult.Text = sbCode.ToString
End Sub

This results in:

Option Strict On
Option Explicit On
Option Compare Binary

However, if I try and use

Private Sub Test2()
Dim cop As New CodeGeneratorOptions
Dim provider As New VBCodeProvider
Dim CodeGenerator As ICodeGenerator =
provider.CreateGenerator()

' Set cop properties
cop.IndentString = " "

Dim myCompileUnit As New CodeCompileUnit

' Option Strict On
myCompileUnit.UserData.Add("AllowLateBound", False)

' Option Explicit On
myCompileUnit.UserData.Add("RequireVariableDeclara tion ",
False)

myCompileUnit.UserData.Add("/optioncompare:", "Text") ' <--
Does not work

Dim sbCode As StringBuilder = New StringBuilder
Dim sw As StringWriter = New StringWriter(sbCode)
CodeGenerator.GenerateCodeFromCompileUnit(myCompil eUnit, sw,
cop)

txtResult.Text = sbCode.ToString
End Sub

These results are

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be
lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On
<-- MISSING Option Compare Binary
Apr 8 '07 #1
0 1189

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ron Bullman | last post: by
2 posts views Thread by Guillaume | last post: by
1 post views Thread by John Livermore | last post: by
6 posts views Thread by moondaddy | last post: by
1 post views Thread by =?Utf-8?B?QU1lcmNlcg==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.