Repository: dotnet/roslyn
File: src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs (C#)

Code before:
                        typeParameters: type.TypeParameters.Select(TypeParameter),
                        members: type.GetMembers().Where(CanBeDeclared).Select(Declaration)),
                    _ => null,
                };

                if (declaration != null)
                    return WithTypeParametersAndConstraints(declaration, type.TypeParameters);

                break;
        }

        throw new ArgumentException("Symbol cannot be converted to a declaration");

        static IEnumerable<ISymbol> GetMembersExceptExtensionImplementations(INamedTypeSymbol type)
        {
            var members = type.GetMembers();
            using var _ = PooledHashSet<IMethodSymbol>.GetInstance(out var implementationsToHide);
            foreach (var nested in type.GetTypeMembers(""))
            {
                if (nested.IsExtension)
                {
                    foreach (var extensionMember in nested.GetMembers())
                    {
                        if (extensionMember is IMethodSymbol { OriginalDefinition.AssociatedExtensionImplementation: { } toShadow })
                        {
                            implementationsToHide.Add(toShadow.OriginalDefinition);
                        }
                    }
                }
            }

            if (implementationsToHide is null)
            {
                return members;
            }

            using var _2 = ArrayBuilder<ISymbol>.GetInstance(out var result);
            foreach (var member in members)
            {
                // Hide implementation methods
                if (member is not IMethodSymbol method ||
                    !implementationsToHide.Contains(method.OriginalDefinition))
                {
                    result.Add(member);
                }
            }

            return result.ToImmutableAndClear();
        }
    }


Review comment (suggestion):
The previous behavior of the API was to associate a definition with a definition, but now it associates a constructed symbol with a definition.
I'm not sure that's desirable in terms of API design. Maybe it would be better to keep the restriction that the API only works on definitions.

Code after:
                        typeParameters: type.TypeParameters.Select(TypeParameter),
                        members: type.GetMembers().Where(CanBeDeclared).Select(Declaration)),
                    _ => null,
                };

                if (declaration != null)
                    return WithTypeParametersAndConstraints(declaration, type.TypeParameters);

                break;
        }

        throw new ArgumentException("Symbol cannot be converted to a declaration");

        static IEnumerable<ISymbol> GetMembersExceptExtensionImplementations(INamedTypeSymbol type)
        {
            var members = type.GetMembers();
            using var _ = PooledHashSet<IMethodSymbol>.GetInstance(out var implementationsToHide);
            foreach (var nested in type.GetTypeMembers(""))
            {
                if (nested.IsExtension)
                {
                    foreach (var extensionMember in nested.GetMembers())
                    {
                        if (extensionMember is IMethodSymbol { AssociatedExtensionImplementation: { } toShadow })
                        {
                            implementationsToHide.Add(toShadow.OriginalDefinition);
                        }
                    }
                }
            }

            if (implementationsToHide is null)
            {
                return members;
            }

            using var _2 = ArrayBuilder<ISymbol>.GetInstance(out var result);
            foreach (var member in members)
            {
                // Hide implementation methods
                if (member is not IMethodSymbol method ||
                    !implementationsToHide.Contains(method.OriginalDefinition))
                {
                    result.Add(member);
                }
            }

            return result.ToImmutableAndClear();
        }
    }