Add nullability to web.common

This commit is contained in:
Nikolaj Geisle
2022-03-29 13:44:21 +02:00
parent 86ae730b1e
commit b52c4e50cf
151 changed files with 731 additions and 675 deletions

View File

@@ -12,6 +12,6 @@ namespace Umbraco.Cms.Web.Common.DependencyInjection
public ScopedServiceProvider(IHttpContextAccessor accessor) => _accessor = accessor;
/// <inheritdoc />
public IServiceProvider ServiceProvider => _accessor.HttpContext?.RequestServices;
public IServiceProvider? ServiceProvider => _accessor.HttpContext?.RequestServices;
}
}

View File

@@ -62,8 +62,11 @@ namespace Umbraco.Extensions
var headers = context.Response.GetTypedHeaders();
var cacheControl = headers.CacheControl;
cacheControl.MustRevalidate = false;
cacheControl.Extensions.Add(new NameValueHeaderValue("immutable"));
if (cacheControl is not null)
{
cacheControl.MustRevalidate = false;
cacheControl.Extensions.Add(new NameValueHeaderValue("immutable"));
}
headers.CacheControl = cacheControl;
}
@@ -71,7 +74,7 @@ namespace Umbraco.Extensions
return Task.CompletedTask;
};
})
.Configure<PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment.MapPathContentRoot(imagingSettings.Cache.CacheFolder))
.Configure<PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment?.MapPathContentRoot(imagingSettings.Cache.CacheFolder))
.AddProcessor<CropWebProcessor>();
// Configure middleware to use the registered/shared ImageSharp configuration

View File

@@ -220,7 +220,7 @@ namespace Umbraco.Extensions
return builder;
}
public static IUmbracoBuilder AddMvcAndRazor(this IUmbracoBuilder builder, Action<IMvcBuilder> mvcBuilding = null)
public static IUmbracoBuilder AddMvcAndRazor(this IUmbracoBuilder builder, Action<IMvcBuilder>? mvcBuilding = null)
{
// TODO: We need to figure out if we can work around this because calling AddControllersWithViews modifies the global app and order is very important
// this will directly affect developers who need to call that themselves.
@@ -344,7 +344,7 @@ namespace Umbraco.Extensions
builder.Services.AddUnique<IBackOfficeSecurityAccessor, BackOfficeSecurityAccessor>();
var umbracoApiControllerTypes = builder.TypeLoader.GetUmbracoApiControllers().ToList();
builder.WithCollectionBuilder<UmbracoApiControllerTypeCollectionBuilder>()
builder.WithCollectionBuilder<UmbracoApiControllerTypeCollectionBuilder>()?
.Add(umbracoApiControllerTypes);
builder.Services.AddSingleton<UmbracoRequestLoggingMiddleware>();