react to DNX renames
This commit is contained in:
parent
bb618ac437
commit
991dff6b9e
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
get
|
||||
{
|
||||
return GetCandidateLibraries().SelectMany(l => l.LoadableAssemblies)
|
||||
return GetCandidateLibraries().SelectMany(l => l.Assemblies)
|
||||
.Select(Load);
|
||||
}
|
||||
}
|
||||
|
|
@ -60,12 +60,12 @@ namespace Microsoft.AspNet.Mvc
|
|||
/// By default it returns all assemblies that reference any of the primary MVC assemblies
|
||||
/// while ignoring MVC assemblies.
|
||||
/// </summary>
|
||||
/// <returns>A set of <see cref="ILibraryInformation"/>.</returns>
|
||||
protected virtual IEnumerable<ILibraryInformation> GetCandidateLibraries()
|
||||
/// <returns>A set of <see cref="Library"/>.</returns>
|
||||
protected virtual IEnumerable<Library> GetCandidateLibraries()
|
||||
{
|
||||
if (ReferenceAssemblies == null)
|
||||
{
|
||||
return Enumerable.Empty<ILibraryInformation>();
|
||||
return Enumerable.Empty<Library>();
|
||||
}
|
||||
|
||||
// GetReferencingLibraries returns the transitive closure of referencing assemblies
|
||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
return Assembly.Load(assemblyName);
|
||||
}
|
||||
|
||||
private bool IsCandidateLibrary(ILibraryInformation library)
|
||||
private bool IsCandidateLibrary(Library library)
|
||||
{
|
||||
Debug.Assert(ReferenceAssemblies != null);
|
||||
return !ReferenceAssemblies.Contains(library.Name);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
"Microsoft.Framework.PropertyActivator.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||
"Microsoft.Framework.SecurityHelper.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||
"Microsoft.Framework.Runtime.Abstractions": "1.0.0-*",
|
||||
"Microsoft.Framework.Runtime.Compilation.Abstractions": "1.0.0-*",
|
||||
"Newtonsoft.Json": "6.0.6"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Runtime.Compilation;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||
{
|
||||
|
|
@ -20,16 +20,16 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
/// <param name="compilationFailures"><see cref="ICompilationFailure"/>s containing
|
||||
/// details of the compilation failure.</param>
|
||||
public CompilationFailedException(
|
||||
[NotNull] IEnumerable<ICompilationFailure> compilationFailures)
|
||||
[NotNull] IEnumerable<CompilationFailure> compilationFailures)
|
||||
: base(FormatMessage(compilationFailures))
|
||||
{
|
||||
CompilationFailures = compilationFailures;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ICompilationFailure> CompilationFailures { get; }
|
||||
public IEnumerable<CompilationFailure> CompilationFailures { get; }
|
||||
|
||||
private static string FormatMessage(IEnumerable<ICompilationFailure> compilationFailures)
|
||||
private static string FormatMessage(IEnumerable<CompilationFailure> compilationFailures)
|
||||
{
|
||||
return Resources.CompilationFailed + Environment.NewLine +
|
||||
string.Join(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Compilation;
|
||||
using Microsoft.Framework.Runtime.Roslyn;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Compilation;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||
{
|
||||
|
|
@ -37,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
/// </summary>
|
||||
/// <remarks>This property is <c>null</c> when compilation succeeded. An empty sequence
|
||||
/// indicates a failed compilation.</remarks>
|
||||
public IEnumerable<ICompilationFailure> CompilationFailures { get; private set; }
|
||||
public IEnumerable<CompilationFailure> CompilationFailures { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CompilationResult"/>.
|
||||
|
|
@ -57,10 +58,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
/// <summary>
|
||||
/// Creates a <see cref="CompilationResult"/> for a failed compilation.
|
||||
/// </summary>
|
||||
/// <param name="compilationFailures"><see cref="ICompilationFailure"/>s produced from parsing or
|
||||
/// <param name="compilationFailures"><see cref="CompilationFailure"/>s produced from parsing or
|
||||
/// compiling the Razor file.</param>
|
||||
/// <returns>A <see cref="CompilationResult"/> instance for a failed compilation.</returns>
|
||||
public static CompilationResult Failed([NotNull] IEnumerable<ICompilationFailure> compilationFailures)
|
||||
public static CompilationResult Failed([NotNull] IEnumerable<CompilationFailure> compilationFailures)
|
||||
{
|
||||
return new CompilationResult
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ICompilationFailure"/> for Razor parse failures.
|
||||
/// </summary>
|
||||
public class RazorCompilationFailure : ICompilationFailure
|
||||
{
|
||||
/// <summary>Initializes a new instance of <see cref="RazorCompilationFailure"/>.</summary>
|
||||
/// <param name="sourceFilePath">The path of the Razor source file that was compiled.</param>
|
||||
/// <param name="sourceFileContent">The contents of the Razor source file.</param>
|
||||
/// <param name="messages">A sequence of <see cref="ICompilationMessage"/> encountered
|
||||
/// during compilation.</param>
|
||||
public RazorCompilationFailure(
|
||||
[NotNull] string sourceFilePath,
|
||||
[NotNull] string sourceFileContent,
|
||||
[NotNull] IEnumerable<RazorCompilationMessage> messages)
|
||||
{
|
||||
SourceFilePath = sourceFilePath;
|
||||
SourceFileContent = sourceFileContent;
|
||||
Messages = messages;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string SourceFilePath { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string SourceFileContent { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string CompiledContent { get; } = null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ICompilationMessage> Messages { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Razor;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ICompilationMessage"/> for a <see cref="RazorError"/> encountered during parsing.
|
||||
/// </summary>
|
||||
public class RazorCompilationMessage : ICompilationMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a <see cref="RazorCompilationMessage"/> with the specified message.
|
||||
/// </summary>
|
||||
/// <param name="razorError">A <see cref="RazorError"/>.</param>
|
||||
/// <param name="sourceFilePath">The path of the Razor source file that was parsed.</param>
|
||||
public RazorCompilationMessage(
|
||||
[NotNull] RazorError razorError,
|
||||
string sourceFilePath)
|
||||
{
|
||||
SourceFilePath = sourceFilePath;
|
||||
Message = razorError.Message;
|
||||
|
||||
var location = razorError.Location;
|
||||
FormattedMessage =
|
||||
$"{sourceFilePath} ({location.LineIndex},{location.CharacterIndex}) {razorError.Message}";
|
||||
|
||||
StartColumn = location.CharacterIndex;
|
||||
StartLine = location.LineIndex + 1;
|
||||
EndColumn = location.CharacterIndex + razorError.Length;
|
||||
EndLine = location.LineIndex + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a message produced from compilation.
|
||||
/// </summary>
|
||||
public string Message { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int StartColumn { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int StartLine { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int EndColumn { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int EndLine { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string SourceFilePath { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string FormattedMessage { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
// All Razor diagnostics are errors
|
||||
public CompilationMessageSeverity Severity { get; } = CompilationMessageSeverity.Error;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="string"/> representation of this instance of <see cref="RazorCompilationMessage"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="string"/> representing this <see cref="RazorCompilationMessage"/> instance.</returns>
|
||||
/// <remarks>Returns same value as <see cref="Message"/>.</remarks>
|
||||
public override string ToString()
|
||||
{
|
||||
return FormattedMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ using Microsoft.AspNet.Razor;
|
|||
using Microsoft.AspNet.Razor.CodeGenerators;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Compilation;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||
{
|
||||
|
|
@ -82,21 +84,34 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
razorError.Location.FilePath ?? file.RelativePath,
|
||||
StringComparer.Ordinal);
|
||||
|
||||
var failures = new List<RazorCompilationFailure>();
|
||||
var failures = new List<CompilationFailure>();
|
||||
foreach (var group in messageGroups)
|
||||
{
|
||||
var filePath = group.Key;
|
||||
var fileContent = ReadFileContentsSafely(filePath);
|
||||
var compilationFailure = new RazorCompilationFailure(
|
||||
var compilationFailure = new CompilationFailure(
|
||||
filePath,
|
||||
fileContent,
|
||||
group.Select(parserError => new RazorCompilationMessage(parserError, filePath)));
|
||||
group.Select(parserError => CreateDiagnosticMessage(parserError, filePath)));
|
||||
failures.Add(compilationFailure);
|
||||
}
|
||||
|
||||
return CompilationResult.Failed(failures);
|
||||
}
|
||||
|
||||
private DiagnosticMessage CreateDiagnosticMessage(RazorError error, string filePath)
|
||||
{
|
||||
return new DiagnosticMessage(
|
||||
error.Message,
|
||||
$"{error} ({error.Location.LineIndex},{error.Location.CharacterIndex}) {error.Message}",
|
||||
filePath,
|
||||
DiagnosticMessageSeverity.Error,
|
||||
error.Location.LineIndex + 1,
|
||||
error.Location.CharacterIndex,
|
||||
error.Location.LineIndex + 1,
|
||||
error.Location.CharacterIndex + error.Length);
|
||||
}
|
||||
|
||||
private string ReadFileContentsSafely(string relativePath)
|
||||
{
|
||||
var fileInfo = _fileProvider.GetFileInfo(relativePath);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
private readonly ConcurrentDictionary<string, AssemblyMetadata> _metadataFileCache =
|
||||
new ConcurrentDictionary<string, AssemblyMetadata>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILibraryExporter _libraryExporter;
|
||||
private readonly IApplicationEnvironment _environment;
|
||||
private readonly IAssemblyLoadContext _loader;
|
||||
private readonly ICompilerOptionsProvider _compilerOptionsProvider;
|
||||
|
|
@ -53,14 +53,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
/// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param>
|
||||
public RoslynCompilationService(IApplicationEnvironment environment,
|
||||
IAssemblyLoadContextAccessor loaderAccessor,
|
||||
ILibraryManager libraryManager,
|
||||
ILibraryExporter libraryExporter,
|
||||
ICompilerOptionsProvider compilerOptionsProvider,
|
||||
IMvcRazorHost host,
|
||||
IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||
{
|
||||
_environment = environment;
|
||||
_loader = loaderAccessor.GetLoadContext(typeof(RoslynCompilationService).GetTypeInfo().Assembly);
|
||||
_libraryManager = libraryManager;
|
||||
_libraryExporter = libraryExporter;
|
||||
_applicationReferences = new Lazy<List<MetadataReference>>(GetApplicationReferences);
|
||||
_compilerOptionsProvider = compilerOptionsProvider;
|
||||
_fileProvider = optionsAccessor.Options.FileProvider;
|
||||
|
|
@ -141,7 +141,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
.Where(IsError)
|
||||
.GroupBy(diagnostic => GetFilePath(relativePath, diagnostic), StringComparer.Ordinal);
|
||||
|
||||
var failures = new List<ICompilationFailure>();
|
||||
var failures = new List<CompilationFailure>();
|
||||
foreach (var group in diagnosticGroups)
|
||||
{
|
||||
var sourceFilePath = group.Key;
|
||||
|
|
@ -157,12 +157,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
sourceFileContent = ReadFileContentsSafely(_fileProvider, sourceFilePath);
|
||||
}
|
||||
|
||||
var compilationFailure = new RoslynCompilationFailure(group)
|
||||
{
|
||||
CompiledContent = compilationContent,
|
||||
SourceFileContent = sourceFileContent,
|
||||
SourceFilePath = sourceFilePath
|
||||
};
|
||||
var compilationFailure = new CompilationFailure(sourceFilePath, sourceFileContent, compilationContent, group.Select(d => d.ToDiagnosticMessage(_environment.RuntimeFramework)));
|
||||
|
||||
failures.Add(compilationFailure);
|
||||
}
|
||||
|
|
@ -187,7 +182,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
// Get the MetadataReference for the executing application. If it's a Roslyn reference,
|
||||
// we can copy the references created when compiling the application to the Razor page being compiled.
|
||||
// This avoids performing expensive calls to MetadataReference.CreateFromImage.
|
||||
var libraryExport = _libraryManager.GetLibraryExport(_environment.ApplicationName);
|
||||
var libraryExport = _libraryExporter.GetLibraryExport(_environment.ApplicationName);
|
||||
if (libraryExport?.MetadataReferences != null && libraryExport.MetadataReferences.Count > 0)
|
||||
{
|
||||
Debug.Assert(libraryExport.MetadataReferences.Count == 1,
|
||||
|
|
@ -202,7 +197,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
}
|
||||
}
|
||||
|
||||
var export = _libraryManager.GetAllExports(_environment.ApplicationName);
|
||||
var export = _libraryExporter.GetAllExports(_environment.ApplicationName);
|
||||
foreach (var metadataReference in export.MetadataReferences)
|
||||
{
|
||||
// Taken from https://github.com/aspnet/KRuntime/blob/757ba9bfdf80bd6277e715d6375969a7f44370ee/src/...
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Microsoft.AspNet.Mvc.Razor.Precompilation;
|
|||
using Microsoft.Framework.Caching.Memory;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Compilation;
|
||||
using Microsoft.Framework.Runtime.Roslyn;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ namespace Microsoft.AspNet.Mvc.Core
|
|||
manager.Setup(f => f.GetReferencingLibraries(It.IsAny<string>()))
|
||||
.Returns(new[]
|
||||
{
|
||||
CreateLibraryInfo("Microsoft.AspNet.Mvc.Core"),
|
||||
CreateLibraryInfo("Microsoft.AspNet.Mvc"),
|
||||
CreateLibraryInfo("Microsoft.AspNet.Mvc.Abstractions"),
|
||||
CreateLibraryInfo("SomeRandomAssembly"),
|
||||
new Library("Microsoft.AspNet.Mvc.Core"),
|
||||
new Library("Microsoft.AspNet.Mvc"),
|
||||
new Library("Microsoft.AspNet.Mvc.Abstractions"),
|
||||
new Library("SomeRandomAssembly"),
|
||||
})
|
||||
.Verifiable();
|
||||
var provider = new TestAssemblyProvider(manager.Object);
|
||||
|
|
@ -45,13 +45,13 @@ namespace Microsoft.AspNet.Mvc.Core
|
|||
// Arrange
|
||||
var manager = new Mock<ILibraryManager>();
|
||||
manager.Setup(f => f.GetReferencingLibraries(It.IsAny<string>()))
|
||||
.Returns(Enumerable.Empty<ILibraryInformation>());
|
||||
.Returns(Enumerable.Empty<Library>());
|
||||
manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc.Core"))
|
||||
.Returns(new[] { CreateLibraryInfo("Foo") });
|
||||
.Returns(new[] { new Library("Foo") });
|
||||
manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc.Abstractions"))
|
||||
.Returns(new[] { CreateLibraryInfo("Bar") });
|
||||
.Returns(new[] { new Library("Bar") });
|
||||
manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc"))
|
||||
.Returns(new[] { CreateLibraryInfo("Baz") });
|
||||
.Returns(new[] { new Library("Baz") });
|
||||
var provider = new TestAssemblyProvider(manager.Object);
|
||||
|
||||
// Act
|
||||
|
|
@ -118,30 +118,23 @@ namespace Microsoft.AspNet.Mvc.Core
|
|||
Assert.True(expected.SetEquals(referenceAssemblies));
|
||||
}
|
||||
|
||||
private static ILibraryInformation CreateLibraryInfo(string name)
|
||||
{
|
||||
var info = new Mock<ILibraryInformation>();
|
||||
info.SetupGet(b => b.Name).Returns(name);
|
||||
return info.Object;
|
||||
}
|
||||
|
||||
private static ILibraryManager CreateLibraryManager()
|
||||
{
|
||||
var manager = new Mock<ILibraryManager>();
|
||||
manager.Setup(f => f.GetReferencingLibraries(It.IsAny<string>()))
|
||||
.Returns(Enumerable.Empty<ILibraryInformation>());
|
||||
.Returns(Enumerable.Empty<Library>());
|
||||
manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc.Core"))
|
||||
.Returns(new[] { CreateLibraryInfo("Baz") });
|
||||
.Returns(new[] { new Library("Baz") });
|
||||
manager.Setup(f => f.GetReferencingLibraries("MyAssembly"))
|
||||
.Returns(new[] { CreateLibraryInfo("Foo") });
|
||||
.Returns(new[] { new Library("Foo") });
|
||||
manager.Setup(f => f.GetReferencingLibraries("AnotherAssembly"))
|
||||
.Returns(new[] { CreateLibraryInfo("Bar") });
|
||||
.Returns(new[] { new Library("Bar") });
|
||||
return manager.Object;
|
||||
}
|
||||
|
||||
private class TestAssemblyProvider : DefaultAssemblyProvider
|
||||
{
|
||||
public new IEnumerable<ILibraryInformation> GetCandidateLibraries()
|
||||
public new IEnumerable<Library> GetCandidateLibraries()
|
||||
{
|
||||
return base.GetCandidateLibraries();
|
||||
}
|
||||
|
|
@ -202,7 +195,7 @@ namespace Microsoft.AspNet.Mvc.Core
|
|||
|
||||
return new HashSet<string>(
|
||||
SelectMvcAssemblies(
|
||||
GetLoadableAssemblies(dependencies)));
|
||||
GetAssemblies(dependencies)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -249,11 +242,11 @@ namespace Microsoft.AspNet.Mvc.Core
|
|||
return mvcAssemblies;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetLoadableAssemblies(IEnumerable<string> libraries)
|
||||
private static IEnumerable<string> GetAssemblies(IEnumerable<string> libraries)
|
||||
{
|
||||
return libraries
|
||||
.Select(n => _libraryManager.GetLibraryInformation(n))
|
||||
.SelectMany(n => n.LoadableAssemblies)
|
||||
.SelectMany(n => n.Assemblies)
|
||||
.Distinct()
|
||||
.Select(n => n.Name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
}
|
||||
|
||||
protected override IEnumerable<ILibraryInformation> GetCandidateLibraries()
|
||||
protected override IEnumerable<Library> GetCandidateLibraries()
|
||||
{
|
||||
var libraries = base.GetCandidateLibraries();
|
||||
// Filter out other WebSite projects
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
get { return _applicationName; }
|
||||
}
|
||||
|
||||
public string Version
|
||||
public string ApplicationVersion
|
||||
{
|
||||
get { return _originalAppEnvironment.Version; }
|
||||
get { return _originalAppEnvironment.ApplicationVersion; }
|
||||
}
|
||||
|
||||
public string ApplicationBasePath
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Compilation;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -13,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
public void EnsureSuccessful_ThrowsIfCompilationFailed()
|
||||
{
|
||||
// Arrange
|
||||
var compilationFailure = Mock.Of<ICompilationFailure>();
|
||||
var compilationFailure = new CompilationFailure("test", Enumerable.Empty<Framework.Runtime.DiagnosticMessage>());
|
||||
var failures = new[] { compilationFailure };
|
||||
var result = CompilationResult.Failed(failures);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
|||
public class MyTestType {}";
|
||||
var applicationEnvironment = GetApplicationEnvironment();
|
||||
var accessor = GetLoadContextAccessor();
|
||||
var libraryManager = GetLibraryManager();
|
||||
var libraryExporter = GetLibraryExporter();
|
||||
|
||||
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
|
||||
compilerOptionsProvider.Setup(p => p.GetCompilerOptions(applicationEnvironment.ApplicationName,
|
||||
|
|
@ -39,7 +39,7 @@ public class MyTestType {}";
|
|||
|
||||
var compilationService = new RoslynCompilationService(applicationEnvironment,
|
||||
accessor,
|
||||
libraryManager,
|
||||
libraryExporter,
|
||||
compilerOptionsProvider.Object,
|
||||
mvcRazorHost.Object,
|
||||
GetOptions());
|
||||
|
|
@ -66,7 +66,7 @@ public class MyTestType {}";
|
|||
this should fail";
|
||||
var applicationEnvironment = GetApplicationEnvironment();
|
||||
var accessor = GetLoadContextAccessor();
|
||||
var libraryManager = GetLibraryManager();
|
||||
var libraryExporter = GetLibraryExporter();
|
||||
|
||||
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
|
||||
compilerOptionsProvider.Setup(p => p.GetCompilerOptions(applicationEnvironment.ApplicationName,
|
||||
|
|
@ -79,7 +79,7 @@ this should fail";
|
|||
|
||||
var compilationService = new RoslynCompilationService(applicationEnvironment,
|
||||
accessor,
|
||||
libraryManager,
|
||||
libraryExporter,
|
||||
compilerOptionsProvider.Object,
|
||||
mvcRazorHost,
|
||||
GetOptions(fileProvider));
|
||||
|
|
@ -104,7 +104,7 @@ this should fail";
|
|||
var content = @"this should fail";
|
||||
var applicationEnvironment = GetApplicationEnvironment();
|
||||
var accessor = GetLoadContextAccessor();
|
||||
var libraryManager = GetLibraryManager();
|
||||
var libraryExporter = GetLibraryExporter();
|
||||
|
||||
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
|
||||
compilerOptionsProvider.Setup(p => p.GetCompilerOptions(applicationEnvironment.ApplicationName,
|
||||
|
|
@ -115,7 +115,7 @@ this should fail";
|
|||
|
||||
var compilationService = new RoslynCompilationService(applicationEnvironment,
|
||||
accessor,
|
||||
libraryManager,
|
||||
libraryExporter,
|
||||
compilerOptionsProvider.Object,
|
||||
mvcRazorHost,
|
||||
GetOptions());
|
||||
|
|
@ -144,7 +144,7 @@ this should fail";
|
|||
this should fail";
|
||||
var applicationEnvironment = GetApplicationEnvironment();
|
||||
var accessor = GetLoadContextAccessor();
|
||||
var libraryManager = GetLibraryManager();
|
||||
var libraryExporter = GetLibraryExporter();
|
||||
|
||||
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
|
||||
compilerOptionsProvider.Setup(p => p.GetCompilerOptions(applicationEnvironment.ApplicationName,
|
||||
|
|
@ -161,7 +161,7 @@ this should fail";
|
|||
|
||||
var compilationService = new RoslynCompilationService(applicationEnvironment,
|
||||
accessor,
|
||||
libraryManager,
|
||||
libraryExporter,
|
||||
compilerOptionsProvider.Object,
|
||||
mvcRazorHost,
|
||||
GetOptions(fileProvider));
|
||||
|
|
@ -192,7 +192,7 @@ public class MyNonCustomDefinedClass {}
|
|||
";
|
||||
var applicationEnvironment = GetApplicationEnvironment();
|
||||
var accessor = GetLoadContextAccessor();
|
||||
var libraryManager = GetLibraryManager();
|
||||
var libraryExporter = GetLibraryExporter();
|
||||
|
||||
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
|
||||
compilerOptionsProvider.Setup(p => p.GetCompilerOptions(applicationEnvironment.ApplicationName,
|
||||
|
|
@ -205,7 +205,7 @@ public class MyNonCustomDefinedClass {}
|
|||
|
||||
var compilationService = new RoslynCompilationService(applicationEnvironment,
|
||||
accessor,
|
||||
libraryManager,
|
||||
libraryExporter,
|
||||
compilerOptionsProvider.Object,
|
||||
mvcRazorHost.Object,
|
||||
GetOptions());
|
||||
|
|
@ -229,7 +229,7 @@ public class RazorPrefixType {}
|
|||
public class NotRazorPrefixType {}";
|
||||
var applicationEnvironment = GetApplicationEnvironment();
|
||||
var accessor = GetLoadContextAccessor();
|
||||
var libraryManager = GetLibraryManager();
|
||||
var libraryExporter = GetLibraryExporter();
|
||||
|
||||
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
|
||||
compilerOptionsProvider.Setup(p => p.GetCompilerOptions(applicationEnvironment.ApplicationName,
|
||||
|
|
@ -242,7 +242,7 @@ public class NotRazorPrefixType {}";
|
|||
|
||||
var compilationService = new RoslynCompilationService(applicationEnvironment,
|
||||
accessor,
|
||||
libraryManager,
|
||||
libraryExporter,
|
||||
compilerOptionsProvider.Object,
|
||||
mvcRazorHost.Object,
|
||||
GetOptions());
|
||||
|
|
@ -275,7 +275,7 @@ public class NotRazorPrefixType {}";
|
|||
var compilationService = new RoslynCompilationService(
|
||||
GetApplicationEnvironment(),
|
||||
GetLoadContextAccessor(),
|
||||
GetLibraryManager(),
|
||||
GetLibraryExporter(),
|
||||
Mock.Of<ICompilerOptionsProvider>(),
|
||||
Mock.Of<IMvcRazorHost>(),
|
||||
options.Object);
|
||||
|
|
@ -365,21 +365,17 @@ public class NotRazorPrefixType {}";
|
|||
isEnabledByDefault: true);
|
||||
}
|
||||
|
||||
private static ILibraryManager GetLibraryManager()
|
||||
private static ILibraryExporter GetLibraryExporter()
|
||||
{
|
||||
var fileReference = new Mock<IMetadataFileReference>();
|
||||
fileReference.SetupGet(f => f.Path)
|
||||
.Returns(typeof(string).Assembly.Location);
|
||||
var libraryExport = new Mock<ILibraryExport>();
|
||||
libraryExport.SetupGet(e => e.MetadataReferences)
|
||||
.Returns(new[] { fileReference.Object });
|
||||
libraryExport.SetupGet(e => e.SourceReferences)
|
||||
.Returns(new ISourceReference[0]);
|
||||
var libraryExport = new LibraryExport(fileReference.Object);
|
||||
|
||||
var libraryManager = new Mock<ILibraryManager>();
|
||||
libraryManager.Setup(l => l.GetAllExports(It.IsAny<string>()))
|
||||
.Returns(libraryExport.Object);
|
||||
return libraryManager.Object;
|
||||
var libraryExporter = new Mock<ILibraryExporter>();
|
||||
libraryExporter.Setup(l => l.GetAllExports(It.IsAny<string>()))
|
||||
.Returns(libraryExport);
|
||||
return libraryExporter.Object;
|
||||
}
|
||||
|
||||
private static IAssemblyLoadContextAccessor GetLoadContextAccessor()
|
||||
|
|
|
|||
Loading…
Reference in New Issue