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

[wasm][debugger] Fix source-link test #62786

Merged
merged 3 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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))
radical marked this conversation as resolved.
Show resolved Hide resolved
{
await file.CopyToAsync(mem, token).ConfigureAwait(false);
mem.Position = 0;
Expand Down
19 changes: 19 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,25 @@ await LoadAssemblyDynamically(
Assert.DoesNotContain(source_location, scripts.Values);
}

[Fact]
public async Task GetSourceUsingSourceUri()
{
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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<PackageId>LibraryTest</PackageId>
<Version>1.0.0</Version>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing spaces

</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>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
<DisableSourceLink>false</DisableSourceLink>
</PropertyGroup>
</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/*": ""
radical marked this conversation as resolved.
Show resolved Hide resolved
}
}