Skip to content

Commit 824c902

Browse files
github-actions[bot]thaystgradical
authored
[release/7.0] [wasm][debugger] Fix chinese character in project name (#74816)
* Fix chinese character in project name * Adding more tests as suggested by @radical Renaming variable as suggested by @radical * Update src/mono/wasm/debugger/tests/debugger-test-chinese-char-in-path-ㄨ/debugger-test-chinese-char-in-path-ㄨ.csproj Co-authored-by: Thays Grazia <[email protected]> Co-authored-by: Ankit Jain <[email protected]>
1 parent 6f3db06 commit 824c902

File tree

14 files changed

+407
-27
lines changed

14 files changed

+407
-27
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,11 +1469,12 @@ public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_fil
14691469
continue;
14701470
try
14711471
{
1472+
string unescapedFileName = Uri.UnescapeDataString(file_name);
14721473
steps.Add(
14731474
new DebugItem
14741475
{
14751476
Url = file_name,
1476-
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(file_name), token)
1477+
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token)
14771478
});
14781479
}
14791480
catch (Exception e)

src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,43 +51,45 @@ public async Task DebugHotReloadMethodUnchanged()
5151
CheckNumber(locals, "a", 10);
5252
}
5353

54-
[ConditionalFact(nameof(RunningOnChrome))]
55-
public async Task DebugHotReloadMethodAddBreakpoint()
54+
[ConditionalTheory(nameof(RunningOnChrome))]
55+
[InlineData("ApplyUpdateReferencedAssembly")]
56+
[InlineData("ApplyUpdateReferencedAssemblyChineseCharInPathㄨ")]
57+
public async Task DebugHotReloadMethodAddBreakpoint(string assembly_name)
5658
{
5759
int line = 30;
5860
await SetBreakpoint(".*/MethodBody1.cs$", line, 12, use_regex: true);
5961
var pause_location = await LoadAssemblyAndTestHotReload(
60-
Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"),
61-
Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"),
62-
Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"),
62+
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"),
63+
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"),
64+
Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll"),
6365
"MethodBody3", "StaticMethod3", expectBpResolvedEvent: true);
6466

6567
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
6668
CheckNumber(locals, "a", 10);
67-
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 30, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3");
69+
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", $"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3");
6870
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
6971
CheckNumber(locals, "b", 15);
7072

71-
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 30, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3");
73+
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", $"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3");
7274
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
7375
await CheckBool(locals, "c", true);
7476

75-
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
77+
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
7678
locals_fn: async (locals) =>
7779
{
7880
CheckNumber(locals, "d", 10);
7981
await Task.CompletedTask;
8082
}
8183
);
82-
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
84+
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
8385
locals_fn: async (locals) =>
8486
{
8587
CheckNumber(locals, "d", 10);
8688
CheckNumber(locals, "e", 20);
8789
await Task.CompletedTask;
8890
}
8991
);
90-
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
92+
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
9193
locals_fn: async (locals) =>
9294
{
9395
CheckNumber(locals, "d", 10);
@@ -217,12 +219,14 @@ public async Task DebugHotReloadMethodUnchangedUsingSDB()
217219
CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, scripts, top_frame["location"]);
218220
}
219221

220-
[ConditionalFact(nameof(RunningOnChrome))]
221-
public async Task DebugHotReloadMethodAddBreakpointUsingSDB()
222+
[ConditionalTheory(nameof(RunningOnChrome))]
223+
[InlineData("ApplyUpdateReferencedAssembly")]
224+
[InlineData("ApplyUpdateReferencedAssemblyChineseCharInPathㄨ")]
225+
public async Task DebugHotReloadMethodAddBreakpointUsingSDB(string assembly_name)
222226
{
223-
string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll");
224-
string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb");
225-
string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll");
227+
string asm_file = Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll");
228+
string pdb_file = Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb");
229+
string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll");
226230

227231
int line = 30;
228232
await SetBreakpoint(".*/MethodBody1.cs$", line, 12, use_regex: true);
@@ -238,7 +242,7 @@ public async Task DebugHotReloadMethodAddBreakpointUsingSDB()
238242

239243
JToken top_frame = pause_location["callFrames"]?[0];
240244
AssertEqual("ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", top_frame?["functionName"]?.Value<string>(), top_frame?.ToString());
241-
CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 30, 12, scripts, top_frame["location"]);
245+
CheckLocation($"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, scripts, top_frame["location"]);
242246

243247
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
244248
CheckNumber(locals, "b", 15);
@@ -249,27 +253,27 @@ public async Task DebugHotReloadMethodAddBreakpointUsingSDB()
249253

250254
top_frame = pause_location["callFrames"]?[0];
251255
AssertEqual("ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", top_frame?["functionName"]?.Value<string>(), top_frame?.ToString());
252-
CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 30, 12, scripts, top_frame["location"]);
256+
CheckLocation($"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, scripts, top_frame["location"]);
253257

254258
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
255259
await CheckBool(locals, "c", true);
256260

257-
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
261+
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
258262
locals_fn: async (locals) =>
259263
{
260264
CheckNumber(locals, "d", 10);
261265
await Task.CompletedTask;
262266
}
263267
);
264-
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
268+
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
265269
locals_fn: async (locals) =>
266270
{
267271
CheckNumber(locals, "d", 10);
268272
CheckNumber(locals, "e", 20);
269273
await Task.CompletedTask;
270274
}
271275
);
272-
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
276+
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
273277
locals_fn: async (locals) =>
274278
{
275279
CheckNumber(locals, "d", 10);

src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,23 +735,25 @@ JObject FindFrame(JObject pause_location, string function_name)
735735
?.Where(f => f["functionName"]?.Value<string>() == function_name)
736736
?.FirstOrDefault();
737737

738-
[ConditionalFact(nameof(RunningOnChrome))]
739-
public async Task DebugLazyLoadedAssemblyWithPdb()
738+
[ConditionalTheory(nameof(RunningOnChrome))]
739+
[InlineData("lazy-debugger-test")]
740+
[InlineData("lazy-debugger-test-chinese-char-in-path-ㄨ")]
741+
public async Task DebugLazyLoadedAssemblyWithPdb(string assembly_name)
740742
{
741743
Task<JObject> bpResolved = WaitForBreakpointResolvedEvent();
742744
int line = 9;
743745
await SetBreakpoint(".*/lazy-debugger-test.cs$", line, 0, use_regex: true);
744746
await LoadAssemblyDynamically(
745-
Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.dll"),
746-
Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.pdb"));
747+
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"),
748+
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"));
747749

748-
var source_location = "dotnet://lazy-debugger-test.dll/lazy-debugger-test.cs";
750+
var source_location = $"dotnet://{assembly_name}.dll/lazy-debugger-test.cs";
749751
Assert.Contains(source_location, scripts.Values);
750752

751753
await bpResolved;
752754

753755
var pause_location = await EvaluateAndCheck(
754-
"window.setTimeout(function () { invoke_static_method('[lazy-debugger-test] LazyMath:IntAdd', 5, 10); }, 1);",
756+
"window.setTimeout(function () { invoke_static_method('[" + assembly_name + "] LazyMath:IntAdd', 5, 10); }, 1);",
755757
source_location, line, 8,
756758
"LazyMath.IntAdd");
757759
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
@@ -1086,5 +1088,17 @@ await EvaluateAndCheck(
10861088
}
10871089
);
10881090
}
1091+
1092+
[ConditionalFact(nameof(RunningOnChrome))]
1093+
public async Task SetBreakpointInProjectWithChineseCharactereInPath()
1094+
{
1095+
var bp = await SetBreakpointInMethod("debugger-test-chinese-char-in-path-ㄨ.dll", "DebuggerTests.CheckChineseCharacterInPath", "Evaluate", 1);
1096+
await EvaluateAndCheck(
1097+
$"window.setTimeout(function() {{ invoke_static_method ('[debugger-test-chinese-char-in-path-ㄨ] DebuggerTests.CheckChineseCharacterInPath:Evaluate'); }}, 1);",
1098+
"dotnet://debugger-test-chinese-char-in-path-ㄨ.dll/test.cs",
1099+
bp.Value["locations"][0]["lineNumber"].Value<int>(),
1100+
bp.Value["locations"][0]["columnNumber"].Value<int>(),
1101+
$"DebuggerTests.CheckChineseCharacterInPath.Evaluate");
1102+
}
10891103
}
10901104
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Project Sdk="Microsoft.NET.Sdk" TreatAsLocalProperty="EnableAggressiveTrimming;PublishTrimmed">
2+
<PropertyGroup>
3+
<TestRuntime>true</TestRuntime>
4+
<DeltaScript>deltascript.json</DeltaScript>
5+
<OutputType>library</OutputType>
6+
<IsTestProject>false</IsTestProject>
7+
<IsTestSupportProject>true</IsTestSupportProject>
8+
<!-- to call AsssemblyExtensions.ApplyUpdate we need Optimize=false, EmitDebugInformation=true in all configurations -->
9+
<Optimize>false</Optimize>
10+
<EmitDebugInformation>true</EmitDebugInformation>
11+
<!-- hot reload is not compatible with trimming -->
12+
<EnableAggressiveTrimming>false</EnableAggressiveTrimming>
13+
<PublishTrimmed>false</PublishTrimmed>
14+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
15+
<EmbedAllSources>true</EmbedAllSources>
16+
17+
<!-- FIXME: issue -->
18+
<DisableSourceLink>true</DisableSourceLink>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<Compile Include="MethodBody0.cs" />
23+
<Compile Include="MethodBody1.cs" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<!-- This package from https://github.com/dotnet/hotreload-utils provides
28+
targets that read the json delta script and generates deltas based on the baseline assembly and the modified sources.
29+
30+
Projects must define the DeltaScript property that specifies the (relative) path to the json script.
31+
Deltas will be emitted next to the output assembly. Deltas will be copied when the current
32+
project is referenced from other other projects.
33+
-->
34+
<PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="$(MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion)" />
35+
</ItemGroup>
36+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics;
5+
using System;
6+
7+
namespace ApplyUpdateReferencedAssembly
8+
{
9+
public class MethodBodyUnchangedAssembly {
10+
public static string StaticMethod1 () {
11+
Console.WriteLine("original");
12+
return "ok";
13+
}
14+
}
15+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics;
5+
using System;
6+
//keep the same line number for class in the original file and the updates ones
7+
namespace ApplyUpdateReferencedAssembly
8+
{
9+
public class MethodBody1 {
10+
public static string StaticMethod1 () {
11+
Console.WriteLine("original");
12+
int a = 10;
13+
Debugger.Break();
14+
return "OLD STRING";
15+
}
16+
}
17+
18+
public class MethodBody2 {
19+
public static string StaticMethod1 () {
20+
Console.WriteLine("original");
21+
int a = 10;
22+
Debugger.Break();
23+
return "OLD STRING";
24+
}
25+
}
26+
27+
public class MethodBody3 {
28+
public static string StaticMethod3 () {
29+
int a = 10;
30+
Console.WriteLine("original");
31+
return "OLD STRING";
32+
}
33+
}
34+
35+
36+
37+
public class MethodBody4 {
38+
public static void StaticMethod4 () {
39+
}
40+
}
41+
42+
43+
44+
45+
46+
47+
public class MethodBody5 {
48+
public static void StaticMethod1 () {
49+
Console.WriteLine("breakpoint in a line that will not be changed");
50+
Console.WriteLine("original");
51+
}
52+
}
53+
54+
public class MethodBody6 {
55+
public static void StaticMethod1 () {
56+
Console.WriteLine("breakpoint in a line that will not be changed");
57+
Console.WriteLine("original");
58+
}
59+
}
60+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics;
5+
using System;
6+
//keep the same line number for class in the original file and the updates ones
7+
namespace ApplyUpdateReferencedAssembly
8+
{
9+
public class MethodBody1 {
10+
public static string StaticMethod1 () {
11+
Console.WriteLine("v1");
12+
double b = 15;
13+
Debugger.Break();
14+
return "NEW STRING";
15+
}
16+
}
17+
18+
public class MethodBody2 {
19+
public static string StaticMethod1 () {
20+
Console.WriteLine("original");
21+
int a = 10;
22+
Debugger.Break();
23+
return "OLD STRING";
24+
}
25+
}
26+
27+
public class MethodBody3 {
28+
public static string StaticMethod3 () {
29+
float b = 15;
30+
Console.WriteLine("v1");
31+
return "NEW STRING";
32+
}
33+
}
34+
35+
36+
37+
public class MethodBody4 {
38+
public static void StaticMethod4 () {
39+
int a = 10;
40+
int b = 20;
41+
Console.WriteLine(a + b);
42+
Console.WriteLine(a + b);
43+
Console.WriteLine(a + b);
44+
}
45+
}
46+
47+
public class MethodBody5 {
48+
public static void StaticMethod1 () {
49+
Console.WriteLine("breakpoint in a line that will not be changed");
50+
Console.WriteLine("beforeoriginal");
51+
Console.WriteLine("original");
52+
}
53+
}
54+
public class MethodBody6 {
55+
public static void StaticMethod1 () {
56+
Console.WriteLine("breakpoint in a line that will not be changed");
57+
Console.WriteLine("original");
58+
}
59+
public static void NewMethodStatic () {
60+
int i = 20;
61+
newStaticField = 10;
62+
Console.WriteLine($"add a breakpoint in the new static method, look at locals {newStaticField}");
63+
/*var newvar = new MethodBody6();
64+
newvar.NewMethodInstance (10);*/
65+
}
66+
public static int newStaticField;
67+
}
68+
69+
public class MethodBody7 {
70+
public static int staticField;
71+
int attr1;
72+
string attr2;
73+
public static void StaticMethod1 () {
74+
Console.WriteLine("breakpoint in a method in a new class");
75+
Console.WriteLine("original");
76+
MethodBody7 newvar = new MethodBody7();
77+
staticField = 80;
78+
newvar.InstanceMethod();
79+
}
80+
public void InstanceMethod () {
81+
int aLocal = 50;
82+
attr1 = 15;
83+
attr2 = "20";
84+
Console.WriteLine($"add a breakpoint the instance method of the new class");
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)