Skip to content
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
4 changes: 2 additions & 2 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,14 @@ internal void AddMethod(MethodInfo mi)
return (start.StartLocation.Line, start.StartLocation.Column, end.EndLocation.Line, end.EndLocation.Column);
}

private async Task<MemoryStream> GetDataAsync(Uri uri, CancellationToken token)
private static async Task<MemoryStream> GetDataAsync(Uri uri, CancellationToken token)
{
var mem = new MemoryStream();
try
{
if (uri.IsFile && File.Exists(uri.LocalPath))
{
using (FileStream file = File.Open(SourceUri.LocalPath, FileMode.Open))
using (FileStream file = File.Open(uri.LocalPath, FileMode.Open))
{
await file.CopyToAsync(mem, token).ConfigureAwait(false);
mem.Position = 0;
Expand Down
29 changes: 29 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,38 @@ await LoadAssemblyDynamically(
Assert.DoesNotContain(source_location, scripts.Values);
}

[Fact]
public async Task GetSourceUsingSourceUri()
{
//testing without using sourcelink, expected values at GetSourceAsync
//SourceUri - file:///LOCAL_PATH/runtime/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
//SourceLinkUri - empty
var bp1_res = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8);

Assert.EndsWith("debugger-test.cs", bp1_res.Value["breakpointId"].ToString());
Assert.Equal(1, bp1_res.Value["locations"]?.Value<JArray>()?.Count);

var loc = bp1_res.Value["locations"]?.Value<JArray>()[0];

var sourceToGet = JObject.FromObject(new
{
scriptId = loc["scriptId"]?.Value<string>()
});

Assert.Equal("dotnet://debugger-test.dll/debugger-test.cs", scripts[loc["scriptId"]?.Value<string>()]);
var source = await cli.SendCommand("Debugger.getScriptSource", sourceToGet, token);
Assert.True(source.IsOk);
}
[Fact]
public async Task GetSourceUsingSourceLink()
{
//testing using sourcelink, expected values at GetSourceAsync
// On CI
//SourceUri - file:///fakepath/LOCAL_PATH/runtime/src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
//SourceLinkUri - file:///LOCAL_PATH/runtime/src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
// Locally
// SourceUri - file:////src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
// SourceLinkUri - https://raw.githubusercontent.com/FORK/runtime/COMMIT_ID/src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
var bp = await SetBreakpointInMethod("debugger-test-with-source-link.dll", "DebuggerTests.ClassToBreak", "TestBreakpoint", 0);
var pause_location = await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method ('[debugger-test-with-source-link] DebuggerTests.ClassToBreak:TestBreakpoint'); }, 1);",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>LibraryTest</PackageId>
<Version>1.0.0</Version>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/dotnet/runtime.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<EnableSourceLink>true</EnableSourceLink>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<IncludeSymbols>true</IncludeSymbols>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
<DisableSourceLink>false</DisableSourceLink>
</PropertyGroup>
<PropertyGroup>
<PackageId>LibraryTest</PackageId>
<Version>1.0.0</Version>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
</PropertyGroup>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/dotnet/runtime.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<EnableSourceLink>true</EnableSourceLink>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<IncludeSymbols>true</IncludeSymbols>
<DisableSourceLink>false</DisableSourceLink>
</PropertyGroup>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<SourceLink>source-link.json</SourceLink>
<AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
<PathMap>$(AppOutputBase)=/fakepath/$(MSBuildProjectDirectory)</PathMap>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"documents": {
"/fakepath/*": ""
}
}