Repository: dotnet/roslyn
File: src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/IMethodSymbolExtensions.cs (C#)

Code before:
    /// <summary>
    /// Returns true if the method is a primary constructor.
    /// Primary constructors are not implicitly declared and have their declaring syntax reference
    /// on the type declaration itself (not a separate constructor declaration).
    /// </summary>
    public static bool IsPrimaryConstructor(this IMethodSymbol constructor)
    {
        if (constructor.IsImplicitlyDeclared)
            return false;

        if (constructor.DeclaringSyntaxReferences.Length == 0)
            return false;

        // Primary constructors have their declaring syntax on the containing type's declaration
        var constructorSyntax = constructor.DeclaringSyntaxReferences[0].SyntaxTree;
        var containingType = constructor.ContainingType;
        
        if (containingType.DeclaringSyntaxReferences.Length == 0)
            return false;

        // Check if any of the containing type's syntax references match the constructor's syntax tree
        // and are at the same location (same syntax node)
        foreach (var typeRef in containingType.DeclaringSyntaxReferences)
        {
            if (typeRef.SyntaxTree == constructorSyntax && 
                typeRef.Span == constructor.DeclaringSyntaxReferences[0].Span)
            {
                return true;
            }
        }

        return false;
    }
}


Review comment (suggestion):
```suggestion
        if (constructor.DeclaringSyntaxReferences is not [{ SyntaxTree: var constructorSyntaxTree, Span: var constructorSpan }])
            return false;

        // Primary constructors have their declaring syntax on the containing type's declaration
        var containingType = constructor.ContainingType;        
        if (containingType.DeclaringSyntaxReferences.Length == 0)
            return false;

        // Check if any of the containing type's syntax references match the constructor's syntax tree
        // and are at the same location (same syntax node)
        foreach (var typeRef in containingType.DeclaringSyntaxReferences)
        {
            if (typeRef.SyntaxTree == constructorSyntaxTree && typeRef.Span == constructorSpan)
```

Code after:
    /// <summary>
    /// Returns true if the method is a primary constructor.
    /// Primary constructors are not implicitly declared and have their declaring syntax reference
    /// on the type declaration itself (not a separate constructor declaration).
    /// </summary>
    public static bool IsPrimaryConstructor(this IMethodSymbol constructor)
    {
        if (constructor.IsImplicitlyDeclared)
            return false;

        if (constructor.DeclaringSyntaxReferences is not [{ SyntaxTree: var constructorSyntaxTree, Span: var constructorSpan }])
            return false;

        // Primary constructors have their declaring syntax on the containing type's declaration
        var containingType = constructor.ContainingType;
        if (containingType.DeclaringSyntaxReferences.Length == 0)
            return false;

        // Check if any of the containing type's syntax references match the constructor's syntax tree
        // and are at the same location (same syntax node)
        foreach (var typeRef in containingType.DeclaringSyntaxReferences)
        {
            if (typeRef.SyntaxTree == constructorSyntaxTree && typeRef.Span == constructorSpan)
                return true;
        }

        return false;
    }
}