dotnet / dotnet/dotnet-api-docs

Space used in UnmanagedMemoryAccessor.WriteArray is not documented

Open
#5,239 1 comment 0 reactions 0 assignees View on GitHub
area-System.Runtime.InteropServices Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

The important bit of this issue is here: https://referencesource.microsoft.com/#mscorlib/system/runtime/interopservices/safebuffer.cs,334

`WriteArray` is specified to take an array and write it to an unmanaged buffer. However, the space used for each element of the array is not the standard `Marshal.SizeOf`, it's an internal-only `Marshal.SizeOfAligned`, which can be significantly different. This means that callers can't know how much space is actually required to write the array without reading the source code themselves.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.