Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions RoslynCodeProvider.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- Composite targets -->
<Target Name="BuildCI" DependsOnTargets="Clean;Build" />

<Target Name="Build" DependsOnTargets="BuildAssemblies;BuildTests;BuildPackages" />
<Target Name="Build" DependsOnTargets="BuildAssemblies;UnitTest;BuildPackages" />
<Target Name="Clean" DependsOnTargets="CleanPackages;CleanTests;CleanAssemblies" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />

Expand Down Expand Up @@ -58,5 +58,8 @@
<Exec Command=".nuget\NuGet.exe restore" />
</Target>

<Import Project="tools\RoslynCodeProvider.targets" />
<Target Name="UnitTest" DependsOnTargets="BuildTests">
<MSBuild Targets="XunitTest" Projects="@(TestProject)" />
</Target>

</Project>
53 changes: 28 additions & 25 deletions RoslynCodeProviderTest/CSharpProviderTest.cs
Original file line number Diff line number Diff line change
@@ -1,128 +1,131 @@
using System;
using System.CodeDom.Compiler;
using System.IO;
using Microsoft.CodeDom.Providers.DotNetCompilerPlatform;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;

namespace Microsoft.CodeDom.Providers.DotNetCompilerPlatformTest {

[TestClass]
public class CSharpProviderTest {

private CommonCodeDomProviderTests commonTests = new CommonCodeDomProviderTests();
private static CodeDomProvider csharpCodeProvider;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext) {
static CSharpProviderTest() {
#pragma warning disable CS0618
csharpCodeProvider = new CSharpCodeProvider(compilerSettings: CompilerSettingsHelper.CSC);
#pragma warning restore CS0618
AppContext.SetSwitch("Switch.System.DisableTempFileCollectionDirectoryFeature", true);
}

[TestMethod]
[Fact]
public void AssemblyVersion()
{
commonTests.AssemblyVersion(csharpCodeProvider);
}

[Fact]
public void FileExtension() {
commonTests.FileExtension(csharpCodeProvider, "cs");
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_Parse_Error() {
commonTests.CompileAssemblyFromSource_Parse_Error(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_WarningAsError() {
commonTests.CompileAssemblyFromSource_WarningAsError(csharpCodeProvider,
// the variable a is declared but not used
"public class FooClass { public string Execute() { int a; return \"output\"; }}",
"CS0168"/*errorNumber*/);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_ReferenceAssembly_AssemblyNameOnly() {
commonTests.CompileAssemblyFromSource_ReferenceAssembly_AssemblyNameOnly(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_ReferenceAssembly_NameCannotBeResolved() {
commonTests.CompileAssemblyFromSource_ReferenceAssembly_NameCannotBeResolved(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_ReferenceAssembly_LocalReference() {
commonTests.CompileAssemblyFromSource_ReferenceAssembly_LocalReference(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_ReferenceAssembly_PathWithComma() {
commonTests.CompileAssemblyFromSource_ReferenceAssembly_PathWithComma(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_GenerateInMemory_True() {
commonTests.CompileAssemblyFromSource_GenerateInMemory_True(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_GenerateInMemory_False() {
commonTests.CompileAssemblyFromSource_GenerateInMemory_False(csharpCodeProvider,
"public class FooClass { public string Execute() { return \"output\";}}");
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_InvalidOutputPath() {
commonTests.CompileAssemblyFromSource_InvalidOutputPath(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_GenerateExecutable_True() {
commonTests.CompileAssemblyFromSource_GenerateExecutable_True(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_GenerateExecutable_True_Failed() {
commonTests.CompileAssemblyFromSource_GenerateExecutable_True_Failed(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_CreateOutputFileFailed() {
commonTests.CompileAssemblyFromSource_CreateOutputFileFailed(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_CreatePDBFileFailed() {
commonTests.CompileAssemblyFromSource_CreatePDBFileFailed(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_IncludeDebugInformation_True() {
commonTests.CompileAssemblyFromSource_IncludeDebugInformation_True(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromSource_IncludeDebugInformation_False() {
commonTests.CompileAssemblyFromSource_IncludeDebugInformation_False(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromDom() {
commonTests.CompileAssemblyFromDom(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromFile() {
commonTests.CompileAssemblyFromFile(csharpCodeProvider);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromFile_ASPNet_Magic()
{
// Complete added frippery is: "/nowarn:1659;1699;1701;612;618"
ProviderOptions opts = new ProviderOptions(CompilerSettingsHelper.CSC) { UseAspNetSettings = true };
commonTests.CompileAssemblyFromFile_CheckArgs(new CSharpCodeProvider(opts), "/nowarn:1659;1699;1701;612;618", true);
}

[TestMethod]
[Fact]
public void CompileAssemblyFromFile_No_ASPNet_Magic()
{
// _codeProvider uses options (aka CompilerSettingsHelper.VB) created via constructor, so it should
Expand Down
Loading