Re-enable netcoreapp1.1 tests

Fixes #1003
This commit is contained in:
Pranav K 2017-02-16 12:49:57 -08:00
parent f56d1b9441
commit cfa4689d47
7 changed files with 40 additions and 17 deletions

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m }); var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m });
// Act // Act
var result = diagnostic.GetMessage(CultureInfo.GetCultureInfo("fr-FR")); var result = diagnostic.GetMessage(new CultureInfo("fr-FR"));
// Assert // Assert
Assert.Equal("this is an 1,3", result); Assert.Equal("this is an 1,3", result);
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m }); var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m });
// Act // Act
var result = ((IFormattable)diagnostic).ToString("ignored", CultureInfo.GetCultureInfo("fr-FR")); var result = ((IFormattable)diagnostic).ToString("ignored", new CultureInfo("fr-FR"));
// Assert // Assert
Assert.Equal("test.cs(2,9): Error RZ0000: this is an 1,3", result); Assert.Equal("test.cs(2,9): Error RZ0000: this is an 1,3", result);

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
{ {

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<!-- TODO re-enable tests on .NET Core when we upgrade to 2.0. This project started using 2.0 API but we had to drop temporarily to .NET Core 1.1 --> <TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
<TargetFramework>net46</TargetFramework> <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp1.1</TargetFrameworks>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants> <DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes> <DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes>
</PropertyGroup> </PropertyGroup>

View File

@ -2098,11 +2098,11 @@ public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelpe
{ {
// Arrange // Arrange
var errorSink = new ErrorSink(); var errorSink = new ErrorSink();
var objectAssemblyName = typeof(object).GetTypeInfo().Assembly.GetName().Name; var objectAssemblyName = typeof(Enumerable).GetTypeInfo().Assembly.GetName().Name;
var expectedDescriptor = var expectedDescriptor =
CreateTagHelperDescriptor("object", "System.Object", objectAssemblyName); CreateTagHelperDescriptor("enumerable", "System.Linq.Enumerable", objectAssemblyName);
var factory = new DefaultTagHelperDescriptorFactory(Compilation, designTime: false); var factory = new DefaultTagHelperDescriptorFactory(Compilation, designTime: false);
var typeSymbol = Compilation.GetTypeByMetadataName(typeof(object).FullName); var typeSymbol = Compilation.GetTypeByMetadataName(typeof(Enumerable).FullName);
// Act // Act
var descriptors = factory.CreateDescriptors(typeSymbol, errorSink); var descriptors = factory.CreateDescriptors(typeSymbol, errorSink);

View File

@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn> <TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp1.1</TargetFrameworks>
<!-- TODO re-enable tests on .NET Core when we upgrade to 2.0. This project started using 2.0 API but we had to drop temporarily to .NET Core 1.1 -->
<TargetFramework>net452</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes> <DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' "> <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback> <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
@ -19,6 +18,7 @@
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" /> <ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj" /> <ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.3.0" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-*" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-*" />
<PackageReference Include="xunit" Version="2.2.0-*" /> <PackageReference Include="xunit" Version="2.2.0-*" />

View File

@ -3,8 +3,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Extensions.DependencyModel;
using Xunit;
namespace Microsoft.CodeAnalysis.Razor namespace Microsoft.CodeAnalysis.Razor
{ {
@ -19,13 +23,30 @@ namespace Microsoft.CodeAnalysis.Razor
syntaxTrees = new[] { syntaxTree }; syntaxTrees = new[] { syntaxTree };
} }
var references = AppDomain.CurrentDomain var assemblyName = new AssemblyName(typeof(TestCompilation).GetTypeInfo().Assembly.GetName().Name);
.GetAssemblies() var dependencyContext = DependencyContext.Load(Assembly.Load(assemblyName));
.Select(assembly => MetadataReference.CreateFromFile(assembly.Location));
var references = dependencyContext.CompileLibraries.SelectMany(l => l.ResolveReferencePaths())
.Select(assemblyPath => MetadataReference.CreateFromFile(assemblyPath));
var compilation = CSharpCompilation.Create("TestAssembly", syntaxTrees, references); var compilation = CSharpCompilation.Create("TestAssembly", syntaxTrees, references);
EnsureValidCompilation(compilation);
return compilation; return compilation;
} }
private static void EnsureValidCompilation(CSharpCompilation compilation)
{
using (var stream = new MemoryStream())
{
var emitResult = compilation
.WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
.Emit(stream);
var diagnostics = string.Join(
Environment.NewLine,
emitResult.Diagnostics.Select(d => CSharpDiagnosticFormatter.Instance.Format(d)));
Assert.True(emitResult.Success, $"Compilation is invalid : {Environment.NewLine}{diagnostics}");
}
}
} }
} }

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Evolution; using Microsoft.AspNetCore.Razor.Evolution;
using Microsoft.CodeAnalysis.Razor.Workspaces.Test; using Microsoft.CodeAnalysis.Razor.Workspaces.Test;
using Microsoft.CodeAnalysis.Razor.Workspaces.Test.Comparers; using Microsoft.CodeAnalysis.Razor.Workspaces.Test.Comparers;
@ -22,7 +23,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
{ {
TagName = "vc:string-parameter", TagName = "vc:string-parameter",
TypeName = "__Generated__StringParameterViewComponentTagHelper", TypeName = "__Generated__StringParameterViewComponentTagHelper",
AssemblyName = typeof(StringParameterViewComponent).Assembly.GetName().Name, AssemblyName = typeof(StringParameterViewComponent).GetTypeInfo().Assembly.GetName().Name,
Attributes = new List<TagHelperAttributeDescriptor> Attributes = new List<TagHelperAttributeDescriptor>
{ {
new TagHelperAttributeDescriptor new TagHelperAttributeDescriptor
@ -70,7 +71,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
{ {
TagName = "vc:various-parameter", TagName = "vc:various-parameter",
TypeName = "__Generated__VariousParameterViewComponentTagHelper", TypeName = "__Generated__VariousParameterViewComponentTagHelper",
AssemblyName = typeof(VariousParameterViewComponent).Assembly.GetName().Name, AssemblyName = typeof(VariousParameterViewComponent).GetTypeInfo().Assembly.GetName().Name,
Attributes = new List<TagHelperAttributeDescriptor> Attributes = new List<TagHelperAttributeDescriptor>
{ {
new TagHelperAttributeDescriptor new TagHelperAttributeDescriptor
@ -133,7 +134,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
{ {
TagName = "vc:generic-parameter", TagName = "vc:generic-parameter",
TypeName = "__Generated__GenericParameterViewComponentTagHelper", TypeName = "__Generated__GenericParameterViewComponentTagHelper",
AssemblyName = typeof(GenericParameterViewComponent).Assembly.GetName().Name, AssemblyName = typeof(GenericParameterViewComponent).GetTypeInfo().Assembly.GetName().Name,
Attributes = new List<TagHelperAttributeDescriptor> Attributes = new List<TagHelperAttributeDescriptor>
{ {
new TagHelperAttributeDescriptor new TagHelperAttributeDescriptor