Buffer.BlockCopy count in elements (CA2018)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.codequality.blockcopy-count · Severity warning · Category codequality
Microsoft analyzer CA2018. Flags Buffer.BlockCopy given an element count where it expects bytes - on anything but a byte array only part of the data is copied.
Incorrect
Section titled “Incorrect”Buffer.BlockCopy(source, 0, target, 0, source.Length); // int[]Correct
Section titled “Correct”Buffer.BlockCopy(source, 0, target, 0, source.Length * sizeof(int));