< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 54
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
GetMemoryBlockImpl(...)100%110%
Dispose(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/MemoryBlocks/ExternalMemoryBlockProvider.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.IO;
 6
 7namespace System.Reflection.Internal
 8{
 9    /// <summary>
 10    /// Represents raw memory owned by an external object.
 11    /// </summary>
 12    internal sealed unsafe class ExternalMemoryBlockProvider : MemoryBlockProvider
 13    {
 14        private byte* _memory;
 15        private int _size;
 16
 017        public ExternalMemoryBlockProvider(byte* memory, int size)
 018        {
 019            _memory = memory;
 020            _size = size;
 021        }
 22
 23        public override int Size
 24        {
 25            get
 026            {
 027                return _size;
 028            }
 29        }
 30
 31        protected override AbstractMemoryBlock GetMemoryBlockImpl(int start, int size)
 032        {
 033            return new ExternalMemoryBlock(this, _memory + start, size);
 034        }
 35
 36        protected override void Dispose(bool disposing)
 037        {
 038            Debug.Assert(disposing);
 39
 40            // we don't own the memory, just null out the pointer.
 041            _memory = null;
 042            _size = 0;
 043        }
 44
 45        public byte* Pointer
 46        {
 47            get
 048            {
 049                return _memory;
 050            }
 51        }
 52    }
 53}
 54