Skip to content

VBCompiler.CompileAssemblyFromFileBatch() is modifying the passed in CompilerOptions #8

@niemyjski

Description

@niemyjski

I was using the legacy VB CodeDom provider to generate VB Code and compile it on the fly for our app. It was working great but we wanted to support newer language features so we brought in the latest Roslyn Code Dom provider via nuget... The change was simple and our c# implementation works flawlessly but I can't even compile the simplest sample due to the VBCompiler is injecting unwanted/invalid compiler options

Lets say I pass in the compiler options of /optionInfer+ /define:CodeSmith40 /define:CodeSmith50 /define:CodeSmith60 /define:CodeSmith70 /define:CodeSmith80 /define:TRACE they are modified once I call CompileAssemblyFromFileBatch to /nowarn:41008,40000,40008 /define:_MYTYPE=\\\"Web\\\" /imports:Microsoft.VisualBasic /optionInfer+ /define:CodeSmith40 /define:CodeSmith50 /define:CodeSmith60 /define:CodeSmith70 /define:CodeSmith80 /define:TRACE

Once it defines _MYTYPE (unwanted), I believe it's calling the following code (https://github.com/dotnet/roslyn/blob/614299ff83da9959fa07131c6d0ffbc58873b6ae/src/Compilers/VisualBasic/Portable/Symbols/EmbeddedSymbols/VbMyTemplateText.vb#L287) which causes my compile to fail with:

vbc : (1,1): error BC30002: Type 'Global.System.Web.HttpRequest' is not defined.
vbc : (1,1): error BC30002: Type 'Global.System.Web.HttpResponse' is not defined.
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.5" targetFramework="net462" />
  <package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net462" developmentDependency="true" />

dotnet/roslyn#20214

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions