提交 e863aad6 编写于 作者: T TomasMatousek

More robust command line compiler testing

Previously the command line tests were looking in various directories for csc.exe/vbc.exe. Instead, add a reference to csc/vbc project to the command line unit test assembly, so that we always test what we build and not depend on directories outside of Roslyn.
To make it easy to test the default .rsp file this change links it into the command line unit test project and includes it to resources. The tests then extract the .rsp from the resources and save it to a temp file for testing.
 (changeset 1285693)
上级 f5073989
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
<ProjectReference Include="..\..\csc\csc.csproj"> <ProjectReference Include="..\..\csc\csc.csproj">
<Project>{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}</Project> <Project>{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}</Project>
<Name>csc</Name> <Name>csc</Name>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\Test\Utilities\TestUtilities.csproj"> <ProjectReference Include="..\..\..\..\Test\Utilities\TestUtilities.csproj">
<Project>{76C6F005-C89D-4348-BB4A-391898DBEB52}</Project> <Project>{76C6F005-C89D-4348-BB4A-391898DBEB52}</Project>
...@@ -98,12 +97,27 @@ ...@@ -98,12 +97,27 @@
<Compile Include="AssemblyAttributes.cs" /> <Compile Include="AssemblyAttributes.cs" />
<Compile Include="CommandLineDiagnosticFormatterTests.cs" /> <Compile Include="CommandLineDiagnosticFormatterTests.cs" />
<Compile Include="CommandLineTests.cs" /> <Compile Include="CommandLineTests.cs" />
<Compile Include="CommandLineTestResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>CommandLineTestResources.resx</DependentUpon>
</Compile>
<Compile Include="TouchedFileLoggingTests.cs" /> <Compile Include="TouchedFileLoggingTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<None Include="..\..\csc\csc.rsp">
<Link>csc.rsp</Link>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CommandLineTestResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>CommandLineTestResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ImportGroup Label="Targets"> <ImportGroup Label="Targets">
<Import Project="..\..\..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" /> <Import Project="..\..\..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
......
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] csc_rsp {
get {
object obj = ResourceManager.GetObject("csc_rsp", resourceCulture);
return ((byte[])(obj));
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="csc_rsp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\csc\csc.rsp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
...@@ -16,18 +17,18 @@ ...@@ -16,18 +17,18 @@
using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers;
using Roslyn.Test.Utilities; using Roslyn.Test.Utilities;
using Roslyn.Utilities; using Roslyn.Utilities;
using Xunit; using Xunit;
using ProprietaryTestResources = Microsoft.CodeAnalysis.Test.Resources.Proprietary; 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 public class CommandLineTests : CSharpTestBase
{ {
private static readonly string CSharpCompilerExecutable = typeof(Microsoft.CodeAnalysis.CSharp.CommandLine.Csc).Assembly.Location;
private readonly string baseDirectory = TempRoot.Root; private readonly string baseDirectory = TempRoot.Root;
private class TestCommandLineParser : CSharpCommandLineParser private class TestCommandLineParser : CSharpCommandLineParser
...@@ -66,7 +67,14 @@ internal override TextReader CreateTextFileReader(string fullPath) ...@@ -66,7 +67,14 @@ internal override TextReader CreateTextFileReader(string fullPath)
return new StringReader(responseFiles[fullPath]); return new StringReader(responseFiles[fullPath]);
} }
} }
[Fact]
[WorkItem(946954)]
public void CompilerBinariesAreAnyCPU()
{
Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(CSharpCompilerExecutable).ProcessorArchitecture);
}
[Fact] [Fact]
public void ResponseFiles1() public void ResponseFiles1()
{ {
...@@ -4681,7 +4689,7 @@ public void NoStdLib() ...@@ -4681,7 +4689,7 @@ public void NoStdLib()
private string GetDefaultResponseFilePath() 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")] [Fact, WorkItem(530359, "DevDiv")]
...@@ -5106,7 +5114,7 @@ public static void Main() ...@@ -5106,7 +5114,7 @@ public static void Main()
public void DefaultResponseFile() public void DefaultResponseFile()
{ {
MockCSharpCompiler csc = new MockCSharpCompiler(GetDefaultResponseFilePath(), baseDirectory, new string[0]); 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, typeof(object).Assembly.Location,
"Accessibility.dll", "Accessibility.dll",
......
// 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. // 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;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell.Interop;
namespace RoslynCsc namespace Microsoft.CodeAnalysis.CSharp.CommandLine
{ {
internal sealed class Csc : CSharpCompiler internal sealed class Csc : CSharpCompiler
{ {
......
// 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. // 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 Microsoft.CodeAnalysis.CSharp.CommandLine
namespace RoslynCsc
{ {
class Program class Program
{ {
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}</ProjectGuid> <ProjectGuid>{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>RoslynCsc</RootNamespace> <RootNamespace>Microsoft.CodeAnalysis.CSharp.CommandLine</RootNamespace>
<AssemblyName>csc</AssemblyName> <AssemblyName>csc</AssemblyName>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<LargeAddressAware>true</LargeAddressAware> <LargeAddressAware>true</LargeAddressAware>
<StartupObject>RoslynCsc.Program</StartupObject> <StartupObject>Microsoft.CodeAnalysis.CSharp.CommandLine.Program</StartupObject>
<StyleCopEnabled>false</StyleCopEnabled> <StyleCopEnabled>false</StyleCopEnabled>
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir> <SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
......
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
<InternalsVisibleTo Include="vbi" /> <InternalsVisibleTo Include="vbi" />
<InternalsVisibleTo Include="VBCSCompiler" /> <InternalsVisibleTo Include="VBCSCompiler" />
<InternalsVisibleToTest Include="MdReaderPerf" /> <InternalsVisibleToTest Include="MdReaderPerf" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CompilerServer.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.CommandLine.UnitTests" /> <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.CommandLine.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Emit.UnitTests" /> <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Emit.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.EnC.UnitTests" /> <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.EnC.UnitTests" />
......
...@@ -35,7 +35,178 @@ public override void Dispose() ...@@ -35,7 +35,178 @@ public override void Dispose()
base.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;
}
}
/// <summary>
/// Given a binary to look for, determines which is the first to actually exist on the filesystem.
/// </summary>
/// <param name="binaryFile">The binary file name that may exist in the system at <see cref="TestBase.ApplicationDirectory"/>, <see cref="TestBase.WorkingDirectory"/>, or <see cref="TestBase.MSBuildDirectory"/>.</param>
/// <returns>The binary which had the highest priority and was found.</returns>
protected static string FindBinary(string binaryFile)
{
IEnumerable<string> searchPaths = new[] {
Path.Combine(BinariesDirectory, binaryFile),
Path.Combine(ApplicationDirectory, binaryFile),
Path.Combine(WorkingDirectory, binaryFile),
Path.Combine(MSBuildDirectory, binaryFile)
};
return FindBinary(searchPaths);
}
/// <summary>
/// Given a list of binaries to look for, determines which is the first to actually appear on the Filesystem.
/// </summary>
/// <param name="binaryPriority">A list of binary file names that may exist in the system.</param>
/// <returns>The binary which had the highest priority and was found.</returns>
private static string FindBinary(IEnumerable<string> 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<string, string> AddForLoggingEnvironmentVars(Dictionary<string, string> vars) private Dictionary<string, string> AddForLoggingEnvironmentVars(Dictionary<string, string> vars)
{ {
var dict = vars == null ? new Dictionary<string, string>() : vars; var dict = vars == null ? new Dictionary<string, string>() : vars;
...@@ -163,11 +334,7 @@ static void Main() ...@@ -163,11 +334,7 @@ static void Main()
[WorkItem(946954)] [WorkItem(946954)]
public void CompilerBinariesAreAnyCPU() public void CompilerBinariesAreAnyCPU()
{ {
foreach (var dllPath in new[] { CSharpCompilerExecutable, BasicCompilerExecutable, CompilerServerExecutable }) Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(CompilerServerExecutable).ProcessorArchitecture);
{
var assemblyName = AssemblyName.GetAssemblyName(dllPath);
Assert.Equal(ProcessorArchitecture.MSIL, assemblyName.ProcessorArchitecture);
}
} }
/// <summary> /// <summary>
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
<OutDir>..\..\..\..\Binaries\$(Configuration)\</OutDir> <OutDir>..\..\..\..\Binaries\$(Configuration)\</OutDir>
</PropertyGroup> </PropertyGroup>
<ItemGroup Label="Project References"> <ItemGroup Label="Project References">
<ProjectReference Include="..\Desktop\CodeAnalysis.Desktop.csproj">
<Project>{dfa21ca1-7f96-47ee-940c-069858e81727}</Project>
<Name>CodeAnalysis.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\VBCSCompiler\VBCSCompiler.csproj"> <ProjectReference Include="..\VBCSCompiler\VBCSCompiler.csproj">
<Project>{9508F118-F62E-4C16-A6F4-7C3B56E166AD}</Project> <Project>{9508F118-F62E-4C16-A6F4-7C3B56E166AD}</Project>
<Name>VBCSCompiler</Name> <Name>VBCSCompiler</Name>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<Platform Condition="'$(Platform)' == ''">x86</Platform> <Platform Condition="'$(Platform)' == ''">x86</Platform>
<ProjectGuid>{E3B32027-3362-41DF-9172-4D3B623F42A5}</ProjectGuid> <ProjectGuid>{E3B32027-3362-41DF-9172-4D3B623F42A5}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.VisualBasic.UnitTests</RootNamespace> <RootNamespace></RootNamespace>
<AssemblyName>Roslyn.Compilers.VisualBasic.CommandLine.UnitTests</AssemblyName> <AssemblyName>Roslyn.Compilers.VisualBasic.CommandLine.UnitTests</AssemblyName>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks> <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
...@@ -139,6 +139,11 @@ ...@@ -139,6 +139,11 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="CommandLineTestResources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>CommandLineTestResources.resx</DependentUpon>
</Compile>
<Compile Include="TouchedFileLoggingTests.vb" /> <Compile Include="TouchedFileLoggingTests.vb" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
...@@ -148,8 +153,15 @@ ...@@ -148,8 +153,15 @@
<CustomToolNamespace>My.Resources</CustomToolNamespace> <CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="CommandLineTestResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>CommandLineTestResources.Designer.vb</LastGenOutput>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\vbc\vbc.rsp">
<Link>vbc.rsp</Link>
</None>
<None Include="My Project\Application.myapp"> <None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator> <Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput> <LastGenOutput>Application.Designer.vb</LastGenOutput>
......
' 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. ' 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
Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities Imports Roslyn.Test.Utilities
Imports Xunit Imports Xunit
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
Public Class CommandLineArgumentsTests Public Class CommandLineArgumentsTests
Inherits BasicTestBase Inherits BasicTestBase
......
' 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. ' 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.Reflection
Imports System.Collections.Generic Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers
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 Roslyn.Test.Utilities Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
Imports Xunit Imports Xunit
Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers
Partial Public Class CommandLineTests Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
<Fact, WorkItem(530256, "DevDiv")>
Public Sub WarnAsErrorPrecedence1() Partial Public Class CommandLineTests
Dim src As String = Temp.CreateFile().WriteAllText(<text>
<Fact, WorkItem(530256, "DevDiv")>
Public Sub WarnAsErrorPrecedence1()
Dim src As String = Temp.CreateFile().WriteAllText("
Imports System
Module Module1 Module Module1
Sub Main() Sub Main()
Dim x Dim x
Console.WriteLine(x.ToString) Console.WriteLine(x.ToString)
End Sub End Sub
End Module End Module
</text>.Value).Path ").Path
Dim tempBinary = Temp.CreateFile() Dim tempBinary = Temp.CreateFile()
Dim tempLog = Temp.CreateFile() Dim tempLog = Temp.CreateFile()
Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /warnaserror+ /warnaserror- /out:" & tempBinary.Path & " " & src & " > " & tempLog.Path, expectedRetCode:=0) Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /warnaserror+ /warnaserror- /out:" & tempBinary.Path & " " & src & " > " & tempLog.Path, expectedRetCode:=0)
Assert.Equal("", output.Trim()) Assert.Equal("", output.Trim())
'See bug 15593. This is not strictly a 'breaking' change. '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 Dev11, /warnaserror+ trumps /warnaserror- in the above case and warnings are reported as errors.
'In Roslyn, /warnaserror- (i.e. last one) wins. 'In Roslyn, /warnaserror- (i.e. last one) wins.
Assert.Equal(<text> Assert.Equal(<text>
SRC.VB(5) : warning BC42104: Variable 'x' is used before it has been assigned a value. A null reference exception could result at runtime. 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) Console.WriteLine(x.ToString)
~ ~
</text>.Value.Trim().Replace(vbLf, vbCrLf), tempLog.ReadAllText().Trim().Replace(src, "SRC.VB")) </text>.Value.Trim().Replace(vbLf, vbCrLf), tempLog.ReadAllText().Trim().Replace(src, "SRC.VB"))
CleanupAllGeneratedFiles(src) CleanupAllGeneratedFiles(src)
CleanupAllGeneratedFiles(tempBinary.Path) CleanupAllGeneratedFiles(tempBinary.Path)
CleanupAllGeneratedFiles(tempLog.Path) CleanupAllGeneratedFiles(tempLog.Path)
End Sub End Sub
<Fact, WorkItem(530668, "DevDiv")> <Fact, WorkItem(530668, "DevDiv")>
Public Sub WarnAsErrorPrecedence2() Public Sub WarnAsErrorPrecedence2()
Dim src As String = Temp.CreateFile().WriteAllText(<text> Dim src As String = Temp.CreateFile().WriteAllText(<text>
Module M1 Module M1
Sub Main Sub Main
End Sub End Sub
...@@ -57,15 +53,15 @@ Module M1 ...@@ -57,15 +53,15 @@ Module M1
End Sub End Sub
End Module End Module
</text>.Value).Path </text>.Value).Path
Dim tempOut = Temp.CreateFile() Dim tempOut = Temp.CreateFile()
Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /nowarn:41008 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1) Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /nowarn:41008 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1)
Assert.Equal("", output.Trim()) Assert.Equal("", output.Trim())
'See bug 16673. 'See bug 16673.
'In Dev11, /warnaserror+ does not come into effect strangely and the code only reports warnings. '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. 'In Roslyn, /warnaserror+ does come into effect and the code reports the warnings as errors.
Assert.Equal(<text> Assert.Equal(<text>
SRC.VB(6) : error BC42017: Late bound resolution; runtime errors could occur. SRC.VB(6) : error BC42017: Late bound resolution; runtime errors could occur.
if (a.Something &lt;&gt; 2) if (a.Something &lt;&gt; 2)
...@@ -83,11 +79,11 @@ SRC.VB(6) : error BC42016: Implicit conversion from 'Object' to 'Boolean'. ...@@ -83,11 +79,11 @@ SRC.VB(6) : error BC42016: Implicit conversion from 'Object' to 'Boolean'.
if (a.Something &lt;&gt; 2) if (a.Something &lt;&gt; 2)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
</text>.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB")) </text>.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB"))
End Sub End Sub
<Fact, WorkItem(530668, "DevDiv")> <Fact, WorkItem(530668, "DevDiv")>
Public Sub WarnAsErrorPrecedence3() Public Sub WarnAsErrorPrecedence3()
Dim src As String = Temp.CreateFile().WriteAllText(<text> Dim src As String = Temp.CreateFile().WriteAllText(<text>
Module M1 Module M1
Sub Main Sub Main
End Sub End Sub
...@@ -97,15 +93,15 @@ Module M1 ...@@ -97,15 +93,15 @@ Module M1
End Sub End Sub
End Module End Module
</text>.Value).Path </text>.Value).Path
Dim tempOut = Temp.CreateFile() Dim tempOut = Temp.CreateFile()
Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /warnaserror-:42025 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1) Dim output = RunAndGetOutput("cmd", "/C """ & BasicCompilerExecutable & """ /nologo /optionstrict:custom /warnaserror-:42025 /warnaserror+ " & src & " > " & tempOut.Path, expectedRetCode:=1)
Assert.Equal("", output.Trim()) Assert.Equal("", output.Trim())
'See bug 16673. 'See bug 16673.
'In Dev11, /warnaserror+ does not come into effect strangely and the code only reports warnings. '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. 'In Roslyn, /warnaserror+ does come into effect and the code reports the warnings as errors.
Assert.Equal(<text> Assert.Equal(<text>
SRC.VB(6) : error BC42017: Late bound resolution; runtime errors could occur. SRC.VB(6) : error BC42017: Late bound resolution; runtime errors could occur.
if (a.Something &lt;&gt; 2) if (a.Something &lt;&gt; 2)
...@@ -124,7 +120,8 @@ SRC.VB(6) : error BC42016: Implicit conversion from 'Object' to 'Boolean'. ...@@ -124,7 +120,8 @@ SRC.VB(6) : error BC42016: Implicit conversion from 'Object' to 'Boolean'.
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
</text>.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB")) </text>.Value.Trim().Replace(vbLf, vbCrLf), tempOut.ReadAllText().Trim().Replace(src, "SRC.VB"))
CleanupAllGeneratedFiles(src) CleanupAllGeneratedFiles(src)
CleanupAllGeneratedFiles(tempOut.Path) CleanupAllGeneratedFiles(tempOut.Path)
End Sub End Sub
End Class End Class
End Namespace
'------------------------------------------------------------------------------
' <auto-generated>
' 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.
' </auto-generated>
'------------------------------------------------------------------------------
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.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Class CommandLineTestResources
Private Shared resourceMan As Global.System.Resources.ResourceManager
Private Shared resourceCulture As Global.System.Globalization.CultureInfo
<Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
Friend Sub New()
MyBase.New
End Sub
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
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
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Shared Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
'''<summary>
''' Looks up a localized resource of type System.Byte[].
'''</summary>
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
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="vbc_rsp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\vbc\vbc.rsp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
\ No newline at end of file
...@@ -39,7 +39,7 @@ Namespace My.Resources ...@@ -39,7 +39,7 @@ Namespace My.Resources
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get Get
If Object.ReferenceEquals(resourceMan, Nothing) Then If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Microsoft.CodeAnalysis.VisualBasic.UnitTests.Resources", GetType(Resources).Assembly) Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Resources", GetType(Resources).Assembly)
resourceMan = temp resourceMan = temp
End If End If
Return resourceMan Return resourceMan
......
...@@ -15,7 +15,7 @@ Option Explicit On ...@@ -15,7 +15,7 @@ Option Explicit On
Namespace My Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0"), _ Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase Inherits Global.System.Configuration.ApplicationSettingsBase
...@@ -64,9 +64,9 @@ Namespace My ...@@ -64,9 +64,9 @@ Namespace My
Friend Module MySettingsProperty Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.Microsoft.CodeAnalysis.VisualBasic.UnitTests.My.MySettings Friend ReadOnly Property Settings() As Global.My.MySettings
Get Get
Return Global.Microsoft.CodeAnalysis.VisualBasic.UnitTests.My.MySettings.Default Return Global.My.MySettings.Default
End Get End Get
End Property End Property
End Module End Module
......
' 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. ' 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 Microsoft.CodeAnalysis.CompilerServer
Imports System.Globalization Imports System.Globalization
Imports System.IO Imports System.IO
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Xunit
Imports System.Runtime.InteropServices Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.CompilerServer
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers Imports Microsoft.CodeAnalysis.Test.Utilities.SharedResourceHelpers
Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
Imports Xunit
Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests
......
'------------------------------------------------------------------------------ '------------------------------------------------------------------------------
' <auto-generated> ' <auto-generated>
' This code was generated by a tool. ' This code was generated by a tool.
' Runtime Version:4.0.30319.1 ' Runtime Version:4.0.30319.1
...@@ -14,13 +14,13 @@ Option Explicit On ...@@ -14,13 +14,13 @@ Option Explicit On
Namespace My Namespace My
<System.Runtime.CompilerServices.CompilerGenerated(), _ <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
CodeDom.Compiler.GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _ Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0"), _
ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Advanced)> _ Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings Partial Friend NotInheritable Class MySettings
Inherits Configuration.ApplicationSettingsBase Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings Auto-Save Functionality" #Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then #If _MyType = "WindowsForms" Then
...@@ -59,14 +59,14 @@ End Namespace ...@@ -59,14 +59,14 @@ End Namespace
Namespace My Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _ <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
DebuggerNonUserCode(), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
System.Runtime.CompilerServices.CompilerGenerated()> _ Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty Friend Module MySettingsProperty
<ComponentModel.Design.HelpKeyword("My.Settings")> _ <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As MySettings Friend ReadOnly Property Settings() As Global.My.MySettings
Get Get
Return MySettings.Default Return Global.My.MySettings.Default
End Get End Get
End Property End Property
End Module End Module
......
' 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. ' 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 Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine
Friend Module Program
Friend Module Program Function Main(args As String()) As Integer
Function Main(args As String()) As Integer Return Vbc.Run(args)
Return Vbc.Run(args) End Function
End Function End Module
End Module End Namespace
\ No newline at end of file
' 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. ' 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.IO Imports System.IO
Imports System.Reflection
Imports System.Text Imports System.Text
Imports System.Threading
Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.VisualStudio.Shell.Interop Imports Microsoft.VisualStudio.Shell.Interop
Friend NotInheritable Class Vbc Namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine
Inherits VisualBasicCompiler
Friend Sub New(responseFile As String, baseDirectory As String, args As String()) Friend NotInheritable Class Vbc
MyBase.New(VisualBasicCommandLineParser.Default, responseFile, args, baseDirectory, Environment.GetEnvironmentVariable("LIB")) Inherits VisualBasicCompiler
End Sub
Overloads Shared Function Run(args As String()) As Integer Friend Sub New(responseFile As String, baseDirectory As String, args As String())
MyBase.New(VisualBasicCommandLineParser.Default, responseFile, args, baseDirectory, Environment.GetEnvironmentVariable("LIB"))
End Sub
Dim compiler = New Vbc(BasicResponseFileName, Directory.GetCurrentDirectory(), args) Overloads Shared Function Run(args As String()) As Integer
CompilerFatalError.Handler = AddressOf FailFast.OnFatalException Dim compiler = New Vbc(BasicResponseFileName, Directory.GetCurrentDirectory(), args)
' We store original encoding and restore it later to revert CompilerFatalError.Handler = AddressOf FailFast.OnFatalException
' the changes that might be done by /utf8output options
' NOTE: original encoding may not be restored if process terminated ' We store original encoding and restore it later to revert
Dim origEncoding = Console.OutputEncoding ' the changes that might be done by /utf8output options
Try ' NOTE: original encoding may not be restored if process terminated
If compiler.Arguments.Utf8Output AndAlso Console.IsOutputRedirected Then Dim origEncoding = Console.OutputEncoding
Console.OutputEncoding = Encoding.UTF8
End If
Return compiler.Run(cancellationToken:=Nothing, consoleOutput:=Console.Out)
Finally
Try Try
Console.OutputEncoding = origEncoding If compiler.Arguments.Utf8Output AndAlso Console.IsOutputRedirected Then
Catch Console.OutputEncoding = Encoding.UTF8
'Try to reset the output encoding, ignore if we can't End If
Return compiler.Run(cancellationToken:=Nothing, consoleOutput:=Console.Out)
Finally
Try
Console.OutputEncoding = origEncoding
Catch
'Try to reset the output encoding, ignore if we can't
End Try
End Try End Try
End Try
End Function
Protected Overrides Function GetSqmAppID() As UInt32
Return SqmServiceProvider.BASIC_APPID
End Function
Protected Overrides Sub CompilerSpecificSqm(sqm As IVsSqmMulti, sqmSession As UInt32) End Function
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, CType(SqmServiceProvider.CompilerType.Compiler, UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_LANGUAGEVERSION, CType(Arguments.ParseOptions.LanguageVersion, UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, CType(If(Arguments.CompilationOptions.GeneralDiagnosticOption = ReportDiagnostic.Suppress, 1, 0), UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_EMBEDVBCORE, CType(If(Arguments.CompilationOptions.EmbedVbCoreRuntime, 1, 0), UInt32))
' Project complexity # of source files, # of references Protected Overrides Function GetSqmAppID() As UInt32
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SOURCES, CType(Arguments.SourceFiles.Count(), UInt32)) Return SqmServiceProvider.BASIC_APPID
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_REFERENCES, CType(Arguments.ReferencePaths.Count(), UInt32)) End Function
End Sub
End Class Protected Overrides Sub CompilerSpecificSqm(sqm As IVsSqmMulti, sqmSession As UInt32)
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, CType(SqmServiceProvider.CompilerType.Compiler, UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_LANGUAGEVERSION, CType(Arguments.ParseOptions.LanguageVersion, UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, CType(If(Arguments.CompilationOptions.GeneralDiagnosticOption = ReportDiagnostic.Suppress, 1, 0), UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_EMBEDVBCORE, CType(If(Arguments.CompilationOptions.EmbedVbCoreRuntime, 1, 0), UInt32))
' Project complexity # of source files, # of references
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SOURCES, CType(Arguments.SourceFiles.Count(), UInt32))
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_REFERENCES, CType(Arguments.ReferencePaths.Count(), UInt32))
End Sub
End Class
End Namespace
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{2AC2755D-9437-4271-BBDE-1A3795A0C320}</ProjectGuid> <ProjectGuid>{2AC2755D-9437-4271-BBDE-1A3795A0C320}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<StartupObject>RoslynVbc.Program</StartupObject> <StartupObject>Microsoft.CodeAnalysis.VisualBasic.CommandLine.Program</StartupObject>
<RootNamespace>RoslynVbc</RootNamespace> <RootNamespace></RootNamespace>
<AssemblyName>vbc</AssemblyName> <AssemblyName>vbc</AssemblyName>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
......
...@@ -798,220 +798,5 @@ public static void VerifySerializability<T>(T obj) ...@@ -798,220 +798,5 @@ public static void VerifySerializability<T>(T obj)
} }
#endregion #endregion
#region Helper Methods
/// <summary>
/// Given a binary to look for, determines which is the first to actually exist on the filesystem.
/// </summary>
/// <param name="binaryFile">The binary file name that may exist in the system at <see cref="TestBase.ApplicationDirectory"/>, <see cref="TestBase.WorkingDirectory"/>, or <see cref="TestBase.MSBuildDirectory"/>.</param>
/// <returns>The binary which had the highest priority and was found.</returns>
private static string FindBinary(string binaryFile)
{
IEnumerable<string> searchPaths = new[] {
Path.Combine(BinariesDirectory, binaryFile),
Path.Combine(ApplicationDirectory, binaryFile),
Path.Combine(WorkingDirectory, binaryFile),
Path.Combine(MSBuildDirectory, binaryFile)
};
return FindBinary(searchPaths);
}
/// <summary>
/// Given a list of binaries to look for, determines which is the first to actually appear on the Filesystem.
/// </summary>
/// <param name="binaryPriority">A list of binary file names that may exist in the system.</param>
/// <returns>The binary which had the highest priority and was found.</returns>
private static string FindBinary(IEnumerable<string> 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;
}
}
private static string workingDirectory;
protected static string WorkingDirectory
{
get
{
return Environment.CurrentDirectory;
}
}
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;
}
}
private static string frameworkDirectory;
protected static string FrameworkDirectory
{
get
{
if (frameworkDirectory == null)
{
frameworkDirectory = Path.GetDirectoryName(typeof(object).Assembly.Location);
}
return frameworkDirectory;
}
}
private static string csharpCompilerExecutable;
protected static string CSharpCompilerExecutable
{
get
{
if (csharpCompilerExecutable == null)
{
var foundCompiler = FindBinary("csc.exe");
if (string.IsNullOrEmpty(foundCompiler))
{
foundCompiler = "csc.exe";
}
csharpCompilerExecutable = foundCompiler;
}
return csharpCompilerExecutable;
}
}
private static string csharpCompilerClientExecutable;
protected static string CSharpCompilerClientExecutable
{
get
{
if (csharpCompilerClientExecutable == null)
{
var foundCompiler = FindBinary("csc2.exe");
csharpCompilerClientExecutable = foundCompiler;
}
return csharpCompilerClientExecutable;
}
}
private static string basicCompilerExecutable;
protected static string BasicCompilerExecutable
{
get
{
if (basicCompilerExecutable == null)
{
var foundCompiler = FindBinary("vbc.exe");
if (string.IsNullOrEmpty(foundCompiler))
{
foundCompiler = "vbc.exe";
}
basicCompilerExecutable = foundCompiler;
}
return basicCompilerExecutable;
}
}
private static string basicCompilerClientExecutable;
protected static string BasicCompilerClientExecutable
{
get
{
if (basicCompilerClientExecutable == null)
{
var foundCompiler = FindBinary("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;
}
}
#endregion
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册