Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs (C#)

Code before:
            if (thisParam.RefKind == RefKind.Ref && !thisParam.Type.IsValueType)
            {
                return false;
            }

            if (thisParam.RefKind is RefKind.In or RefKind.RefReadOnlyParameter
                && !thisParam.Type.IsValidInOrRefReadonlyExtensionParameterType())
            {
                return false;
            }

            return true;
        }

        /// <remarks>Does not perform a full viability check</remarks>
        internal void GetExtensionMembers(ArrayBuilder<Symbol> members, string? name, string? alternativeName, int arity, LookupOptions options, ConsList<FieldSymbol> fieldsBeingBound)
        {
            Debug.Assert((options & ~(LookupOptions.AllMethodsOnArityZero
                | LookupOptions.MustBeInstance | LookupOptions.MustNotBeInstance | LookupOptions.MustBeInvocableIfMember
                | LookupOptions.MustBeOperator | LookupOptions.MustNotBeMethodTypeParameter)) == 0);

            Debug.Assert(name is not null || alternativeName is null);

            if (!this.IsClassType() || !IsStatic || IsGenericType || !MightContainExtensionMethods) return;

            foreach (NamedTypeSymbol nestedType in GetTypeMembersUnordered())
            {
                if (nestedType is not { IsExtension: true, ExtensionParameter: { } extensionParameter }
                    || !IsValidExtensionReceiverParameter(extensionParameter))
                {
                    continue;
                }

                var candidates = name is null || alternativeName is not null
                    ? nestedType.GetMembersUnordered()
                    : nestedType.GetMembers(name);

                foreach (var candidate in candidates)
                {
                    if (!SourceMemberContainerTypeSymbol.IsAllowedExtensionMember(candidate))
                    {
                        // Not supported yet
                        continue;
                    }

                    if (extensionMemberMatches(candidate, name, alternativeName, arity, options, fieldsBeingBound))
                    {
                        members.Add(candidate);
                    }
                }
            }

Review comment (suggestion):
>GetTypeMembers(name: "") [](http://example.com/codeflow?start=51&length=24)

Not blocking this PR, but we probably should check other places where we look for extension blocks and see if they should be adjusted the same way.

Code after:
            if (thisParam.RefKind == RefKind.Ref && !thisParam.Type.IsValueType)
            {
                return false;
            }

            if (thisParam.RefKind is RefKind.In or RefKind.RefReadOnlyParameter
                && !thisParam.Type.IsValidInOrRefReadonlyExtensionParameterType())
            {
                return false;
            }

            return true;
        }

        /// <remarks>Does not perform a full viability check</remarks>
        internal void GetExtensionMembers(ArrayBuilder<Symbol> members, string? name, string? alternativeName, int arity, LookupOptions options, ConsList<FieldSymbol> fieldsBeingBound)
        {
            Debug.Assert((options & ~(LookupOptions.AllMethodsOnArityZero
                | LookupOptions.MustBeInstance | LookupOptions.MustNotBeInstance | LookupOptions.MustBeInvocableIfMember
                | LookupOptions.MustBeOperator | LookupOptions.MustNotBeMethodTypeParameter)) == 0);

            Debug.Assert(name is not null || alternativeName is null);

            if (!this.IsClassType() || !IsStatic || IsGenericType || !MightContainExtensionMethods) return;

            foreach (NamedTypeSymbol nestedType in GetTypeMembers(name: ""))
            {
                if (nestedType is not { IsExtension: true, ExtensionParameter: { } extensionParameter }
                    || !IsValidExtensionReceiverParameter(extensionParameter))
                {
                    continue;
                }

                var candidates = name is null || alternativeName is not null
                    ? nestedType.GetMembersUnordered()
                    : nestedType.GetMembers(name);

                foreach (var candidate in candidates)
                {
                    if (!SourceMemberContainerTypeSymbol.IsAllowedExtensionMember(candidate))
                    {
                        // Not supported yet
                        continue;
                    }

                    if (extensionMemberMatches(candidate, name, alternativeName, arity, options, fieldsBeingBound))
                    {
                        members.Add(candidate);
                    }
                }
            }