in src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb [74:1421]
Public Shadows Function Parse(args As IEnumerable(Of String), baseDirectory As String, sdkDirectory As String, Optional additionalReferenceDirectories As String = Nothing) As VisualBasicCommandLineArguments
Const GenerateFileNameForDocComment As String = "USE-OUTPUT-NAME"
Dim diagnostics As List(Of Diagnostic) = New List(Of Diagnostic)()
Dim flattenedArgs As List(Of String) = New List(Of String)()
Dim scriptArgs As List(Of String) = If(IsScriptCommandLineParser, New List(Of String)(), Nothing)
Dim responsePaths As New List(Of String)
FlattenArgs(args, diagnostics, flattenedArgs, scriptArgs, baseDirectory, responsePaths)
Dim displayLogo As Boolean = True
Dim displayHelp As Boolean = False
Dim displayVersion As Boolean = False
Dim displayLangVersions As Boolean = False
Dim outputLevel As OutputLevel = OutputLevel.Normal
Dim optimize As Boolean = False
Dim checkOverflow As Boolean = True
Dim concurrentBuild As Boolean = True
Dim deterministic As Boolean = False
Dim emitPdb As Boolean
Dim debugInformationFormat As DebugInformationFormat = If(PathUtilities.IsUnixLikePlatform, DebugInformationFormat.PortablePdb, DebugInformationFormat.Pdb)
Dim noStdLib As Boolean = False
Dim utf8output As Boolean = False
Dim outputFileName As String = Nothing
Dim outputRefFileName As String = Nothing
Dim refOnly As Boolean = False
Dim outputDirectory As String = baseDirectory
Dim documentationPath As String = Nothing
Dim errorLogPath As String = Nothing
Dim parseDocumentationComments As Boolean = False
Dim outputKind As OutputKind = OutputKind.ConsoleApplication
Dim ssVersion As SubsystemVersion = SubsystemVersion.None
Dim languageVersion As LanguageVersion = LanguageVersion.Default
Dim mainTypeName As String = Nothing
Dim win32ManifestFile As String = Nothing
Dim win32ResourceFile As String = Nothing
Dim win32IconFile As String = Nothing
Dim noWin32Manifest As Boolean = False
Dim managedResources = New List(Of ResourceDescription)()
Dim sourceFiles = New List(Of CommandLineSourceFile)()
Dim hasSourceFiles = False
Dim additionalFiles = New List(Of CommandLineSourceFile)()
Dim embeddedFiles = New List(Of CommandLineSourceFile)()
Dim embedAllSourceFiles = False
Dim codepage As Encoding = Nothing
Dim checksumAlgorithm = SourceHashAlgorithm.Sha1
Dim defines As IReadOnlyDictionary(Of String, Object) = Nothing
Dim metadataReferences = New List(Of CommandLineReference)()
Dim analyzers = New List(Of CommandLineAnalyzerReference)()
Dim sdkPaths As New List(Of String)()
Dim libPaths As New List(Of String)()
Dim sourcePaths As New List(Of String)()
Dim keyFileSearchPaths = New List(Of String)()
Dim globalImports = New List(Of GlobalImport)
Dim rootNamespace As String = ""
Dim optionStrict As OptionStrict = OptionStrict.Off
Dim optionInfer As Boolean = False
Dim optionExplicit As Boolean = True
Dim optionCompareText As Boolean = False
Dim embedVbCoreRuntime As Boolean = False
Dim platform As Platform = Platform.AnyCpu
Dim preferredUILang As CultureInfo = Nothing
Dim fileAlignment As Integer = 0
Dim baseAddress As ULong = 0
Dim highEntropyVA As Boolean = False
Dim vbRuntimePath As String = Nothing
Dim includeVbRuntimeReference As Boolean = True
Dim generalDiagnosticOption As ReportDiagnostic = ReportDiagnostic.Default
Dim pathMap As ImmutableArray(Of KeyValuePair(Of String, String)) = ImmutableArray(Of KeyValuePair(Of String, String)).Empty
Dim specificDiagnosticOptionsFromRuleSet = New Dictionary(Of String, ReportDiagnostic)(CaseInsensitiveComparison.Comparer)
Dim specificDiagnosticOptionsFromGeneralArguments = New Dictionary(Of String, ReportDiagnostic)(CaseInsensitiveComparison.Comparer)
Dim specificDiagnosticOptionsFromSpecificArguments = New Dictionary(Of String, ReportDiagnostic)(CaseInsensitiveComparison.Comparer)
Dim specificDiagnosticOptionsFromNoWarnArguments = New Dictionary(Of String, ReportDiagnostic)(CaseInsensitiveComparison.Comparer)
Dim keyFileSetting As String = Nothing
Dim keyContainerSetting As String = Nothing
Dim delaySignSetting As Boolean? = Nothing
Dim moduleAssemblyName As String = Nothing
Dim moduleName As String = Nothing
Dim touchedFilesPath As String = Nothing
Dim features = New List(Of String)()
Dim reportAnalyzer As Boolean = False
Dim publicSign As Boolean = False
Dim interactiveMode As Boolean = False
Dim instrumentationKinds As ArrayBuilder(Of InstrumentationKind) = ArrayBuilder(Of InstrumentationKind).GetInstance()
Dim sourceLink As String = Nothing
Dim ruleSetPath As String = Nothing
If Not IsScriptCommandLineParser Then
For Each arg In flattenedArgs
Dim name As String = Nothing
Dim value As String = Nothing
If TryParseOption(arg, name, value) AndAlso (name = "ruleset") Then
Dim unquoted = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(unquoted) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<file>")
Continue For
End If
ruleSetPath = ParseGenericPathToFile(unquoted, diagnostics, baseDirectory)
generalDiagnosticOption = GetDiagnosticOptionsFromRulesetFile(ruleSetPath, specificDiagnosticOptionsFromRuleSet, diagnostics)
End If
Next
End If
For Each arg In flattenedArgs
Debug.Assert(Not arg.StartsWith("@", StringComparison.Ordinal))
Dim name As String = Nothing
Dim value As String = Nothing
If Not TryParseOption(arg, name, value) Then
sourceFiles.AddRange(ParseFileArgument(arg, baseDirectory, diagnostics))
hasSourceFiles = True
Continue For
End If
Select Case name
Case "?", "help"
If value IsNot Nothing Then
Exit Select
End If
displayHelp = True
Continue For
Case "version"
If value IsNot Nothing Then
Exit Select
End If
displayVersion = True
Continue For
Case "r", "reference"
metadataReferences.AddRange(ParseAssemblyReferences(name, value, diagnostics, embedInteropTypes:=False))
Continue For
Case "a", "analyzer"
analyzers.AddRange(ParseAnalyzers(name, value, diagnostics))
Continue For
Case "d", "define"
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<symbol_list>")
Continue For
End If
Dim conditionalCompilationDiagnostics As IEnumerable(Of Diagnostic) = Nothing
defines = ParseConditionalCompilationSymbols(value, conditionalCompilationDiagnostics, defines)
diagnostics.AddRange(conditionalCompilationDiagnostics)
Continue For
Case "imports", "import"
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, If(name = "import", ":<str>", ":<import_list>"))
Continue For
End If
ParseGlobalImports(value, globalImports, diagnostics)
Continue For
Case "optionstrict"
value = RemoveQuotesAndSlashes(value)
If value Is Nothing Then
optionStrict = VisualBasic.OptionStrict.On
ElseIf String.Equals(value, "custom", StringComparison.OrdinalIgnoreCase) Then
optionStrict = VisualBasic.OptionStrict.Custom
Else
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "optionstrict", ":custom")
End If
Continue For
Case "optionstrict+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optionstrict")
Continue For
End If
optionStrict = VisualBasic.OptionStrict.On
Continue For
Case "optionstrict-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optionstrict")
Continue For
End If
optionStrict = VisualBasic.OptionStrict.Off
Continue For
Case "optioncompare"
value = RemoveQuotesAndSlashes(value)
If value Is Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "optioncompare", ":binary|text")
ElseIf String.Equals(value, "text", StringComparison.OrdinalIgnoreCase) Then
optionCompareText = True
ElseIf String.Equals(value, "binary", StringComparison.OrdinalIgnoreCase) Then
optionCompareText = False
Else
AddDiagnostic(diagnostics, ERRID.ERR_InvalidSwitchValue, "optioncompare", value)
End If
Continue For
Case "optionexplicit", "optionexplicit+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optionexplicit")
Continue For
End If
optionExplicit = True
Continue For
Case "optionexplicit-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optionexplicit")
Continue For
End If
optionExplicit = False
Continue For
Case "optioninfer", "optioninfer+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optioninfer")
Continue For
End If
optionInfer = True
Continue For
Case "optioninfer-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optioninfer")
Continue For
End If
optionInfer = False
Continue For
Case "codepage"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "codepage", ":<number>")
Continue For
End If
Dim encoding = TryParseEncodingName(value)
If encoding Is Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_BadCodepage, value)
Continue For
End If
codepage = encoding
Continue For
Case "checksumalgorithm"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "checksumalgorithm", ":<algorithm>")
Continue For
End If
Dim newChecksumAlgorithm = TryParseHashAlgorithmName(value)
If newChecksumAlgorithm = SourceHashAlgorithm.None Then
AddDiagnostic(diagnostics, ERRID.ERR_BadChecksumAlgorithm, value)
Continue For
End If
checksumAlgorithm = newChecksumAlgorithm
Continue For
Case "removeintchecks", "removeintchecks+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "removeintchecks")
Continue For
End If
checkOverflow = False
Continue For
Case "removeintchecks-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "removeintchecks")
Continue For
End If
checkOverflow = True
Continue For
Case "sqmsessionguid"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrWhiteSpace(value) = True Then
AddDiagnostic(diagnostics, ERRID.ERR_MissingGuidForOption, value, name)
Else
Dim sqmsessionguid As Guid
If Not Guid.TryParse(value, sqmsessionguid) Then
AddDiagnostic(diagnostics, ERRID.ERR_InvalidFormatForGuidForOption, value, name)
End If
End If
Continue For
Case "preferreduilang"
value = RemoveQuotesAndSlashes(value)
If (String.IsNullOrEmpty(value)) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<string>")
Continue For
End If
Try
preferredUILang = New CultureInfo(value)
If (CorLightup.Desktop.IsUserCustomCulture(preferredUILang)) Then
preferredUILang = Nothing
End If
Catch ex As CultureNotFoundException
End Try
If preferredUILang Is Nothing Then
AddDiagnostic(diagnostics, ERRID.WRN_BadUILang, value)
End If
Continue For
Case "lib", "libpath", "libpaths"
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<path_list>")
Continue For
End If
libPaths.AddRange(ParseSeparatedPaths(value))
Continue For
#If DEBUG Then
Case "attachdebugger"
Debugger.Launch()
Continue For
#End If
End Select
If IsScriptCommandLineParser Then
Select Case name
Case "i", "i+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "i")
End If
interactiveMode = True
Continue For
Case "i-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "i")
End If
interactiveMode = False
Continue For
Case "loadpath", "loadpaths"
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<path_list>")
Continue For
End If
sourcePaths.AddRange(ParseSeparatedPaths(value))
Continue For
End Select
Else
Select Case name
Case "out"
If String.IsNullOrWhiteSpace(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<file>")
Else
ParseOutputFile(value, diagnostics, baseDirectory, outputFileName, outputDirectory)
End If
Continue For
Case "refout"
Dim unquoted = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(unquoted) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<file>")
Else
outputRefFileName = ParseGenericPathToFile(unquoted, diagnostics, baseDirectory)
End If
Continue For
Case "refonly", "refonly+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "refonly")
End If
refOnly = True
Continue For
Case "t", "target"
value = RemoveQuotesAndSlashes(value)
outputKind = ParseTarget(name, value, diagnostics)
Continue For
Case "moduleassemblyname"
value = RemoveQuotesAndSlashes(value)
Dim identity As AssemblyIdentity = Nothing
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "moduleassemblyname", ":<string>")
ElseIf Not AssemblyIdentity.TryParseDisplayName(value, identity) OrElse
Not MetadataHelpers.IsValidAssemblyOrModuleName(identity.Name) Then
AddDiagnostic(diagnostics, ERRID.ERR_InvalidAssemblyName, value, arg)
Else
moduleAssemblyName = identity.Name
End If
Continue For
Case "rootnamespace"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "rootnamespace", ":<string>")
Continue For
End If
rootNamespace = value
Continue For
Case "doc"
value = RemoveQuotesAndSlashes(value)
parseDocumentationComments = True
If value Is Nothing Then
documentationPath = GenerateFileNameForDocComment
Continue For
End If
Dim unquoted = RemoveQuotesAndSlashes(value)
If unquoted.Length = 0 Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "doc", ":<file>")
Else
documentationPath = ParseGenericPathToFile(unquoted, diagnostics, baseDirectory, generateDiagnostic:=False)
If String.IsNullOrWhiteSpace(documentationPath) Then
AddDiagnostic(diagnostics, ERRID.WRN_XMLCannotWriteToXMLDocFile2, unquoted, New LocalizableErrorArgument(ERRID.IDS_TheSystemCannotFindThePathSpecified))
documentationPath = Nothing
End If
End If
Continue For
Case "doc+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "doc")
End If
documentationPath = GenerateFileNameForDocComment
parseDocumentationComments = True
Continue For
Case "doc-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "doc")
End If
documentationPath = Nothing
parseDocumentationComments = False
Continue For
Case "errorlog"
Dim unquoted = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(unquoted) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "errorlog", ":<file>")
Else
errorLogPath = ParseGenericPathToFile(unquoted, diagnostics, baseDirectory)
End If
Continue For
Case "netcf"
Continue For
Case "sdkpath"
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "sdkpath", ":<path>")
Continue For
End If
sdkPaths.Clear()
sdkPaths.AddRange(ParseSeparatedPaths(value))
Continue For
Case "instrument"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "instrument", ":<string>")
Continue For
End If
For Each instrumentationKind As InstrumentationKind In ParseInstrumentationKinds(value, diagnostics)
If Not instrumentationKinds.Contains(instrumentationKind) Then
instrumentationKinds.Add(instrumentationKind)
End If
Next
Continue For
Case "recurse"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "recurse", ":<wildcard>")
Continue For
End If
Dim before As Integer = sourceFiles.Count
sourceFiles.AddRange(ParseRecurseArgument(value, baseDirectory, diagnostics))
If sourceFiles.Count > before Then
hasSourceFiles = True
End If
Continue For
Case "addmodule"
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "addmodule", ":<file_list>")
Continue For
End If
metadataReferences.AddRange(
ParseSeparatedPaths(value).Select(
Function(path) New CommandLineReference(path, New MetadataReferenceProperties(MetadataImageKind.Module))))
Continue For
Case "l", "link"
metadataReferences.AddRange(ParseAssemblyReferences(name, value, diagnostics, embedInteropTypes:=True))
Continue For
Case "win32resource"
win32ResourceFile = GetWin32Setting(s_win32Res, RemoveQuotesAndSlashes(value), diagnostics)
Continue For
Case "win32icon"
win32IconFile = GetWin32Setting(s_win32Icon, RemoveQuotesAndSlashes(value), diagnostics)
Continue For
Case "win32manifest"
win32ManifestFile = GetWin32Setting(s_win32Manifest, RemoveQuotesAndSlashes(value), diagnostics)
Continue For
Case "nowin32manifest"
If value IsNot Nothing Then
Exit Select
End If
noWin32Manifest = True
Continue For
Case "res", "resource"
Dim embeddedResource = ParseResourceDescription(name, value, baseDirectory, diagnostics, embedded:=True)
If embeddedResource IsNot Nothing Then
managedResources.Add(embeddedResource)
End If
Continue For
Case "linkres", "linkresource"
Dim linkedResource = ParseResourceDescription(name, value, baseDirectory, diagnostics, embedded:=False)
If linkedResource IsNot Nothing Then
managedResources.Add(linkedResource)
End If
Continue For
Case "sourcelink"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "sourcelink", ":<file>")
Else
sourceLink = ParseGenericPathToFile(value, diagnostics, baseDirectory)
End If
Continue For
Case "debug"
value = RemoveQuotesAndSlashes(value)
If value IsNot Nothing Then
Select Case value.ToLower()
Case "full", "pdbonly"
debugInformationFormat = If(PathUtilities.IsUnixLikePlatform, DebugInformationFormat.PortablePdb, DebugInformationFormat.Pdb)
Case "portable"
debugInformationFormat = DebugInformationFormat.PortablePdb
Case "embedded"
debugInformationFormat = DebugInformationFormat.Embedded
Case Else
AddDiagnostic(diagnostics, ERRID.ERR_InvalidSwitchValue, "debug", value)
End Select
End If
emitPdb = True
Continue For
Case "debug+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "debug")
End If
emitPdb = True
Continue For
Case "debug-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "debug")
End If
emitPdb = False
Continue For
Case "optimize", "optimize+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optimize")
Continue For
End If
optimize = True
Continue For
Case "optimize-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "optimize")
Continue For
End If
optimize = False
Continue For
Case "parallel", "p"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, name)
Continue For
End If
concurrentBuild = True
Continue For
Case "deterministic", "deterministic+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, name)
Continue For
End If
deterministic = True
Continue For
Case "deterministic-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, name)
Continue For
End If
deterministic = False
Continue For
Case "parallel+", "p+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, name.Substring(0, name.Length - 1))
Continue For
End If
concurrentBuild = True
Continue For
Case "parallel-", "p-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, name.Substring(0, name.Length - 1))
Continue For
End If
concurrentBuild = False
Continue For
Case "warnaserror", "warnaserror+"
If value Is Nothing Then
generalDiagnosticOption = ReportDiagnostic.Error
specificDiagnosticOptionsFromGeneralArguments.Clear()
For Each pair In specificDiagnosticOptionsFromRuleSet
If pair.Value = ReportDiagnostic.Warn Then
specificDiagnosticOptionsFromGeneralArguments.Add(pair.Key, ReportDiagnostic.Error)
End If
Next
Continue For
End If
AddWarnings(specificDiagnosticOptionsFromSpecificArguments, ReportDiagnostic.Error, ParseWarnings(value))
Continue For
Case "warnaserror-"
If value Is Nothing Then
If generalDiagnosticOption <> ReportDiagnostic.Suppress Then
generalDiagnosticOption = ReportDiagnostic.Default
End If
specificDiagnosticOptionsFromGeneralArguments.Clear()
Continue For
End If
For Each id In ParseWarnings(value)
Dim ruleSetValue As ReportDiagnostic
If specificDiagnosticOptionsFromRuleSet.TryGetValue(id, ruleSetValue) Then
specificDiagnosticOptionsFromSpecificArguments(id) = ruleSetValue
Else
specificDiagnosticOptionsFromSpecificArguments(id) = ReportDiagnostic.Default
End If
Next
Continue For
Case "nowarn"
If value Is Nothing Then
generalDiagnosticOption = ReportDiagnostic.Suppress
specificDiagnosticOptionsFromGeneralArguments.Clear()
For Each pair In specificDiagnosticOptionsFromRuleSet
If pair.Value <> ReportDiagnostic.Error Then
specificDiagnosticOptionsFromGeneralArguments.Add(pair.Key, ReportDiagnostic.Suppress)
End If
Next
Continue For
End If
AddWarnings(specificDiagnosticOptionsFromNoWarnArguments, ReportDiagnostic.Suppress, ParseWarnings(value))
Continue For
Case "langversion"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "langversion", ":<number>")
ElseIf value = "?" Then
displayLangVersions = True
Else
If Not value.TryParse(languageVersion) Then
AddDiagnostic(diagnostics, ERRID.ERR_InvalidSwitchValue, "langversion", value)
End If
End If
Continue For
Case "delaysign", "delaysign+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "delaysign")
Continue For
End If
delaySignSetting = True
Continue For
Case "delaysign-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "delaysign")
Continue For
End If
delaySignSetting = False
Continue For
Case "publicsign", "publicsign+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "publicsign")
Continue For
End If
publicSign = True
Continue For
Case "publicsign-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "publicsign")
Continue For
End If
publicSign = False
Continue For
Case "keycontainer"
value = RemoveQuotesAndSlashes(value)
keyFileSetting = Nothing
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "keycontainer", ":<string>")
Else
keyContainerSetting = value
End If
Continue For
Case "keyfile"
value = RemoveQuotesAndSlashes(value)
keyContainerSetting = Nothing
If String.IsNullOrWhiteSpace(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "keyfile", ":<file>")
Else
keyFileSetting = value
End If
Continue For
Case "highentropyva", "highentropyva+"
If value IsNot Nothing Then
Exit Select
End If
highEntropyVA = True
Continue For
Case "highentropyva-"
If value IsNot Nothing Then
Exit Select
End If
highEntropyVA = False
Continue For
Case "nologo", "nologo+"
If value IsNot Nothing Then
Exit Select
End If
displayLogo = False
Continue For
Case "nologo-"
If value IsNot Nothing Then
Exit Select
End If
displayLogo = True
Continue For
Case "quiet+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "quiet")
Continue For
End If
outputLevel = VisualBasic.OutputLevel.Quiet
Continue For
Case "quiet"
If value IsNot Nothing Then
Exit Select
End If
outputLevel = VisualBasic.OutputLevel.Quiet
Continue For
Case "verbose"
If value IsNot Nothing Then
Exit Select
End If
outputLevel = VisualBasic.OutputLevel.Verbose
Continue For
Case "verbose+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "verbose")
Continue For
End If
outputLevel = VisualBasic.OutputLevel.Verbose
Continue For
Case "quiet-", "verbose-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, name.Substring(0, name.Length - 1))
Continue For
End If
outputLevel = VisualBasic.OutputLevel.Normal
Continue For
Case "utf8output", "utf8output+"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "utf8output")
End If
utf8output = True
Continue For
Case "utf8output-"
If value IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_SwitchNeedsBool, "utf8output")
End If
utf8output = False
Continue For
Case "noconfig"
Continue For
Case "bugreport"
Continue For
Case "errorreport"
Continue For
Case "novbruntimeref"
Continue For
Case "m", "main"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<class>")
Continue For
End If
mainTypeName = value
Continue For
Case "subsystemversion"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<version>")
Continue For
End If
Dim version As SubsystemVersion = Nothing
If SubsystemVersion.TryParse(value, version) Then
ssVersion = version
Else
AddDiagnostic(diagnostics, ERRID.ERR_InvalidSubsystemVersion, value)
End If
Continue For
Case "touchedfiles"
Dim unquoted = RemoveQuotesAndSlashes(value)
If (String.IsNullOrEmpty(unquoted)) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<touchedfiles>")
Continue For
Else
touchedFilesPath = unquoted
End If
Continue For
Case "fullpaths", "errorendlocation"
UnimplementedSwitch(diagnostics, name)
Continue For
Case "pathmap"
Dim unquoted = RemoveQuotesAndSlashes(value)
If unquoted = Nothing Then
Exit Select
End If
pathMap = pathMap.Concat(ParsePathMap(unquoted, diagnostics))
Continue For
Case "reportanalyzer"
reportAnalyzer = True
Continue For
Case "nostdlib"
If value IsNot Nothing Then
Exit Select
End If
noStdLib = True
Continue For
Case "vbruntime"
If value Is Nothing Then
GoTo lVbRuntimePlus
End If
vbRuntimePath = RemoveQuotesAndSlashes(value)
includeVbRuntimeReference = True
embedVbCoreRuntime = False
Continue For
Case "vbruntime+"
If value IsNot Nothing Then
Exit Select
End If
lVbRuntimePlus:
vbRuntimePath = Nothing
includeVbRuntimeReference = True
embedVbCoreRuntime = False
Continue For
Case "vbruntime-"
If value IsNot Nothing Then
Exit Select
End If
vbRuntimePath = Nothing
includeVbRuntimeReference = False
embedVbCoreRuntime = False
Continue For
Case "vbruntime*"
If value IsNot Nothing Then
Exit Select
End If
vbRuntimePath = Nothing
includeVbRuntimeReference = False
embedVbCoreRuntime = True
Continue For
Case "platform"
value = RemoveQuotesAndSlashes(value)
If value IsNot Nothing Then
platform = ParsePlatform(name, value, diagnostics)
Else
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "platform", ":<string>")
End If
Continue For
Case "filealign"
fileAlignment = ParseFileAlignment(name, RemoveQuotesAndSlashes(value), diagnostics)
Continue For
Case "baseaddress"
baseAddress = ParseBaseAddress(name, RemoveQuotesAndSlashes(value), diagnostics)
Continue For
Case "ruleset"
Continue For
Case "features"
If value Is Nothing Then
features.Clear()
Else
features.Add(RemoveQuotesAndSlashes(value))
End If
Continue For
Case "additionalfile"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, name, ":<file_list>")
Continue For
End If
additionalFiles.AddRange(ParseSeparatedFileArgument(value, baseDirectory, diagnostics))
Continue For
Case "embed"
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrEmpty(value) Then
embedAllSourceFiles = True
Continue For
End If
embeddedFiles.AddRange(ParseSeparatedFileArgument(value, baseDirectory, diagnostics))
Continue For
End Select
End If
AddDiagnostic(diagnostics, ERRID.WRN_BadSwitch, arg)
Next
Dim specificDiagnosticOptions = New Dictionary(Of String, ReportDiagnostic)(specificDiagnosticOptionsFromRuleSet, CaseInsensitiveComparison.Comparer)
For Each item In specificDiagnosticOptionsFromGeneralArguments
specificDiagnosticOptions(item.Key) = item.Value
Next
For Each item In specificDiagnosticOptionsFromSpecificArguments
specificDiagnosticOptions(item.Key) = item.Value
Next
For Each item In specificDiagnosticOptionsFromNoWarnArguments
specificDiagnosticOptions(item.Key) = item.Value
Next
If refOnly AndAlso outputRefFileName IsNot Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_NoRefOutWhenRefOnly)
End If
If outputKind = OutputKind.NetModule AndAlso (refOnly OrElse outputRefFileName IsNot Nothing) Then
AddDiagnostic(diagnostics, ERRID.ERR_NoNetModuleOutputWhenRefOutOrRefOnly)
End If
If Not IsScriptCommandLineParser AndAlso Not hasSourceFiles AndAlso managedResources.IsEmpty() Then
If flattenedArgs.Any Then
AddDiagnostic(diagnostics, ERRID.ERR_NoSources)
Else
displayHelp = True
End If
End If
If sdkDirectory IsNot Nothing AndAlso sdkPaths.Count = 0 Then
sdkPaths.Add(sdkDirectory)
End If
Dim defaultCoreLibraryReference As CommandLineReference? = LoadCoreLibraryReference(sdkPaths, baseDirectory)
If Not noStdLib Then
Dim systemDllPath As String = FindFileInSdkPath(sdkPaths, "System.dll", baseDirectory)
If systemDllPath Is Nothing Then
AddDiagnostic(diagnostics, ERRID.WRN_CannotFindStandardLibrary1, "System.dll")
Else
metadataReferences.Add(
New CommandLineReference(systemDllPath, New MetadataReferenceProperties(MetadataImageKind.Assembly)))
End If
End If
If includeVbRuntimeReference Then
If vbRuntimePath Is Nothing Then
Dim msVbDllPath As String = FindFileInSdkPath(sdkPaths, "Microsoft.VisualBasic.dll", baseDirectory)
If msVbDllPath Is Nothing Then
AddDiagnostic(diagnostics, ERRID.ERR_LibNotFound, "Microsoft.VisualBasic.dll")
Else
metadataReferences.Add(
New CommandLineReference(msVbDllPath, New MetadataReferenceProperties(MetadataImageKind.Assembly)))
End If
Else
metadataReferences.Add(New CommandLineReference(vbRuntimePath, New MetadataReferenceProperties(MetadataImageKind.Assembly)))
End If
End If
If Not String.IsNullOrWhiteSpace(additionalReferenceDirectories) Then
libPaths.AddRange(ParseSeparatedPaths(additionalReferenceDirectories))
End If
Dim searchPaths As ImmutableArray(Of String) = BuildSearchPaths(baseDirectory, sdkPaths, responsePaths, libPaths)
If publicSign AndAlso Not String.IsNullOrWhiteSpace(keyFileSetting) Then
keyFileSetting = ParseGenericPathToFile(keyFileSetting, diagnostics, baseDirectory)
End If
ValidateWin32Settings(noWin32Manifest, win32ResourceFile, win32IconFile, win32ManifestFile, outputKind, diagnostics)
If sourceLink IsNot Nothing And Not emitPdb Then
AddDiagnostic(diagnostics, ERRID.ERR_SourceLinkRequiresPdb)
End If
If embedAllSourceFiles Then
embeddedFiles.AddRange(sourceFiles)
End If
If embeddedFiles.Count > 0 And Not emitPdb Then
AddDiagnostic(diagnostics, ERRID.ERR_CannotEmbedWithoutPdb)
End If
Debug.Assert(rootNamespace IsNot Nothing)
If Not String.Empty.Equals(rootNamespace) Then
rootNamespace = rootNamespace.Unquote()
If String.IsNullOrWhiteSpace(rootNamespace) OrElse Not OptionsValidator.IsValidNamespaceName(rootNamespace) Then
AddDiagnostic(diagnostics, ERRID.ERR_BadNamespaceName1, rootNamespace)
rootNamespace = ""
End If
End If
keyFileSearchPaths.Add(baseDirectory)
If baseDirectory <> outputDirectory Then
keyFileSearchPaths.Add(outputDirectory)
End If
Dim parsedFeatures = ParseFeatures(features)
Dim compilationName As String = Nothing
GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, moduleAssemblyName, outputFileName, moduleName, compilationName)
If Not IsScriptCommandLineParser AndAlso
Not hasSourceFiles AndAlso
Not managedResources.IsEmpty() AndAlso
outputFileName = Nothing AndAlso
Not flattenedArgs.IsEmpty() Then
AddDiagnostic(diagnostics, ERRID.ERR_NoSourcesOut)
End If
Dim parseOptions = New VisualBasicParseOptions(
languageVersion:=languageVersion,
documentationMode:=If(parseDocumentationComments, DocumentationMode.Diagnose, DocumentationMode.None),
kind:=If(IsScriptCommandLineParser, SourceCodeKind.Script, SourceCodeKind.Regular),
preprocessorSymbols:=AddPredefinedPreprocessorSymbols(outputKind, defines.AsImmutableOrEmpty()),
features:=parsedFeatures)
Dim reportSuppressedDiagnostics = errorLogPath IsNot Nothing
Dim options = New VisualBasicCompilationOptions(
outputKind:=outputKind,
moduleName:=moduleName,
mainTypeName:=mainTypeName,
scriptClassName:=WellKnownMemberNames.DefaultScriptClassName,
globalImports:=globalImports,
rootNamespace:=rootNamespace,
optionStrict:=optionStrict,
optionInfer:=optionInfer,
optionExplicit:=optionExplicit,
optionCompareText:=optionCompareText,
embedVbCoreRuntime:=embedVbCoreRuntime,
checkOverflow:=checkOverflow,
concurrentBuild:=concurrentBuild,
deterministic:=deterministic,
cryptoKeyContainer:=keyContainerSetting,
cryptoKeyFile:=keyFileSetting,
delaySign:=delaySignSetting,
publicSign:=publicSign,
platform:=platform,
generalDiagnosticOption:=generalDiagnosticOption,
specificDiagnosticOptions:=specificDiagnosticOptions,
optimizationLevel:=If(optimize, OptimizationLevel.Release, OptimizationLevel.Debug),
parseOptions:=parseOptions,
reportSuppressedDiagnostics:=reportSuppressedDiagnostics)
Dim emitOptions = New EmitOptions(
metadataOnly:=refOnly,
includePrivateMembers:=Not refOnly AndAlso outputRefFileName Is Nothing,
debugInformationFormat:=debugInformationFormat,
pdbFilePath:=Nothing,
outputNameOverride:=Nothing,
fileAlignment:=fileAlignment,
baseAddress:=baseAddress,
highEntropyVirtualAddressSpace:=highEntropyVA,
subsystemVersion:=ssVersion,
runtimeMetadataVersion:=Nothing,
instrumentationKinds:=instrumentationKinds.ToImmutableAndFree(),
pdbChecksumAlgorithm:=HashAlgorithmName.SHA256)
diagnostics.AddRange(options.Errors)
If documentationPath Is GenerateFileNameForDocComment Then
documentationPath = PathUtilities.CombineAbsoluteAndRelativePaths(outputDirectory, PathUtilities.RemoveExtension(outputFileName))
documentationPath = documentationPath + ".xml"
End If
interactiveMode = interactiveMode Or (IsScriptCommandLineParser AndAlso sourceFiles.Count = 0)
Return New VisualBasicCommandLineArguments With
{
.IsScriptRunner = IsScriptCommandLineParser,
.InteractiveMode = interactiveMode,
.BaseDirectory = baseDirectory,
.Errors = diagnostics.AsImmutable(),
.Utf8Output = utf8output,
.CompilationName = compilationName,
.OutputFileName = outputFileName,
.OutputRefFilePath = outputRefFileName,
.OutputDirectory = outputDirectory,
.DocumentationPath = documentationPath,
.ErrorLogPath = errorLogPath,
.SourceFiles = sourceFiles.AsImmutable(),
.PathMap = pathMap,
.Encoding = codepage,
.ChecksumAlgorithm = checksumAlgorithm,
.MetadataReferences = metadataReferences.AsImmutable(),
.AnalyzerReferences = analyzers.AsImmutable(),
.AdditionalFiles = additionalFiles.AsImmutable(),
.ReferencePaths = searchPaths,
.SourcePaths = sourcePaths.AsImmutable(),
.KeyFileSearchPaths = keyFileSearchPaths.AsImmutable(),
.Win32ResourceFile = win32ResourceFile,
.Win32Icon = win32IconFile,
.Win32Manifest = win32ManifestFile,
.NoWin32Manifest = noWin32Manifest,
.DisplayLogo = displayLogo,
.DisplayHelp = displayHelp,
.DisplayVersion = displayVersion,
.DisplayLangVersions = displayLangVersions,
.ManifestResources = managedResources.AsImmutable(),
.CompilationOptions = options,
.ParseOptions = parseOptions,
.EmitOptions = emitOptions,
.ScriptArguments = scriptArgs.AsImmutableOrEmpty(),
.TouchedFilesPath = touchedFilesPath,
.OutputLevel = outputLevel,
.EmitPdb = emitPdb AndAlso Not refOnly,
.SourceLink = sourceLink,
.RuleSetPath = ruleSetPath,
.DefaultCoreLibraryReference = defaultCoreLibraryReference,
.PreferredUILang = preferredUILang,
.ReportAnalyzer = reportAnalyzer,
.EmbeddedFiles = embeddedFiles.AsImmutable()
}
End Function