parent
f56d1b9441
commit
cfa4689d47
|
|
@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
|
|||
var diagnostic = new DefaultRazorDiagnostic(descriptor, span, new object[] { 1.3m });
|
||||
|
||||
// Act
|
||||
var result = diagnostic.GetMessage(CultureInfo.GetCultureInfo("fr-FR"));
|
||||
var result = diagnostic.GetMessage(new CultureInfo("fr-FR"));
|
||||
|
||||
// Assert
|
||||
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 });
|
||||
|
||||
// Act
|
||||
var result = ((IFormattable)diagnostic).ToString("ignored", CultureInfo.GetCultureInfo("fr-FR"));
|
||||
var result = ((IFormattable)diagnostic).ToString("ignored", new CultureInfo("fr-FR"));
|
||||
|
||||
// Assert
|
||||
Assert.Equal("test.cs(2,9): Error RZ0000: this is an 1,3", result);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\build\common.props" />
|
||||
<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 -->
|
||||
<TargetFramework>net46</TargetFramework>
|
||||
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp1.1</TargetFrameworks>
|
||||
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -2098,11 +2098,11 @@ public class DynamicTestTagHelper : {typeof(AspNetCore.Razor.TagHelpers.TagHelpe
|
|||
{
|
||||
// Arrange
|
||||
var errorSink = new ErrorSink();
|
||||
var objectAssemblyName = typeof(object).GetTypeInfo().Assembly.GetName().Name;
|
||||
var objectAssemblyName = typeof(Enumerable).GetTypeInfo().Assembly.GetName().Name;
|
||||
var expectedDescriptor =
|
||||
CreateTagHelperDescriptor("object", "System.Object", objectAssemblyName);
|
||||
CreateTagHelperDescriptor("enumerable", "System.Linq.Enumerable", objectAssemblyName);
|
||||
var factory = new DefaultTagHelperDescriptorFactory(Compilation, designTime: false);
|
||||
var typeSymbol = Compilation.GetTypeByMetadataName(typeof(object).FullName);
|
||||
var typeSymbol = Compilation.GetTypeByMetadataName(typeof(Enumerable).FullName);
|
||||
|
||||
// Act
|
||||
var descriptors = factory.CreateDescriptors(typeSymbol, errorSink);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\build\common.props" />
|
||||
<PropertyGroup>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<!-- 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>
|
||||
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp1.1</TargetFrameworks>
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**\*</DefaultItemExcludes>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
|
||||
<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\Microsoft.AspNetCore.Razor.csproj" />
|
||||
<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="xunit.runner.visualstudio" Version="2.2.0-*" />
|
||||
<PackageReference Include="xunit" Version="2.2.0-*" />
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor
|
||||
{
|
||||
|
|
@ -19,13 +23,30 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
syntaxTrees = new[] { syntaxTree };
|
||||
}
|
||||
|
||||
var references = AppDomain.CurrentDomain
|
||||
.GetAssemblies()
|
||||
.Select(assembly => MetadataReference.CreateFromFile(assembly.Location));
|
||||
var assemblyName = new AssemblyName(typeof(TestCompilation).GetTypeInfo().Assembly.GetName().Name);
|
||||
var dependencyContext = DependencyContext.Load(Assembly.Load(assemblyName));
|
||||
|
||||
var references = dependencyContext.CompileLibraries.SelectMany(l => l.ResolveReferencePaths())
|
||||
.Select(assemblyPath => MetadataReference.CreateFromFile(assemblyPath));
|
||||
|
||||
var compilation = CSharpCompilation.Create("TestAssembly", syntaxTrees, references);
|
||||
EnsureValidCompilation(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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Razor.Evolution;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces.Test;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces.Test.Comparers;
|
||||
|
|
@ -22,7 +23,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
|
|||
{
|
||||
TagName = "vc:string-parameter",
|
||||
TypeName = "__Generated__StringParameterViewComponentTagHelper",
|
||||
AssemblyName = typeof(StringParameterViewComponent).Assembly.GetName().Name,
|
||||
AssemblyName = typeof(StringParameterViewComponent).GetTypeInfo().Assembly.GetName().Name,
|
||||
Attributes = new List<TagHelperAttributeDescriptor>
|
||||
{
|
||||
new TagHelperAttributeDescriptor
|
||||
|
|
@ -70,7 +71,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
|
|||
{
|
||||
TagName = "vc:various-parameter",
|
||||
TypeName = "__Generated__VariousParameterViewComponentTagHelper",
|
||||
AssemblyName = typeof(VariousParameterViewComponent).Assembly.GetName().Name,
|
||||
AssemblyName = typeof(VariousParameterViewComponent).GetTypeInfo().Assembly.GetName().Name,
|
||||
Attributes = new List<TagHelperAttributeDescriptor>
|
||||
{
|
||||
new TagHelperAttributeDescriptor
|
||||
|
|
@ -133,7 +134,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
|
|||
{
|
||||
TagName = "vc:generic-parameter",
|
||||
TypeName = "__Generated__GenericParameterViewComponentTagHelper",
|
||||
AssemblyName = typeof(GenericParameterViewComponent).Assembly.GetName().Name,
|
||||
AssemblyName = typeof(GenericParameterViewComponent).GetTypeInfo().Assembly.GetName().Name,
|
||||
Attributes = new List<TagHelperAttributeDescriptor>
|
||||
{
|
||||
new TagHelperAttributeDescriptor
|
||||
|
|
|
|||
Loading…
Reference in New Issue