From d4464c714dda3b733b9e013872abc538507cc49e Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 10 Jul 2023 21:28:56 -0300 Subject: [PATCH] Fix hotreload 88528 (#88635) --- .../debugger/BrowserDebugProxy/DebugStore.cs | 48 +++++++++++-------- .../DebuggerTestSuite/HotReloadTests.cs | 4 -- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index f3a0d160a30157..67f8185b52f0d5 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -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 GetDebugId(MonoSDBHelper sdbAgent, CancellationToken token) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs index fe0a05b948a83e..1ce00cb2bca501 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs @@ -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) @@ -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) @@ -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"); @@ -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");