예제 #1
0
        public void AccessPointerAfterDisposeThrows()
        {
            var array  = ImmutableArray.Create(1, 2, 3);
            var helper = PinnedImmutableArray.Create(array);

            helper.Dispose();
            Assert.Throws <ObjectDisposedException>(() => helper.Pointer);
        }
예제 #2
0
        public void DisposeTwice()
        {
            var array  = ImmutableArray.Create(1, 2, 3);
            var helper = PinnedImmutableArray.Create(array);

            helper.Dispose();
            helper.Dispose();
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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));
        }
예제 #5
0
        /// <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);
            }
        }
예제 #6
0
 public void CtorRefType()
 {
     Assert.Throws <ArgumentException>(() => PinnedImmutableArray.Create(ImmutableArray.Create <string>()));
     Assert.Throws <ArgumentException>(() => PinnedImmutableArray.Create(ImmutableArray.Create <StructWithReferenceTypeField>()));
 }
예제 #7
0
 public void CtorDefault()
 {
     Assert.Throws <ArgumentNullException>(() => PinnedImmutableArray.Create(emptyDefault));
 }
예제 #8
0
 public PinnedMetadata(ImmutableArray <byte> metadata)
 {
     bytes       = PinnedImmutableArray.Create(metadata);
     this.Reader = new MetadataReader(bytes.Pointer, metadata.Length, MetadataReaderOptions.None, null);
 }