Repository: dotnet/roslyn
File: src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberService.cs (C#)

Code before:
        }
        else if (syntaxFacts.IsMemberBindingExpression(expression))
        {
            var target = syntaxFacts.GetTargetOfMemberBinding(expression);

            if (target != null)
            {
                typeToGenerateIn = semanticModel.GetTypeInfo(target, cancellationToken).Type as INamedTypeSymbol;
            }
        }
        else
        {
            // Generating into the containing type.
            typeToGenerateIn = containingType;
            isStatic = syntaxFacts.IsInStaticContext(expression);

            // If the expression is used in an address-of operator for a function pointer,
            // the method must be static (CS8759).
            if (!isStatic && IsInFunctionPointerAddressOfContext(semanticDocument, expression, semanticModel, cancellationToken))
            {
                isStatic = true;
            }
        }
    }

    private static bool IsInFunctionPointerAddressOfContext(
        SemanticDocument semanticDocument,
        SyntaxNode expression,
        SemanticModel semanticModel,
        CancellationToken cancellationToken)
    {
        // Check if this expression is the operand of an address-of operator
        // that's being used to create a function pointer
        if (expression.Parent == null)
            return false;

        var syntaxKinds = semanticDocument.Document.GetLanguageService<ISyntaxKindsService>();
        if (syntaxKinds == null || expression.Parent.RawKind != syntaxKinds.AddressOfExpression)
            return false;

        var typeInfo = semanticModel.GetTypeInfo(expression.Parent, cancellationToken);
        return typeInfo.Type is IFunctionPointerTypeSymbol;
    }

    private static void DetermineTypeToGenerateInWorker(
        SemanticModel semanticModel,
        SyntaxNode expression,
        out INamedTypeSymbol? typeToGenerateIn,
        out bool isStatic,
        out bool isColorColorCase,
        CancellationToken cancellationToken)

Review comment (suggestion):
@copilot pass in the syntaxFacts, you can get .SyntaxKinds from it. Remove any parameters you no longer need. 

Code after:

            if (target != null)
            {
                typeToGenerateIn = semanticModel.GetTypeInfo(target, cancellationToken).Type as INamedTypeSymbol;
            }
        }
        else
        {
            // Generating into the containing type.
            typeToGenerateIn = containingType;
            isStatic = IsInStaticContext();
        }

        bool IsInStaticContext()
        {
            if (syntaxFacts.IsInStaticContext(expression))
                return true;

            // If the expression is used in an '&' operator, the method must be static.
            if (expression.Parent?.RawKind == syntaxFacts.SyntaxKinds.AddressOfExpression &&
                expression.Language == LanguageNames.CSharp)
            {
                return true;
            }

            return false;
        }
    }

    private static void DetermineTypeToGenerateInWorker(
        SemanticModel semanticModel,
        SyntaxNode expression,
        out INamedTypeSymbol? typeToGenerateIn,
        out bool isStatic,
        out bool isColorColorCase,
        CancellationToken cancellationToken)
    {
        var typeInfo = semanticModel.GetTypeInfo(expression, cancellationToken);
        var semanticInfo = semanticModel.GetSymbolInfo(expression, cancellationToken);

        typeToGenerateIn = typeInfo.Type is ITypeParameterSymbol typeParameter
            ? typeParameter.GetNamedTypeSymbolConstraint()
            : typeInfo.Type as INamedTypeSymbol;

        isStatic = semanticInfo.Symbol is INamedTypeSymbol;
        isColorColorCase = typeInfo.Type != null && semanticInfo.Symbol != null && semanticInfo.Symbol.Name == typeInfo.Type.Name;
    }
}