diff --git a/src/mono/mono/component/hot_reload.c b/src/mono/mono/component/hot_reload.c index 09df9461f89f6e..c76caa61439517 100644 --- a/src/mono/mono/component/hot_reload.c +++ b/src/mono/mono/component/hot_reload.c @@ -2118,6 +2118,13 @@ apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base if (func_code == ENC_FUNC_ADD_PARAM) break; + if (!base_info->method_table_update) + base_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal); + if (!delta_info->method_table_update) + delta_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal); + if (!delta_info->method_ppdb_table_update) + delta_info->method_ppdb_table_update = g_hash_table_new (g_direct_hash, g_direct_equal); + if (is_addition) { g_assertf (add_member_typedef, "EnC: new method added but I don't know the class, should be caught by pass1"); if (pass2_context_is_skeleton (ctx, add_member_typedef)) { @@ -2139,14 +2146,6 @@ apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base add_member_typedef = 0; } - if (!base_info->method_table_update) - base_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal); - if (!delta_info->method_table_update) - delta_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal); - if (!delta_info->method_ppdb_table_update) - - delta_info->method_ppdb_table_update = g_hash_table_new (g_direct_hash, g_direct_equal); - int mapped_token = hot_reload_relative_delta_index (image_dmeta, delta_info, mono_metadata_make_token (token_table, token_index)); guint32 rva = mono_metadata_decode_row_col (&image_dmeta->tables [MONO_TABLE_METHOD], mapped_token - 1, MONO_METHOD_RVA); if (rva < dil_length) { diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index 3c015f83add7f3..6d6fa4c4036caf 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -996,7 +996,7 @@ private void PopulateEnC(MetadataReader asmMetadataReaderParm, MetadataReader pd { var document = pdbMetadataReaderParm.GetDocument(methodDebugInformation.Document); var documentName = pdbMetadataReaderParm.GetString(document.Name); - source = GetOrAddSourceFile(methodDebugInformation.Document, asmMetadataReaderParm.GetRowNumber(methodDebugInformation.Document), documentName); + source = GetOrAddSourceFile(methodDebugInformation.Document, documentName); } var methodInfo = new MethodInfo(this, MetadataTokens.MethodDefinitionHandle(methodIdxAsm), entryRow, source, typeInfo, asmMetadataReaderParm, pdbMetadataReaderParm); methods[entryRow] = methodInfo; @@ -1019,13 +1019,13 @@ private void PopulateEnC(MetadataReader asmMetadataReaderParm, MetadataReader pd } } } - private SourceFile GetOrAddSourceFile(DocumentHandle doc, int rowid, string documentName) + private SourceFile GetOrAddSourceFile(DocumentHandle doc, string documentName) { - if (_documentIdToSourceFileTable.TryGetValue(rowid, out SourceFile source)) + if (_documentIdToSourceFileTable.TryGetValue(documentName.GetHashCode(), out SourceFile source)) return source; var src = new SourceFile(this, _documentIdToSourceFileTable.Count, doc, GetSourceLinkUrl(documentName), documentName); - _documentIdToSourceFileTable[rowid] = src; + _documentIdToSourceFileTable[documentName.GetHashCode()] = src; return src; } @@ -1055,7 +1055,7 @@ private void Populate() { var document = pdbMetadataReader.GetDocument(methodDebugInformation.Document); var documentName = pdbMetadataReader.GetString(document.Name); - source = GetOrAddSourceFile(methodDebugInformation.Document, asmMetadataReader.GetRowNumber(methodDebugInformation.Document), documentName); + source = GetOrAddSourceFile(methodDebugInformation.Document, documentName); } } var methodInfo = new MethodInfo(this, method, asmMetadataReader.GetRowNumber(method), source, typeInfo, asmMetadataReader, pdbMetadataReader); diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 0aa7650c42c2bd..1130f53efc97d8 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -871,7 +871,7 @@ private async Task SendBreakpointsOfMethodUpdated(SessionId sessionId, Exe { var methodId = retDebuggerCmdReader.ReadInt32(); var method = await context.SdbAgent.GetMethodInfo(methodId, token); - if (method == null) + if (method == null || method.Info.Source is null) { return true; } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs index 01c3a787e8fb83..555c0cf744dcd8 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs @@ -1322,7 +1322,7 @@ internal async Task LoadAssemblyDynamicallyALCAndRunMethod(string asm_f return await WaitFor(Inspector.PAUSE); } - internal async Task LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(string asm_file, string pdb_file, string class_name, string method_name, bool expectBpResolvedEvent) + internal async Task LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(string asm_file, string pdb_file, string class_name, string method_name, bool expectBpResolvedEvent, params string[] sourcesToWait) { byte[] bytes = File.ReadAllBytes(asm_file); string asm_base64 = Convert.ToBase64String(bytes); @@ -1338,7 +1338,7 @@ internal async Task LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( Task eventTask = expectBpResolvedEvent ? WaitForBreakpointResolvedEvent() - : WaitForScriptParsedEventsAsync("MethodBody0.cs", "MethodBody1.cs"); + : WaitForScriptParsedEventsAsync(sourcesToWait); (await cli.SendCommand("Runtime.evaluate", load_assemblies, token)).AssertOk(); await eventTask; @@ -1397,7 +1397,7 @@ internal async Task LoadAssemblyAndTestHotReloadUsingSDB(string asm_fil return await WaitFor(Inspector.PAUSE); } - internal async Task LoadAssemblyAndTestHotReload(string asm_file, string pdb_file, string asm_file_hot_reload, string class_name, string method_name, bool expectBpResolvedEvent) + internal async Task LoadAssemblyAndTestHotReload(string asm_file, string pdb_file, string asm_file_hot_reload, string class_name, string method_name, bool expectBpResolvedEvent, string[] sourcesToWait, string methodName2 = "", string methodName3 = "") { byte[] bytes = File.ReadAllBytes(asm_file); string asm_base64 = Convert.ToBase64String(bytes); @@ -1434,13 +1434,18 @@ internal async Task LoadAssemblyAndTestHotReload(string asm_file, strin Task eventTask = expectBpResolvedEvent ? WaitForBreakpointResolvedEvent() - : WaitForScriptParsedEventsAsync("MethodBody0.cs", "MethodBody1.cs"); + : WaitForScriptParsedEventsAsync(sourcesToWait); (await cli.SendCommand("Runtime.evaluate", load_assemblies, token)).AssertOk(); await eventTask; + if (methodName2 == "") + methodName2 = method_name; + if (methodName3 == "") + methodName3 = method_name; + var run_method = JObject.FromObject(new { - expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReload:RunMethod', '" + class_name + "', '" + method_name + "'); }, 1);" + expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReload:RunMethod', '" + class_name + "', '" + method_name + "', '" + methodName2 + "', '" + methodName3 + "'); }, 1);" }); await cli.SendCommand("Runtime.evaluate", run_method, token); diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs index 7e5f5fa3cd8102..eec98fcbd1902b 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs @@ -22,7 +22,7 @@ public async Task DebugHotReloadMethodChangedUserBreak() Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"), Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"), Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"), - "MethodBody1", "StaticMethod1", expectBpResolvedEvent: false); + "MethodBody1", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 16, "ApplyUpdateReferencedAssembly.MethodBody1.StaticMethod1"); @@ -40,7 +40,7 @@ public async Task DebugHotReloadMethodUnchanged() Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"), Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"), Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"), - "MethodBody2", "StaticMethod1", expectBpResolvedEvent: false); + "MethodBody2", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "ApplyUpdateReferencedAssembly.MethodBody2.StaticMethod1"); @@ -62,7 +62,7 @@ public async Task DebugHotReloadMethodAddBreakpoint(string assembly_name) Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"), Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"), Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll"), - "MethodBody3", "StaticMethod3", expectBpResolvedEvent: true); + "MethodBody3", "StaticMethod3", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); @@ -110,7 +110,7 @@ public async Task DebugHotReloadMethodEmpty() Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"), Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"), Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"), - "MethodBody4", "StaticMethod4", expectBpResolvedEvent: true); + "MethodBody4", "StaticMethod4", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 38, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4"); @@ -166,7 +166,7 @@ public async Task DebugHotReloadMethodChangedUserBreakUsingSDB() string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody1", "StaticMethod1", expectBpResolvedEvent: false); + asm_file, pdb_file, "MethodBody1", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); @@ -198,7 +198,7 @@ public async Task DebugHotReloadMethodUnchangedUsingSDB() string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody2", "StaticMethod1", expectBpResolvedEvent: false); + asm_file, pdb_file, "MethodBody2", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); @@ -231,7 +231,7 @@ public async Task DebugHotReloadMethodAddBreakpointUsingSDB(string assembly_name int line = 30; await SetBreakpoint(".*/MethodBody1.cs$", line, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody3", "StaticMethod3", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody3", "StaticMethod3", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); @@ -294,7 +294,7 @@ public async Task DebugHotReloadMethodEmptyUsingSDB() int line = 38; await SetBreakpoint(".*/MethodBody1.cs$", line, 0, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody4", "StaticMethod4", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody4", "StaticMethod4", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); //apply first update pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( @@ -351,7 +351,7 @@ public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated var bp = await SetBreakpoint(".*/MethodBody1.cs$", 48, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); //apply first update pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( @@ -376,7 +376,7 @@ public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated var bp = await SetBreakpoint(".*/MethodBody1.cs$", 49, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); //apply first update pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( @@ -403,7 +403,7 @@ public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 48, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 48, 12, scripts, pause_location["callFrames"]?[0]["location"]); //apply first update @@ -426,7 +426,7 @@ public async Task DebugHotReloadMethod_AddingNewMethod() var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 59, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); //apply first update @@ -456,7 +456,7 @@ public async Task DebugHotReloadMethod_AddingNewStaticField() var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 59, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); //apply first update @@ -492,7 +492,7 @@ public async Task DebugHotReloadMethod_AddingNewClass() var bp_invalid2 = await SetBreakpoint(".*/MethodBody1.cs$", 102, 12, use_regex: true); var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true); + asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); //apply first update @@ -530,5 +530,36 @@ await EvaluateOnCallFrameAndCheck(pause_location["callFrames"]?[0]["callFrameId" await EvaluateOnCallFrameAndCheck(pause_location["callFrames"]?[0]["callFrameId"].Value(), ("ApplyUpdateReferencedAssembly.MethodBody8.staticField", TNumber(80))); } + + [ConditionalFact(nameof(RunningOnChrome))] + public async Task DebugHotReloadMethod_AddingNewMethodWithoutAnyOtherChange() + { + string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly2.dll"); + string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly2.pdb"); + string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly2.dll"); + + var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( + asm_file, pdb_file, "AddMethod", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody2.cs" }); + CheckLocation("dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 12, 12, scripts, pause_location["callFrames"]?[0]["location"]); + //apply first update + pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( + asm_file_hot_reload, "AddMethod", "StaticMethod2", 1); + + JToken top_frame = pause_location["callFrames"]?[0]; + AssertEqual("ApplyUpdateReferencedAssembly.AddMethod.StaticMethod2", top_frame?["functionName"]?.Value(), top_frame?.ToString()); + CheckLocation("dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 18, 12, scripts, top_frame["location"]); + } + + [ConditionalFact(nameof(RunningOnChrome))] + public async Task DebugHotReloadMethod_AddingNewMethodWithoutAnyOtherChange_WithoutSDB() + { + var pause_location = await LoadAssemblyAndTestHotReload( + Path.Combine(DebuggerTestAppPath, $"ApplyUpdateReferencedAssembly2.dll"), + Path.Combine(DebuggerTestAppPath, $"ApplyUpdateReferencedAssembly2.pdb"), + Path.Combine(DebuggerTestAppPath, $"../wasm/ApplyUpdateReferencedAssembly2.dll"), + "AddMethod", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody2.cs" }, "StaticMethod2"); + CheckLocation("dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 12, 12, scripts, pause_location["callFrames"]?[0]["location"]); + await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", $"dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 18, 12, "ApplyUpdateReferencedAssembly.AddMethod.StaticMethod2"); + } } } diff --git a/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj new file mode 100644 index 00000000000000..f024e0e58b3f6b --- /dev/null +++ b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj @@ -0,0 +1,35 @@ + + + true + deltascript.json + library + false + true + + false + true + + false + false + false + true + + + true + + + + + + + + + + + diff --git a/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs new file mode 100644 index 00000000000000..9ae61a4ee789e5 --- /dev/null +++ b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System; +//keep the same line number for class in the original file and the updates ones +namespace ApplyUpdateReferencedAssembly +{ + public class AddMethod { + public static string StaticMethod1 () { + Console.WriteLine("original"); + int a = 10; + Debugger.Break(); + return "OLD STRING"; + } + } +} \ No newline at end of file diff --git a/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs new file mode 100644 index 00000000000000..b8e75a4e39300b --- /dev/null +++ b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System; +//keep the same line number for class in the original file and the updates ones +namespace ApplyUpdateReferencedAssembly +{ + public class AddMethod { + public static string StaticMethod1 () { + Console.WriteLine("original"); + int a = 10; + Debugger.Break(); + return "OLD STRING"; + } + public static string StaticMethod2 () { + Console.WriteLine("original"); + int a = 10; + Debugger.Break(); + return "OLD STRING"; + } + } +} \ No newline at end of file diff --git a/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs new file mode 100644 index 00000000000000..615e47f2c936b4 --- /dev/null +++ b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System; +//keep the same line number for class in the original file and the updates ones +namespace ApplyUpdateReferencedAssembly +{ + public class AddMethod { + public static string StaticMethod1 () { + Console.WriteLine("original"); + int a = 10; + Debugger.Break(); + return "OLD STRING"; + } + public static string StaticMethod2 () { + Console.WriteLine("original"); + int a = 10; + Debugger.Break(); + return "OLD STRING"; + } + public static string StaticMethod3 () { + Console.WriteLine("original"); + int a = 10; + Debugger.Break(); + return "OLD STRING"; + } + } +} \ No newline at end of file diff --git a/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json new file mode 100644 index 00000000000000..6603dcff23d1f8 --- /dev/null +++ b/src/mono/wasm/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json @@ -0,0 +1,7 @@ +{ + "changes": [ + {"document": "MethodBody2.cs", "update": "MethodBody2_v1.cs"}, + {"document": "MethodBody2.cs", "update": "MethodBody2_v2.cs"} + ] +} + diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs index 6b5f84561beb9e..b8f52c788f0d2b 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -604,7 +604,7 @@ public static void LoadLazyHotReload(string asm_base64, string pdb_base64, strin Console.WriteLine($"Loaded - {loadedAssembly}"); } - public static void RunMethod(string className, string methodName) + public static void RunMethod(string className, string methodName, string methodName2, string methodName3) { var ty = typeof(System.Reflection.Metadata.MetadataUpdater); var mi = ty.GetMethod("GetCapabilities", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, Array.Empty()); @@ -624,13 +624,13 @@ public static void RunMethod(string className, string methodName) ApplyUpdate(loadedAssembly, 1); myType = loadedAssembly.GetType($"ApplyUpdateReferencedAssembly.{className}"); - myMethod = myType.GetMethod(methodName); + myMethod = myType.GetMethod(methodName2); myMethod.Invoke(null, null); ApplyUpdate(loadedAssembly, 2); myType = loadedAssembly.GetType($"ApplyUpdateReferencedAssembly.{className}"); - myMethod = myType.GetMethod(methodName); + myMethod = myType.GetMethod(methodName3); myMethod.Invoke(null, null); } diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj index c6977c5f2d0407..a9d8b0e66ecdc0 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -20,6 +20,7 @@ +