SequencePoint Struktura

Definicja

Reprezentuje przenośny punkt sekwencji PDB.

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)
Dziedziczenie
SequencePoint
Implementuje

Przykłady

W tym przykładzie pokazano, jak odczytywać punkty sekwencji metody zdefiniowanej przez token metadanych i wyświetlać mapowania linii źródłowej:

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));
        }
    }
}

Uwagi

Punkt sekwencji to struktura zawierająca mapowanie między przesunięciem IL a odpowiadającymi numerami wierszy i kolumn w dokumencie źródłowym, z którego został skompilowany ten IL. Punkty sekwencji są przechowywane w MethodDebugInformation tabeli symboli debugowania przenośnego pliku PDB. Aby uzyskać więcej informacji, zobacz Portable PDB v1.0: Format Specification (Przenośna wersja PDB w wersji 1.0: specyfikacja formatu).

Pola

HiddenLine

Określa wartość numeru wiersza dla ukrytego punktu sekwencji.

Właściwości

Document

Pobiera dokument źródłowy zawierający ten punkt sekwencji.

EndColumn

Pobiera numer kolumny ostatniego znaku w tym punkcie sekwencji.

EndLine

Pobiera numer wiersza ostatniego znaku w tym punkcie sekwencji.

IsHidden

Pobiera wartość wskazującą, czy ten punkt sekwencji jest ukryty.

Offset

Pobiera przesunięcie IL tego punktu sekwencji od początku treści metody w bajtach.

StartColumn

Pobiera numer kolumny pierwszego znaku w tym punkcie sekwencji.

StartLine

Pobiera numer wiersza pierwszego znaku w tym punkcie sekwencji.

Metody

Equals(Object)

Wskazuje, czy bieżący punkt sekwencji jest równy określonemu obiektowi.

Equals(SequencePoint)

Wskazuje, czy bieżący obiekt jest równy innemu obiektowi tego samego typu.

GetHashCode()

Pobiera kod skrótu tego punktu sekwencji.

Dotyczy