public void DangerousGetUnderlyingArray()
        {
            ImmutableArray <int> immutable = ImmutableArray.Create(1, 2, 3);

            int[] array = ImmutableArrayInterop.DangerousGetUnderlyingArray(immutable);

            Assert.Equal(3, array.Length);
            Assert.Equal(1, array[0]);
            Assert.Equal(2, array[1]);
            Assert.Equal(3, array[2]);

            array[0] = 9;

            Assert.Equal(9, immutable[0]);
        }
Ejemplo n.º 2
0
 /// <exception cref="ArgumentNullException"><paramref name="buffer"/> is null.</exception>
 /// <exception cref="ArgumentOutOfRangeException">Range specified by <paramref name="start"/> and <paramref name="byteCount"/> falls outside of the bounds of the <paramref name="buffer"/>.</exception>
 /// <exception cref="InvalidOperationException">Builder is not writable, it has been linked with another one.</exception>
 public void WriteBytes(ImmutableArray <byte> buffer, int start, int byteCount)
 {
     WriteBytes(ImmutableArrayInterop.DangerousGetUnderlyingArray(buffer), start, byteCount);
 }
        public void DangerousGetUnderlyingArrayNegativeTests()
        {
            ImmutableArray <int> immutable = default(ImmutableArray <int>);

            Assert.Null(ImmutableArrayInterop.DangerousGetUnderlyingArray(immutable));
        }