From be85be7c1b8c9c8fd6de9abaaaa2ddf9cf01a3c8 Mon Sep 17 00:00:00 2001 From: tmat Date: Tue, 7 May 2024 09:26:41 -0700 Subject: [PATCH] EnC: workaround for empty display class --- .../Core/Portable/Emit/EditAndContinue/DefinitionMap.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Compilers/Core/Portable/Emit/EditAndContinue/DefinitionMap.cs b/src/Compilers/Core/Portable/Emit/EditAndContinue/DefinitionMap.cs index 03aebde7eba92..dfdd6d5956f06 100644 --- a/src/Compilers/Core/Portable/Emit/EditAndContinue/DefinitionMap.cs +++ b/src/Compilers/Core/Portable/Emit/EditAndContinue/DefinitionMap.cs @@ -588,7 +588,14 @@ void recurse(ImmutableArray members, DebugId? containingDisplay Debug.Assert(!containingDisplayClassId.HasValue); var displayClass = (INamedTypeSymbolInternal)member; - var displayClassMembers = (synthesizedMemberMap != null) ? synthesizedMemberMap[displayClass] : displayClass.GetMembers(); + + // Synthesized member map, if given, contains all the synthesized members that implement lambdas and closures. + // If not given (for PE symbols) the members are defined on the type symbol directly. + // If the display class doesn't have any synthesized members it won't be present in the map. + // See https://github.com/dotnet/roslyn/issues/73365 + var displayClassMembers = synthesizedMemberMap != null + ? (synthesizedMemberMap.TryGetValue(displayClass, out var m) ? m : []) + : displayClass.GetMembers(); if (displayClass.TypeKind == TypeKind.Struct) {