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

[release/7.0] [wasm][debugger] Fix chinese character in project name #74816

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1469,11 +1469,12 @@ public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_fil
continue;
try
{
string unescapedFileName = Uri.UnescapeDataString(file_name);
steps.Add(
new DebugItem
{
Url = file_name,
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(file_name), token)
Data = context.SdbAgent.GetBytesFromAssemblyAndPdb(Path.GetFileName(unescapedFileName), token)
});
}
catch (Exception e)
Expand Down
44 changes: 24 additions & 20 deletions src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,45 @@ public async Task DebugHotReloadMethodUnchanged()
CheckNumber(locals, "a", 10);
}

[ConditionalFact(nameof(RunningOnChrome))]
public async Task DebugHotReloadMethodAddBreakpoint()
[ConditionalTheory(nameof(RunningOnChrome))]
[InlineData("ApplyUpdateReferencedAssembly")]
[InlineData("ApplyUpdateReferencedAssemblyChineseCharInPathㄨ")]
public async Task DebugHotReloadMethodAddBreakpoint(string assembly_name)
{
int line = 30;
await SetBreakpoint(".*/MethodBody1.cs$", line, 12, use_regex: true);
var pause_location = await LoadAssemblyAndTestHotReload(
Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"),
Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"),
Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"),
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"),
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"),
Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll"),
"MethodBody3", "StaticMethod3", expectBpResolvedEvent: true);

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

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

await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
locals_fn: async (locals) =>
{
CheckNumber(locals, "d", 10);
await Task.CompletedTask;
}
);
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
locals_fn: async (locals) =>
{
CheckNumber(locals, "d", 10);
CheckNumber(locals, "e", 20);
await Task.CompletedTask;
}
);
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
locals_fn: async (locals) =>
{
CheckNumber(locals, "d", 10);
Expand Down Expand Up @@ -217,12 +219,14 @@ public async Task DebugHotReloadMethodUnchangedUsingSDB()
CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, scripts, top_frame["location"]);
}

[ConditionalFact(nameof(RunningOnChrome))]
public async Task DebugHotReloadMethodAddBreakpointUsingSDB()
[ConditionalTheory(nameof(RunningOnChrome))]
[InlineData("ApplyUpdateReferencedAssembly")]
[InlineData("ApplyUpdateReferencedAssemblyChineseCharInPathㄨ")]
public async Task DebugHotReloadMethodAddBreakpointUsingSDB(string assembly_name)
{
string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll");
string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb");
string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll");
string asm_file = Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll");
string pdb_file = Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb");
string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll");

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

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

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

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

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

await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
locals_fn: async (locals) =>
{
CheckNumber(locals, "d", 10);
await Task.CompletedTask;
}
);
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
locals_fn: async (locals) =>
{
CheckNumber(locals, "d", 10);
CheckNumber(locals, "e", 20);
await Task.CompletedTask;
}
);
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3",
locals_fn: async (locals) =>
{
CheckNumber(locals, "d", 10);
Expand Down
26 changes: 20 additions & 6 deletions src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,23 +735,25 @@ JObject FindFrame(JObject pause_location, string function_name)
?.Where(f => f["functionName"]?.Value<string>() == function_name)
?.FirstOrDefault();

[ConditionalFact(nameof(RunningOnChrome))]
public async Task DebugLazyLoadedAssemblyWithPdb()
[ConditionalTheory(nameof(RunningOnChrome))]
[InlineData("lazy-debugger-test")]
[InlineData("lazy-debugger-test-chinese-char-in-path-ㄨ")]
public async Task DebugLazyLoadedAssemblyWithPdb(string assembly_name)
{
Task<JObject> bpResolved = WaitForBreakpointResolvedEvent();
int line = 9;
await SetBreakpoint(".*/lazy-debugger-test.cs$", line, 0, use_regex: true);
await LoadAssemblyDynamically(
Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.dll"),
Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.pdb"));
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"),
Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"));

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

await bpResolved;

var pause_location = await EvaluateAndCheck(
"window.setTimeout(function () { invoke_static_method('[lazy-debugger-test] LazyMath:IntAdd', 5, 10); }, 1);",
"window.setTimeout(function () { invoke_static_method('[" + assembly_name + "] LazyMath:IntAdd', 5, 10); }, 1);",
source_location, line, 8,
"LazyMath.IntAdd");
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
Expand Down Expand Up @@ -1086,5 +1088,17 @@ await EvaluateAndCheck(
}
);
}

[ConditionalFact(nameof(RunningOnChrome))]
public async Task SetBreakpointInProjectWithChineseCharactereInPath()
{
var bp = await SetBreakpointInMethod("debugger-test-chinese-char-in-path-ㄨ.dll", "DebuggerTests.CheckChineseCharacterInPath", "Evaluate", 1);
await EvaluateAndCheck(
$"window.setTimeout(function() {{ invoke_static_method ('[debugger-test-chinese-char-in-path-ㄨ] DebuggerTests.CheckChineseCharacterInPath:Evaluate'); }}, 1);",
"dotnet://debugger-test-chinese-char-in-path-ㄨ.dll/test.cs",
bp.Value["locations"][0]["lineNumber"].Value<int>(),
bp.Value["locations"][0]["columnNumber"].Value<int>(),
$"DebuggerTests.CheckChineseCharacterInPath.Evaluate");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk" TreatAsLocalProperty="EnableAggressiveTrimming;PublishTrimmed">
<PropertyGroup>
<TestRuntime>true</TestRuntime>
<DeltaScript>deltascript.json</DeltaScript>
<OutputType>library</OutputType>
<IsTestProject>false</IsTestProject>
<IsTestSupportProject>true</IsTestSupportProject>
<!-- to call AsssemblyExtensions.ApplyUpdate we need Optimize=false, EmitDebugInformation=true in all configurations -->
<Optimize>false</Optimize>
<EmitDebugInformation>true</EmitDebugInformation>
<!-- hot reload is not compatible with trimming -->
<EnableAggressiveTrimming>false</EnableAggressiveTrimming>
<PublishTrimmed>false</PublishTrimmed>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EmbedAllSources>true</EmbedAllSources>

<!-- FIXME: issue -->
<DisableSourceLink>true</DisableSourceLink>
</PropertyGroup>

<ItemGroup>
<Compile Include="MethodBody0.cs" />
<Compile Include="MethodBody1.cs" />
</ItemGroup>

<ItemGroup>
<!-- This package from https://github.com/dotnet/hotreload-utils provides
targets that read the json delta script and generates deltas based on the baseline assembly and the modified sources.

Projects must define the DeltaScript property that specifies the (relative) path to the json script.
Deltas will be emitted next to the output assembly. Deltas will be copied when the current
project is referenced from other other projects.
-->
<PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="$(MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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;

namespace ApplyUpdateReferencedAssembly
{
public class MethodBodyUnchangedAssembly {
public static string StaticMethod1 () {
Console.WriteLine("original");
return "ok";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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 MethodBody1 {
public static string StaticMethod1 () {
Console.WriteLine("original");
int a = 10;
Debugger.Break();
return "OLD STRING";
}
}

public class MethodBody2 {
public static string StaticMethod1 () {
Console.WriteLine("original");
int a = 10;
Debugger.Break();
return "OLD STRING";
}
}

public class MethodBody3 {
public static string StaticMethod3 () {
int a = 10;
Console.WriteLine("original");
return "OLD STRING";
}
}



public class MethodBody4 {
public static void StaticMethod4 () {
}
}






public class MethodBody5 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("original");
}
}

public class MethodBody6 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("original");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// 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 MethodBody1 {
public static string StaticMethod1 () {
Console.WriteLine("v1");
double b = 15;
Debugger.Break();
return "NEW STRING";
}
}

public class MethodBody2 {
public static string StaticMethod1 () {
Console.WriteLine("original");
int a = 10;
Debugger.Break();
return "OLD STRING";
}
}

public class MethodBody3 {
public static string StaticMethod3 () {
float b = 15;
Console.WriteLine("v1");
return "NEW STRING";
}
}



public class MethodBody4 {
public static void StaticMethod4 () {
int a = 10;
int b = 20;
Console.WriteLine(a + b);
Console.WriteLine(a + b);
Console.WriteLine(a + b);
}
}

public class MethodBody5 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("beforeoriginal");
Console.WriteLine("original");
}
}
public class MethodBody6 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("original");
}
public static void NewMethodStatic () {
int i = 20;
newStaticField = 10;
Console.WriteLine($"add a breakpoint in the new static method, look at locals {newStaticField}");
/*var newvar = new MethodBody6();
newvar.NewMethodInstance (10);*/
}
public static int newStaticField;
}

public class MethodBody7 {
public static int staticField;
int attr1;
string attr2;
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a method in a new class");
Console.WriteLine("original");
MethodBody7 newvar = new MethodBody7();
staticField = 80;
newvar.InstanceMethod();
}
public void InstanceMethod () {
int aLocal = 50;
attr1 = 15;
attr2 = "20";
Console.WriteLine($"add a breakpoint the instance method of the new class");
}
}
}
Loading