Rediger

Del via


SequencePoint Struct

Definition

Represents a Portable PDB sequence point.

public value class SequencePoint : IEquatable<System::Reflection::Metadata::SequencePoint>
public readonly struct SequencePoint : IEquatable<System.Reflection.Metadata.SequencePoint>
public struct SequencePoint : IEquatable<System.Reflection.Metadata.SequencePoint>
type SequencePoint = struct
Public Structure SequencePoint
Implements IEquatable(Of SequencePoint)
Inheritance
SequencePoint
Implements

Examples

This example shows how to read sequence points of the method defined by the metadata token and display its source line mappings:

public static void ReadSourceLineData(string pdbPath, int methodToken)
{
    // Determine method row number
    EntityHandle ehMethod = MetadataTokens.EntityHandle(methodToken);

    if (ehMethod.Kind != HandleKind.MethodDefinition)
    {
        Console.WriteLine($"Invalid token kind: {ehMethod.Kind}");
        return;
    }

    int rowNumber = MetadataTokens.GetRowNumber(ehMethod);

    // MethodDebugInformation table is indexed by same row numbers as MethodDefinition table
    MethodDebugInformationHandle hDebug = MetadataTokens.MethodDebugInformationHandle(rowNumber);

    // Open Portable PDB file
    using var fs = new FileStream(pdbPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
    using MetadataReaderProvider provider = MetadataReaderProvider.FromPortablePdbStream(fs);
    MetadataReader reader = provider.GetMetadataReader();

    if (rowNumber > reader.MethodDebugInformation.Count)
    {
        Console.WriteLine("Error: Method row number is out of range");
        return;
    }

    // Print source line information as console table
    MethodDebugInformation di = reader.GetMethodDebugInformation(hDebug);
    Console.WriteLine("IL offset | Start line | Start col. | End line | End col. |");

    foreach (SequencePoint sp in di.GetSequencePoints())
    {
        if (sp.IsHidden)
        {
            Console.WriteLine($"{sp.Offset.ToString().PadLeft(9)} | (hidden sequence point)");
        }
        else
        {
            Console.WriteLine("{0} |{1} |{2} |{3} |{4} |", 
                sp.Offset.ToString().PadLeft(9), 
                sp.StartLine.ToString().PadLeft(11),
                sp.StartColumn.ToString().PadLeft(11),
                sp.EndLine.ToString().PadLeft(9),
                sp.EndColumn.ToString().PadLeft(9));
        }
    }
}

Remarks

Sequence point is a structure that contains the mapping between IL offset and corresponding line and column numbers in a source document this IL was compiled from. Sequence points are stored in the MethodDebugInformation table of Portable PDB debugging symbols. For more information, see Portable PDB v1.0: Format Specification.

Fields

HiddenLine

Specifies a line number value for a hidden sequence point.

Properties

Document

Gets the source document that contains this sequence point.

EndColumn

Gets the column number of the last character in this sequence point.

EndLine

Gets the line number of the last character in this sequence point.

IsHidden

Gets a value that indicates whether this sequence point is hidden.

Offset

Gets the IL offset of this sequence point from the start of the method body, in bytes.

StartColumn

Gets the column number of the first character in this sequence point.

StartLine

Gets the line number of the first character in this sequence point.

Methods

Equals(Object)

Indicates whether the current sequence point is equal to the specified object.

Equals(SequencePoint)

Indicates whether the current object is equal to another object of the same type.

GetHashCode()

Gets the hash code of this sequence point.

Applies to