1414
1515#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
1616
17- namespace Microsoft . DotNet . HotReload . WebAssembly ;
17+ namespace Microsoft . DotNet . HotReload . WebAssembly . Browser ;
1818
1919/// <summary>
2020/// Contains methods called by interop. Intended for framework use only, not supported for use in application
@@ -63,9 +63,11 @@ public readonly struct Delta
6363 private static bool s_initialized ;
6464 private static HotReloadAgent ? s_hotReloadAgent ;
6565
66- internal static async Task InitializeAsync ( string baseUri )
66+ [ JSExport ]
67+ [ SupportedOSPlatform ( "browser" ) ]
68+ public static async Task InitializeAsync ( string baseUri )
6769 {
68- if ( Environment . GetEnvironmentVariable ( "__ASPNETCORE_BROWSER_TOOLS" ) == "true" &&
70+ if ( MetadataUpdater . IsSupported && Environment . GetEnvironmentVariable ( "__ASPNETCORE_BROWSER_TOOLS" ) == "true" &&
6971 OperatingSystem . IsBrowser ( ) )
7072 {
7173 s_initialized = true ;
@@ -131,20 +133,7 @@ private static async ValueTask ApplyPreviousDeltasAsync(HotReloadAgent agent, st
131133 private static HotReloadAgent ? GetAgent ( )
132134 => s_hotReloadAgent ?? ( s_initialized ? throw new InvalidOperationException ( "Hot Reload agent not initialized" ) : null ) ;
133135
134- /// <summary>
135- /// For framework use only.
136- /// </summary>
137- [ Obsolete ( "Use ApplyHotReloadDeltas instead" ) ]
138- public static void ApplyHotReloadDelta ( string moduleIdString , byte [ ] metadataDelta , byte [ ] ilDelta , byte [ ] pdbBytes , int [ ] ? updatedTypes )
139- {
140- GetAgent ( ) ? . ApplyDeltas (
141- [ new UpdateDelta ( Guid . Parse ( moduleIdString , CultureInfo . InvariantCulture ) , metadataDelta , ilDelta , pdbBytes , updatedTypes ?? [ ] ) ] ) ;
142- }
143-
144- /// <summary>
145- /// For framework use only.
146- /// </summary>
147- public static LogEntry [ ] ApplyHotReloadDeltas ( Delta [ ] deltas , int loggingLevel )
136+ private static LogEntry [ ] ApplyHotReloadDeltas ( Delta [ ] deltas , int loggingLevel )
148137 {
149138 var agent = GetAgent ( ) ;
150139
@@ -155,34 +144,13 @@ public static LogEntry[] ApplyHotReloadDeltas(Delta[] deltas, int loggingLevel)
155144 . Select ( log => new LogEntry ( ) { Message = log . message , Severity = ( int ) log . severity } ) . ToArray ( ) ;
156145 }
157146
158- /// <summary>
159- /// For framework use only.
160- /// </summary>
161- public static string GetApplyUpdateCapabilities ( )
162- => GetAgent ( ) ? . Capabilities ?? "" ;
163- }
164-
165- internal static partial class Interop
166- {
167147 private static readonly WebAssemblyHotReloadJsonSerializerContext jsonContext = new ( new ( JsonSerializerDefaults . Web ) ) ;
168148
169- [ JSExport ]
170- [ SupportedOSPlatform ( "browser" ) ]
171- public static Task InitializeAsync ( string baseUri )
172- {
173- if ( MetadataUpdater . IsSupported )
174- {
175- return WebAssemblyHotReload . InitializeAsync ( baseUri ) ;
176- }
177-
178- return Task . CompletedTask ;
179- }
180-
181149 [ JSExport ]
182150 [ SupportedOSPlatform ( "browser" ) ]
183151 public static string GetApplyUpdateCapabilities ( )
184152 {
185- return WebAssemblyHotReload . GetApplyUpdateCapabilities ( ) ;
153+ return GetAgent ( ) ? . Capabilities ?? "" ;
186154 }
187155
188156 [ JSExport ]
@@ -195,7 +163,7 @@ public static string ApplyHotReloadDeltas(string deltasJson, int loggingLevel)
195163 return null ;
196164 }
197165
198- var result = WebAssemblyHotReload . ApplyHotReloadDeltas ( deltas , loggingLevel ) ;
166+ var result = ApplyHotReloadDeltas ( deltas , loggingLevel ) ;
199167 return result == null ? null : JsonSerializer . Serialize ( result , jsonContext . LogEntryArray ) ;
200168 }
201169}
0 commit comments