-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API to Renderer to trigger a UI refresh on hot reload (#30884)
* Add API to Renderer to trigger a UI refresh on hot reload Fixes #30816
- Loading branch information
Showing
26 changed files
with
498 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Components/Components/src/HotReload/HotReloadContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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. | ||
|
||
namespace Microsoft.AspNetCore.Components.HotReload | ||
{ | ||
/// <summary> | ||
/// A context that indicates when a component is being rendered because of a hot reload operation. | ||
/// </summary> | ||
public sealed class HotReloadContext | ||
{ | ||
/// <summary> | ||
/// Gets a value that indicates if the application is re-rendering in response to a hot-reload change. | ||
/// </summary> | ||
public bool IsHotReloading { get; internal set; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Components/Components/src/HotReload/HotReloadEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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. | ||
|
||
using System; | ||
|
||
namespace Microsoft.AspNetCore.Components.HotReload | ||
{ | ||
internal class HotReloadEnvironment | ||
{ | ||
public static readonly HotReloadEnvironment Instance = new(Environment.GetEnvironmentVariable("DOTNET_MODIFIABLE_ASSEMBLIES") == "debug"); | ||
|
||
public HotReloadEnvironment(bool isHotReloadEnabled) | ||
{ | ||
IsHotReloadEnabled = isHotReloadEnabled; | ||
} | ||
|
||
/// <summary> | ||
/// Gets a value that determines if HotReload is configured for this application. | ||
/// </summary> | ||
public bool IsHotReloadEnabled { get; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Components/Components/src/HotReload/HotReloadManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyMetadata("ReceiveHotReloadDeltaNotification", "Microsoft.AspNetCore.Components.HotReload.HotReloadManager")] | ||
|
||
namespace Microsoft.AspNetCore.Components.HotReload | ||
{ | ||
internal static class HotReloadManager | ||
{ | ||
internal static event Action? OnDeltaApplied; | ||
|
||
public static void DeltaApplied() | ||
{ | ||
OnDeltaApplied?.Invoke(); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Components/Components/src/HotReload/IReceiveHotReloadContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 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. | ||
|
||
namespace Microsoft.AspNetCore.Components.HotReload | ||
{ | ||
/// <summary> | ||
/// Allows a component to receive a <see cref="HotReloadContext"/>. | ||
/// </summary> | ||
public interface IReceiveHotReloadContext : IComponent | ||
{ | ||
/// <summary> | ||
/// Configures a component to use the hot reload context. | ||
/// </summary> | ||
/// <param name="context">The hot reload context.</param> | ||
void Receive(HotReloadContext context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Components/Components/src/Properties/ILLink.Substitutions.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<linker> | ||
<assembly fullname="Microsoft.AspNetCore.Components" > | ||
<!-- HotReload will not be available in a trimmed app. We'll attempt to aggressively remove all references to it. --> | ||
<type fullname="Microsoft.AspNetCore.Components.RenderTree.Renderer"> | ||
<method signature="System.Void RenderRootComponentsOnHotReload()" body="remove" /> | ||
<method signature="System.Void InitializeHotReload(System.IServiceProvider)" body="stub" /> | ||
<method signature="System.Void InstatiateComponentForHotReload(Microsoft.AspNetCore.Components.IComponent)" body="stub" /> | ||
<method signature="System.Void CaptureRootComponentForHotReload(Microsoft.AspNetCore.Components.ParameterView,Microsoft.AspNetCore.Components.Rendering.ComponentState)" body="stub" /> | ||
<method signature="System.Void DisposeForHotReload()" body="stub" /> | ||
</type> | ||
<type fullname="Microsoft.AspNetCore.Components.HotReload.HotReloadContext"> | ||
<method signature="System.Boolean get_IsHotReloading()" body="stub" value="false" /> | ||
<method signature="System.Void set_IsHotReloading(System.Boolean)" body="remove" /> | ||
</type> | ||
<type fullname="Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder"> | ||
<method signature="System.Boolean IsHotReloading(Microsoft.AspNetCore.Components.RenderTree.Renderer)" body="stub" value="false" /> | ||
</type> | ||
</assembly> | ||
</linker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.