提交 24f1af71 编写于 作者: J Jared Parsons

Refactor C# test libraries

Similar change as to TestUtilities.  Insteading of having two
independent projects with shared sources there are now a portable and
desktop only version.  The desktop version references the portable one.
上级 4332186d
......@@ -22,6 +22,10 @@
<Project>{7a4b2176-7bfd-4b75-a61a-e25a1fdd0a1e}</Project>
<Name>CSharpCompilerTestUtilities.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\csc\csc.csproj">
<Project>{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}</Project>
<Name>csc</Name>
......
......@@ -42,6 +42,10 @@
<Project>{7a4b2176-7bfd-4b75-a61a-e25a1fdd0a1e}</Project>
<Name>CSharpCompilerTestUtilities.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\VisualBasic\Portable\BasicCodeAnalysis.vbproj">
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name>
......
......@@ -38,6 +38,10 @@
<Project>{7a4b2176-7bfd-4b75-a61a-e25a1fdd0a1e}</Project>
<Name>CSharpCompilerTestUtilities.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\VisualBasic\Portable\BasicCodeAnalysis.vbproj">
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name>
......
......@@ -38,6 +38,10 @@
<Project>{7a4b2176-7bfd-4b75-a61a-e25a1fdd0a1e}</Project>
<Name>CSharpCompilerTestUtilities.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\VisualBasic\Portable\BasicCodeAnalysis.vbproj">
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name>
......
......@@ -47,6 +47,10 @@
<Project>{7a4b2176-7bfd-4b75-a61a-e25a1fdd0a1e}</Project>
<Name>CSharpCompilerTestUtilities.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Portable\CSharpCodeAnalysis.csproj">
<Project>{b501a547-c911-4a05-ac6e-274a50dff30e}</Project>
<Name>CSharpCodeAnalysis</Name>
......
......@@ -84,7 +84,7 @@ public static void Main(string[] args)
1
0";
var verifier = CompileAndVerifyOnWin8Only(source, expectedOutput: expectedOutput);
var verifier = this.CompileAndVerifyOnWin8Only(source, expectedOutput: expectedOutput);
verifier.VerifyIL("Class1.Main",
@"{
......@@ -182,7 +182,7 @@ public static void Main(string[] args)
}
}";
var expectedOut = "param1test";
var verifier = CompileAndVerifyOnWin8Only(
var verifier = this.CompileAndVerifyOnWin8Only(
source,
expectedOutput: expectedOut);
......@@ -247,7 +247,7 @@ public static void Main(string[] args)
testValue2
testKey2testValue3
";
var verifier = CompileAndVerifyOnWin8Only(
var verifier = this.CompileAndVerifyOnWin8Only(
source,
expectedOutput: expectedOut);
......
......@@ -324,7 +324,7 @@ static void Main()
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "d2").WithArguments("A.d2")
});
var verifier = CompileAndVerifyOnWin8Only(
var verifier = this.CompileAndVerifyOnWin8Only(
src,
additionalRefs: new[] {
MscorlibRef_v4_0_30316_17626,
......@@ -2485,7 +2485,7 @@ public class abcdef{
}
} ";
var cv = CompileAndVerifyOnWin8Only(text);
var cv = this.CompileAndVerifyOnWin8Only(text);
cv.VerifyIL("abcdef.foo()", @"
{
......@@ -2545,7 +2545,7 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
}
} ";
var cv = CompileAndVerifyOnWin8Only(text);
var cv = this.CompileAndVerifyOnWin8Only(text);
var ExpectedIl =
@"
......@@ -2609,7 +2609,7 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
}
}";
var cv = CompileAndVerifyOnWin8Only(text);
var cv = this.CompileAndVerifyOnWin8Only(text);
cv.VerifyIL("abcdef.foo()", @"
{
......
......@@ -18,6 +18,7 @@
using Xunit;
using Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
......@@ -201,7 +202,7 @@ public static void Main(string[] args)
Console.WriteLine(result);
}
}";
var verifier = CompileAndVerifyOnWin8Only(source,
var verifier = this.CompileAndVerifyOnWin8Only(source,
expectedOutput: "10\r\n0");
verifier.VerifyDiagnostics();
}
......
......@@ -7,7 +7,7 @@
using Roslyn.Test.Utilities;
using static Microsoft.CodeAnalysis.Test.Utilities.CommonTestBase;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen
namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
internal static class WinRTUtil
{
......
......@@ -42,6 +42,10 @@
<Project>{AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}</Project>
<Name>PdbUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
</PropertyGroup>
......@@ -60,47 +64,6 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CSharp\CompilingTestBase.cs">
<Link>CompilingTestBase.cs</Link>
</Compile>
<Compile Include="..\CSharp\CSharpTrackingDiagnosticAnalyzer.cs">
<Link>CSharpTrackingDiagnosticAnalyzer.cs</Link>
</Compile>
<Compile Include="..\CSharp\DiagnosticTestUtilities.cs">
<Link>DiagnosticTestUtilities.cs</Link>
</Compile>
<Compile Include="..\CSharp\ScriptTestFixtures.cs">
<Link>ScriptTestFixtures.cs</Link>
</Compile>
<Compile Include="..\CSharp\SemanticModelTestBase.cs">
<Link>SemanticModelTestBase.cs</Link>
</Compile>
<Compile Include="..\CSharp\SymbolUtilities.cs">
<Link>SymbolUtilities.cs</Link>
</Compile>
<Compile Include="..\CSharp\SyntaxTreeExtensions.cs">
<Link>SyntaxTreeExtensions.cs</Link>
</Compile>
<Compile Include="..\CSharp\TestOptions.cs">
<Link>TestOptions.cs</Link>
</Compile>
<Compile Include="..\CSharp\BasicCompilationUtils.cs">
<Link>BasicCompilationUtils.cs</Link>
</Compile>
<Compile Include="..\CSharp\CompilationTestUtils.cs">
<Link>CompilationTestUtils.cs</Link>
</Compile>
<Compile Include="CSharpTestBase.cs" />
<Compile Include="..\CSharp\DiagnosticExtensions.cs">
<Link>DiagnosticExtensions.cs</Link>
</Compile>
<Compile Include="Extensions.cs" />
<Compile Include="..\CSharp\LocalVariableDeclaratorsCollector.cs">
<Link>LocalVariableDeclaratorsCollector.cs</Link>
</Compile>
<Compile Include="..\CSharp\MetadataTestHelpers.cs">
<Link>MetadataTestHelpers.cs</Link>
</Compile>
<Compile Include="MockCSharpCompiler.cs" />
</ItemGroup>
<ItemGroup>
......
......@@ -34,7 +34,6 @@
<Compile Include="Extensions.cs" />
<Compile Include="LocalVariableDeclaratorsCollector.cs" />
<Compile Include="MetadataTestHelpers.cs" />
<Compile Include="MockCSharpCompiler.cs" />
<Compile Include="ScriptTestFixtures.cs" />
<Compile Include="SemanticModelTestBase.cs" />
<Compile Include="SymbolUtilities.cs" />
......
......@@ -21,7 +21,6 @@
using Roslyn.Utilities;
using Xunit;
using Roslyn.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities.CodeRuntime;
using System.Globalization;
namespace Microsoft.CodeAnalysis.CSharp.Test.Utilities
......
// Copyright (c) Microsoft. 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.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Test.Utilities
{
internal class MockCSharpCompiler : CSharpCompiler
{
private readonly ImmutableArray<DiagnosticAnalyzer> _analyzers;
internal Compilation Compilation;
public MockCSharpCompiler(string responseFile, string baseDirectory, string[] args)
: this(responseFile, baseDirectory, args, ImmutableArray<DiagnosticAnalyzer>.Empty)
{
}
public MockCSharpCompiler(string responseFile, string workingDirectory, string[] args, ImmutableArray<DiagnosticAnalyzer> analyzers)
: base(CSharpCommandLineParser.Default, responseFile, args, CreateBuildPaths(workingDirectory), Environment.GetEnvironmentVariable("LIB"), new DesktopAnalyzerAssemblyLoader())
{
_analyzers = analyzers;
}
private static BuildPaths CreateBuildPaths(string workingDirectory)
{
return new BuildPaths(
clientDir: Path.GetDirectoryName(CorLightup.Desktop.GetAssemblyLocation(typeof(CSharpCompiler).GetTypeInfo().Assembly)),
workingDir: workingDirectory,
sdkDir: RuntimeEnvironment.GetRuntimeDirectory(),
tempDir: Path.GetTempPath());
}
protected override ImmutableArray<DiagnosticAnalyzer> ResolveAnalyzersFromArguments(
List<DiagnosticInfo> diagnostics,
CommonMessageProvider messageProvider)
{
var analyzers = base.ResolveAnalyzersFromArguments(diagnostics, messageProvider);
if (!_analyzers.IsDefaultOrEmpty)
{
analyzers = analyzers.InsertRange(0, _analyzers);
}
return analyzers;
}
public override Compilation CreateCompilation(TextWriter consoleOutput, TouchedFileLogger touchedFilesLogger, ErrorLogger errorLogger)
{
Compilation = base.CreateCompilation(consoleOutput, touchedFilesLogger, errorLogger);
return Compilation;
}
}
}
......@@ -6,7 +6,7 @@
using Microsoft.CodeAnalysis;
using static Roslyn.Test.Utilities.ExceptionHelper;
namespace Microsoft.CodeAnalysis.Test.Utilities.CodeRuntime
namespace Roslyn.Test.Utilities
{
public class EmitException : Exception
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册