Skip to content
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

Add support for updatedTypes in metadata updates #55347

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Components/Web.JS/src/Boot.WebAssembly.Common.ts
Expand Up @@ -97,8 +97,8 @@ async function startCore(components: RootComponentManager<WebAssemblyComponentDe
}
});

Blazor._internal.applyHotReload = (id: string, metadataDelta: string, ilDelta: string, pdbDelta: string | undefined) => {
dispatcher.invokeDotNetStaticMethod('Microsoft.AspNetCore.Components.WebAssembly', 'ApplyHotReloadDelta', id, metadataDelta, ilDelta, pdbDelta);
Blazor._internal.applyHotReload = (id: string, metadataDelta: string, ilDelta: string, pdbDelta: string | undefined, updatedTypes: number[]) => {
dispatcher.invokeDotNetStaticMethod('Microsoft.AspNetCore.Components.WebAssembly', 'ApplyHotReloadDelta', id, metadataDelta, ilDelta, pdbDelta, updatedTypes);
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved
};

Blazor._internal.getApplyUpdateCapabilities = () => dispatcher.invokeDotNetStaticMethod('Microsoft.AspNetCore.Components.WebAssembly', 'GetApplyUpdateCapabilities');
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Web.JS/src/GlobalExports.ts
Expand Up @@ -89,7 +89,7 @@ export interface IBlazor {
}

// APIs invoked by hot reload
applyHotReload?: (id: string, metadataDelta: string, ilDelta: string, pdbDelta: string | undefined) => void;
applyHotReload?: (id: string, metadataDelta: string, ilDelta: string, pdbDelta: string | undefined, updatedTypes: number[]) => void;
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved
getApplyUpdateCapabilities?: () => string;
hotReloadApplied?: () => void;
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
/// For framework use only.
/// </summary>
[JSInvokable(nameof(ApplyHotReloadDelta))]
public static void ApplyHotReloadDelta(string moduleIdString, byte[] metadataDelta, byte[] ilDelta, byte[] pdbBytes)
public static void ApplyHotReloadDelta(string moduleIdString, byte[] metadataDelta, byte[] ilDelta, byte[] pdbBytes, int[] updatedTypes)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 46 in src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs#L46

src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs(46,24): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'ApplyHotReloadDelta' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how the public API policy works here. The JS invoker will likely be able to invoke the method without a type, but there may be a need for a separate method that matches previous versions of VS (which injects the browserlink payload).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having two separate methods, could we allow the updatedTypes parameter to be an int[]?? It seems like this logic should still work even if the updated types are not provided by the scripts injected by the SDK. And we could make updated Blazor._internal.applyHotReload implementation pass updatedTypes ?? null in the call to dispatcher.invokeDotNetStaticMethod.

This is technically a breaking API change, but that should be fine in this case because the API is meant for framework use only (customers should not be relying on it).

If you are able to open the solution in VS, there should be a codefix to update the PublicAPI.*.txt files to reflect the public API changes. If you don't have this set up, I'd be happy to update those files and add the changes to this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I was indeed able to run the code fix, it added an entry in the unshipped file.

{
// Analyzer has a bug where it doesn't handle ConditionalAttribute: https://github.com/dotnet/roslyn/issues/63464
#pragma warning disable IDE0200 // Remove unnecessary lambda expression
Expand All @@ -56,6 +56,7 @@
_updateDeltas[0].MetadataDelta = metadataDelta;
_updateDeltas[0].ILDelta = ilDelta;
_updateDeltas[0].PdbBytes = pdbBytes;
_updateDeltas[0].UpdatedTypes = updatedTypes;

_hotReloadAgent.ApplyDeltas(_updateDeltas);
}
Expand Down