V10 - Reduce usage of temp AspNetCoreHostingEnvironment (#12270)

* Move MapPathWebRoot & MapPathContentRoot to extension methods.

* Set AspNetCoreHostingEnvironment ApplicationId without service provider.

* Drop some usages of TempHostingEnvironment

* Logging setup cleanup - AppDomainId has no value (it is always "1")

Creating new AppDomains isn't possible in .Net core.
Attempting to do so results in a platform exception.

A dotnet core process has a single AppDomain instance whose Id property
is always the integer 1.

* Setup logging without IHostingEnvironment

* Mark IUmbracoBuilder.BuilderHostingEnvironment obsolete
And remove internal usages.

* Typeloader no longer uses umbraco-types.list

* Added UmbracoHost - setup serilog two-stage init.

* Add ApplicationIdEnricher

* Defensive tweaks for those not using UmbracoHost

* Drop UmbracoHost static class

* Setup runtime logger without host builder extensions.

* Prevent RefreshingRazorViewEngine related explosions

* Filescoped namespaces for new classes.

* Apply suggestions from code review
This commit is contained in:
Paul Johnson
2022-04-25 15:27:53 +01:00
committed by GitHub
parent f9840ed4b1
commit 551f523079
24 changed files with 629 additions and 810 deletions

View File

@@ -0,0 +1,35 @@
using System;
using Microsoft.AspNetCore.DataProtection.Infrastructure;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.Common.Extensions
{
/// <summary>
/// Contains extension methods for the <see cref="IApplicationDiscriminator" /> interface.
/// </summary>
public static class ApplicationDiscriminatorExtensions
{
private static string s_applicationId;
/// <summary>
/// Gets an application id which respects downstream customizations.
/// </summary>
/// <remarks>
/// Hashed to obscure any unintended infrastructure details e.g. the default value is ContentRootPath.
/// </remarks>
public static string GetApplicationId(this IApplicationDiscriminator applicationDiscriminator)
{
if (s_applicationId != null)
{
return s_applicationId;
}
if (applicationDiscriminator == null)
{
throw new ArgumentNullException(nameof(applicationDiscriminator));
}
return s_applicationId = applicationDiscriminator.Discriminator.GenerateHash();
}
}
}