Merge remote-tracking branch 'origin/release/2.2'
This commit is contained in:
commit
caa9778180
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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.Generic;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
|
|
@ -9,6 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the list of <see cref="MetadataReference"/> used in Razor compilation.
|
/// Specifies the list of <see cref="MetadataReference"/> used in Razor compilation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This type is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")]
|
||||||
public class MetadataReferenceFeature
|
public class MetadataReferenceFeature
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
/// uses <see cref="DependencyContext"/> for registered <see cref="AssemblyPart"/> instances to create
|
/// uses <see cref="DependencyContext"/> for registered <see cref="AssemblyPart"/> instances to create
|
||||||
/// <see cref="MetadataReference"/>.
|
/// <see cref="MetadataReference"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This type is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")]
|
||||||
public class MetadataReferenceFeatureProvider : IApplicationFeatureProvider<MetadataReferenceFeature>
|
public class MetadataReferenceFeatureProvider : IApplicationFeatureProvider<MetadataReferenceFeature>
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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.Generic;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
|
|
@ -9,6 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manages compilation references for Razor compilation.
|
/// Manages compilation references for Razor compilation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This type is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")]
|
||||||
public abstract class RazorReferenceManager
|
public abstract class RazorReferenceManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,12 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
private static void AddRazorViewEngineFeatureProviders(IMvcCoreBuilder builder)
|
private static void AddRazorViewEngineFeatureProviders(IMvcCoreBuilder builder)
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
if (!builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>().Any())
|
if (!builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>().Any())
|
||||||
{
|
{
|
||||||
builder.PartManager.FeatureProviders.Add(new MetadataReferenceFeatureProvider());
|
builder.PartManager.FeatureProviders.Add(new MetadataReferenceFeatureProvider());
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
if (!builder.PartManager.FeatureProviders.OfType<TagHelperFeatureProvider>().Any())
|
if (!builder.PartManager.FeatureProviders.OfType<TagHelperFeatureProvider>().Any())
|
||||||
{
|
{
|
||||||
|
|
@ -146,7 +148,9 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
internal static void AddRazorViewEngineServices(IServiceCollection services)
|
internal static void AddRazorViewEngineServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.TryAddSingleton<CSharpCompiler>();
|
services.TryAddSingleton<CSharpCompiler>();
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
services.TryAddSingleton<RazorReferenceManager, DefaultRazorReferenceManager>();
|
services.TryAddSingleton<RazorReferenceManager, DefaultRazorReferenceManager>();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
services.TryAddEnumerable(
|
services.TryAddEnumerable(
|
||||||
ServiceDescriptor.Transient<IConfigureOptions<MvcViewOptions>, MvcRazorMvcViewOptionsSetup>());
|
ServiceDescriptor.Transient<IConfigureOptions<MvcViewOptions>, MvcRazorMvcViewOptionsSetup>());
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
public class CSharpCompiler
|
public class CSharpCompiler
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
private readonly RazorReferenceManager _referenceManager;
|
private readonly RazorReferenceManager _referenceManager;
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
private readonly IHostingEnvironment _hostingEnvironment;
|
private readonly IHostingEnvironment _hostingEnvironment;
|
||||||
private bool _optionsInitialized;
|
private bool _optionsInitialized;
|
||||||
private CSharpParseOptions _parseOptions;
|
private CSharpParseOptions _parseOptions;
|
||||||
|
|
@ -27,7 +29,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
private EmitOptions _emitOptions;
|
private EmitOptions _emitOptions;
|
||||||
private bool _emitPdb;
|
private bool _emitPdb;
|
||||||
|
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public CSharpCompiler(RazorReferenceManager manager, IHostingEnvironment hostingEnvironment)
|
public CSharpCompiler(RazorReferenceManager manager, IHostingEnvironment hostingEnvironment)
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
_referenceManager = manager ?? throw new ArgumentNullException(nameof(manager));
|
_referenceManager = manager ?? throw new ArgumentNullException(nameof(manager));
|
||||||
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
|
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public class DefaultRazorReferenceManager : RazorReferenceManager
|
public class DefaultRazorReferenceManager : RazorReferenceManager
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
private readonly ApplicationPartManager _partManager;
|
private readonly ApplicationPartManager _partManager;
|
||||||
private readonly IList<MetadataReference> _additionalMetadataReferences;
|
private readonly IList<MetadataReference> _additionalMetadataReferences;
|
||||||
|
|
@ -24,7 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
IOptions<RazorViewEngineOptions> optionsAccessor)
|
IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
_partManager = partManager;
|
_partManager = partManager;
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
_additionalMetadataReferences = optionsAccessor.Value.AdditionalCompilationReferences;
|
_additionalMetadataReferences = optionsAccessor.Value.AdditionalCompilationReferences;
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IReadOnlyList<MetadataReference> CompilationReferences
|
public override IReadOnlyList<MetadataReference> CompilationReferences
|
||||||
|
|
@ -41,7 +45,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
|
|
||||||
private IReadOnlyList<MetadataReference> GetCompilationReferences()
|
private IReadOnlyList<MetadataReference> GetCompilationReferences()
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var feature = new MetadataReferenceFeature();
|
var feature = new MetadataReferenceFeature();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
_partManager.PopulateFeature(feature);
|
_partManager.PopulateFeature(feature);
|
||||||
var applicationReferences = feature.MetadataReferences;
|
var applicationReferences = feature.MetadataReferences;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
public class LazyMetadataReferenceFeature : IMetadataReferenceFeature
|
public class LazyMetadataReferenceFeature : IMetadataReferenceFeature
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
private readonly RazorReferenceManager _referenceManager;
|
private readonly RazorReferenceManager _referenceManager;
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public LazyMetadataReferenceFeature(RazorReferenceManager referenceManager)
|
public LazyMetadataReferenceFeature(RazorReferenceManager referenceManager)
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
_referenceManager = referenceManager;
|
_referenceManager = referenceManager;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
_fileProviderAccessor.FileProvider,
|
_fileProviderAccessor.FileProvider,
|
||||||
_razorProjectEngine,
|
_razorProjectEngine,
|
||||||
_csharpCompiler,
|
_csharpCompiler,
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
_viewEngineOptions.CompilationCallback,
|
_viewEngineOptions.CompilationCallback,
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
feature.ViewDescriptors,
|
feature.ViewDescriptors,
|
||||||
_compilationMemoryCacheProvider.CompilationMemoryCache,
|
_compilationMemoryCacheProvider.CompilationMemoryCache,
|
||||||
_logger);
|
_logger);
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
/// Gets the <see cref="MetadataReference" /> instances that should be included in Razor compilation, along with
|
/// Gets the <see cref="MetadataReference" /> instances that should be included in Razor compilation, along with
|
||||||
/// those discovered by <see cref="MetadataReferenceFeatureProvider" />s.
|
/// those discovered by <see cref="MetadataReferenceFeatureProvider" />s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This property is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")]
|
||||||
public IList<MetadataReference> AdditionalCompilationReferences { get; } = new List<MetadataReference>();
|
public IList<MetadataReference> AdditionalCompilationReferences { get; } = new List<MetadataReference>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -166,6 +167,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Customizations made here would not reflect in tooling (Intellisense).
|
/// Customizations made here would not reflect in tooling (Intellisense).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[Obsolete("This property is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")]
|
||||||
public Action<RoslynCompilationContext> CompilationCallback
|
public Action<RoslynCompilationContext> CompilationCallback
|
||||||
{
|
{
|
||||||
get => _compilationCallback;
|
get => _compilationCallback;
|
||||||
|
|
|
||||||
|
|
@ -257,8 +257,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
// not function properly.
|
// not function properly.
|
||||||
Href = output.Attributes[HrefAttributeName]?.Value as string;
|
Href = output.Attributes[HrefAttributeName]?.Value as string;
|
||||||
|
|
||||||
Mode mode;
|
if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out var mode))
|
||||||
if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out mode))
|
|
||||||
{
|
{
|
||||||
// No attributes matched so we have nothing to do
|
// No attributes matched so we have nothing to do
|
||||||
return;
|
return;
|
||||||
|
|
@ -295,8 +294,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
||||||
if (mode == Mode.Fallback && HasStyleSheetLinkType(output.Attributes))
|
if (mode == Mode.Fallback && HasStyleSheetLinkType(output.Attributes))
|
||||||
{
|
{
|
||||||
string resolvedUrl;
|
if (TryResolveUrl(FallbackHref, resolvedUrl: out string resolvedUrl))
|
||||||
if (TryResolveUrl(FallbackHref, resolvedUrl: out resolvedUrl))
|
|
||||||
{
|
{
|
||||||
FallbackHref = resolvedUrl;
|
FallbackHref = resolvedUrl;
|
||||||
}
|
}
|
||||||
|
|
@ -395,17 +393,15 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
||||||
private bool HasStyleSheetLinkType(TagHelperAttributeList attributes)
|
private bool HasStyleSheetLinkType(TagHelperAttributeList attributes)
|
||||||
{
|
{
|
||||||
TagHelperAttribute relAttribute;
|
if (!attributes.TryGetAttribute(RelAttributeName, out var relAttribute) ||
|
||||||
if (!attributes.TryGetAttribute(RelAttributeName, out relAttribute) ||
|
|
||||||
relAttribute.Value == null)
|
relAttribute.Value == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributeValue = relAttribute.Value;
|
var attributeValue = relAttribute.Value;
|
||||||
var contentValue = attributeValue as IHtmlContent;
|
|
||||||
var stringValue = attributeValue as string;
|
var stringValue = attributeValue as string;
|
||||||
if (contentValue != null)
|
if (attributeValue is IHtmlContent contentValue)
|
||||||
{
|
{
|
||||||
contentValue.WriteTo(StringWriter, HtmlEncoder);
|
contentValue.WriteTo(StringWriter, HtmlEncoder);
|
||||||
stringValue = StringWriter.ToString();
|
stringValue = StringWriter.ToString();
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
// not function properly.
|
// not function properly.
|
||||||
Src = output.Attributes[SrcAttributeName]?.Value as string;
|
Src = output.Attributes[SrcAttributeName]?.Value as string;
|
||||||
|
|
||||||
Mode mode;
|
if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out var mode))
|
||||||
if (!AttributeMatcher.TryDetermineMode(context, ModeDetails, Compare, out mode))
|
|
||||||
{
|
{
|
||||||
// No attributes matched so we have nothing to do
|
// No attributes matched so we have nothing to do
|
||||||
return;
|
return;
|
||||||
|
|
@ -259,8 +258,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
||||||
if (mode == Mode.Fallback)
|
if (mode == Mode.Fallback)
|
||||||
{
|
{
|
||||||
string resolvedUrl;
|
if (TryResolveUrl(FallbackSrc, resolvedUrl: out string resolvedUrl))
|
||||||
if (TryResolveUrl(FallbackSrc, resolvedUrl: out resolvedUrl))
|
|
||||||
{
|
{
|
||||||
FallbackSrc = resolvedUrl;
|
FallbackSrc = resolvedUrl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public class MetadataReferenceFeatureProviderTest
|
public class MetadataReferenceFeatureProviderTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -48,4 +49,5 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
reference => reference.Display.Equals(currentAssembly.Location));
|
reference => reference.Display.Equals(currentAssembly.Location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.DependencyInjection
|
||||||
builder.AddRazorViewEngine();
|
builder.AddRazorViewEngine();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
Assert.Single(builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>());
|
Assert.Single(builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>());
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -83,7 +85,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.DependencyInjection
|
||||||
builder.AddRazorViewEngine();
|
builder.AddRazorViewEngine();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
Assert.Single(builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>());
|
Assert.Single(builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>());
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -92,7 +96,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.DependencyInjection
|
||||||
// Arrange
|
// Arrange
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
var builder = services.AddMvcCore();
|
var builder = services.AddMvcCore();
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var metadataReferenceFeatureProvider = new MetadataReferenceFeatureProvider();
|
var metadataReferenceFeatureProvider = new MetadataReferenceFeatureProvider();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
builder.PartManager.FeatureProviders.Add(metadataReferenceFeatureProvider);
|
builder.PartManager.FeatureProviders.Add(metadataReferenceFeatureProvider);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -100,7 +106,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.DependencyInjection
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actual = Assert.Single(
|
var actual = Assert.Single(
|
||||||
builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>());
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
collection: builder.PartManager.FeatureProviders.OfType<MetadataReferenceFeatureProvider>());
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Same(metadataReferenceFeatureProvider, actual);
|
Assert.Same(metadataReferenceFeatureProvider, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
public class CSharpCompilerTest
|
public class CSharpCompilerTest
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
private readonly RazorReferenceManager ReferenceManager = Mock.Of<RazorReferenceManager>();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(null)]
|
[InlineData(null)]
|
||||||
[InlineData("")]
|
[InlineData("")]
|
||||||
|
|
@ -24,8 +28,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>(e => e.ApplicationName == name);
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>(e => e.ApplicationName == name);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment);
|
||||||
var compiler = new CSharpCompiler(referenceManager, hostingEnvironment);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var options = compiler.GetDependencyContextCompilationOptions();
|
var options = compiler.GetDependencyContextCompilationOptions();
|
||||||
|
|
@ -41,8 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
||||||
hostingEnvironment.SetupGet(e => e.ApplicationName)
|
hostingEnvironment.SetupGet(e => e.ApplicationName)
|
||||||
.Returns(typeof(Controller).GetTypeInfo().Assembly.GetName().Name);
|
.Returns(typeof(Controller).GetTypeInfo().Assembly.GetName().Name);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment.Object);
|
||||||
var compiler = new CSharpCompiler(referenceManager, hostingEnvironment.Object);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var options = compiler.GetDependencyContextCompilationOptions();
|
var options = compiler.GetDependencyContextCompilationOptions();
|
||||||
|
|
@ -58,7 +60,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
||||||
hostingEnvironment.SetupGet(e => e.ApplicationName)
|
hostingEnvironment.SetupGet(e => e.ApplicationName)
|
||||||
.Returns(GetType().GetTypeInfo().Assembly.GetName().Name);
|
.Returns(GetType().GetTypeInfo().Assembly.GetName().Name);
|
||||||
var compiler = new CSharpCompiler(Mock.Of<RazorReferenceManager>(), hostingEnvironment.Object);
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment.Object);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var parseOptions = compiler.ParseOptions;
|
var parseOptions = compiler.ParseOptions;
|
||||||
|
|
@ -78,7 +80,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
||||||
hostingEnvironment.SetupGet(e => e.EnvironmentName)
|
hostingEnvironment.SetupGet(e => e.EnvironmentName)
|
||||||
.Returns(environment);
|
.Returns(environment);
|
||||||
var compiler = new CSharpCompiler(Mock.Of<RazorReferenceManager>(), hostingEnvironment.Object);
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment.Object);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var compilationOptions = compiler.CSharpCompilationOptions;
|
var compilationOptions = compiler.CSharpCompilationOptions;
|
||||||
|
|
@ -96,7 +98,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
var hostingEnvironment = new Mock<IHostingEnvironment>();
|
||||||
hostingEnvironment.SetupGet(e => e.EnvironmentName)
|
hostingEnvironment.SetupGet(e => e.EnvironmentName)
|
||||||
.Returns(environment);
|
.Returns(environment);
|
||||||
var compiler = new CSharpCompiler(Mock.Of<RazorReferenceManager>(), hostingEnvironment.Object);
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment.Object);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var parseOptions = compiler.ParseOptions;
|
var parseOptions = compiler.ParseOptions;
|
||||||
|
|
@ -108,7 +110,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>(h => h.EnvironmentName == "Development");
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>(h => h.EnvironmentName == "Development");
|
||||||
var compiler = new CSharpCompiler(Mock.Of<RazorReferenceManager>(), hostingEnvironment);
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var compilationOptions = compiler.CSharpCompilationOptions;
|
var compilationOptions = compiler.CSharpCompilationOptions;
|
||||||
|
|
@ -138,7 +140,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>(h => h.EnvironmentName == "Development");
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>(h => h.EnvironmentName == "Development");
|
||||||
var compiler = new CSharpCompiler(Mock.Of<RazorReferenceManager>(), hostingEnvironment);
|
var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var parseOptions = compiler.ParseOptions;
|
var parseOptions = compiler.ParseOptions;
|
||||||
|
|
@ -163,10 +165,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: null,
|
debugType: null,
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var compilationOptions = compiler.ParseOptions;
|
var compilationOptions = compiler.ParseOptions;
|
||||||
|
|
@ -191,10 +192,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: "portable",
|
debugType: "portable",
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var emitOptions = compiler.EmitOptions;
|
var emitOptions = compiler.EmitOptions;
|
||||||
|
|
@ -219,10 +219,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: "embedded",
|
debugType: "embedded",
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var emitOptions = compiler.EmitOptions;
|
var emitOptions = compiler.EmitOptions;
|
||||||
|
|
@ -247,10 +246,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: "none",
|
debugType: "none",
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
Assert.False(compiler.EmitPdb);
|
Assert.False(compiler.EmitPdb);
|
||||||
|
|
@ -273,10 +271,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: null,
|
debugType: null,
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var compilationOptions = compiler.CSharpCompilationOptions;
|
var compilationOptions = compiler.CSharpCompilationOptions;
|
||||||
|
|
@ -300,10 +297,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: null,
|
debugType: null,
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var compilationOptions = compiler.CSharpCompilationOptions;
|
var compilationOptions = compiler.CSharpCompilationOptions;
|
||||||
|
|
@ -327,10 +323,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: null,
|
debugType: null,
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var compilationOptions = compiler.CSharpCompilationOptions;
|
var compilationOptions = compiler.CSharpCompilationOptions;
|
||||||
|
|
@ -354,10 +349,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: null,
|
debugType: null,
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
|
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var parseOptions = compiler.ParseOptions;
|
var parseOptions = compiler.ParseOptions;
|
||||||
|
|
@ -383,9 +377,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
debugType: null,
|
debugType: null,
|
||||||
emitEntryPoint: null,
|
emitEntryPoint: null,
|
||||||
generateXmlDocumentation: null);
|
generateXmlDocumentation: null);
|
||||||
var referenceManager = Mock.Of<RazorReferenceManager>();
|
|
||||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||||
var compiler = new TestCSharpCompiler(referenceManager, hostingEnvironment, dependencyContextOptions);
|
var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var syntaxTree = compiler.CreateSyntaxTree(SourceText.From(content));
|
var syntaxTree = compiler.CreateSyntaxTree(SourceText.From(content));
|
||||||
|
|
@ -399,7 +392,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
||||||
private readonly DependencyContextCompilationOptions _options;
|
private readonly DependencyContextCompilationOptions _options;
|
||||||
|
|
||||||
public TestCSharpCompiler(
|
public TestCSharpCompiler(
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
RazorReferenceManager referenceManager,
|
RazorReferenceManager referenceManager,
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
IHostingEnvironment hostingEnvironment,
|
IHostingEnvironment hostingEnvironment,
|
||||||
DependencyContextCompilationOptions options)
|
DependencyContextCompilationOptions options)
|
||||||
: base(referenceManager, hostingEnvironment)
|
: base(referenceManager, hostingEnvironment)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal
|
namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public class DefaultRazorReferenceManagerTest
|
public class DefaultRazorReferenceManagerTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -52,4 +53,5 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.Internal
|
||||||
return applicationPartManager;
|
return applicationPartManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -824,7 +824,9 @@ this should fail";
|
||||||
private static TestRazorViewCompiler GetViewCompiler(
|
private static TestRazorViewCompiler GetViewCompiler(
|
||||||
TestFileProvider fileProvider = null,
|
TestFileProvider fileProvider = null,
|
||||||
Action<RoslynCompilationContext> compilationCallback = null,
|
Action<RoslynCompilationContext> compilationCallback = null,
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
RazorReferenceManager referenceManager = null,
|
RazorReferenceManager referenceManager = null,
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
IList<CompiledViewDescriptor> precompiledViews = null,
|
IList<CompiledViewDescriptor> precompiledViews = null,
|
||||||
CSharpCompiler csharpCompiler = null)
|
CSharpCompiler csharpCompiler = null)
|
||||||
{
|
{
|
||||||
|
|
@ -858,6 +860,7 @@ this should fail";
|
||||||
return viewCompiler;
|
return viewCompiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
private static RazorReferenceManager CreateReferenceManager(IOptions<RazorViewEngineOptions> options)
|
private static RazorReferenceManager CreateReferenceManager(IOptions<RazorViewEngineOptions> options)
|
||||||
{
|
{
|
||||||
var applicationPartManager = new ApplicationPartManager();
|
var applicationPartManager = new ApplicationPartManager();
|
||||||
|
|
@ -867,6 +870,7 @@ this should fail";
|
||||||
|
|
||||||
return new DefaultRazorReferenceManager(applicationPartManager, options);
|
return new DefaultRazorReferenceManager(applicationPartManager, options);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
private class TestRazorViewCompiler : RazorViewCompiler
|
private class TestRazorViewCompiler : RazorViewCompiler
|
||||||
{
|
{
|
||||||
|
|
@ -900,7 +904,9 @@ this should fail";
|
||||||
|
|
||||||
private class TestCSharpCompiler : CSharpCompiler
|
private class TestCSharpCompiler : CSharpCompiler
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public TestCSharpCompiler(RazorReferenceManager manager, IHostingEnvironment hostingEnvironment)
|
public TestCSharpCompiler(RazorReferenceManager manager, IHostingEnvironment hostingEnvironment)
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
: base(manager, hostingEnvironment)
|
: base(manager, hostingEnvironment)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,9 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
Assert.Collection(manager.FeatureProviders,
|
Assert.Collection(manager.FeatureProviders,
|
||||||
feature => Assert.IsType<ControllerFeatureProvider>(feature),
|
feature => Assert.IsType<ControllerFeatureProvider>(feature),
|
||||||
feature => Assert.IsType<ViewComponentFeatureProvider>(feature),
|
feature => Assert.IsType<ViewComponentFeatureProvider>(feature),
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
feature => Assert.IsType<MetadataReferenceFeatureProvider>(feature),
|
feature => Assert.IsType<MetadataReferenceFeatureProvider>(feature),
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
feature => Assert.IsType<TagHelperFeatureProvider>(feature),
|
feature => Assert.IsType<TagHelperFeatureProvider>(feature),
|
||||||
feature => Assert.IsType<RazorCompiledItemFeatureProvider>(feature),
|
feature => Assert.IsType<RazorCompiledItemFeatureProvider>(feature),
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace ControllersFromServicesWebSite
|
namespace ControllersFromServicesWebSite
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public class AssemblyMetadataReferenceFeatureProvider : IApplicationFeatureProvider<MetadataReferenceFeature>
|
public class AssemblyMetadataReferenceFeatureProvider : IApplicationFeatureProvider<MetadataReferenceFeature>
|
||||||
{
|
{
|
||||||
public void PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature)
|
public void PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature)
|
||||||
|
|
@ -17,4 +18,5 @@ namespace ControllersFromServicesWebSite
|
||||||
feature.MetadataReferences.Add(MetadataReference.CreateFromFile(currentAssembly.Location));
|
feature.MetadataReferences.Add(MetadataReference.CreateFromFile(currentAssembly.Location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue