You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Drawing.Drawing2D.Matrix.Transform*(ReadOnlySpan) methods mutate the ReadOnlySpan #15226
The System.Drawing.Drawing2D.Matrix.TransformPoints and TransformVectors methods are intended to transform the array of values in-place, and that's clearly what the code is doing. The T[] overloads even call the ReadOnlySpan overloads to do the work. But because of the mutation, the span overloads should take Spans, not ReadOnlySpans.
It may also be worth doing a sweep through System.Drawing to see if anything else was transcribed incorrectly like this.
I'm seeing this in .NET 10 and .NET 11-rc1. I don't know when these APIs were originally added.
API Proposal
namespaceSystem.Drawing.Drawing2D;publicsealedclassMatrix{// Remove or mark [Obsolete("Use the Span overloads", true)]// Also add [EditorBrowsable(EditorBrowsableState.Never)]publicvoidTransformPoints(paramsReadOnlySpan<PointF>pts);publicvoidTransformPoints(paramsReadOnlySpan<Point>pts);publicvoidTransformVectors(paramsReadOnlySpan<PointF>pts);publicvoidTransformVectors(paramsReadOnlySpan<Point>pts);// Add these, and also tag with [OverloadResolutionPriority(1)] if not deleting the ReadOnlySpan overloadspublicvoidTransformPoints(paramsSpan<PointF>pts);publicvoidTransformPoints(paramsSpan<Point>pts);publicvoidTransformVectors(paramsSpan<PointF>pts);publicvoidTransformVectors(paramsSpan<Point>pts);}
API Usage
APIs would be consumed in the same way they are today. I'm guessing most uses are going through the array overloads or via implicit cast to ReadOnlySpanfrom arrays or mutable Spans.
Alternative Designs
No response
Risks
Removing the methods risks breaking any code that was using them. At compile time it may be fine, but it will definitely break binary compatibility.
The ReadOnlySpan<T> overload was introduced in #11416 and is public on .NET 9+, and the transformation modifies the points in place.
So I think the concern here is valid. We may need to consider whether this should use Span<T> instead.
Activity
LeafShi1 commentedon Oct 12, 2026
The
ReadOnlySpan<T>overload was introduced in #11416 and is public on .NET 9+, and the transformation modifies the points in place.So I think the concern here is valid. We may need to consider whether this should use
Span<T>instead.