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