Skip to content

[WIP] Link more assemblies using type granularity #17819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Components/Blazor/Blazor/src/Hosting/WebAssemblyHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ internal class WebAssemblyHost : IWebAssemblyHost

public WebAssemblyHost(IServiceProvider services, IJSRuntime runtime)
{
// To ensure [JSInterop] methods don't get linked out, have a reference to their enclosing types
GC.KeepAlive(typeof(JSInteropMethods));
GC.KeepAlive(typeof(WebAssemblyEventDispatcher));

Services = services ?? throw new ArgumentNullException(nameof(services));
_runtime = runtime ?? throw new ArgumentNullException(nameof(runtime));
}
Expand Down
8 changes: 8 additions & 0 deletions src/Components/Blazor/Build/src/Tasks/BlazorILLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ protected override string GenerateResponseFileCommands()
args.Append(action);
args.Append(" ").AppendLine(Quote(assemblyName));
}

var actionflag = assembly.GetMetadata("actionflag");
if ((actionflag != null) && (actionflag.Length > 0))
{
args.Append("-f ");
args.Append(actionflag);
args.Append(" ").AppendLine(Quote(assemblyName));
}
}

if (ReferenceAssemblyPaths != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
Outputs="$(_BlazorLinkerOutputCache)">

<ItemGroup>
<_BlazorDependencyAssembly Include="@(_BlazorDependencyInput)" IsLinkable="$([System.String]::Copy('%(FileName)').StartsWith('System.'))" />
<_BlazorDependencyAssembly Include="@(_BlazorDependencyInput)" />
<_BlazorDependencyAssembly IsLinkable="true" Condition="$([System.String]::Copy(%(Filename)).StartsWith('System.'))" />
<_BlazorDependencyAssembly IsLinkable="true" ActionFlag="TypeGranularity" Condition="$([System.String]::Copy(%(Filename)).StartsWith('Microsoft.AspNetCore.'))" />
<_BlazorDependencyAssembly IsLinkable="true" Condition="$([System.String]::Copy(%(Filename)).StartsWith('Microsoft.Extensions.'))" />

<_BlazorAssemblyToLink Include="@(_WebAssemblyBCLAssembly)" />
<_BlazorAssemblyToLink Include="@(_BlazorDependencyAssembly)" Condition="'%(_BlazorDependencyAssembly.IsLinkable)' == 'true'" />
Expand Down