Skip to content

Commit 223fe49

Browse files
Obsolete RazorRuntimeCompilation (#62793)
1 parent 773dd5a commit 223fe49

19 files changed

+51
-0
lines changed

src/Mvc/Mvc.Razor.RuntimeCompilation/src/AssemblyPartExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts;
99
/// <summary>
1010
/// Static class that adds methods to <see cref="AssemblyPart"/>.
1111
/// </summary>
12+
[Obsolete("Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead. For more information, visit https://aka.ms/aspnet/deprecate/003.", DiagnosticId = "ASPDEPR003")]
1213
public static class AssemblyPartExtensions
1314
{
1415
/// <inheritdoc />

src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/MvcRazorRuntimeCompilationOptionsSetup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
88

9+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
910
internal sealed class MvcRazorRuntimeCompilationOptionsSetup : IConfigureOptions<MvcRazorRuntimeCompilationOptions>
11+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
1012
{
1113
private readonly IWebHostEnvironment _hostingEnvironment;
1214

@@ -15,7 +17,9 @@ public MvcRazorRuntimeCompilationOptionsSetup(IWebHostEnvironment hostingEnviron
1517
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
1618
}
1719

20+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
1821
public void Configure(MvcRazorRuntimeCompilationOptions options)
22+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
1923
{
2024
ArgumentNullException.ThrowIfNull(options);
2125

src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/RazorRuntimeCompilationMvcBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Microsoft.Extensions.DependencyInjection;
88
/// <summary>
99
/// Static class that adds razor compilation extension methods.
1010
/// </summary>
11+
[Obsolete("Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead. For more information, visit https://aka.ms/aspnet/deprecate/003.", DiagnosticId = "ASPDEPR003")]
1112
public static class RazorRuntimeCompilationMvcBuilderExtensions
1213
{
1314
/// <summary>

src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/RazorRuntimeCompilationMvcCoreBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection;
2020
/// <summary>
2121
/// Static class that adds razor runtime compilation extension methods.
2222
/// </summary>
23+
[Obsolete("Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead. For more information, visit https://aka.ms/aspnet/deprecate/003.", DiagnosticId = "ASPDEPR003")]
2324
public static class RazorRuntimeCompilationMvcCoreBuilderExtensions
2425
{
2526
/// <summary>

src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectFileSystem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public override RazorProjectItem GetItem(string path, string? fileKind)
3434
path = NormalizeAndEnsureValidPath(path);
3535
var fileInfo = FileProvider.GetFileInfo(path);
3636

37+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
3738
return new FileProviderRazorProjectItem(fileInfo, basePath: string.Empty, filePath: path, root: _hostingEnvironment.ContentRootPath, fileKind);
39+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
3840
}
3941

4042
public override IEnumerable<RazorProjectItem> EnumerateItems(string path)
@@ -63,7 +65,9 @@ private IEnumerable<RazorProjectItem> EnumerateFiles(IDirectoryContents director
6365
{
6466
var filePath = prefix + "/" + fileInfo.Name;
6567

68+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
6669
yield return new FileProviderRazorProjectItem(fileInfo, basePath, filePath: filePath, root: _hostingEnvironment.ContentRootPath);
70+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
6771
}
6872
}
6973
}

src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
99
/// <summary>
1010
/// A file provider <see cref="RazorProjectItem"/>.
1111
/// </summary>
12+
[Obsolete("Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead. For more information, visit https://aka.ms/aspnet/deprecate/003.", DiagnosticId = "ASPDEPR003")]
1213
public class FileProviderRazorProjectItem : RazorProjectItem
1314
{
1415
private readonly string _root;

src/Mvc/Mvc.Razor.RuntimeCompilation/src/MvcRazorRuntimeCompilationOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
1010
/// <summary>
1111
/// Used to configure razor compilation.
1212
/// </summary>
13+
[Obsolete("Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead. For more information, visit https://aka.ms/aspnet/deprecate/003.", DiagnosticId = "ASPDEPR003")]
1314
public class MvcRazorRuntimeCompilationOptions
1415
{
1516
/// <summary>

src/Mvc/Mvc.Razor.RuntimeCompilation/src/RazorReferenceManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ internal class RazorReferenceManager
1414
#pragma warning restore CA1852 // Seal internal types
1515
{
1616
private readonly ApplicationPartManager _partManager;
17+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
1718
private readonly MvcRazorRuntimeCompilationOptions _options;
19+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
1820
private object _compilationReferencesLock = new object();
1921
private bool _compilationReferencesInitialized;
2022
private IReadOnlyList<MetadataReference>? _compilationReferences;
2123

2224
public RazorReferenceManager(
2325
ApplicationPartManager partManager,
26+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
2427
IOptions<MvcRazorRuntimeCompilationOptions> options)
28+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
2529
{
2630
_partManager = partManager;
2731
_options = options.Value;

src/Mvc/Mvc.Razor.RuntimeCompilation/src/RazorRuntimeCompilationHostingStartup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ internal sealed class RazorRuntimeCompilationHostingStartup : IHostingStartup
1111
public void Configure(IWebHostBuilder builder)
1212
{
1313
// Add Razor services
14+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
1415
builder.ConfigureServices(RazorRuntimeCompilationMvcCoreBuilderExtensions.AddServices);
16+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
1517
}
1618
}

src/Mvc/Mvc.Razor.RuntimeCompilation/src/RuntimeCompilationFileProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
88

99
internal sealed class RuntimeCompilationFileProvider
1010
{
11+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
1112
private readonly MvcRazorRuntimeCompilationOptions _options;
13+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
1214
private IFileProvider? _compositeFileProvider;
1315

16+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
1417
public RuntimeCompilationFileProvider(IOptions<MvcRazorRuntimeCompilationOptions> options)
18+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
1519
{
1620
ArgumentNullException.ThrowIfNull(options);
1721

@@ -31,15 +35,19 @@ public IFileProvider FileProvider
3135
}
3236
}
3337

38+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
3439
private static IFileProvider GetCompositeFileProvider(MvcRazorRuntimeCompilationOptions options)
40+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
3541
{
3642
var fileProviders = options.FileProviders;
3743
if (fileProviders.Count == 0)
3844
{
45+
#pragma warning disable ASPDEPR003 // Type or member is obsolete
3946
var message = Resources.FormatFileProvidersAreRequired(
4047
typeof(MvcRazorRuntimeCompilationOptions).FullName,
4148
nameof(MvcRazorRuntimeCompilationOptions.FileProviders),
4249
typeof(IFileProvider).FullName);
50+
#pragma warning restore ASPDEPR003 // Type or member is obsolete
4351
throw new InvalidOperationException(message);
4452
}
4553
else if (fileProviders.Count == 1)

0 commit comments

Comments
 (0)