CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.8k stars 277 forks source link

Include sizeof(T) in offset calculation for Memory2D from MemoryManager #841

Open Lillenne opened 4 months ago

Lillenne commented 4 months ago

Closes #742

Overview

Memory2D<T> and ReadOnlyMemory2D<T> instances created from a MemoryManager calculate the offset field in units of T instead of byte in the constructor. Since this fix in v8.2.1 where Span creation was changed to Unsafe.AddByteOffset, this causes incorrect indexing into the span.

Fixes were added for NET6 or greater.

PR Checklist

Lillenne commented 4 months ago

@dotnet-policy-service agree

Lillenne commented 1 week ago

@dotnet-policy-service agree