diff --git a/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs b/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs index 59c10d8d3f896..643856b5ad493 100644 --- a/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs +++ b/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs @@ -603,7 +603,8 @@ private static void GetExportedTypes(NamespaceOrTypeSymbol symbol, int parentInd foreach (var member in symbol.GetMembers()) { var namespaceOrType = member as NamespaceOrTypeSymbol; - if ((object)namespaceOrType != null) + if ((object)namespaceOrType != null && + member is not NamedTypeSymbol { IsExtension: true }) // https://github.com/dotnet/roslyn/issues/78963 - This is a temporary handling, we should get grouping and marker types processed instead. { GetExportedTypes(namespaceOrType, index, builder); } @@ -792,6 +793,11 @@ private static void GetForwardedTypes( ImmutableArray nested = type.GetTypeMembers(); // Ordered. for (int i = nested.Length - 1; i >= 0; i--) { + if (nested[i].IsExtension) + { + continue; // https://github.com/dotnet/roslyn/issues/78963 - This is a temporary handling, we should get grouping and marker types processed instead. + } + stack.Push((nested[i], index)); } } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/TypeForwarders.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/TypeForwarders.cs index 7396ff9004b6d..54dc455d3aeb0 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/TypeForwarders.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/TypeForwarders.cs @@ -1353,6 +1353,29 @@ public class Inner CheckForwarderEmit(source1, source2, "NS.Forwarded", "NS.Forwarded+Inner"); } + [ClrOnlyFact] + [WorkItem("https://github.com/dotnet/roslyn/issues/79894")] + [WorkItem("https://github.com/dotnet/roslyn/issues/78963")] + public void Extensions_01() + { + var source1 = @" +public static class Extensions +{ + extension(int) + { + } +}"; + + var source2 = @" +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Extensions))] +"; + + // https://github.com/dotnet/roslyn/issues/78963 - The grouping and marker types should be among the forwarded types since they are public. + // They also should be among exported types for library built from source1. Type symbols + // representing extensions from the language perspective should not be in either set. + CheckForwarderEmit(source1, source2, "Extensions"); + } + [ClrOnlyFact] public void EmitForwarder_Nested_Private() {