diff --git a/Src/Compilers/CSharp/Test/CommandLine/CSharpCommandLineTest.csproj b/Src/Compilers/CSharp/Test/CommandLine/CSharpCommandLineTest.csproj
index 5406447987fc1e987906c6b73de2c56c5d453001..b0fd5b7bb5ca4339ed4f7cc0ae045a3e18ca0788 100644
--- a/Src/Compilers/CSharp/Test/CommandLine/CSharpCommandLineTest.csproj
+++ b/Src/Compilers/CSharp/Test/CommandLine/CSharpCommandLineTest.csproj
@@ -32,7 +32,6 @@
{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}
csc
- false
{76C6F005-C89D-4348-BB4A-391898DBEB52}
@@ -98,12 +97,27 @@
+
+ True
+ True
+ CommandLineTestResources.resx
+
-
+
+
+ csc.rsp
+
+
+
+
+ ResXFileCodeGenerator
+ CommandLineTestResources.Designer.cs
+
+
diff --git a/Src/Compilers/CSharp/Test/CommandLine/CommandLineTestResources.Designer.cs b/Src/Compilers/CSharp/Test/CommandLine/CommandLineTestResources.Designer.cs
new file mode 100644
index 0000000000000000000000000000000000000000..117412b32f6b84204f5a94db55689c8bba4923b9
--- /dev/null
+++ b/Src/Compilers/CSharp/Test/CommandLine/CommandLineTestResources.Designer.cs
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34014
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class CommandLineTestResources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal CommandLineTestResources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests.CommandLineTestResources", typeof(CommandLineTestResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Byte[].
+ ///
+ internal static byte[] csc_rsp {
+ get {
+ object obj = ResourceManager.GetObject("csc_rsp", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+ }
+}
diff --git a/Src/Compilers/CSharp/Test/CommandLine/CommandLineTestResources.resx b/Src/Compilers/CSharp/Test/CommandLine/CommandLineTestResources.resx
new file mode 100644
index 0000000000000000000000000000000000000000..5548f2e7ba2beb9dbd66bfd952abace0fd347741
--- /dev/null
+++ b/Src/Compilers/CSharp/Test/CommandLine/CommandLineTestResources.resx
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\..\csc\csc.rsp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/Src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
index 43401c62245956774d31597bcb4972e9b523aa93..58b5c397d96d862da1575068b02f7b2071ec2a76 100644
--- a/Src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+++ b/Src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel;
using System.Globalization;
using System.IO;
@@ -16,18 +17,18 @@
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
+using Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
using ProprietaryTestResources = Microsoft.CodeAnalysis.Test.Resources.Proprietary;
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers;
-using Microsoft.Win32;
-namespace Microsoft.CodeAnalysis.CSharp.UnitTests
+namespace Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests
{
public class CommandLineTests : CSharpTestBase
{
+ private static readonly string CSharpCompilerExecutable = typeof(Microsoft.CodeAnalysis.CSharp.CommandLine.Csc).Assembly.Location;
+
private readonly string baseDirectory = TempRoot.Root;
private class TestCommandLineParser : CSharpCommandLineParser
@@ -66,7 +67,14 @@ internal override TextReader CreateTextFileReader(string fullPath)
return new StringReader(responseFiles[fullPath]);
}
}
-
+
+ [Fact]
+ [WorkItem(946954)]
+ public void CompilerBinariesAreAnyCPU()
+ {
+ Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(CSharpCompilerExecutable).ProcessorArchitecture);
+ }
+
[Fact]
public void ResponseFiles1()
{
@@ -4681,7 +4689,7 @@ public void NoStdLib()
private string GetDefaultResponseFilePath()
{
- return Path.Combine(Path.GetDirectoryName(CSharpCompilerExecutable), Path.GetFileNameWithoutExtension(CSharpCompilerExecutable) + ".rsp");
+ return Temp.CreateFile().WriteAllBytes(CommandLineTestResources.csc_rsp).Path;
}
[Fact, WorkItem(530359, "DevDiv")]
@@ -5106,7 +5114,7 @@ public static void Main()
public void DefaultResponseFile()
{
MockCSharpCompiler csc = new MockCSharpCompiler(GetDefaultResponseFilePath(), baseDirectory, new string[0]);
- Assert.Equal(csc.Arguments.MetadataReferences.Select(r => r.Reference), new string[]
+ AssertEx.Equal(csc.Arguments.MetadataReferences.Select(r => r.Reference), new string[]
{
typeof(object).Assembly.Location,
"Accessibility.dll",
diff --git a/Src/Compilers/CSharp/csc/Csc.cs b/Src/Compilers/CSharp/csc/Csc.cs
index ba1759274c1753f6942dfe834da66f351f204d1d..55ee7d15b8128f7a69e2c0d0e372f29e6239e5e6 100644
--- a/Src/Compilers/CSharp/csc/Csc.cs
+++ b/Src/Compilers/CSharp/csc/Csc.cs
@@ -1,17 +1,12 @@
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Reflection;
using System.Text;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.Shell.Interop;
-namespace RoslynCsc
+namespace Microsoft.CodeAnalysis.CSharp.CommandLine
{
internal sealed class Csc : CSharpCompiler
{
diff --git a/Src/Compilers/CSharp/csc/Program.cs b/Src/Compilers/CSharp/csc/Program.cs
index d257bcf2e3d907610f3b811188b8c6edd1c33411..a8ce90bbe27f418ee273a49089de74f418189f65 100644
--- a/Src/Compilers/CSharp/csc/Program.cs
+++ b/Src/Compilers/CSharp/csc/Program.cs
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
-
-namespace RoslynCsc
+namespace Microsoft.CodeAnalysis.CSharp.CommandLine
{
class Program
{
diff --git a/Src/Compilers/CSharp/csc/csc.csproj b/Src/Compilers/CSharp/csc/csc.csproj
index 41219c8149c47d74c4394d4445961194ebbf3645..ff05900700719ec78af0a1eaef677847d45bf362 100644
--- a/Src/Compilers/CSharp/csc/csc.csproj
+++ b/Src/Compilers/CSharp/csc/csc.csproj
@@ -10,11 +10,11 @@
AnyCPU
{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}
Exe
- RoslynCsc
+ Microsoft.CodeAnalysis.CSharp.CommandLine
csc
false
true
- RoslynCsc.Program
+ Microsoft.CodeAnalysis.CSharp.CommandLine.Program
false
..\..\..\
true
diff --git a/Src/Compilers/Core/Desktop/CodeAnalysis.Desktop.csproj b/Src/Compilers/Core/Desktop/CodeAnalysis.Desktop.csproj
index 25ce7886aa580674eb7e6be022315b146c4deca0..bb5b5f5e9eb183c8c27dbf346587437c253c6292 100644
--- a/Src/Compilers/Core/Desktop/CodeAnalysis.Desktop.csproj
+++ b/Src/Compilers/Core/Desktop/CodeAnalysis.Desktop.csproj
@@ -118,6 +118,7 @@
+
diff --git a/Src/Compilers/Core/VBCSCompilerTests/CompilerServerTests.cs b/Src/Compilers/Core/VBCSCompilerTests/CompilerServerTests.cs
index d4fc511674a010c8fbde0a1c9b02898f38bea8c0..5274b9bba5b65ee81176b4d0c4e12ab8eb5ded43 100644
--- a/Src/Compilers/Core/VBCSCompilerTests/CompilerServerTests.cs
+++ b/Src/Compilers/Core/VBCSCompilerTests/CompilerServerTests.cs
@@ -35,7 +35,178 @@ public override void Dispose()
base.Dispose();
}
-
+
+ private static string csharpCompilerClientExecutable;
+ protected static string CSharpCompilerClientExecutable
+ {
+ get
+ {
+ if (csharpCompilerClientExecutable == null)
+ {
+ var foundCompiler = FindBinary("csc2.exe");
+
+ if (string.IsNullOrEmpty(foundCompiler))
+ {
+ foundCompiler = "csc2.exe";
+ }
+ csharpCompilerClientExecutable = foundCompiler;
+ }
+ return csharpCompilerClientExecutable;
+ }
+ }
+
+ private static string basicCompilerClientExecutable;
+ protected static string BasicCompilerClientExecutable
+ {
+ get
+ {
+ if (basicCompilerClientExecutable == null)
+ {
+ var foundCompiler = FindBinary("vbc2.exe");
+
+ if (string.IsNullOrEmpty(foundCompiler))
+ {
+ foundCompiler = "vbc2.exe";
+ }
+ basicCompilerClientExecutable = foundCompiler;
+ }
+ return basicCompilerClientExecutable;
+ }
+ }
+
+ private static string compilerServerExecutable;
+ protected static string CompilerServerExecutable
+ {
+ get
+ {
+ if (compilerServerExecutable == null)
+ {
+ var foundCompiler = FindBinary("vbcscompiler.exe");
+
+ if (string.IsNullOrEmpty(foundCompiler))
+ {
+ foundCompiler = "vbcscompiler.exe";
+ }
+ compilerServerExecutable = foundCompiler;
+ }
+ return compilerServerExecutable;
+ }
+ }
+
+ private static string msbuildExecutable;
+ protected static string MSBuildExecutable
+ {
+ get
+ {
+ if (msbuildExecutable == null)
+ {
+ msbuildExecutable = Path.Combine(MSBuildDirectory, "MSBuild.exe");
+ }
+ return msbuildExecutable;
+ }
+ }
+
+ private static string msbuildDirectory;
+ protected static string MSBuildDirectory
+ {
+ get
+ {
+ if (msbuildDirectory == null)
+ {
+ var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0", false);
+
+ if (key != null)
+ {
+ var toolsPath = key.GetValue("MSBuildToolsPath");
+ if (toolsPath != null)
+ {
+ msbuildDirectory = toolsPath.ToString();
+ }
+ }
+ }
+ return msbuildDirectory;
+ }
+ }
+
+ ///
+ /// Given a binary to look for, determines which is the first to actually exist on the filesystem.
+ ///
+ /// The binary file name that may exist in the system at , , or .
+ /// The binary which had the highest priority and was found.
+ protected static string FindBinary(string binaryFile)
+ {
+ IEnumerable searchPaths = new[] {
+ Path.Combine(BinariesDirectory, binaryFile),
+ Path.Combine(ApplicationDirectory, binaryFile),
+ Path.Combine(WorkingDirectory, binaryFile),
+ Path.Combine(MSBuildDirectory, binaryFile)
+ };
+
+ return FindBinary(searchPaths);
+ }
+
+ ///
+ /// Given a list of binaries to look for, determines which is the first to actually appear on the Filesystem.
+ ///
+ /// A list of binary file names that may exist in the system.
+ /// The binary which had the highest priority and was found.
+ private static string FindBinary(IEnumerable binaryPriority)
+ {
+ string highestPriorityCompiler = string.Empty;
+
+ foreach (string path in binaryPriority)
+ {
+ try
+ {
+ if (File.Exists(path) && (FileVersionInfo.GetVersionInfo(path).FileVersion == FileVersionInfo.GetVersionInfo(typeof(TestBase).Assembly.Location).FileVersion))
+ {
+ highestPriorityCompiler = path;
+ }
+ break;
+ }
+ catch
+ {
+ continue;
+ }
+ }
+
+ return highestPriorityCompiler;
+ }
+
+ private static string applicationDirectory;
+ protected static string ApplicationDirectory
+ {
+ get
+ {
+ if (applicationDirectory == null)
+ {
+ applicationDirectory = Path.GetDirectoryName(typeof(CommonCompiler).Assembly.Location);
+ }
+ return applicationDirectory;
+ }
+ }
+
+ private static string binariesDirectory;
+ protected static string BinariesDirectory
+ {
+ get
+ {
+ if (binariesDirectory == null)
+ {
+ binariesDirectory = Path.GetDirectoryName(typeof(TestBase).Assembly.Location);
+ }
+ return binariesDirectory;
+ }
+ }
+
+ protected static string WorkingDirectory
+ {
+ get
+ {
+ return Environment.CurrentDirectory;
+ }
+ }
+
private Dictionary AddForLoggingEnvironmentVars(Dictionary vars)
{
var dict = vars == null ? new Dictionary() : vars;
@@ -163,11 +334,7 @@ static void Main()
[WorkItem(946954)]
public void CompilerBinariesAreAnyCPU()
{
- foreach (var dllPath in new[] { CSharpCompilerExecutable, BasicCompilerExecutable, CompilerServerExecutable })
- {
- var assemblyName = AssemblyName.GetAssemblyName(dllPath);
- Assert.Equal(ProcessorArchitecture.MSIL, assemblyName.ProcessorArchitecture);
- }
+ Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(CompilerServerExecutable).ProcessorArchitecture);
}
///
diff --git a/Src/Compilers/Core/VBCSCompilerTests/VBCSCompilerTests.csproj b/Src/Compilers/Core/VBCSCompilerTests/VBCSCompilerTests.csproj
index 9a2e33a6227b339c2545085723c6427674eee2ee..78779e6bcaf9047afa9df0a4eaa1373620609669 100644
--- a/Src/Compilers/Core/VBCSCompilerTests/VBCSCompilerTests.csproj
+++ b/Src/Compilers/Core/VBCSCompilerTests/VBCSCompilerTests.csproj
@@ -20,6 +20,10 @@
..\..\..\..\Binaries\$(Configuration)\
+
+ {dfa21ca1-7f96-47ee-940c-069858e81727}
+ CodeAnalysis.Desktop
+
{9508F118-F62E-4C16-A6F4-7C3B56E166AD}
VBCSCompiler
diff --git a/Src/Compilers/VisualBasic/Test/CommandLine/BasicCommandLineTest.vbproj b/Src/Compilers/VisualBasic/Test/CommandLine/BasicCommandLineTest.vbproj
index 2577bc55b43b5fd040ba2a430aa91c59af8e9831..0d0d535ceeb54793dc0856794f74acb2e9406482 100644
--- a/Src/Compilers/VisualBasic/Test/CommandLine/BasicCommandLineTest.vbproj
+++ b/Src/Compilers/VisualBasic/Test/CommandLine/BasicCommandLineTest.vbproj
@@ -11,7 +11,7 @@
x86
{E3B32027-3362-41DF-9172-4D3B623F42A5}
Library
- Microsoft.CodeAnalysis.VisualBasic.UnitTests
+
Roslyn.Compilers.VisualBasic.CommandLine.UnitTests
false
x86
@@ -139,6 +139,11 @@
Settings.settings
True
+
+ True
+ True
+ CommandLineTestResources.resx
+
@@ -148,8 +153,15 @@
My.Resources
Designer
+
+ ResXFileCodeGenerator
+ CommandLineTestResources.Designer.vb
+
+
+ vbc.rsp
+
MyApplicationCodeGenerator
Application.Designer.vb
diff --git a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineArgumentsTests.vb b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineArgumentsTests.vb
index 5a7975cdf19fa65586dfe5941b78f8f281ad78d5..386d114d6ed65c3f142847a94e4e7a912edbdcb5 100644
--- a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineArgumentsTests.vb
+++ b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineArgumentsTests.vb
@@ -1,16 +1,11 @@
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis
-Imports Microsoft.CodeAnalysis.Test.Utilities
-Imports Microsoft.CodeAnalysis.Text
-Imports Microsoft.CodeAnalysis.VisualBasic
-Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
-Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
+Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
Imports Roslyn.Test.Utilities
Imports Xunit
-Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
+Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
Public Class CommandLineArgumentsTests
Inherits BasicTestBase
diff --git a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineBreakingChanges.vb b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineBreakingChanges.vb
index 85ad5c3d7ccb5e0b17f10029bacd0417c6589701..6b81d5e7a2ffd7068ea6e2dfad995f9d5890a6e1 100644
--- a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineBreakingChanges.vb
+++ b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineBreakingChanges.vb
@@ -1,53 +1,49 @@
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-Imports System
-Imports System.Collections.Generic
-Imports System.ComponentModel
-Imports System.Diagnostics
-Imports System.IO
-Imports System.Linq
-Imports System.Runtime.InteropServices
-Imports System.Text.RegularExpressions
-Imports Microsoft.CodeAnalysis.Test.Utilities
+Imports System.Reflection
+Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers
Imports Roslyn.Test.Utilities
-Imports Roslyn.Utilities
Imports Xunit
-Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers
-Partial Public Class CommandLineTests
-
- Public Sub WarnAsErrorPrecedence1()
- Dim src As String = Temp.CreateFile().WriteAllText(
+Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
+
+ Partial Public Class CommandLineTests
+
+
+ Public Sub WarnAsErrorPrecedence1()
+ Dim src As String = Temp.CreateFile().WriteAllText("
+Imports System
+
Module Module1
Sub Main()
Dim x
Console.WriteLine(x.ToString)
End Sub
End Module
-.Value).Path
- Dim tempBinary = Temp.CreateFile()
- Dim tempLog = Temp.CreateFile()
- Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /warnaserror+ /warnaserror- /out:" & tempBinary.Path & " " & src & " > " & tempLog.Path, expectedRetCode:=0)
- Assert.Equal("", output.Trim())
-
- 'See bug 15593. This is not strictly a 'breaking' change.
- 'In Dev11, /warnaserror+ trumps /warnaserror- in the above case and warnings are reported as errors.
- 'In Roslyn, /warnaserror- (i.e. last one) wins.
- Assert.Equal(
-SRC.VB(5) : warning BC42104: Variable 'x' is used before it has been assigned a value. A null reference exception could result at runtime.
+").Path
+ Dim tempBinary = Temp.CreateFile()
+ Dim tempLog = Temp.CreateFile()
+ Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /warnaserror+ /warnaserror- /out:" & tempBinary.Path & " " & src & " > " & tempLog.Path, expectedRetCode:=0)
+ Assert.Equal("", output.Trim())
+
+ 'See bug 15593. This is not strictly a 'breaking' change.
+ 'In Dev11, /warnaserror+ trumps /warnaserror- in the above case and warnings are reported as errors.
+ 'In Roslyn, /warnaserror- (i.e. last one) wins.
+ Assert.Equal(
+SRC.VB(7) : warning BC42104: Variable 'x' is used before it has been assigned a value. A null reference exception could result at runtime.
Console.WriteLine(x.ToString)
~
.Value.Trim().Replace(vbLf, vbCrLf), tempLog.ReadAllText().Trim().Replace(src, "SRC.VB"))
- CleanupAllGeneratedFiles(src)
- CleanupAllGeneratedFiles(tempBinary.Path)
- CleanupAllGeneratedFiles(tempLog.Path)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ CleanupAllGeneratedFiles(tempBinary.Path)
+ CleanupAllGeneratedFiles(tempLog.Path)
+ End Sub
-
- Public Sub WarnAsErrorPrecedence2()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub WarnAsErrorPrecedence2()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Module M1
Sub Main
End Sub
@@ -57,15 +53,15 @@ Module M1
End Sub
End Module
.Value).Path
- Dim tempOut = Temp.CreateFile()
- Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /nowarn:41008 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1)
- Assert.Equal("", output.Trim())
+ Dim tempOut = Temp.CreateFile()
+ Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /nowarn:41008 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1)
+ Assert.Equal("", output.Trim())
- 'See bug 16673.
- 'In Dev11, /warnaserror+ does not come into effect strangely and the code only reports warnings.
- 'In Roslyn, /warnaserror+ does come into effect and the code reports the warnings as errors.
+ 'See bug 16673.
+ 'In Dev11, /warnaserror+ does not come into effect strangely and the code only reports warnings.
+ 'In Roslyn, /warnaserror+ does come into effect and the code reports the warnings as errors.
- Assert.Equal(
+ Assert.Equal(
SRC.VB(6) : error BC42017: Late bound resolution; runtime errors could occur.
if (a.Something <> 2)
@@ -83,11 +79,11 @@ SRC.VB(6) : error BC42016: Implicit conversion from 'Object' to 'Boolean'.
if (a.Something <> 2)
~~~~~~~~~~~~~~~~~~
.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB"))
- End Sub
+ End Sub
-
- Public Sub WarnAsErrorPrecedence3()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub WarnAsErrorPrecedence3()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Module M1
Sub Main
End Sub
@@ -97,15 +93,15 @@ Module M1
End Sub
End Module
.Value).Path
- Dim tempOut = Temp.CreateFile()
- Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /warnaserror-:42025 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1)
- Assert.Equal("", output.Trim())
+ Dim tempOut = Temp.CreateFile()
+ Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /warnaserror-:42025 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1)
+ Assert.Equal("", output.Trim())
- 'See bug 16673.
- 'In Dev11, /warnaserror+ does not come into effect strangely and the code only reports warnings.
- 'In Roslyn, /warnaserror+ does come into effect and the code reports the warnings as errors.
+ 'See bug 16673.
+ 'In Dev11, /warnaserror+ does not come into effect strangely and the code only reports warnings.
+ 'In Roslyn, /warnaserror+ does come into effect and the code reports the warnings as errors.
- Assert.Equal(
+ Assert.Equal(
SRC.VB(6) : error BC42017: Late bound resolution; runtime errors could occur.
if (a.Something <> 2)
@@ -124,7 +120,8 @@ SRC.VB(6) : error BC42016: Implicit conversion from 'Object' to 'Boolean'.
~~~~~~~~~~~~~~~~~~
.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB"))
- CleanupAllGeneratedFiles(src)
- CleanupAllGeneratedFiles(tempOut.Path)
- End Sub
-End Class
+ CleanupAllGeneratedFiles(src)
+ CleanupAllGeneratedFiles(tempOut.Path)
+ End Sub
+ End Class
+End Namespace
diff --git a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTestResources.Designer.vb b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTestResources.Designer.vb
new file mode 100644
index 0000000000000000000000000000000000000000..75f9f5a3da92af0d3e23de6303874956be89fb4a
--- /dev/null
+++ b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTestResources.Designer.vb
@@ -0,0 +1,75 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.34014
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+Imports System
+
+
+'This class was auto-generated by the StronglyTypedResourceBuilder
+'class via a tool like ResGen or Visual Studio.
+'To add or remove a member, edit your .ResX file then rerun ResGen
+'with the /str option, or rebuild your VS project.
+'''
+''' A strongly-typed resource class, for looking up localized strings, etc.
+'''
+ _
+Friend Class CommandLineTestResources
+
+ Private Shared resourceMan As Global.System.Resources.ResourceManager
+
+ Private Shared resourceCulture As Global.System.Globalization.CultureInfo
+
+ _
+ Friend Sub New()
+ MyBase.New
+ End Sub
+
+ '''
+ ''' Returns the cached ResourceManager instance used by this class.
+ '''
+ _
+ Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
+ Get
+ If Object.ReferenceEquals(resourceMan, Nothing) Then
+ Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CommandLineTestResources", GetType(CommandLineTestResources).Assembly)
+ resourceMan = temp
+ End If
+ Return resourceMan
+ End Get
+ End Property
+
+ '''
+ ''' Overrides the current thread's CurrentUICulture property for all
+ ''' resource lookups using this strongly typed resource class.
+ '''
+ _
+ Friend Shared Property Culture() As Global.System.Globalization.CultureInfo
+ Get
+ Return resourceCulture
+ End Get
+ Set
+ resourceCulture = value
+ End Set
+ End Property
+
+ '''
+ ''' Looks up a localized resource of type System.Byte[].
+ '''
+ Friend Shared ReadOnly Property vbc_rsp() As Byte()
+ Get
+ Dim obj As Object = ResourceManager.GetObject("vbc_rsp", resourceCulture)
+ Return CType(obj,Byte())
+ End Get
+ End Property
+End Class
diff --git a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTestResources.resx b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTestResources.resx
new file mode 100644
index 0000000000000000000000000000000000000000..a6bf0ec678094b3d3a8e8a9de090567e8cb2fdc3
--- /dev/null
+++ b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTestResources.resx
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\..\vbc\vbc.rsp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
index dabb4b6776481f1352cc6bd16d32d509d3ebdfbf..62d29a40ba031de15f2459990b4123b5c94c86a6 100644
--- a/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
+++ b/Src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
@@ -17,47 +17,55 @@ Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis
Imports System.Threading
Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers
-Imports Microsoft.Win32
+Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
-Partial Public Class CommandLineTests
- Inherits BasicTestBase
+Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
+ Partial Public Class CommandLineTests
+ Inherits BasicTestBase
- Private ReadOnly _baseDirectory As String = TempRoot.Root
+ Private ReadOnly _baseDirectory As String = TempRoot.Root
+ Private Shared ReadOnly BasicCompilerExecutable As String = GetType(Vbc).Assembly.Location
-
- Public Sub NowarnWarnaserrorTest()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+
+ Sub CompilerBinariesAreAnyCPU()
+ Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(BasicCompilerExecutable).ProcessorArchitecture)
+ End Sub
+
+
+ Public Sub NowarnWarnaserrorTest()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Class C
End Class
.Value).Path
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/nowarn", "/warnaserror-", src})
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/nowarn", "/warnaserror-", src})
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/nowarn", "/warnaserror", src})
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Error)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/nowarn", "/warnaserror", src})
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Error)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/nowarn", "/warnaserror+", src})
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Error)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/nowarn", "/warnaserror+", src})
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Error)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/warnaserror-", "/nowarn", src})
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/warnaserror-", "/nowarn", src})
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/warnaserror", "/nowarn", src})
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/warnaserror", "/nowarn", src})
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/warnaserror+", "/nowarn", src})
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", "/warnaserror+", "/nowarn", src})
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Suppress)
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
-
- Public Sub CommandLineCompilationWithQuotedMainArgument()
- ' Arguments with quoted rootnamespace and maintype are unquoted when
- ' the arguments are read in by the command line compiler.
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+
+ Public Sub CommandLineCompilationWithQuotedMainArgument()
+ ' Arguments with quoted rootnamespace and maintype are unquoted when
+ ' the arguments are read in by the command line compiler.
+ Dim src As String = Temp.CreateFile().WriteAllText(
Module Module1
Sub Main()
@@ -65,88 +73,88 @@ Module Module1
End Module
.Value).Path
- Dim output As New StringWriter()
- Dim vbc As New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/target:exe", "/rootnamespace:""test""", "/main:""test.Module1""", src})
-
- Dim exitCode = vbc.Run(output, Nothing)
- Assert.Equal(0, exitCode)
- Assert.Equal("", output.ToString().Trim())
- End Sub
-
-
- Public Sub ParseQuotedMainTypeAndRootnamespace()
- 'These options are always unquoted when parsed in VisualBasicCommandLineParser.Parse.
-
- Dim args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:Test", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- Assert.Equal("Test", args.CompilationOptions.RootNamespace)
-
- args = VisualBasicCommandLineParser.Default.Parse({"/main:Test", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- Assert.Equal("Test", args.CompilationOptions.MainTypeName)
+ Dim output As New StringWriter()
+ Dim vbc As New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/target:exe", "/rootnamespace:""test""", "/main:""test.Module1""", src})
- args = VisualBasicCommandLineParser.Default.Parse({"/main:""Test""", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- Assert.Equal("Test", args.CompilationOptions.MainTypeName)
-
- args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""Test""", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- Assert.Equal("Test", args.CompilationOptions.RootNamespace)
-
- args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""test""", "/main:""test.Module1""", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- Assert.Equal("test.Module1", args.CompilationOptions.MainTypeName)
- Assert.Equal("test", args.CompilationOptions.RootNamespace)
-
- ' Use of Cyrillic namespace
- args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""решения""", "/main:""решения.Module1""", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- Assert.Equal("решения.Module1", args.CompilationOptions.MainTypeName)
- Assert.Equal("решения", args.CompilationOptions.RootNamespace)
-
- End Sub
-
-
-
- Public Sub EnsureLegacyWarningsAreMaintained()
- Dim src As String = Temp.CreateFile().WriteAllText(
+ Dim exitCode = vbc.Run(output, Nothing)
+ Assert.Equal(0, exitCode)
+ Assert.Equal("", output.ToString().Trim())
+ End Sub
+
+
+ Public Sub ParseQuotedMainTypeAndRootnamespace()
+ 'These options are always unquoted when parsed in VisualBasicCommandLineParser.Parse.
+
+ Dim args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:Test", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ Assert.Equal("Test", args.CompilationOptions.RootNamespace)
+
+ args = VisualBasicCommandLineParser.Default.Parse({"/main:Test", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ Assert.Equal("Test", args.CompilationOptions.MainTypeName)
+
+ args = VisualBasicCommandLineParser.Default.Parse({"/main:""Test""", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ Assert.Equal("Test", args.CompilationOptions.MainTypeName)
+
+ args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""Test""", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ Assert.Equal("Test", args.CompilationOptions.RootNamespace)
+
+ args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""test""", "/main:""test.Module1""", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ Assert.Equal("test.Module1", args.CompilationOptions.MainTypeName)
+ Assert.Equal("test", args.CompilationOptions.RootNamespace)
+
+ ' Use of Cyrillic namespace
+ args = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""решения""", "/main:""решения.Module1""", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ Assert.Equal("решения.Module1", args.CompilationOptions.MainTypeName)
+ Assert.Equal("решения", args.CompilationOptions.RootNamespace)
+
+ End Sub
+
+
+
+ Public Sub EnsureLegacyWarningsAreMaintained()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Public Class C
End Class
.Value).Path
- ' the warning numbers have been taken from the Dev11 sources (vb\include\errors.inc)
- ' the command line warnings (vb\language\commandlineerrors.inc) are not valid to pass them to /nowarn for vbc.exe
- Dim allDev11Warnings As Integer() = {40000, 40003, 40004, 40005, 40007, 40008, 40009, 40010, 40011, 40012, 40014, 40018, 40019, 40020, 40021,
- 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40038,
- 40039, 40040, 40041, 40042, 40043, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053, 40054, 40055,
- 40056, 40057, 40059, 41000, 41001, 41002, 41003, 41004, 41005, 41007, 41008, 41998, 41999, 42000, 42001,
- 42002, 42004, 42014, 42015, 42016, 42017, 42018, 42019, 42020, 42021, 42022, 42024, 42025, 42026, 42029,
- 42030, 42031, 42032, 42033, 42034, 42035, 42036, 42037, 42038, 42099, 42101, 42102, 42104, 42105, 42106,
- 42107, 42108, 42109, 42110, 42111, 42203, 42204, 42205, 42206, 42300, 42301, 42302, 42303, 42304, 42305,
- 42306, 42307, 42308, 42309, 42310, 42311, 42312, 42313, 42314, 42315, 42316, 42317, 42318, 42319, 42320,
- 42321, 42322, 42324, 42326, 42327, 42328, 42332, 42333, 42334, 42335, 42336, 42337, 42338, 42339, 42340,
- 42341, 42342, 42343, 42344, 42345, 42346, 42347, 42348, 42349, 42350, 42351, 42352, 42353, 42354, 42355}
-
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:" & String.Join(",", allDev11Warnings), src})
- Dim writer As New StringWriter()
- Dim result = cmd.Run(writer, Nothing)
-
- Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Default)
- Assert.Equal(0, writer.ToString.Length)
- AssertEx.SetEqual(cmd.Arguments.CompilationOptions.SpecificDiagnosticOptions.Keys, allDev11Warnings.AsEnumerable().Select(Function(err) MessageProvider.Instance.GetIdForErrorCode(err)))
-
- For Each reportWarningOption In cmd.Arguments.CompilationOptions.SpecificDiagnosticOptions.Values
- Assert.Equal(reportWarningOption, ReportDiagnostic.Suppress)
- Next
-
- ' the command line warnings (vb\language\commandlineerrors.inc)
- Dim allDev11CommandLineWarnings As Integer() = {2002, 2007, 2024, 2025, 2028, 2034}
-
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:" & String.Join(",", allDev11CommandLineWarnings), src})
- writer = New StringWriter()
- result = cmd.Run(writer, Nothing)
-
- Assert.Equal(
+ ' the warning numbers have been taken from the Dev11 sources (vb\include\errors.inc)
+ ' the command line warnings (vb\language\commandlineerrors.inc) are not valid to pass them to /nowarn for vbc.exe
+ Dim allDev11Warnings As Integer() = {40000, 40003, 40004, 40005, 40007, 40008, 40009, 40010, 40011, 40012, 40014, 40018, 40019, 40020, 40021,
+ 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40038,
+ 40039, 40040, 40041, 40042, 40043, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053, 40054, 40055,
+ 40056, 40057, 40059, 41000, 41001, 41002, 41003, 41004, 41005, 41007, 41008, 41998, 41999, 42000, 42001,
+ 42002, 42004, 42014, 42015, 42016, 42017, 42018, 42019, 42020, 42021, 42022, 42024, 42025, 42026, 42029,
+ 42030, 42031, 42032, 42033, 42034, 42035, 42036, 42037, 42038, 42099, 42101, 42102, 42104, 42105, 42106,
+ 42107, 42108, 42109, 42110, 42111, 42203, 42204, 42205, 42206, 42300, 42301, 42302, 42303, 42304, 42305,
+ 42306, 42307, 42308, 42309, 42310, 42311, 42312, 42313, 42314, 42315, 42316, 42317, 42318, 42319, 42320,
+ 42321, 42322, 42324, 42326, 42327, 42328, 42332, 42333, 42334, 42335, 42336, 42337, 42338, 42339, 42340,
+ 42341, 42342, 42343, 42344, 42345, 42346, 42347, 42348, 42349, 42350, 42351, 42352, 42353, 42354, 42355}
+
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:" & String.Join(",", allDev11Warnings), src})
+ Dim writer As New StringWriter()
+ Dim result = cmd.Run(writer, Nothing)
+
+ Assert.Equal(cmd.Arguments.CompilationOptions.GeneralDiagnosticOption, ReportDiagnostic.Default)
+ Assert.Equal(0, writer.ToString.Length)
+ AssertEx.SetEqual(cmd.Arguments.CompilationOptions.SpecificDiagnosticOptions.Keys, allDev11Warnings.AsEnumerable().Select(Function(err) MessageProvider.Instance.GetIdForErrorCode(err)))
+
+ For Each reportWarningOption In cmd.Arguments.CompilationOptions.SpecificDiagnosticOptions.Values
+ Assert.Equal(reportWarningOption, ReportDiagnostic.Suppress)
+ Next
+
+ ' the command line warnings (vb\language\commandlineerrors.inc)
+ Dim allDev11CommandLineWarnings As Integer() = {2002, 2007, 2024, 2025, 2028, 2034}
+
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:" & String.Join(",", allDev11CommandLineWarnings), src})
+ writer = New StringWriter()
+ result = cmd.Run(writer, Nothing)
+
+ Assert.Equal(
vbc : warning BC2026: warning number '2002' for the option 'nowarn' is either not configurable or not valid
vbc : warning BC2026: warning number '2007' for the option 'nowarn' is either not configurable or not valid
vbc : warning BC2026: warning number '2024' for the option 'nowarn' is either not configurable or not valid
@@ -155,182 +163,182 @@ vbc : warning BC2026: warning number '2028' for the option 'nowarn' is either no
vbc : warning BC2026: warning number '2034' for the option 'nowarn' is either not configurable or not valid
.Value.Trim.Replace(vbLf, vbCrLf), writer.ToString.Trim)
- ' if this tests fails, the warning number is most probably used
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:42325", src})
- writer = New StringWriter()
- result = cmd.Run(writer, Nothing)
+ ' if this tests fails, the warning number is most probably used
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:42325", src})
+ writer = New StringWriter()
+ result = cmd.Run(writer, Nothing)
- Assert.Equal(
+ Assert.Equal(
vbc : warning BC2026: warning number '42325' for the option 'nowarn' is either not configurable or not valid
.Value.Trim.Replace(vbLf, vbCrLf), writer.ToString.Trim)
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
-
- Public Sub Bug_722561()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+
+ Public Sub Bug_722561()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Public Class C
End Class
.Value).Path
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:-1", src})
- Dim writer As New StringWriter()
- Dim result = cmd.Run(writer, Nothing)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:-1", src})
+ Dim writer As New StringWriter()
+ Dim result = cmd.Run(writer, Nothing)
- Assert.Equal(
+ Assert.Equal(
vbc : warning BC2026: warning number '-1' for the option 'nowarn' is either not configurable or not valid
.Value.Trim.Replace(vbLf, vbCrLf), writer.ToString.Trim)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:-12345678901234567890", src})
- writer = New StringWriter()
- result = cmd.Run(writer, Nothing)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:-12345678901234567890", src})
+ writer = New StringWriter()
+ result = cmd.Run(writer, Nothing)
- Assert.Equal(
+ Assert.Equal(
vbc : error BC2014: the value '-12345678901234567890' is invalid for option 'nowarn'
.Value.Trim.Replace(vbLf, vbCrLf), writer.ToString.Trim)
- cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:-1234567890123456789", src})
- writer = New StringWriter()
- result = cmd.Run(writer, Nothing)
+ cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", "/nowarn:-1234567890123456789", src})
+ writer = New StringWriter()
+ result = cmd.Run(writer, Nothing)
- Assert.Equal(
+ Assert.Equal(
vbc : warning BC2026: warning number '-1234567890123456789' for the option 'nowarn' is either not configurable or not valid
.Value.Trim.Replace(vbLf, vbCrLf), writer.ToString.Trim)
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub VbcTest()
- Dim output As StringWriter = New StringWriter()
+
+ Public Sub VbcTest()
+ Dim output As StringWriter = New StringWriter()
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {})
- cmd.Run(output, Nothing)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {})
+ cmd.Run(output, Nothing)
- Assert.True(output.ToString().StartsWith(LogoLine1), "vbc should print logo and help if no args specified")
- End Sub
+ Assert.True(output.ToString().StartsWith(LogoLine1), "vbc should print logo and help if no args specified")
+ End Sub
-
- Public Sub VbcNologo_1()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub VbcNologo_1()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Class C
End Class
.Value).Path
- Dim output As StringWriter = New StringWriter()
+ Dim output As StringWriter = New StringWriter()
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", src})
- Dim exitCode = cmd.Run(output, Nothing)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo", "/t:library", src})
+ Dim exitCode = cmd.Run(output, Nothing)
- Assert.Equal(0, exitCode)
- Assert.Equal("", output.ToString().Trim())
+ Assert.Equal(0, exitCode)
+ Assert.Equal("", output.ToString().Trim())
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub VbcNologo_1a()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub VbcNologo_1a()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Class C
End Class
.Value).Path
- Dim output As StringWriter = New StringWriter()
+ Dim output As StringWriter = New StringWriter()
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo+", "/t:library", src})
- Dim exitCode = cmd.Run(output, Nothing)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo+", "/t:library", src})
+ Dim exitCode = cmd.Run(output, Nothing)
- Assert.Equal(0, exitCode)
- Assert.Equal("", output.ToString().Trim())
+ Assert.Equal(0, exitCode)
+ Assert.Equal("", output.ToString().Trim())
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub VbcNologo_2()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub VbcNologo_2()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Class C
End Class
.Value).Path
- Dim output As StringWriter = New StringWriter()
+ Dim output As StringWriter = New StringWriter()
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", src})
- Dim exitCode = cmd.Run(output, Nothing)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/t:library", src})
+ Dim exitCode = cmd.Run(output, Nothing)
- Assert.Equal(0, exitCode)
- Assert.Equal(
+ Assert.Equal(0, exitCode)
+ Assert.Equal(
Microsoft (R) Visual Basic Compiler version A.B.C.D
Copyright (C) Microsoft Corporation. All rights reserved.
.Value.Replace(vbLf, vbCrLf).Trim,
- Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D"))
- ' Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
- ' making the last part optional will fix this.
+ Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D"))
+ ' Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
+ ' making the last part optional will fix this.
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub VbcNologo_2a()
- Dim src As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub VbcNologo_2a()
+ Dim src As String = Temp.CreateFile().WriteAllText(
Class C
End Class
.Value).Path
- Dim output As StringWriter = New StringWriter()
+ Dim output As StringWriter = New StringWriter()
- Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo-", "/t:library", src})
- Dim exitCode = cmd.Run(output, Nothing)
+ Dim cmd = New MockVisualBasicCompiler(Nothing, _baseDirectory, {"/nologo-", "/t:library", src})
+ Dim exitCode = cmd.Run(output, Nothing)
- Assert.Equal(0, exitCode)
- Assert.Equal(
+ Assert.Equal(0, exitCode)
+ Assert.Equal(
Microsoft (R) Visual Basic Compiler version A.B.C.D
Copyright (C) Microsoft Corporation. All rights reserved.
.Value.Replace(vbLf, vbCrLf).Trim,
- Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D"))
- ' Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
- ' making the last part optional will fix this.
+ Regex.Replace(output.ToString().Trim(), "version \d+\.\d+\.\d+(\.\d+)?", "version A.B.C.D"))
+ ' Privately queued builds have 3-part version numbers instead of 4. Since we're throwing away the version number,
+ ' making the last part optional will fix this.
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub VbcUtf8Output_WithRedirecting_Off()
- Dim src As String = Temp.CreateFile().WriteAllText("♚", New System.Text.UTF8Encoding(False)).Path
+
+ Public Sub VbcUtf8Output_WithRedirecting_Off()
+ Dim src As String = Temp.CreateFile().WriteAllText("♚", New System.Text.UTF8Encoding(False)).Path
- Dim tempOut = Temp.CreateFile()
+ Dim tempOut = Temp.CreateFile()
- Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /t:library " & src & " > " & tempOut.Path, expectedRetCode:=1)
- Assert.Equal("", output.Trim())
+ Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /t:library " & src & " > " & tempOut.Path, expectedRetCode:=1)
+ Assert.Equal("", output.Trim())
- Assert.Equal(
+ Assert.Equal(
SRC.VB(1) : error BC30037: Character is not valid.
?
~
.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB"))
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub VbcUtf8Output_WithRedirecting_On()
- Dim src As String = Temp.CreateFile().WriteAllText("♚", New System.Text.UTF8Encoding(False)).Path
+
+ Public Sub VbcUtf8Output_WithRedirecting_On()
+ Dim src As String = Temp.CreateFile().WriteAllText("♚", New System.Text.UTF8Encoding(False)).Path
- Dim tempOut = Temp.CreateFile()
+ Dim tempOut = Temp.CreateFile()
- Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /utf8output /nologo /t:library " & src & " > " & tempOut.Path, expectedRetCode:=1)
- Assert.Equal("", output.Trim())
+ Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /utf8output /nologo /t:library " & src & " > " & tempOut.Path, expectedRetCode:=1)
+ Assert.Equal("", output.Trim())
- Assert.Equal(
+ Assert.Equal(
SRC.VB(1) : error BC30037: Character is not valid.
♚
@@ -338,12 +346,12 @@ SRC.VB(1) : error BC30037: Character is not valid.
.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB"))
- CleanupAllGeneratedFiles(src)
- End Sub
+ CleanupAllGeneratedFiles(src)
+ End Sub
-
- Public Sub ResponseFiles1()
- Dim rsp As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub ResponseFiles1()
+ Dim rsp As String = Temp.CreateFile().WriteAllText(
/r:System.dll
/nostdlib
/vbruntime-
@@ -351,73 +359,73 @@ SRC.VB(1) : error BC30037: Character is not valid.
System.Console.WriteLine("*?"); # this is error
a.vb
.Value).Path
- Dim cmd = New MockVisualBasicCompiler(rsp, _baseDirectory, {"b.vb"})
+ Dim cmd = New MockVisualBasicCompiler(rsp, _baseDirectory, {"b.vb"})
- AssertEx.Equal({"System.dll"}, cmd.Arguments.MetadataReferences.Select(Function(r) r.Reference))
- AssertEx.Equal(
- {
- Path.Combine(_baseDirectory, "a.vb"),
- Path.Combine(_baseDirectory, "b.vb")
- },
- cmd.Arguments.SourceFiles.Select(Function(file) file.Path))
- Assert.NotEmpty(cmd.Arguments.Errors)
+ AssertEx.Equal({"System.dll"}, cmd.Arguments.MetadataReferences.Select(Function(r) r.Reference))
+ AssertEx.Equal(
+ {
+ Path.Combine(_baseDirectory, "a.vb"),
+ Path.Combine(_baseDirectory, "b.vb")
+ },
+ cmd.Arguments.SourceFiles.Select(Function(file) file.Path))
+ Assert.NotEmpty(cmd.Arguments.Errors)
- CleanupAllGeneratedFiles(rsp)
- End Sub
+ CleanupAllGeneratedFiles(rsp)
+ End Sub
-
-
- Public Sub ResponseFiles_RootNamespace()
- Dim rsp As String = Temp.CreateFile().WriteAllText(
+
+
+ Public Sub ResponseFiles_RootNamespace()
+ Dim rsp As String = Temp.CreateFile().WriteAllText(
/r:System.dll
/rootnamespace:"Hello"
a.vb
.Value).Path
- Dim cmd = New MockVisualBasicCompiler(rsp, _baseDirectory, {"b.vb"})
+ Dim cmd = New MockVisualBasicCompiler(rsp, _baseDirectory, {"b.vb"})
- Assert.Equal("Hello", cmd.Arguments.CompilationOptions.RootNamespace)
+ Assert.Equal("Hello", cmd.Arguments.CompilationOptions.RootNamespace)
- CleanupAllGeneratedFiles(rsp)
- End Sub
+ CleanupAllGeneratedFiles(rsp)
+ End Sub
- Private Sub AssertGlobalImports(expectedImportStrings As String(), actualImports As GlobalImport())
- Assert.Equal(expectedImportStrings.Length, actualImports.Count)
- For i = 0 To expectedImportStrings.Length - 1
- Assert.Equal(expectedImportStrings(i), actualImports(i).Clause.ToString)
- Next
- End Sub
+ Private Sub AssertGlobalImports(expectedImportStrings As String(), actualImports As GlobalImport())
+ Assert.Equal(expectedImportStrings.Length, actualImports.Count)
+ For i = 0 To expectedImportStrings.Length - 1
+ Assert.Equal(expectedImportStrings(i), actualImports(i).Clause.ToString)
+ Next
+ End Sub
-
- Public Sub ParseGlobalImports()
- Dim args = VisualBasicCommandLineParser.Default.Parse({"/imports: System ,System.Xml ,System.Linq", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- AssertEx.Equal({"System", "System.Xml", "System.Linq"}, args.CompilationOptions.GlobalImports.Select(Function(import) import.Clause.ToString()))
+
+ Public Sub ParseGlobalImports()
+ Dim args = VisualBasicCommandLineParser.Default.Parse({"/imports: System ,System.Xml ,System.Linq", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ AssertEx.Equal({"System", "System.Xml", "System.Linq"}, args.CompilationOptions.GlobalImports.Select(Function(import) import.Clause.ToString()))
- args = VisualBasicCommandLineParser.Default.Parse({"/impORt: System,,,,,", "/IMPORTs:,,,Microsoft.VisualBasic,,System.IO", "a.vb"}, _baseDirectory)
- args.Errors.Verify()
- AssertEx.Equal({"System", "Microsoft.VisualBasic", "System.IO"}, args.CompilationOptions.GlobalImports.Select(Function(import) import.Clause.ToString()))
+ args = VisualBasicCommandLineParser.Default.Parse({"/impORt: System,,,,,", "/IMPORTs:,,,Microsoft.VisualBasic,,System.IO", "a.vb"}, _baseDirectory)
+ args.Errors.Verify()
+ AssertEx.Equal({"System", "Microsoft.VisualBasic", "System.IO"}, args.CompilationOptions.GlobalImports.Select(Function(import) import.Clause.ToString()))
- args = VisualBasicCommandLineParser.Default.Parse({"/impORt: System, ,, ,,", "a.vb"}, _baseDirectory)
- args.Errors.Verify(Diagnostic(ERRID.ERR_ExpectedIdentifier),
- Diagnostic(ERRID.ERR_ExpectedIdentifier))
+ args = VisualBasicCommandLineParser.Default.Parse({"/impORt: System, ,, ,,", "a.vb"}, _baseDirectory)
+ args.Errors.Verify(Diagnostic(ERRID.ERR_ExpectedIdentifier),
+ Diagnostic(ERRID.ERR_ExpectedIdentifier))
- args = VisualBasicCommandLineParser.Default.Parse({"/impORt:", "a.vb"}, _baseDirectory)
- args.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("import", ":"))
+ args = VisualBasicCommandLineParser.Default.Parse({"/impORt:", "a.vb"}, _baseDirectory)
+ args.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("import", ":"))
- args = VisualBasicCommandLineParser.Default.Parse({"/impORts:", "a.vb"}, _baseDirectory)
- args.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("imports", ":"))
+ args = VisualBasicCommandLineParser.Default.Parse({"/impORts:", "a.vb"}, _baseDirectory)
+ args.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("imports", ":"))
- args = VisualBasicCommandLineParser.Default.Parse({"/imports", "a.vb"}, _baseDirectory)
- args.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("imports", ":"))
+ args = VisualBasicCommandLineParser.Default.Parse({"/imports", "a.vb"}, _baseDirectory)
+ args.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("imports", ":"))
- args = VisualBasicCommandLineParser.Default.Parse({"/imports+", "a.vb"}, _baseDirectory)
- args.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/imports+")) ' TODO: Dev11 reports ERR_ArgumentRequired
- End Sub
+ args = VisualBasicCommandLineParser.Default.Parse({"/imports+", "a.vb"}, _baseDirectory)
+ args.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/imports+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+ End Sub
-
- Public Sub ResponseFiles2()
- Dim rsp As String = Temp.CreateFile().WriteAllText(
+
+ Public Sub ResponseFiles2()
+ Dim rsp As String = Temp.CreateFile().WriteAllText(
/r:System
/r:System.Core
/r:System.Data
@@ -428,2009 +436,2009 @@ a.vb
/imports:System.Collections.Generic
/imports:System.Linq
/imports:System.Text.Value).Path
- Dim cmd = New MockVbi(rsp, _baseDirectory, {"b.vbx"})
-
- ' TODO (tomat): mscorlib, vbruntime order
- 'AssertEx.Equal({GetType(Object).Assembly.Location,
- ' GetType(Microsoft.VisualBasic.Globals).Assembly.Location,
- ' "System", "System.Core", "System.Data", "System.Data.DataSetExtensions", "System.Xml", "System.Xml.Linq"},
- ' cmd.Arguments.AssemblyReferences.Select(Function(r)
- ' Return If(r.Kind = ReferenceKind.AssemblyName,
- ' (DirectCast(r, AssemblyNameReference)).Name,
- ' (DirectCast(r, AssemblyFileReference)).Path)
- ' End Function))
-
- AssertEx.Equal({"System", "System.Collections.Generic", "System.Linq", "System.Text"},
- cmd.Arguments.CompilationOptions.GlobalImports.Select(Function(import) import.Clause.ToString()))
- End Sub
-
-
- Public Sub Win32ResourceArguments()
- Dim args As String() = {"/win32manifest:..\here\there\everywhere\nonexistent"}
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- Dim compilation = CreateCompilationWithMscorlib(New VisualBasicSyntaxTree() {})
- Dim errors As IEnumerable(Of DiagnosticInfo) = Nothing
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_UnableToReadUacManifest2, Integer), errors.First().Code)
- Assert.Equal(2, errors.First().Arguments.Count())
- args = {"/Win32icon:\bogus"}
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
- Assert.Equal(2, errors.First().Arguments.Count())
- args = {"/Win32Resource:\bogus"}
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
- Assert.Equal(2, errors.First().Arguments.Count())
-
- args = {"/win32manifest:foo.win32data:bar.win32data2"}
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_UnableToReadUacManifest2, Integer), errors.First().Code)
- Assert.Equal(2, errors.First().Arguments.Count())
- args = {"/Win32icon:foo.win32data:bar.win32data2"}
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
- Assert.Equal(2, errors.First().Arguments.Count())
- args = {"/Win32Resource:foo.win32data:bar.win32data2"}
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
- Assert.Equal(2, errors.First().Arguments.Count())
- End Sub
-
-
- Public Sub Win32IconContainsGarbage()
- Dim tmpFileName As String = Temp.CreateFile().WriteAllBytes(New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Path
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon:" + tmpFileName}, _baseDirectory)
- Dim compilation = CreateCompilationWithMscorlib(New VisualBasicSyntaxTree() {})
- Dim errors As IEnumerable(Of DiagnosticInfo) = Nothing
- CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
- Assert.Equal(1, errors.Count())
- Assert.Equal(DirectCast(ERRID.ERR_ErrorCreatingWin32ResourceFile, Integer), errors.First().Code)
- Assert.Equal(1, errors.First().Arguments.Count())
-
-
- CleanupAllGeneratedFiles(tmpFileName)
- End Sub
-
-
- Public Sub Win32ResourceOptions_Valid()
- CheckWin32ResourceOptions({"/win32resource:a"}, "a", Nothing, Nothing, False)
-
- CheckWin32ResourceOptions({"/win32icon:b"}, Nothing, "b", Nothing, False)
-
- CheckWin32ResourceOptions({"/win32manifest:c"}, Nothing, Nothing, "c", False)
-
- CheckWin32ResourceOptions({"/nowin32manifest"}, Nothing, Nothing, Nothing, True)
- End Sub
-
-
- Public Sub Win32ResourceOptions_Empty()
- CheckWin32ResourceOptions({"/win32resource"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
- CheckWin32ResourceOptions({"/win32resource:"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
- CheckWin32ResourceOptions({"/win32resource: "}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
-
- CheckWin32ResourceOptions({"/win32icon"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
- CheckWin32ResourceOptions({"/win32icon:"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
- CheckWin32ResourceOptions({"/win32icon: "}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
-
- CheckWin32ResourceOptions({"/win32manifest"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
- CheckWin32ResourceOptions({"/win32manifest:"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
- CheckWin32ResourceOptions({"/win32manifest: "}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
-
- CheckWin32ResourceOptions({"/nowin32manifest"}, Nothing, Nothing, Nothing, True)
- CheckWin32ResourceOptions({"/nowin32manifest:"}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/nowin32manifest:"))
- CheckWin32ResourceOptions({"/nowin32manifest: "}, Nothing, Nothing, Nothing, False,
- Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/nowin32manifest:"))
- End Sub
-
-
- Public Sub Win32ResourceOptions_Combinations()
- ' last occurence wins
- CheckWin32ResourceOptions({"/win32resource:r", "/win32resource:s"}, "s", Nothing, Nothing, False)
- ' illegal
- CheckWin32ResourceOptions({"/win32resource:r", "/win32icon:i"}, "r", "i", Nothing, False,
- Diagnostic(ERRID.ERR_IconFileAndWin32ResFile))
- ' documented as illegal, but works in dev10
- CheckWin32ResourceOptions({"/win32resource:r", "/win32manifest:m"}, "r", Nothing, "m", False,
- Diagnostic(ERRID.ERR_CantHaveWin32ResAndManifest))
- ' fine
- CheckWin32ResourceOptions({"/win32resource:r", "/nowin32manifest"}, "r", Nothing, Nothing, True)
-
-
- ' illegal
- CheckWin32ResourceOptions({"/win32icon:i", "/win32resource:r"}, "r", "i", Nothing, False,
- Diagnostic(ERRID.ERR_IconFileAndWin32ResFile))
- ' last occurence wins
- CheckWin32ResourceOptions({"/win32icon:i", "/win32icon:j"}, Nothing, "j", Nothing, False)
- ' fine
- CheckWin32ResourceOptions({"/win32icon:i", "/win32manifest:m"}, Nothing, "i", "m", False)
- ' fine
- CheckWin32ResourceOptions({"/win32icon:i", "/nowin32manifest"}, Nothing, "i", Nothing, True)
-
-
- ' documented as illegal, but works in dev10
- CheckWin32ResourceOptions({"/win32manifest:m", "/win32resource:r"}, "r", Nothing, "m", False,
- Diagnostic(ERRID.ERR_CantHaveWin32ResAndManifest))
- ' fine
- CheckWin32ResourceOptions({"/win32manifest:m", "/win32icon:i"}, Nothing, "i", "m", False)
- ' last occurence wins
- CheckWin32ResourceOptions({"/win32manifest:m", "/win32manifest:n"}, Nothing, Nothing, "n", False)
- ' illegal
- CheckWin32ResourceOptions({"/win32manifest:m", "/nowin32manifest"}, Nothing, Nothing, "m", True,
- Diagnostic(ERRID.ERR_ConflictingManifestSwitches))
-
-
- ' fine
- CheckWin32ResourceOptions({"/nowin32manifest", "/win32resource:r"}, "r", Nothing, Nothing, True)
- ' fine
- CheckWin32ResourceOptions({"/nowin32manifest", "/win32icon:i"}, Nothing, "i", Nothing, True)
- ' illegal
- CheckWin32ResourceOptions({"/nowin32manifest", "/win32manifest:m"}, Nothing, Nothing, "m", True,
- Diagnostic(ERRID.ERR_ConflictingManifestSwitches))
- ' fine
- CheckWin32ResourceOptions({"/nowin32manifest", "/nowin32manifest"}, Nothing, Nothing, Nothing, True)
- End Sub
-
-
- Public Sub Win32ResourceOptions_SimplyInvalid()
-
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32resource", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32resource+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32resource+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32resource-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32resource-")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32icon+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32icon-")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32manifest+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32manifest-")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- End Sub
-
- Private Sub CheckWin32ResourceOptions(args As String(), expectedResourceFile As String, expectedIcon As String, expectedManifest As String, expectedNoManifest As Boolean, ParamArray diags As DiagnosticDescription())
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args.Concat({"Test.vb"}), _baseDirectory)
- parsedArgs.Errors.Verify(diags)
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(expectedResourceFile, parsedArgs.Win32ResourceFile)
- Assert.Equal(expectedIcon, parsedArgs.Win32Icon)
- Assert.Equal(expectedManifest, parsedArgs.Win32Manifest)
- Assert.Equal(expectedNoManifest, parsedArgs.NoWin32Manifest)
- End Sub
-
-
- Public Sub ParseResourceDescription()
- Dim diags = New List(Of Diagnostic)()
- Dim desc As ResourceDescription
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someFile.foo.bar", desc.ResourceName)
- Assert.True(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,someName", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someName", desc.ResourceName)
- Assert.True(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,someName,public", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someName", desc.ResourceName)
- Assert.True(desc.IsPublic)
-
- ' use file name in place of missing resource name
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someFile.foo.bar", desc.ResourceName)
- Assert.False(desc.IsPublic)
-
- ' quoted accessibility is fine
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,""private""", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someFile.foo.bar", desc.ResourceName)
- Assert.False(desc.IsPublic)
-
- ' leading commas are ignored...
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", ",,\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someFile.foo.bar", desc.ResourceName)
- Assert.False(desc.IsPublic)
-
- ' ...as long as there's no whitespace between them
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", ", ,\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- ' trailing commas are ignored...
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someFile.foo.bar", desc.ResourceName)
- Assert.False(desc.IsPublic)
-
- ' ...even if there's whitespace between them
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,private, ,", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("someFile.foo.bar", desc.FileName)
- Assert.Equal("someFile.foo.bar", desc.ResourceName)
- Assert.False(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,someName,publi", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("publi", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "D:rive\relative\path,someName,public", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("D:rive\relative\path"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "inva\l*d?path,someName,public", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("inva\l*d?path"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", Nothing, _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " , ", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path, ", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("path", desc.FileName)
- Assert.Equal("path", desc.ResourceName)
- Assert.True(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ,name", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " , , ", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path, , ", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ,name, ", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " , ,private", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path,name,", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("path", desc.FileName)
- Assert.Equal("name", desc.ResourceName)
- Assert.True(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path,name,,", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("path", desc.FileName)
- Assert.Equal("name", desc.ResourceName)
- Assert.True(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path,name, ", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path, ,private", _baseDirectory, diags, embedded:=False)
- diags.Verify()
- diags.Clear()
- Assert.Equal("path", desc.FileName)
- Assert.Equal("path", desc.ResourceName)
- Assert.False(desc.IsPublic)
-
- desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ,name,private", _baseDirectory, diags, embedded:=False)
- diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
- diags.Clear()
- Assert.Null(desc)
- End Sub
-
-
- Public Sub ManagedResourceOptions()
- Dim parsedArgs As VisualBasicCommandLineArguments
- Dim resourceDescription As ResourceDescription
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource:a", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.DisplayHelp)
- resourceDescription = parsedArgs.ManifestResources.Single()
- Assert.Null(resourceDescription.FileName) ' since embedded
- Assert.Equal("a", resourceDescription.ResourceName)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/res:b", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.DisplayHelp)
- resourceDescription = parsedArgs.ManifestResources.Single()
- Assert.Null(resourceDescription.FileName) ' since embedded
- Assert.Equal("b", resourceDescription.ResourceName)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource:c", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.DisplayHelp)
- resourceDescription = parsedArgs.ManifestResources.Single()
- Assert.Equal("c", resourceDescription.FileName)
- Assert.Equal("c", resourceDescription.ResourceName)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkres:d", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.DisplayHelp)
- resourceDescription = parsedArgs.ManifestResources.Single()
- Assert.Equal("d", resourceDescription.FileName)
- Assert.Equal("d", resourceDescription.ResourceName)
- End Sub
-
-
- Public Sub ManagedResourceOptions_SimpleErrors()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/RES+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/RES+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/res-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/res-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("linkresource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("linkresource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("linkresource", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkRES+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/linkRES+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkres-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/linkres-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
- End Sub
-
-
- Public Sub ModuleManifest()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest:blah", "/target:module", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.WRN_IgnoreModuleManifest))
-
- ' Illegal, but not clobbered.
- Assert.Equal("blah", parsedArgs.Win32Manifest)
- End Sub
-
-
- Public Sub ArgumentParsing()
- Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"a + b"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"a + b; c"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/help"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(True, parsedArgs.DisplayHelp)
- Assert.Equal(False, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/?"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(True, parsedArgs.DisplayHelp)
- Assert.Equal(False, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx /langversion:10"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx", "/langversion:-1"}, _baseDirectory)
- Assert.Equal(1, parsedArgs.Errors.Length)
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(1, parsedArgs.SourceFiles.Length)
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx /r:d /r:d.dll"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"@dd"}, _baseDirectory)
- Assert.Equal(True, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(False, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c /define:DEBUG"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"\\"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx", "/r:d.dll", "/define:DEGUG"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"""/r d.dll"""}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(True, parsedArgs.SourceFiles.Any())
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/r: d.dll"}, _baseDirectory)
- Assert.Equal(False, parsedArgs.Errors.Any())
- Assert.Equal(False, parsedArgs.DisplayHelp)
- Assert.Equal(False, parsedArgs.SourceFiles.Any())
- End Sub
-
-
- Public Sub LangVersion()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langversion:9", "a.VB"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic9, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:9.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic9, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:10", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic10, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:10.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic10, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:11", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:11.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:12", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic12, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:12.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic12, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:Experimental", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.Experimental, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:experimental", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.Experimental, parsedArgs.ParseOptions.LanguageVersion)
-
- ' default: "current version"
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- ' overriding
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:10", "/langVERSION:9.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(LanguageVersion.VisualBasic9, parsedArgs.ParseOptions.LanguageVersion)
-
- ' errors
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("langversion", ":"))
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/langVERSION+")) ' TODO: Dev11 reports ERR_ArgumentRequired
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("langversion", ":"))
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:8", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("8", "langversion"))
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:" & (LanguageVersion.VisualBasic12 + 1), "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(CStr(LanguageVersion.VisualBasic12 + 1), "langversion"))
- Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
- End Sub
-
-
- Public Sub DelaySign()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/delaysign", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.NotNull(parsedArgs.CompilationOptions.DelaySign)
- Assert.Equal(True, parsedArgs.CompilationOptions.DelaySign)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/delaysign+", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.NotNull(parsedArgs.CompilationOptions.DelaySign)
- Assert.Equal(True, parsedArgs.CompilationOptions.DelaySign)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/DELAYsign-", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.NotNull(parsedArgs.CompilationOptions.DelaySign)
- Assert.Equal(False, parsedArgs.CompilationOptions.DelaySign)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/delaysign:-", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("delaysign"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
- parsedArgs.Errors.Verify()
- Assert.Null(parsedArgs.CompilationOptions.DelaySign)
- End Sub
-
-
-
- Public Sub OutputVerbose()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Verbose, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Verbose, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/VERBOSE:-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/VERBOSE:-"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("verbose"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose+:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("verbose"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbOSE:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/verbOSE:"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet", "/verbose", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Verbose, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet", "/verbose-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
- End Sub
-
-
-
- Public Sub OutputQuiet()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Quiet, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Quiet, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/QUIET:-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/QUIET:-"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("quiet"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet+:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("quiet"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiET:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/quiET:"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose", "/quiet", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Quiet, parsedArgs.OutputLevel)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose", "/quiet-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
- End Sub
-
-
- Public Sub Optimize()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.Optimize)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.CompilationOptions.Optimize) ' default
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OPTIMIZE+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.Optimize)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.CompilationOptions.Optimize)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize-", "/optimize+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.Optimize)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OPTIMIZE:", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optimize"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OPTIMIZE+:", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optimize"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize-:", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optimize"))
- End Sub
-
-
-
- Public Sub Parallel()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild) ' default
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/PARALLEL+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/PARALLEL-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/PArallel-", "/PArallel+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("parallel"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel+:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("parallel"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("parallel"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/P+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/P-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/P-", "/P+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("p"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p+:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("p"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("p"))
- End Sub
-
-
- Public Sub SubsystemVersionTests()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(SubsystemVersion.Create(4, 0), parsedArgs.CompilationOptions.SubsystemVersion)
-
- ' wrongly supported subsystem version. CompilationOptions data will be faithful to the user input.
- ' It is normalized at the time of emit.
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:0.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify() ' no error in Dev11
- Assert.Equal(SubsystemVersion.Create(0, 0), parsedArgs.CompilationOptions.SubsystemVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify() ' no error in Dev11
- Assert.Equal(SubsystemVersion.Create(0, 0), parsedArgs.CompilationOptions.SubsystemVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:3.99", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify() ' no warning in Dev11
- Assert.Equal(SubsystemVersion.Create(3, 99), parsedArgs.CompilationOptions.SubsystemVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.0", "/subsystemversion:5.333", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(SubsystemVersion.Create(5, 333), parsedArgs.CompilationOptions.SubsystemVersion)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("subsystemversion", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("subsystemversion", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/subsystemversion-")) ' TODO: Dev11 reports ERRID.ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("subsystemversion", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion: 4.1", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments(" 4.1"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4 .0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4 .0"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4. 0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4. 0"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:.", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("."))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4."))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments(".0"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.2 ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.65536", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4.65536"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:65536.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("65536.0"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:-4.0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("-4.0"))
-
- ' TODO: incompatibilities: versions lower than '6.2' and 'arm', 'winmdobj', 'appcontainer'
- End Sub
-
-
- Public Sub Codepage()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/CodePage:1200", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("Unicode", parsedArgs.Encoding.EncodingName)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/CodePage:1200", "/CodePage:65001", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("Unicode (UTF-8)", parsedArgs.Encoding.EncodingName)
-
- ' errors
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:0", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadCodepage).WithArguments("0"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:abc", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadCodepage).WithArguments("abc"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:-5", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadCodepage).WithArguments("-5"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("codepage", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("codepage", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/codepage+")) ' Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("codepage", ":"))
- End Sub
-
-
- Public Sub MainTypeName()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/main:A.B.C", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("A.B.C", parsedArgs.CompilationOptions.MainTypeName)
-
- ' overriding the value
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/Main:A.B.C", "/M:X.Y.Z", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("X.Y.Z", parsedArgs.CompilationOptions.MainTypeName)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/MAIN: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("main", ":"))
- Assert.Null(parsedArgs.CompilationOptions.MainTypeName) ' EDMAURER Dev11 accepts and MainTypeName is " "
-
- ' errors
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/maiN:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("main", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/m", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("m", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/m+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/m+")) ' Dev11 reports ERR_ArgumentRequired
-
- ' incompatibilities ignored by Dev11
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/MAIN:XYZ", "/t:library", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("XYZ", parsedArgs.CompilationOptions.MainTypeName)
- Assert.Equal(OutputKind.DynamicallyLinkedLibrary, parsedArgs.CompilationOptions.OutputKind)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/MAIN:XYZ", "/t:module", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.NetModule, parsedArgs.CompilationOptions.OutputKind)
- End Sub
-
-
- Public Sub OptionCompare()
- Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioncompare"}, _baseDirectory)
- Assert.Equal(1, parsedArgs.Errors.Length)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optioncompare", ":binary|text"))
- Assert.Equal(False, parsedArgs.CompilationOptions.OptionCompareText)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioncompare:text", "/optioncompare"}, _baseDirectory)
- Assert.Equal(1, parsedArgs.Errors.Length)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optioncompare", ":binary|text"))
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionCompareText)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/opTioncompare:Text", "/optioncomparE:bINARY"}, _baseDirectory)
- Assert.Equal(0, parsedArgs.Errors.Length)
- Assert.Equal(False, parsedArgs.CompilationOptions.OptionCompareText)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
- Assert.Equal(0, parsedArgs.Errors.Length)
- Assert.Equal(False, parsedArgs.CompilationOptions.OptionCompareText)
- End Sub
-
-
- Public Sub OptionExplicit()
- Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONexplicit"}, _baseDirectory)
- Assert.Equal(0, parsedArgs.Errors.Length)
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONexplicit:+"}, _baseDirectory)
- Assert.Equal(1, parsedArgs.Errors.Length)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optionexplicit"))
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONexplicit-:"}, _baseDirectory)
- Assert.Equal(1, parsedArgs.Errors.Length)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optionexplicit"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optionexplicit+", "/optiONexplicit-:"}, _baseDirectory)
- Assert.Equal(1, parsedArgs.Errors.Length)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optionexplicit"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optionexplicit+", "/optiONexplicit-", "/optiONexpliCIT+"}, _baseDirectory)
- Assert.Equal(0, parsedArgs.Errors.Length)
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
- Assert.Equal(0, parsedArgs.Errors.Length)
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
- End Sub
-
-
- Public Sub OptionInfer()
- Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONinfer"}, _baseDirectory)
- Assert.Equal(0, parsedArgs.Errors.Length)
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionInfer)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/OptionInfer:+"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optioninfer"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/OPTIONinfer-:"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optioninfer"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioninfer+", "/optioninFER-:"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optioninfer"))
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioninfer+", "/optioninfeR-", "/OptionInfer+"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.CompilationOptions.OptionInfer)
-
- parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.CompilationOptions.OptionInfer)
- End Sub
-
- Const VBC_VER As Double = 11.0
-
-
- Public Sub TestDefine()
- TestDefines({"/D:a=True,b=1", "a.vb"},
- {"a", True},
- {"b", 1},
- {"TARGET", "exe"},
- {"VBC_VER", VBC_VER})
-
- TestDefines({"/D:a=True,b=1", "/define:a=""123"",b=False", "a.vb"},
- {"a", "123"},
- {"b", False},
- {"TARGET", "exe"},
- {"VBC_VER", VBC_VER})
-
- TestDefines({"/D:a=""\\\\a"",b=""\\\\\b""", "a.vb"},
- {"a", "\\\\a"},
- {"b", "\\\\\b"},
- {"TARGET", "exe"},
- {"VBC_VER", VBC_VER})
-
- TestDefines({"/define:DEBUG", "a.vb"},
- {"DEBUG", True},
- {"TARGET", "exe"},
- {"VBC_VER", VBC_VER})
-
- TestDefines({"/D:TARGET=True,VBC_VER=1", "a.vb"},
- {"TARGET", True},
- {"VBC_VER", 1})
- End Sub
-
- Private Sub TestDefines(args As IEnumerable(Of String), ParamArray symbols As Object()())
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
- Assert.False(parsedArgs.Errors.Any)
- Assert.Equal(symbols.Length, parsedArgs.ParseOptions.PreprocessorSymbols.Length)
- Dim sortedDefines = parsedArgs.ParseOptions.
- PreprocessorSymbols.Select(
- Function(d) New With {d.Key, d.Value}).OrderBy(Function(o) o.Key)
-
- For i = 0 To symbols.Length - 1
- Assert.Equal(symbols(i)(0), sortedDefines(i).Key)
- Assert.Equal(symbols(i)(1), sortedDefines(i).Value)
- Next
- End Sub
-
-
- Public Sub OptionStrict()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionStrict", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(VisualBasic.OptionStrict.On, parsedArgs.CompilationOptions.OptionStrict)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionStrict+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(VisualBasic.OptionStrict.On, parsedArgs.CompilationOptions.OptionStrict)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionStrict-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(VisualBasic.OptionStrict.Off, parsedArgs.CompilationOptions.OptionStrict)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OptionStrict:cusTom", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(VisualBasic.OptionStrict.Custom, parsedArgs.CompilationOptions.OptionStrict)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OptionStrict:cusTom", "/optionstrict-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(VisualBasic.OptionStrict.Off, parsedArgs.CompilationOptions.OptionStrict)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionstrict-", "/OptionStrict:cusTom", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(VisualBasic.OptionStrict.Custom, parsedArgs.CompilationOptions.OptionStrict)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionstrict:", "/OptionStrict:cusTom", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optionstrict", ":custom"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionstrict:xxx", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optionstrict", ":custom"))
- End Sub
-
-
-
-
-
- Public Sub RootNamespace()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:One.Two.Three", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("One.Two.Three", parsedArgs.CompilationOptions.RootNamespace)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:One Two Three", "/rootnamespace:One.Two.Three", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("One.Two.Three", parsedArgs.CompilationOptions.RootNamespace)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:""One.Two.Three""", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("One.Two.Three", parsedArgs.CompilationOptions.RootNamespace)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("rootnamespace", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("rootnamespace", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/rootnamespace+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/rootnamespace-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("+"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("rootnamespace", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace: A.B.C", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments(" A.B.C"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:[abcdef", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("[abcdef"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:abcdef]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("abcdef]"))
+ Dim cmd = New MockVbi(rsp, _baseDirectory, {"b.vbx"})
+
+ ' TODO (tomat): mscorlib, vbruntime order
+ 'AssertEx.Equal({GetType(Object).Assembly.Location,
+ ' GetType(Microsoft.VisualBasic.Globals).Assembly.Location,
+ ' "System", "System.Core", "System.Data", "System.Data.DataSetExtensions", "System.Xml", "System.Xml.Linq"},
+ ' cmd.Arguments.AssemblyReferences.Select(Function(r)
+ ' Return If(r.Kind = ReferenceKind.AssemblyName,
+ ' (DirectCast(r, AssemblyNameReference)).Name,
+ ' (DirectCast(r, AssemblyFileReference)).Path)
+ ' End Function))
+
+ AssertEx.Equal({"System", "System.Collections.Generic", "System.Linq", "System.Text"},
+ cmd.Arguments.CompilationOptions.GlobalImports.Select(Function(import) import.Clause.ToString()))
+ End Sub
+
+
+ Public Sub Win32ResourceArguments()
+ Dim args As String() = {"/win32manifest:..\here\there\everywhere\nonexistent"}
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ Dim compilation = CreateCompilationWithMscorlib(New VisualBasicSyntaxTree() {})
+ Dim errors As IEnumerable(Of DiagnosticInfo) = Nothing
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_UnableToReadUacManifest2, Integer), errors.First().Code)
+ Assert.Equal(2, errors.First().Arguments.Count())
+ args = {"/Win32icon:\bogus"}
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
+ Assert.Equal(2, errors.First().Arguments.Count())
+ args = {"/Win32Resource:\bogus"}
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
+ Assert.Equal(2, errors.First().Arguments.Count())
+
+ args = {"/win32manifest:foo.win32data:bar.win32data2"}
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_UnableToReadUacManifest2, Integer), errors.First().Code)
+ Assert.Equal(2, errors.First().Arguments.Count())
+ args = {"/Win32icon:foo.win32data:bar.win32data2"}
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
+ Assert.Equal(2, errors.First().Arguments.Count())
+ args = {"/Win32Resource:foo.win32data:bar.win32data2"}
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_UnableToOpenResourceFile1, Integer), errors.First().Code)
+ Assert.Equal(2, errors.First().Arguments.Count())
+ End Sub
+
+
+ Public Sub Win32IconContainsGarbage()
+ Dim tmpFileName As String = Temp.CreateFile().WriteAllBytes(New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Path
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon:" + tmpFileName}, _baseDirectory)
+ Dim compilation = CreateCompilationWithMscorlib(New VisualBasicSyntaxTree() {})
+ Dim errors As IEnumerable(Of DiagnosticInfo) = Nothing
+ CommonCompiler.GetWin32ResourcesInternal(MessageProvider.Instance, parsedArgs, compilation, errors)
+ Assert.Equal(1, errors.Count())
+ Assert.Equal(DirectCast(ERRID.ERR_ErrorCreatingWin32ResourceFile, Integer), errors.First().Code)
+ Assert.Equal(1, errors.First().Arguments.Count())
+
+
+ CleanupAllGeneratedFiles(tmpFileName)
+ End Sub
+
+
+ Public Sub Win32ResourceOptions_Valid()
+ CheckWin32ResourceOptions({"/win32resource:a"}, "a", Nothing, Nothing, False)
+
+ CheckWin32ResourceOptions({"/win32icon:b"}, Nothing, "b", Nothing, False)
+
+ CheckWin32ResourceOptions({"/win32manifest:c"}, Nothing, Nothing, "c", False)
+
+ CheckWin32ResourceOptions({"/nowin32manifest"}, Nothing, Nothing, Nothing, True)
+ End Sub
+
+
+ Public Sub Win32ResourceOptions_Empty()
+ CheckWin32ResourceOptions({"/win32resource"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
+ CheckWin32ResourceOptions({"/win32resource:"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
+ CheckWin32ResourceOptions({"/win32resource: "}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
+
+ CheckWin32ResourceOptions({"/win32icon"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
+ CheckWin32ResourceOptions({"/win32icon:"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
+ CheckWin32ResourceOptions({"/win32icon: "}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
+
+ CheckWin32ResourceOptions({"/win32manifest"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
+ CheckWin32ResourceOptions({"/win32manifest:"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
+ CheckWin32ResourceOptions({"/win32manifest: "}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
+
+ CheckWin32ResourceOptions({"/nowin32manifest"}, Nothing, Nothing, Nothing, True)
+ CheckWin32ResourceOptions({"/nowin32manifest:"}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/nowin32manifest:"))
+ CheckWin32ResourceOptions({"/nowin32manifest: "}, Nothing, Nothing, Nothing, False,
+ Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/nowin32manifest:"))
+ End Sub
+
+
+ Public Sub Win32ResourceOptions_Combinations()
+ ' last occurence wins
+ CheckWin32ResourceOptions({"/win32resource:r", "/win32resource:s"}, "s", Nothing, Nothing, False)
+ ' illegal
+ CheckWin32ResourceOptions({"/win32resource:r", "/win32icon:i"}, "r", "i", Nothing, False,
+ Diagnostic(ERRID.ERR_IconFileAndWin32ResFile))
+ ' documented as illegal, but works in dev10
+ CheckWin32ResourceOptions({"/win32resource:r", "/win32manifest:m"}, "r", Nothing, "m", False,
+ Diagnostic(ERRID.ERR_CantHaveWin32ResAndManifest))
+ ' fine
+ CheckWin32ResourceOptions({"/win32resource:r", "/nowin32manifest"}, "r", Nothing, Nothing, True)
+
+
+ ' illegal
+ CheckWin32ResourceOptions({"/win32icon:i", "/win32resource:r"}, "r", "i", Nothing, False,
+ Diagnostic(ERRID.ERR_IconFileAndWin32ResFile))
+ ' last occurence wins
+ CheckWin32ResourceOptions({"/win32icon:i", "/win32icon:j"}, Nothing, "j", Nothing, False)
+ ' fine
+ CheckWin32ResourceOptions({"/win32icon:i", "/win32manifest:m"}, Nothing, "i", "m", False)
+ ' fine
+ CheckWin32ResourceOptions({"/win32icon:i", "/nowin32manifest"}, Nothing, "i", Nothing, True)
+
+
+ ' documented as illegal, but works in dev10
+ CheckWin32ResourceOptions({"/win32manifest:m", "/win32resource:r"}, "r", Nothing, "m", False,
+ Diagnostic(ERRID.ERR_CantHaveWin32ResAndManifest))
+ ' fine
+ CheckWin32ResourceOptions({"/win32manifest:m", "/win32icon:i"}, Nothing, "i", "m", False)
+ ' last occurence wins
+ CheckWin32ResourceOptions({"/win32manifest:m", "/win32manifest:n"}, Nothing, Nothing, "n", False)
+ ' illegal
+ CheckWin32ResourceOptions({"/win32manifest:m", "/nowin32manifest"}, Nothing, Nothing, "m", True,
+ Diagnostic(ERRID.ERR_ConflictingManifestSwitches))
+
+
+ ' fine
+ CheckWin32ResourceOptions({"/nowin32manifest", "/win32resource:r"}, "r", Nothing, Nothing, True)
+ ' fine
+ CheckWin32ResourceOptions({"/nowin32manifest", "/win32icon:i"}, Nothing, "i", Nothing, True)
+ ' illegal
+ CheckWin32ResourceOptions({"/nowin32manifest", "/win32manifest:m"}, Nothing, Nothing, "m", True,
+ Diagnostic(ERRID.ERR_ConflictingManifestSwitches))
+ ' fine
+ CheckWin32ResourceOptions({"/nowin32manifest", "/nowin32manifest"}, Nothing, Nothing, Nothing, True)
+ End Sub
+
+
+ Public Sub Win32ResourceOptions_SimplyInvalid()
+
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32resource", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32resource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32resource+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32resource+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32resource-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32resource-")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32icon", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32icon+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32icon-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32icon-")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("win32manifest", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32manifest+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/win32manifest-")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ End Sub
+
+ Private Sub CheckWin32ResourceOptions(args As String(), expectedResourceFile As String, expectedIcon As String, expectedManifest As String, expectedNoManifest As Boolean, ParamArray diags As DiagnosticDescription())
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args.Concat({"Test.vb"}), _baseDirectory)
+ parsedArgs.Errors.Verify(diags)
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(expectedResourceFile, parsedArgs.Win32ResourceFile)
+ Assert.Equal(expectedIcon, parsedArgs.Win32Icon)
+ Assert.Equal(expectedManifest, parsedArgs.Win32Manifest)
+ Assert.Equal(expectedNoManifest, parsedArgs.NoWin32Manifest)
+ End Sub
+
+
+ Public Sub ParseResourceDescription()
+ Dim diags = New List(Of Diagnostic)()
+ Dim desc As ResourceDescription
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someFile.foo.bar", desc.ResourceName)
+ Assert.True(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,someName", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someName", desc.ResourceName)
+ Assert.True(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,someName,public", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someName", desc.ResourceName)
+ Assert.True(desc.IsPublic)
+
+ ' use file name in place of missing resource name
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someFile.foo.bar", desc.ResourceName)
+ Assert.False(desc.IsPublic)
+
+ ' quoted accessibility is fine
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,""private""", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someFile.foo.bar", desc.ResourceName)
+ Assert.False(desc.IsPublic)
+
+ ' leading commas are ignored...
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", ",,\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someFile.foo.bar", desc.ResourceName)
+ Assert.False(desc.IsPublic)
+
+ ' ...as long as there's no whitespace between them
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", ", ,\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ ' trailing commas are ignored...
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someFile.foo.bar", desc.ResourceName)
+ Assert.False(desc.IsPublic)
+
+ ' ...even if there's whitespace between them
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,,private, ,", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("someFile.foo.bar", desc.FileName)
+ Assert.Equal("someFile.foo.bar", desc.ResourceName)
+ Assert.False(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "\somepath\someFile.foo.bar,someName,publi", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("publi", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "D:rive\relative\path,someName,public", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("D:rive\relative\path"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "inva\l*d?path,someName,public", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("inva\l*d?path"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", Nothing, _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " , ", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path, ", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("path", desc.FileName)
+ Assert.Equal("path", desc.ResourceName)
+ Assert.True(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ,name", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " , , ", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path, , ", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ,name, ", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " , ,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path,name,", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("path", desc.FileName)
+ Assert.Equal("name", desc.ResourceName)
+ Assert.True(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path,name,,", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("path", desc.FileName)
+ Assert.Equal("name", desc.ResourceName)
+ Assert.True(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path,name, ", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", "path, ,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify()
+ diags.Clear()
+ Assert.Equal("path", desc.FileName)
+ Assert.Equal("path", desc.ResourceName)
+ Assert.False(desc.IsPublic)
+
+ desc = VisualBasicCommandLineParser.ParseResourceDescription("resource", " ,name,private", _baseDirectory, diags, embedded:=False)
+ diags.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(" ", "resource"))
+ diags.Clear()
+ Assert.Null(desc)
+ End Sub
+
+
+ Public Sub ManagedResourceOptions()
+ Dim parsedArgs As VisualBasicCommandLineArguments
+ Dim resourceDescription As ResourceDescription
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource:a", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ resourceDescription = parsedArgs.ManifestResources.Single()
+ Assert.Null(resourceDescription.FileName) ' since embedded
+ Assert.Equal("a", resourceDescription.ResourceName)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/res:b", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ resourceDescription = parsedArgs.ManifestResources.Single()
+ Assert.Null(resourceDescription.FileName) ' since embedded
+ Assert.Equal("b", resourceDescription.ResourceName)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource:c", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ resourceDescription = parsedArgs.ManifestResources.Single()
+ Assert.Equal("c", resourceDescription.FileName)
+ Assert.Equal("c", resourceDescription.ResourceName)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkres:d", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ resourceDescription = parsedArgs.ManifestResources.Single()
+ Assert.Equal("d", resourceDescription.FileName)
+ Assert.Equal("d", resourceDescription.ResourceName)
+ End Sub
+
+
+ Public Sub ManagedResourceOptions_SimpleErrors()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource: ", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/resource", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("resource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/RES+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/RES+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/res-:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/res-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("linkresource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource: ", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("linkresource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkresource", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("linkresource", ":"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkRES+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/linkRES+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/linkres-:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/linkres-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
+ End Sub
+
+
+ Public Sub ModuleManifest()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/win32manifest:blah", "/target:module", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify(
+ Diagnostic(ERRID.WRN_IgnoreModuleManifest))
+
+ ' Illegal, but not clobbered.
+ Assert.Equal("blah", parsedArgs.Win32Manifest)
+ End Sub
+
+
+ Public Sub ArgumentParsing()
+ Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"a + b"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"a + b; c"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/help"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(True, parsedArgs.DisplayHelp)
+ Assert.Equal(False, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/?"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(True, parsedArgs.DisplayHelp)
+ Assert.Equal(False, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx /langversion:10"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx", "/langversion:-1"}, _baseDirectory)
+ Assert.Equal(1, parsedArgs.Errors.Length)
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(1, parsedArgs.SourceFiles.Length)
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx /r:d /r:d.dll"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"@dd"}, _baseDirectory)
+ Assert.Equal(True, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(False, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c /define:DEBUG"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"\\"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"c.vbx", "/r:d.dll", "/define:DEGUG"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"""/r d.dll"""}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(True, parsedArgs.SourceFiles.Any())
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/r: d.dll"}, _baseDirectory)
+ Assert.Equal(False, parsedArgs.Errors.Any())
+ Assert.Equal(False, parsedArgs.DisplayHelp)
+ Assert.Equal(False, parsedArgs.SourceFiles.Any())
+ End Sub
+
+
+ Public Sub LangVersion()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langversion:9", "a.VB"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic9, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:9.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic9, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:10", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic10, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:10.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic10, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:11", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:11.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:12", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic12, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:12.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic12, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:Experimental", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.Experimental, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:experimental", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.Experimental, parsedArgs.ParseOptions.LanguageVersion)
+
+ ' default: "current version"
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ ' overriding
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:10", "/langVERSION:9.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(LanguageVersion.VisualBasic9, parsedArgs.ParseOptions.LanguageVersion)
+
+ ' errors
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("langversion", ":"))
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/langVERSION+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("langversion", ":"))
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:8", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("8", "langversion"))
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/langVERSION:" & (LanguageVersion.VisualBasic12 + 1), "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments(CStr(LanguageVersion.VisualBasic12 + 1), "langversion"))
+ Assert.Equal(LanguageVersion.VisualBasic11, parsedArgs.ParseOptions.LanguageVersion)
+ End Sub
+
+
+ Public Sub DelaySign()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/delaysign", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.NotNull(parsedArgs.CompilationOptions.DelaySign)
+ Assert.Equal(True, parsedArgs.CompilationOptions.DelaySign)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/delaysign+", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.NotNull(parsedArgs.CompilationOptions.DelaySign)
+ Assert.Equal(True, parsedArgs.CompilationOptions.DelaySign)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/DELAYsign-", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.NotNull(parsedArgs.CompilationOptions.DelaySign)
+ Assert.Equal(False, parsedArgs.CompilationOptions.DelaySign)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/delaysign:-", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("delaysign"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
+ parsedArgs.Errors.Verify()
+ Assert.Null(parsedArgs.CompilationOptions.DelaySign)
+ End Sub
+
+
+
+ Public Sub OutputVerbose()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Verbose, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Verbose, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/VERBOSE:-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/VERBOSE:-"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose-:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("verbose"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose+:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("verbose"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbOSE:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/verbOSE:"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet", "/verbose", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Verbose, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet", "/verbose-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
+ End Sub
+
+
+
+ Public Sub OutputQuiet()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Quiet, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Quiet, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/QUIET:-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/QUIET:-"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet-:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("quiet"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiet+:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("quiet"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/quiET:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/quiET:"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose", "/quiet", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Quiet, parsedArgs.OutputLevel)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/verbose", "/quiet-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputLevel.Normal, parsedArgs.OutputLevel)
+ End Sub
+
+
+ Public Sub Optimize()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.Optimize)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:[[abcdef]]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("[[abcdef]]"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.CompilationOptions.Optimize) ' default
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:[global]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("[global]", parsedArgs.CompilationOptions.RootNamespace)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OPTIMIZE+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.Optimize)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:foo.[global].bar", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("foo.[global].bar", parsedArgs.CompilationOptions.RootNamespace)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.CompilationOptions.Optimize)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:foo.[bar]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("foo.[bar]", parsedArgs.CompilationOptions.RootNamespace)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize-", "/optimize+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.Optimize)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:foo$", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("foo$"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OPTIMIZE:", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optimize"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:I(", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("I("))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OPTIMIZE+:", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optimize"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:_", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("_"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optimize-:", "a.cs"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optimize"))
+ End Sub
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:[_]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("[_]"))
+
+
+ Public Sub Parallel()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:__.___", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("__.___", parsedArgs.CompilationOptions.RootNamespace)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:[", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("["))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild) ' default
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("]"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/PARALLEL+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/rootnamespace:[]", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadNamespaceName1).WithArguments("[]"))
- End Sub
-
-
- Public Sub Link_SimpleTests()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/link:a", "/link:b,,,,c", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- AssertEx.Equal({"a", "b", "c"},
- parsedArgs.MetadataReferences.
- Where(Function(res) res.Properties.EmbedInteropTypes).
- Select(Function(res) res.Reference))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/Link: ,,, b ,,", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- AssertEx.Equal({" ", " b "},
- parsedArgs.MetadataReferences.
- Where(Function(res) res.Properties.EmbedInteropTypes).
- Select(Function(res) res.Reference))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/l:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("l", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/L", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("l", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/l+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/l+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/link-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/link-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
- End Sub
-
-
- Public Sub Recurse_SimpleTests()
- Dim dir = Temp.CreateDirectory()
- Dim file1 = dir.CreateFile("a.vb")
- Dim file2 = dir.CreateFile("b.vb")
- Dim file3 = dir.CreateFile("c.txt")
- Dim file4 = dir.CreateDirectory("d1").CreateFile("d.txt")
- Dim file5 = dir.CreateDirectory("d2").CreateFile("e.vb")
-
- file1.WriteAllText("")
- file2.WriteAllText("")
- file3.WriteAllText("")
- file4.WriteAllText("")
- file5.WriteAllText("")
-
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/recurse:" & dir.ToString() & "\*.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- AssertEx.Equal({"{DIR}\a.vb", "{DIR}\b.vb", "{DIR}\d2\e.vb"}, parsedArgs.SourceFiles.Select(Function(file) file.Path.Replace(dir.ToString(), "{DIR}")))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"*.vb"}, dir.ToString())
- parsedArgs.Errors.Verify()
- AssertEx.Equal({"{DIR}\a.vb", "{DIR}\b.vb"}, parsedArgs.SourceFiles.Select(Function(file) file.Path.Replace(dir.ToString(), "{DIR}")))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/reCURSE:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("recurse", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/RECURSE: ", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("recurse", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/recurse", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("recurse", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/recurse+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/recurse+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/recurse-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/recurse-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- CleanupAllGeneratedFiles(file1.Path)
- CleanupAllGeneratedFiles(file2.Path)
- CleanupAllGeneratedFiles(file3.Path)
- CleanupAllGeneratedFiles(file4.Path)
- CleanupAllGeneratedFiles(file5.Path)
- End Sub
-
-
-
-
- Public Sub Recurse_SimpleTests2()
- Dim folder = Temp.CreateDirectory()
- Dim file1 = folder.CreateFile("a.cs")
- Dim file2 = folder.CreateFile("b.vb")
- Dim file3 = folder.CreateFile("c.cpp")
- Dim file4 = folder.CreateDirectory("A").CreateFile("A_d.txt")
- Dim file5 = folder.CreateDirectory("B").CreateFile("B_e.vb")
- Dim file6 = folder.CreateDirectory("C").CreateFile("B_f.cs")
-
- file1.WriteAllText("")
- file2.WriteAllText("")
- file3.WriteAllText("")
- file4.WriteAllText("")
- file5.WriteAllText("")
- file6.WriteAllText("")
-
- Dim outWriter As New StringWriter()
- Dim exitCode As Integer = New MockVisualBasicCompiler(Nothing, folder.Path, {"/nologo", "/t:library", "/recurse:.", "b.vb", "/out:abc.dll"}).Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- Assert.Equal("vbc : error BC2014: the value '.' is invalid for option 'recurse'", outWriter.ToString().Trim())
-
- outWriter = New StringWriter()
- exitCode = New MockVisualBasicCompiler(Nothing, folder.Path, {"/nologo", "/t:library", "/recurse:. ", "b.vb", "/out:abc.dll"}).Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- Assert.Equal("vbc : error BC2014: the value '.' is invalid for option 'recurse'", outWriter.ToString().Trim())
-
- outWriter = New StringWriter()
- exitCode = New MockVisualBasicCompiler(Nothing, folder.Path, {"/nologo", "/t:library", "/recurse: . ", "/out:abc.dll"}).Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- Assert.Equal("vbc : error BC2014: the value ' .' is invalid for option 'recurse'|vbc : error BC2008: no input sources specified", outWriter.ToString().Trim().Replace(vbCrLf, "|"))
-
- outWriter = New StringWriter()
- exitCode = New MockVisualBasicCompiler(Nothing, folder.Path, {"/nologo", "/t:library", "/recurse:./.", "/out:abc.dll"}).Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- Assert.Equal("vbc : error BC2014: the value './.' is invalid for option 'recurse'|vbc : error BC2008: no input sources specified", outWriter.ToString().Trim().Replace(vbCrLf, "|"))
-
- Dim args As VisualBasicCommandLineArguments
- Dim resolvedSourceFiles As String()
-
- args = VisualBasicCommandLineParser.Default.Parse({"/recurse:*.cp*", "/recurse:b\*.v*", "/out:a.dll"}, folder.Path)
- args.Errors.Verify()
- resolvedSourceFiles = args.SourceFiles.Select(Function(f) f.Path).ToArray()
- AssertEx.Equal({folder.Path + "\c.cpp", folder.Path + "\b\B_e.vb"}, resolvedSourceFiles)
-
- args = VisualBasicCommandLineParser.Default.Parse({"/recurse:.\\\\\\*.vb", "/out:a.dll"}, folder.Path)
- args.Errors.Verify()
- resolvedSourceFiles = args.SourceFiles.Select(Function(f) f.Path).ToArray()
- Assert.Equal(2, resolvedSourceFiles.Length)
-
- args = VisualBasicCommandLineParser.Default.Parse({"/recurse:.////*.vb", "/out:a.dll"}, folder.Path)
- args.Errors.Verify()
- resolvedSourceFiles = args.SourceFiles.Select(Function(f) f.Path).ToArray()
- Assert.Equal(2, resolvedSourceFiles.Length)
-
- CleanupAllGeneratedFiles(file1.Path)
- CleanupAllGeneratedFiles(file2.Path)
- CleanupAllGeneratedFiles(file3.Path)
- CleanupAllGeneratedFiles(file4.Path)
- CleanupAllGeneratedFiles(file5.Path)
- CleanupAllGeneratedFiles(file6.Path)
- End Sub
-
-
- Public Sub Reference_SimpleTests()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/nostdlib", "/vbruntime-", "/r:a", "/REFERENCE:b,,,,c", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- AssertEx.Equal({"a", "b", "c"},
- parsedArgs.MetadataReferences.
- Where(Function(res) Not res.Properties.EmbedInteropTypes AndAlso Not res.Reference.EndsWith("mscorlib.dll")).
- Select(Function(res) res.Reference))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/Reference: ,,, b ,,", "/nostdlib", "/vbruntime-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- AssertEx.Equal({" ", " b "},
- parsedArgs.MetadataReferences.
- Where(Function(res) Not res.Properties.EmbedInteropTypes AndAlso Not res.Reference.EndsWith("mscorlib.dll")).
- Select(Function(res) res.Reference))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/r:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("r", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/R", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("r", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/reference+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/reference+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/reference-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/reference-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
- End Sub
-
-
- Public Sub ParseAnalyzers()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/a:foo.dll", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(1, parsedArgs.AnalyzerReferences.Length)
- Assert.Equal("foo.dll", parsedArgs.AnalyzerReferences(0).FilePath)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/analyzer:foo.dll", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(1, parsedArgs.AnalyzerReferences.Length)
- Assert.Equal("foo.dll", parsedArgs.AnalyzerReferences(0).FilePath)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/analyzer:""foo.dll""", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(1, parsedArgs.AnalyzerReferences.Length)
- Assert.Equal("foo.dll", parsedArgs.AnalyzerReferences(0).FilePath)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/a:foo.dll,bar.dll", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(2, parsedArgs.AnalyzerReferences.Length)
- Assert.Equal("foo.dll", parsedArgs.AnalyzerReferences(0).FilePath)
- Assert.Equal("bar.dll", parsedArgs.AnalyzerReferences(1).FilePath)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/a:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("a", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/a", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("a", ":"))
- End Sub
-
-
- Public Sub Analyzers_Missing()
- Dim source = "Imports System"
- Dim dir = Temp.CreateDirectory()
-
- Dim file = dir.CreateFile("a.vb")
- file.WriteAllText(source)
-
- Dim outWriter = New StringWriter(CultureInfo.InvariantCulture)
- Dim vbc = New MockVisualBasicCompiler(Nothing, dir.Path, {"/nologo", "/t:library", "/a:missing.dll", "a.vb"})
- Dim exitCode = vbc.Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- Assert.Equal("vbc : error BC2017: could not find library 'missing.dll'", outWriter.ToString().Trim())
-
- CleanupAllGeneratedFiles(file.Path)
- End Sub
-
-
- Public Sub Analyzers_Empty()
- Dim source = "Imports System"
- Dim dir = Temp.CreateDirectory()
-
- Dim file = dir.CreateFile("a.vb")
- file.WriteAllText(source)
-
- Dim outWriter = New StringWriter(CultureInfo.InvariantCulture)
- Dim vbc = New MockVisualBasicCompiler(Nothing, dir.Path, {"/nologo", "/t:library", "/a:" + GetType(Object).Assembly.Location, "a.vb"})
- Dim exitCode = vbc.Run(outWriter, Nothing)
- Assert.Equal(0, exitCode)
- Assert.Equal("vbc : warning BC42377: The assembly " + GetType(Object).Assembly.Location + " does not contain any analyzers.", outWriter.ToString().Trim())
-
-
- CleanupAllGeneratedFiles(file.Path)
- End Sub
-
-
- Public Sub Analyzers_Found()
- Dim source = "Imports System " + vbCrLf + "Public Class Tester" + vbCrLf + "End Class"
-
- Dim dir = Temp.CreateDirectory()
-
- Dim file = dir.CreateFile("a.vb")
- file.WriteAllText(source)
- ' This assembly has a MockDiagnosticAnalyzer type which should get run by this compilation.
- Dim outWriter = New StringWriter(CultureInfo.InvariantCulture)
- Dim vbc = New MockVisualBasicCompiler(Nothing, dir.Path, {"/nologo", "/t:library", "/a:" + Assembly.GetExecutingAssembly().Location, "a.vb"})
- Dim exitCode = vbc.Run(outWriter, Nothing)
- Assert.Equal(0, exitCode)
- ' Diagnostic cannot instantiate
- Assert.True(outWriter.ToString().Contains("warning BC42376"))
- ' Diagnostic is thrown
- Assert.True(outWriter.ToString().Contains("a.vb(2) : warning Test01: Throwing a test1 diagnostic for types declared"))
- Assert.True(outWriter.ToString().Contains("a.vb(2) : warning Test03: Throwing a test3 diagnostic for types declared"))
-
- CleanupAllGeneratedFiles(file.Path)
- End Sub
-
-
- Public Sub Analyzers_WithRuleSet()
- Dim source = "Imports System " + vbCrLf + "Public Class Tester" + vbCrLf + "End Class"
-
- Dim dir = Temp.CreateDirectory()
-
- Dim file = dir.CreateFile("a.vb")
- file.WriteAllText(source)
-
- Dim rulesetSource =
-
-
-
-
-
-
-
-
- Dim ruleSetFile = CreateRuleSetFile(rulesetSource)
-
- Dim outWriter = New StringWriter(CultureInfo.InvariantCulture)
- Dim vbc = New MockVisualBasicCompiler(Nothing, dir.Path, {"/nologo", "/t:library", "/a:" + Assembly.GetExecutingAssembly().Location, "a.vb", "/ruleset:" + ruleSetFile.Path})
- Dim exitCode = vbc.Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- ' Diagnostic cannot instantiate
- Assert.True(outWriter.ToString().Contains("warning BC42376"))
- '' Diagnostic thrown as error
- 'Assert.True(outWriter.ToString().Contains("error Test01"))
- ' Compiler warnings are not suppressed
- Assert.True(outWriter.ToString().Contains("error BC31072"))
- ' Diagnostic is suppressed
- Assert.False(outWriter.ToString().Contains("warning Test03"))
-
- CleanupAllGeneratedFiles(file.Path)
- End Sub
-
-
- Public Sub Analyzers_WithRuleSetIncludeAll()
- Dim source = "Imports System \r\n Public Class Tester \r\n Public Sub Foo() \r\n Dim x As Integer \r\n End Sub \r\n End Class"
-
- Dim dir = Temp.CreateDirectory()
-
- Dim file = dir.CreateFile("a.cs")
- file.WriteAllText(source)
-
- Dim rulesetSource =
-
-
-
-
-
-
-
-
-
- Dim ruleSetFile = CreateRuleSetFile(rulesetSource)
-
- Dim outWriter = New StringWriter(CultureInfo.InvariantCulture)
- Dim vbc = New MockVisualBasicCompiler(Nothing, dir.Path, {"/nologo", "/tlibrary", "/a:" + Assembly.GetExecutingAssembly().Location, "a.vb", "/ruleset:" + ruleSetFile.Path})
- Dim exitCode = vbc.Run(outWriter, Nothing)
- Assert.Equal(1, exitCode)
- ' Compiler warnings as errors
- Assert.True(outWriter.ToString().Contains("error BC42376"))
- Assert.True(outWriter.ToString().Contains("error BC42024"))
- ' User diagnostics not thrown due to compiler errors
- Assert.False(outWriter.ToString().Contains("Test01"))
- Assert.False(outWriter.ToString().Contains("Test03"))
-
- CleanupAllGeneratedFiles(file.Path)
- End Sub
-
- Private Function CreateRuleSetFile(source As XDocument) As TempFile
- Dim dir = Temp.CreateDirectory()
- Dim file = dir.CreateFile("a.ruleset")
- file.WriteAllText(source.ToString())
- Return file
- End Function
-
-
- Public Sub RulesetSwitchPositive()
-
- Dim source =
-
-
-
-
-
-
-
-
-
- Dim file = CreateRuleSetFile(source)
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset:" + file.Path, "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.True(parsedArgs.CompilationOptions.SpecificDiagnosticOptions.ContainsKey("CA1012"))
- Assert.True(parsedArgs.CompilationOptions.SpecificDiagnosticOptions("CA1012") = ReportDiagnostic.Error)
- Assert.True(parsedArgs.CompilationOptions.SpecificDiagnosticOptions.ContainsKey("CA1013"))
- Assert.True(parsedArgs.CompilationOptions.SpecificDiagnosticOptions("CA1013") = ReportDiagnostic.Warn)
- Assert.True(parsedArgs.CompilationOptions.SpecificDiagnosticOptions.ContainsKey("CA1014"))
- Assert.True(parsedArgs.CompilationOptions.SpecificDiagnosticOptions("CA1014") = ReportDiagnostic.Suppress)
- Assert.True(parsedArgs.CompilationOptions.GeneralDiagnosticOption = ReportDiagnostic.Warn)
- End Sub
-
-
- Public Sub RuleSetSwitchQuoted()
- Dim source =
-
-
-
-
-
-
-
-
-
- Dim file = CreateRuleSetFile(source)
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset:" + """" + file.Path + """", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- End Sub
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/PARALLEL-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.CompilationOptions.ConcurrentBuild)
-
- Public Sub RulesetSwitchParseErrors()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("ruleset", ":"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/PArallel-", "/PArallel+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("ruleset", ":"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("parallel"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset:blah", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.ERR_CantReadRulesetFile).WithArguments(Path.Combine(TempRoot.Root, "blah"), "File not found."))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel+:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("parallel"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset:blah;blah.ruleset", "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.ERR_CantReadRulesetFile).WithArguments(Path.Combine(TempRoot.Root, "blah;blah.ruleset"), "File not found."))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/parallel-:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("parallel"))
- Dim file = CreateRuleSetFile(New XDocument())
- parsedArgs = VisualBasicCommandLineParser.Default.Parse(New String() {"/ruleset:" + file.Path, "a.cs"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.ERR_CantReadRulesetFile).WithArguments(file.Path, "Root element is missing."))
- End Sub
-
-
- Public Sub Target_SimpleTests()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:exe", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.ConsoleApplication, parsedArgs.CompilationOptions.OutputKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/P+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/t:module", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.NetModule, parsedArgs.CompilationOptions.OutputKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/P-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:library", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.DynamicallyLinkedLibrary, parsedArgs.CompilationOptions.OutputKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/P-", "/P+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.ConcurrentBuild)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/TARGET:winexe", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.WindowsApplication, parsedArgs.CompilationOptions.OutputKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("p"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:winmdobj", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.WindowsRuntimeMetadata, parsedArgs.CompilationOptions.OutputKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p+:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("p"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:appcontainerexe", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.WindowsRuntimeApplication, parsedArgs.CompilationOptions.OutputKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/p-:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("p"))
+ End Sub
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:winexe", "/T:exe", "/target:module", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(OutputKind.NetModule, parsedArgs.CompilationOptions.OutputKind)
+
+ Public Sub SubsystemVersionTests()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(SubsystemVersion.Create(4, 0), parsedArgs.CompilationOptions.SubsystemVersion)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/t", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("t", ":exe|winexe|library|module|appcontainerexe|winmdobj"))
+ ' wrongly supported subsystem version. CompilationOptions data will be faithful to the user input.
+ ' It is normalized at the time of emit.
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:0.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify() ' no error in Dev11
+ Assert.Equal(SubsystemVersion.Create(0, 0), parsedArgs.CompilationOptions.SubsystemVersion)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("target", ":exe|winexe|library|module|appcontainerexe|winmdobj"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify() ' no error in Dev11
+ Assert.Equal(SubsystemVersion.Create(0, 0), parsedArgs.CompilationOptions.SubsystemVersion)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:xyz", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("xyz", "target"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:3.99", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify() ' no warning in Dev11
+ Assert.Equal(SubsystemVersion.Create(3, 99), parsedArgs.CompilationOptions.SubsystemVersion)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/T+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/T+")) ' TODO: Dev11 reports ERR_ArgumentRequired
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.0", "/subsystemversion:5.333", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(SubsystemVersion.Create(5, 333), parsedArgs.CompilationOptions.SubsystemVersion)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/TARGET-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/TARGET-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
- End Sub
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("subsystemversion", ":"))
-
- Public Sub Utf8Output()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/utf8output", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.Utf8Output)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("subsystemversion", ":"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/utf8output+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(True, parsedArgs.Utf8Output)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/subsystemversion-")) ' TODO: Dev11 reports ERRID.ERR_ArgumentRequired
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/utf8output-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.Utf8Output)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion: ", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("subsystemversion", ":"))
- ' default
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/nologo", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.Utf8Output)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion: 4.1", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments(" 4.1"))
- ' overriding
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/utf8output+", "/utf8output-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(False, parsedArgs.Utf8Output)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4 .0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4 .0"))
- ' errors
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/utf8output:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("utf8output"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4. 0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4. 0"))
- End Sub
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:.", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("."))
-
- Public Sub Debug()
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.None, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4."))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.None, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments(".0"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.Full, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.2 ", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.Full, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:4.65536", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("4.65536"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug+", "/debug-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.None, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:65536.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("65536.0"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:full", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.Full, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/subsystemversion:-4.0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("-4.0"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:FULL", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.Full, parsedArgs.CompilationOptions.DebugInformationKind)
+ ' TODO: incompatibilities: versions lower than '6.2' and 'arm', 'winmdobj', 'appcontainer'
+ End Sub
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:pdbonly", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.PDBOnly, parsedArgs.CompilationOptions.DebugInformationKind)
+
+ Public Sub Codepage()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/CodePage:1200", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal("Unicode", parsedArgs.Encoding.EncodingName)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:PDBONLY", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.PDBOnly, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/CodePage:1200", "/CodePage:65001", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal("Unicode (UTF-8)", parsedArgs.Encoding.EncodingName)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:full", "/debug:pdbonly", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.PDBOnly, parsedArgs.CompilationOptions.DebugInformationKind)
+ ' errors
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:0", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadCodepage).WithArguments("0"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:pdbonly", "/debug:full", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.Full, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:abc", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadCodepage).WithArguments("abc"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:pdbonly", "/debug-", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.None, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:-5", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_BadCodepage).WithArguments("-5"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:pdbonly", "/debug-", "/debug", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.PDBOnly, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage: ", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("codepage", ":"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:pdbonly", "/debug-", "/debug+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal(DebugInformationKind.PDBOnly, parsedArgs.CompilationOptions.DebugInformationKind)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("codepage", ":"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("debug", ":pdbonly|full"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/codepage+")) ' Dev11 reports ERR_ArgumentRequired
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:+", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("+", "debug"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/codepage", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("codepage", ":"))
+ End Sub
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug:invalid", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("invalid", "debug"))
+
+ Public Sub MainTypeName()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/main:A.B.C", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal("A.B.C", parsedArgs.CompilationOptions.MainTypeName)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/debug-:", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("debug"))
+ ' overriding the value
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/Main:A.B.C", "/M:X.Y.Z", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal("X.Y.Z", parsedArgs.CompilationOptions.MainTypeName)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/pdb:something", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/pdb:something"))
- End Sub
-
-
-
- Public Sub ParseOut()
- Const baseDirectory As String = "C:\abc\def\baz"
-
- ' Should preserve fully qualified paths
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:C:\MyFolder\MyBinary.dll", "/t:library", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("MyBinary", parsedArgs.CompilationName)
- Assert.Equal("MyBinary.dll", parsedArgs.OutputFileName)
- Assert.Equal("MyBinary.dll", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal("C:\MyFolder", parsedArgs.OutputDirectory)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:C:\""My Folder""\MyBinary.dll", "/t:library", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("MyBinary", parsedArgs.CompilationName)
- Assert.Equal("MyBinary.dll", parsedArgs.OutputFileName)
- Assert.Equal("MyBinary.dll", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal("C:\My Folder", parsedArgs.OutputDirectory)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:MyBinary.dll", "/t:library", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("MyBinary", parsedArgs.CompilationName)
- Assert.Equal("MyBinary.dll", parsedArgs.OutputFileName)
- Assert.Equal("MyBinary.dll", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:Ignored.dll", "/out:MyBinary.dll", "/t:library", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("MyBinary", parsedArgs.CompilationName)
- Assert.Equal("MyBinary.dll", parsedArgs.OutputFileName)
- Assert.Equal("MyBinary.dll", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:..\MyBinary.dll", "/t:library", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("MyBinary", parsedArgs.CompilationName)
- Assert.Equal("MyBinary.dll", parsedArgs.OutputFileName)
- Assert.Equal("MyBinary.dll", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal("C:\abc\def", parsedArgs.OutputDirectory)
-
- ' not specified: exe
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.exe", parsedArgs.OutputFileName)
- Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- ' not specified: dll
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:library", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.dll", parsedArgs.OutputFileName)
- Assert.Equal("a.dll", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- ' not specified: module
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:module", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Null(parsedArgs.CompilationName)
- Assert.Equal("a.netmodule", parsedArgs.OutputFileName)
- Assert.Equal("a.netmodule", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- ' not specified: appcontainerexe
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:appcontainerexe", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.exe", parsedArgs.OutputFileName)
- Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- ' not specified: winmdobj
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:winmdobj", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify()
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.winmdobj", parsedArgs.OutputFileName)
- Assert.Equal("a.winmdobj", parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- ' drive-relative path:
- Dim currentDrive As Char = Directory.GetCurrentDirectory()(0)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({currentDrive + ":a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments(currentDrive + ":a.vb"))
-
- Assert.Null(parsedArgs.CompilationName)
- Assert.Null(parsedArgs.OutputFileName)
- Assert.Null(parsedArgs.CompilationOptions.ModuleName)
- Assert.Equal(baseDirectory, parsedArgs.OutputDirectory)
-
- ' UNC
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:\\b", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("\\b"))
-
- Assert.Equal("a.exe", parsedArgs.OutputFileName)
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:\\server\share\file.exe", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
-
- Assert.Equal("\\server\share", parsedArgs.OutputDirectory)
- Assert.Equal("file.exe", parsedArgs.OutputFileName)
- Assert.Equal("file", parsedArgs.CompilationName)
- Assert.Equal("file.exe", parsedArgs.CompilationOptions.ModuleName)
-
- ' invalid name
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:a.b" & vbNullChar & "b", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("a.b" & vbNullChar & "b"))
-
- Assert.Equal("a.exe", parsedArgs.OutputFileName)
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
-
- ' Temp Skip: Unicode?
- ' parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:a" & ChrW(&HD800) & "b.dll", "a.vb"}, _baseDirectory)
- ' parsedArgs.Errors.Verify(
- ' Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("a" & ChrW(&HD800) & "b.dll"))
-
- ' Assert.Equal("a.exe", parsedArgs.OutputFileName)
- ' Assert.Equal("a", parsedArgs.CompilationName)
- ' Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
-
- ' Temp Skip: error message changed (path)
- 'parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:"" a.dll""", "a.vb"}, _baseDirectory)
- 'parsedArgs.Errors.Verify(
- ' Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments(" a.dll"))
-
- 'Assert.Equal("a.exe", parsedArgs.OutputFileName)
- 'Assert.Equal("a", parsedArgs.CompilationName)
- 'Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
-
- ' Dev11 reports BC2012: can't open 'a<>.z' for writing
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:""a<>.dll""", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(
- Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments("a<>.dll"))
-
- Assert.Equal("a.exe", parsedArgs.OutputFileName)
- Assert.Equal("a", parsedArgs.CompilationName)
- Assert.Equal("a.exe", parsedArgs.CompilationOptions.ModuleName)
-
- ' bad value
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("out", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OUT:", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("out", ":"))
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out+", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/out+")) ' TODO: Dev11 reports ERR_ArgumentRequired
-
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out-:", "a.vb"}, baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/out-:")) ' TODO: Dev11 reports ERR_ArgumentRequired
- End Sub
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/MAIN: ", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("main", ":"))
+ Assert.Null(parsedArgs.CompilationOptions.MainTypeName) ' EDMAURER Dev11 accepts and MainTypeName is " "
-
- Public Sub ParseOut2()
- ' exe
- Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/out:.x", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
+ ' errors
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/maiN:", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("main", ":"))
- Assert.Equal(".x", parsedArgs.CompilationName)
- Assert.Equal(".x.exe", parsedArgs.OutputFileName)
- Assert.Equal(".x.exe", parsedArgs.CompilationOptions.ModuleName)
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/m", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("m", ":"))
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:winexe", "/out:.x.eXe", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify()
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/m+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.WRN_BadSwitch).WithArguments("/m+")) ' Dev11 reports ERR_ArgumentRequired
- Assert.Equal(".x", parsedArgs.CompilationName)
- Assert.Equal(".x.eXe", parsedArgs.OutputFileName)
- Assert.Equal(".x.eXe", parsedArgs.CompilationOptions.ModuleName)
+ ' incompatibilities ignored by Dev11
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/MAIN:XYZ", "/t:library", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal("XYZ", parsedArgs.CompilationOptions.MainTypeName)
+ Assert.Equal(OutputKind.DynamicallyLinkedLibrary, parsedArgs.CompilationOptions.OutputKind)
- parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/target:winexe", "/out:.exe", "a.vb"}, _baseDirectory)
- parsedArgs.Errors.Verify(Diagnostic(ERRID.FTL_InputFileNameTooLong).WithArguments(".exe"))
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/MAIN:XYZ", "/t:module", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(OutputKind.NetModule, parsedArgs.CompilationOptions.OutputKind)
+ End Sub
+
+
+ Public Sub OptionCompare()
+ Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioncompare"}, _baseDirectory)
+ Assert.Equal(1, parsedArgs.Errors.Length)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optioncompare", ":binary|text"))
+ Assert.Equal(False, parsedArgs.CompilationOptions.OptionCompareText)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioncompare:text", "/optioncompare"}, _baseDirectory)
+ Assert.Equal(1, parsedArgs.Errors.Length)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optioncompare", ":binary|text"))
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionCompareText)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/opTioncompare:Text", "/optioncomparE:bINARY"}, _baseDirectory)
+ Assert.Equal(0, parsedArgs.Errors.Length)
+ Assert.Equal(False, parsedArgs.CompilationOptions.OptionCompareText)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
+ Assert.Equal(0, parsedArgs.Errors.Length)
+ Assert.Equal(False, parsedArgs.CompilationOptions.OptionCompareText)
+ End Sub
+
+
+ Public Sub OptionExplicit()
+ Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONexplicit"}, _baseDirectory)
+ Assert.Equal(0, parsedArgs.Errors.Length)
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONexplicit:+"}, _baseDirectory)
+ Assert.Equal(1, parsedArgs.Errors.Length)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optionexplicit"))
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONexplicit-:"}, _baseDirectory)
+ Assert.Equal(1, parsedArgs.Errors.Length)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optionexplicit"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optionexplicit+", "/optiONexplicit-:"}, _baseDirectory)
+ Assert.Equal(1, parsedArgs.Errors.Length)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optionexplicit"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optionexplicit+", "/optiONexplicit-", "/optiONexpliCIT+"}, _baseDirectory)
+ Assert.Equal(0, parsedArgs.Errors.Length)
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
+ Assert.Equal(0, parsedArgs.Errors.Length)
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionExplicit)
+ End Sub
+
+
+ Public Sub OptionInfer()
+ Dim parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optiONinfer"}, _baseDirectory)
+ Assert.Equal(0, parsedArgs.Errors.Length)
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionInfer)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/OptionInfer:+"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optioninfer"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/OPTIONinfer-:"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optioninfer"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioninfer+", "/optioninFER-:"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_SwitchNeedsBool).WithArguments("optioninfer"))
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/optioninfer+", "/optioninfeR-", "/OptionInfer+"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(True, parsedArgs.CompilationOptions.OptionInfer)
+
+ parsedArgs = VisualBasicCommandLineParser.Interactive.Parse({"/d:a=1"}, _baseDirectory) ' test default value
+ parsedArgs.Errors.Verify()
+ Assert.Equal(False, parsedArgs.CompilationOptions.OptionInfer)
+ End Sub
+
+ Const VBC_VER As Double = 11.0
+
+
+ Public Sub TestDefine()
+ TestDefines({"/D:a=True,b=1", "a.vb"},
+ {"a", True},
+ {"b", 1},
+ {"TARGET", "exe"},
+ {"VBC_VER", VBC_VER})
+
+ TestDefines({"/D:a=True,b=1", "/define:a=""123"",b=False", "a.vb"},
+ {"a", "123"},
+ {"b", False},
+ {"TARGET", "exe"},
+ {"VBC_VER", VBC_VER})
+
+ TestDefines({"/D:a=""\\\\a"",b=""\\\\\b""", "a.vb"},
+ {"a", "\\\\a"},
+ {"b", "\\\\\b"},
+ {"TARGET", "exe"},
+ {"VBC_VER", VBC_VER})
+
+ TestDefines({"/define:DEBUG", "a.vb"},
+ {"DEBUG", True},
+ {"TARGET", "exe"},
+ {"VBC_VER", VBC_VER})
+
+ TestDefines({"/D:TARGET=True,VBC_VER=1", "a.vb"},
+ {"TARGET", True},
+ {"VBC_VER", 1})
+ End Sub
+
+ Private Sub TestDefines(args As IEnumerable(Of String), ParamArray symbols As Object()())
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, _baseDirectory)
+ Assert.False(parsedArgs.Errors.Any)
+ Assert.Equal(symbols.Length, parsedArgs.ParseOptions.PreprocessorSymbols.Length)
+ Dim sortedDefines = parsedArgs.ParseOptions.
+ PreprocessorSymbols.Select(
+ Function(d) New With {d.Key, d.Value}).OrderBy(Function(o) o.Key)
+
+ For i = 0 To symbols.Length - 1
+ Assert.Equal(symbols(i)(0), sortedDefines(i).Key)
+ Assert.Equal(symbols(i)(1), sortedDefines(i).Value)
+ Next
+ End Sub
+
+
+ Public Sub OptionStrict()
+ Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionStrict", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(VisualBasic.OptionStrict.On, parsedArgs.CompilationOptions.OptionStrict)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionStrict+", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(VisualBasic.OptionStrict.On, parsedArgs.CompilationOptions.OptionStrict)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionStrict-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(VisualBasic.OptionStrict.Off, parsedArgs.CompilationOptions.OptionStrict)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OptionStrict:cusTom", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(VisualBasic.OptionStrict.Custom, parsedArgs.CompilationOptions.OptionStrict)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/OptionStrict:cusTom", "/optionstrict-", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(VisualBasic.OptionStrict.Off, parsedArgs.CompilationOptions.OptionStrict)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionstrict-", "/OptionStrict:cusTom", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify()
+ Assert.Equal(VisualBasic.OptionStrict.Custom, parsedArgs.CompilationOptions.OptionStrict)
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionstrict:", "/OptionStrict:cusTom", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optionstrict", ":custom"))
+
+ parsedArgs = VisualBasicCommandLineParser.Default.Parse({"/optionstrict:xxx", "a.vb"}, _baseDirectory)
+ parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("optionstrict", ":custom"))
+ End Sub
+
+
+
+
+