Fix hotreload 88528 (#88635)
authorThays Grazia <thaystg@gmail.com>
Tue, 11 Jul 2023 00:28:56 +0000 (21:28 -0300)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2023 00:28:56 +0000 (19:28 -0500)
src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs

index f3a0d16..67f8185 100644 (file)
@@ -942,28 +942,36 @@ namespace Microsoft.WebAssembly.Diagnostics
         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)
index fe0a05b..1ce00cb 100644 (file)
@@ -52,7 +52,6 @@ namespace DebuggerTests
         }
 
         [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 @@ namespace DebuggerTests
         }
 
         [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 @@ namespace DebuggerTests
         }
 
         [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 @@ namespace DebuggerTests
         }
 
         [ConditionalFact(nameof(RunningOnChrome))]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/88528")]
         public async Task DebugHotReloadMethod_AddingNewStaticField()
         {
             string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll");