< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 104
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%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/SectionHeader.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
 4namespace System.Reflection.PortableExecutable
 5{
 6    public readonly struct SectionHeader
 7    {
 8        /// <summary>
 9        /// The name of the section.
 10        /// </summary>
 011        public string Name { get; }
 12
 13        /// <summary>
 14        /// The total size of the section when loaded into memory.
 15        /// If this value is greater than <see cref="SizeOfRawData"/>, the section is zero-padded.
 16        /// This field is valid only for PE images and should be set to zero for object files.
 17        /// </summary>
 018        public int VirtualSize { get; }
 19
 20        /// <summary>
 21        /// For PE images, the address of the first byte of the section relative to the image base when the
 22        /// section is loaded into memory. For object files, this field is the address of the first byte before
 23        /// relocation is applied; for simplicity, compilers should set this to zero. Otherwise,
 24        /// it is an arbitrary value that is subtracted from offsets during relocation.
 25        /// </summary>
 026        public int VirtualAddress { get; }
 27
 28        /// <summary>
 29        /// The size of the section (for object files) or the size of the initialized data on disk (for image files).
 30        /// For PE images, this must be a multiple of <see cref="PEHeader.FileAlignment"/>.
 31        /// If this is less than <see cref="VirtualSize"/>, the remainder of the section is zero-filled.
 32        /// Because the <see cref="SizeOfRawData"/> field is rounded but the <see cref="VirtualSize"/> field is not,
 33        /// it is possible for <see cref="SizeOfRawData"/> to be greater than <see cref="VirtualSize"/> as well.
 34        ///  When a section contains only uninitialized data, this field should be zero.
 35        /// </summary>
 036        public int SizeOfRawData { get; }
 37
 38        /// <summary>
 39        /// The file pointer to the first page of the section within the COFF file.
 40        /// For PE images, this must be a multiple of <see cref="PEHeader.FileAlignment"/>.
 41        /// For object files, the value should be aligned on a 4 byte boundary for best performance.
 42        /// When a section contains only uninitialized data, this field should be zero.
 43        /// </summary>
 044        public int PointerToRawData { get; }
 45
 46        /// <summary>
 47        /// The file pointer to the beginning of relocation entries for the section.
 48        /// This is set to zero for PE images or if there are no relocations.
 49        /// </summary>
 050        public int PointerToRelocations { get; }
 51
 52        /// <summary>
 53        /// The file pointer to the beginning of line-number entries for the section.
 54        /// This is set to zero if there are no COFF line numbers.
 55        /// This value should be zero for an image because COFF debugging information is deprecated.
 56        /// </summary>
 057        public int PointerToLineNumbers { get; }
 58
 59        /// <summary>
 60        /// The number of relocation entries for the section. This is set to zero for PE images.
 61        /// </summary>
 062        public ushort NumberOfRelocations { get; }
 63
 64        /// <summary>
 65        /// The number of line-number entries for the section.
 66        ///  This value should be zero for an image because COFF debugging information is deprecated.
 67        /// </summary>
 068        public ushort NumberOfLineNumbers { get; }
 69
 70        /// <summary>
 71        /// The flags that describe the characteristics of the section.
 72        /// </summary>
 073        public SectionCharacteristics SectionCharacteristics { get; }
 74
 75        internal const int NameSize = 8;
 76
 77        internal const int Size =
 78            NameSize +
 79            sizeof(int) +   // VirtualSize
 80            sizeof(int) +   // VirtualAddress
 81            sizeof(int) +   // SizeOfRawData
 82            sizeof(int) +   // PointerToRawData
 83            sizeof(int) +   // PointerToRelocations
 84            sizeof(int) +   // PointerToLineNumbers
 85            sizeof(short) + // NumberOfRelocations
 86            sizeof(short) + // NumberOfLineNumbers
 87            sizeof(int);    // SectionCharacteristics
 88
 89        internal SectionHeader(ref PEBinaryReader reader)
 090        {
 091            Name = reader.ReadNullPaddedUTF8(NameSize);
 092            VirtualSize = reader.ReadInt32();
 093            VirtualAddress = reader.ReadInt32();
 094            SizeOfRawData = reader.ReadInt32();
 095            PointerToRawData = reader.ReadInt32();
 096            PointerToRelocations = reader.ReadInt32();
 097            PointerToLineNumbers = reader.ReadInt32();
 098            NumberOfRelocations = reader.ReadUInt16();
 099            NumberOfLineNumbers = reader.ReadUInt16();
 0100            SectionCharacteristics = (SectionCharacteristics)reader.ReadUInt32();
 0101        }
 102    }
 103}
 104