Skip to content

Commit

Permalink
Remove WebView dependency to AspNetCore.App (#31071)
Browse files Browse the repository at this point in the history
The Blazor Desktop project must not depend on Microsoft.AspNetCore.App because it needs to run on almost any platform, including Android/iOS. But AspNetCore.App doesn't run on those platforms. This changes WebView to not use any packages that are part of AspNetCore.App, such as StaticFiles and Http.Abstractions. Instead, it has copies of those files.
  • Loading branch information
Eilon authored Mar 19, 2021
1 parent 30e468e commit 2d5da9c
Show file tree
Hide file tree
Showing 9 changed files with 1,483 additions and 4 deletions.
473 changes: 473 additions & 0 deletions src/Components/WebView/WebView/src/FileExtensionContentTypeProvider.cs

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/Components/WebView/WebView/src/IContentTypeProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

// NOTE: This file is copied from src/Middleware/StaticFiles/src/FileExtensionContentTypeProvider.cs
// and made internal with a namespace change.
// It can't be referenced directly from the StaticFiles package because that would cause this package to require
// Microsoft.AspNetCore.App, thus preventing it from being used anywhere ASP.NET Core isn't supported (such as
// various platforms that .NET MAUI runs on, such as Android and iOS).

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.AspNetCore.Components.WebView
{
/// <summary>
/// Used to look up MIME types given a file path
/// </summary>
internal interface IContentTypeProvider
{
/// <summary>
/// Given a file path, determine the MIME type
/// </summary>
/// <param name="subpath">A file path</param>
/// <param name="contentType">The resulting MIME type</param>
/// <returns>True if MIME type could be determined</returns>
bool TryGetContentType(string subpath, [MaybeNullWhen(false)] out string contentType);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
Expand Down Expand Up @@ -28,7 +28,6 @@

<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Components.Web" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
<Reference Include="Microsoft.Extensions.Configuration.Json" />
<Reference Include="Microsoft.Extensions.Configuration.Binder" />
<Reference Include="Microsoft.Extensions.FileProviders.Embedded" />
Expand Down
Loading

0 comments on commit 2d5da9c

Please sign in to comment.