public void AccessPointerAfterDisposeThrows() { var array = ImmutableArray.Create(1, 2, 3); var helper = PinnedImmutableArray.Create(array); helper.Dispose(); Assert.Throws <ObjectDisposedException>(() => helper.Pointer); }
public void DisposeTwice() { var array = ImmutableArray.Create(1, 2, 3); var helper = PinnedImmutableArray.Create(array); helper.Dispose(); helper.Dispose(); }
public void GetPointer() { var array = ImmutableArray.Create(1, 2, 3); using (var handle = PinnedImmutableArray.Create(array)) { var copy = ImmutableArray.Create <int>(handle.Pointer, 3); Assert.Equal <int>(array, copy); } }
public void CreateInitialBaseline() { var provider = new LocalVariableNameProvider(_ => ImmutableArray.Create <string>()); var peModule = ModuleMetadata.CreateFromImage(TestResources.MetadataTests.Basic.Members); var peReader = peModule.Module.PEReaderOpt; var mdBytes = peReader.GetMetadata().GetContent(); var mdBytesHandle = PinnedImmutableArray.Create(mdBytes); var mdModule = ModuleMetadata.CreateFromMetadata(mdBytesHandle.Pointer, mdBytes.Length); Assert.Throws <ArgumentNullException>(() => EmitBaseline.CreateInitialBaseline(null, provider)); Assert.Throws <ArgumentNullException>(() => EmitBaseline.CreateInitialBaseline(peModule, null)); Assert.Throws <ArgumentException>(() => EmitBaseline.CreateInitialBaseline(mdModule, provider)); }
/// <exception cref="IOException"/> private static void Sign(string filePath, ImmutableArray <byte> keyPair) { try { ICLRStrongName strongName = GetStrongNameInterface(); using (var pinned = PinnedImmutableArray.Create(keyPair)) { int unused; strongName.StrongNameSignatureGeneration(filePath, null, pinned.Pointer, keyPair.Length, null, out unused); } } catch (COMException ex) { throw new IOException(ex.Message, ex); } }
public void CtorRefType() { Assert.Throws <ArgumentException>(() => PinnedImmutableArray.Create(ImmutableArray.Create <string>())); Assert.Throws <ArgumentException>(() => PinnedImmutableArray.Create(ImmutableArray.Create <StructWithReferenceTypeField>())); }
public void CtorDefault() { Assert.Throws <ArgumentNullException>(() => PinnedImmutableArray.Create(emptyDefault)); }
public PinnedMetadata(ImmutableArray <byte> metadata) { bytes = PinnedImmutableArray.Create(metadata); this.Reader = new MetadataReader(bytes.Pointer, metadata.Length, MetadataReaderOptions.None, null); }