Skip to content

Commit

Permalink
Fix hotreload 88528 (#88635)
Browse files Browse the repository at this point in the history
  • Loading branch information
thaystg authored Jul 11, 2023
1 parent 23dc6da commit d4464c7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
48 changes: 28 additions & 20 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -942,28 +942,36 @@ private unsafe AssemblyInfo(IDisposable owningReader, string name, MetadataReade
public bool TryGetCustomAttributeName(CustomAttributeHandle customAttribute, MetadataReader metadataReader, out string name)
{
name = "";
EntityHandle ctorHandle = metadataReader.GetCustomAttribute(customAttribute).Constructor;
if (ctorHandle.Kind != HandleKind.MemberReference)
return false;
EntityHandle? container = ctorHandle.Kind switch
try
{
HandleKind.MethodDefinition => metadataReader.GetMethodDefinition((MethodDefinitionHandle)ctorHandle).GetDeclaringType(),
HandleKind.MemberReference => metadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent,
_ => null,
};
if (container == null)
return false;
StringHandle? attributeTypeNameHandle = container.Value.Kind switch
EntityHandle ctorHandle = metadataReader.GetCustomAttribute(customAttribute).Constructor;
if (ctorHandle.Kind != HandleKind.MemberReference)
return false;
EntityHandle? container = ctorHandle.Kind switch
{
HandleKind.MethodDefinition => metadataReader.GetMethodDefinition((MethodDefinitionHandle)ctorHandle).GetDeclaringType(),
HandleKind.MemberReference => metadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent,
_ => null,
};
if (container == null)
return false;
StringHandle? attributeTypeNameHandle = container.Value.Kind switch
{
HandleKind.TypeDefinition => metadataReader.GetTypeDefinition((TypeDefinitionHandle)container.Value).Name,
HandleKind.TypeReference => metadataReader.GetTypeReference((TypeReferenceHandle)container.Value).Name,
HandleKind.TypeSpecification => null, // custom generic attributes, TypeSpecification does not keep the attribute name for them
_ => null,
};
if (attributeTypeNameHandle == null)
return false;
name = EnCGetString(attributeTypeNameHandle.Value);
return true;
}
catch (Exception e)
{
HandleKind.TypeDefinition => metadataReader.GetTypeDefinition((TypeDefinitionHandle)container.Value).Name,
HandleKind.TypeReference => metadataReader.GetTypeReference((TypeReferenceHandle)container.Value).Name,
HandleKind.TypeSpecification => null, // custom generic attributes, TypeSpecification does not keep the attribute name for them
_ => null,
};
if (attributeTypeNameHandle == null)
return false;
name = EnCGetString(attributeTypeNameHandle.Value);
return true;
logger.LogError($"Not able to get CustomAttributeName {e}");
}
return false;
}

public async Task<int> GetDebugId(MonoSDBHelper sdbAgent, CancellationToken token)
Expand Down
4 changes: 0 additions & 4 deletions src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public async Task DebugHotReloadMethodUnchanged()
}

[ConditionalTheory(nameof(RunningOnChrome))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88528")]
[InlineData("ApplyUpdateReferencedAssembly")]
[InlineData("ApplyUpdateReferencedAssemblyChineseCharInPath\u3128")]
public async Task DebugHotReloadMethodAddBreakpoint(string assembly_name)
Expand Down Expand Up @@ -221,7 +220,6 @@ public async Task DebugHotReloadMethodUnchangedUsingSDB()
}

[ConditionalTheory(nameof(RunningOnChrome))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88528")]
[InlineData("ApplyUpdateReferencedAssembly")]
[InlineData("ApplyUpdateReferencedAssemblyChineseCharInPath\u3128")]
public async Task DebugHotReloadMethodAddBreakpointUsingSDB(string assembly_name)
Expand Down Expand Up @@ -418,7 +416,6 @@ public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated
}

[ConditionalFact(nameof(RunningOnChrome))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88528")]
public async Task DebugHotReloadMethod_AddingNewMethod()
{
string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll");
Expand Down Expand Up @@ -449,7 +446,6 @@ await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/Me
}

[ConditionalFact(nameof(RunningOnChrome))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88528")]
public async Task DebugHotReloadMethod_AddingNewStaticField()
{
string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll");
Expand Down

0 comments on commit d4464c7

Please sign in to comment.