Suppress warnings for obsolete Extensions types
This commit is contained in:
parent
49a720c1dc
commit
b571246c93
|
|
@ -1,4 +1,4 @@
|
|||
// 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.
|
||||
|
||||
using System.Threading;
|
||||
|
|
@ -7,8 +7,10 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
{
|
||||
internal class GenericWebHostApplicationLifetime : IApplicationLifetime
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
private readonly Microsoft.Extensions.Hosting.IApplicationLifetime _applicationLifetime;
|
||||
public GenericWebHostApplicationLifetime(Microsoft.Extensions.Hosting.IApplicationLifetime applicationLifetime)
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
_applicationLifetime = applicationLifetime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// 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.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -11,7 +10,9 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
/// <summary>
|
||||
/// Allows consumers to perform cleanup during a graceful shutdown.
|
||||
/// </summary>
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
public class ApplicationLifetime : IApplicationLifetime, Extensions.Hosting.IApplicationLifetime
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
private readonly CancellationTokenSource _startedSource = new CancellationTokenSource();
|
||||
private readonly CancellationTokenSource _stoppingSource = new CancellationTokenSource();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ using Microsoft.Extensions.FileProviders;
|
|||
|
||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;
|
||||
|
||||
|
|
@ -19,4 +21,4 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
|
||||
public IFileProvider ContentRootFileProvider { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,9 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
// There's no way to to register multiple service types per definition. See https://github.com/aspnet/DependencyInjection/issues/360
|
||||
_applicationServiceCollection.AddSingleton(sp =>
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
return sp.GetRequiredService<IApplicationLifetime>() as Extensions.Hosting.IApplicationLifetime;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
});
|
||||
_applicationServiceCollection.AddSingleton<HostedServiceExecutor>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,7 +254,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
var services = new ServiceCollection();
|
||||
services.AddSingleton(_options);
|
||||
services.AddSingleton<IHostingEnvironment>(_hostingEnvironment);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
services.AddSingleton<Extensions.Hosting.IHostingEnvironment>(_hostingEnvironment);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
services.AddSingleton(_context);
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
|
|
|
|||
|
|
@ -552,7 +552,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
Assert.Equal(expected, host.Services.GetService<IHostingEnvironment>().EnvironmentName);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Assert.Equal(expected, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().EnvironmentName);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -597,7 +599,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
Assert.Equal("/", host.Services.GetService<IHostingEnvironment>().ContentRootPath);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Assert.Equal("/", host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -612,7 +616,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var basePath = host.Services.GetRequiredService<IHostingEnvironment>().ContentRootPath;
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var basePath2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
Assert.True(Path.IsPathRooted(basePath));
|
||||
Assert.EndsWith(Path.DirectorySeparatorChar + "testroot", basePath);
|
||||
|
|
@ -633,7 +639,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
var appBase = AppContext.BaseDirectory;
|
||||
Assert.Equal(appBase, host.Services.GetService<IHostingEnvironment>().ContentRootPath);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Assert.Equal(appBase, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -659,7 +667,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var hostingEnv2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
||||
}
|
||||
|
|
@ -675,7 +685,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var hostingEnv2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var lifetime2 = host.Services.GetRequiredService<Extensions.Hosting.IApplicationLifetime>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
var server = (FakeServer)host.Services.GetRequiredService<IServer>();
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
|
|
@ -415,7 +417,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var applicationLifetime2 = host.Services.GetService<Extensions.Hosting.IApplicationLifetime>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
Assert.False(applicationLifetime.ApplicationStarted.IsCancellationRequested);
|
||||
Assert.False(applicationLifetime2.ApplicationStarted.IsCancellationRequested);
|
||||
|
|
@ -434,7 +438,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var applicationLifetime2 = host.Services.GetService<Extensions.Hosting.IApplicationLifetime>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
||||
var stopping = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStopping);
|
||||
|
|
@ -682,7 +688,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var applicationLifetime2 = host.Services.GetService<Extensions.Hosting.IApplicationLifetime>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
||||
var stopping = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStopping);
|
||||
|
|
@ -714,7 +722,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
await host.StartAsync();
|
||||
var env = host.Services.GetService<IHostingEnvironment>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var env2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Assert.Equal("Changed", env.EnvironmentName);
|
||||
Assert.Equal("Changed", env2.EnvironmentName);
|
||||
}
|
||||
|
|
@ -799,7 +809,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
using (var host = CreateBuilder().UseFakeServer().Build())
|
||||
{
|
||||
var env = host.Services.GetService<IHostingEnvironment>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var env2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Assert.Equal(EnvironmentName.Production, env.EnvironmentName);
|
||||
Assert.Equal(EnvironmentName.Production, env2.EnvironmentName);
|
||||
}
|
||||
|
|
@ -820,7 +832,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
using (var host = CreateBuilder(config).UseFakeServer().Build())
|
||||
{
|
||||
var env = host.Services.GetService<IHostingEnvironment>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var env2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
|
||||
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
|
||||
}
|
||||
|
|
@ -1022,7 +1036,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
private readonly IApplicationLifetime _lifetime;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
public TestHostedService(IApplicationLifetime lifetime, Extensions.Hosting.IApplicationLifetime lifetime2)
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
_lifetime = lifetime;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue