Document 구조체

정의

디버그 메타데이터의 소스 문서입니다.

public value class Document
public readonly struct Document
public struct Document
type Document = struct
Public Structure Document
상속
Document

예제

이 예제에서는 이식 가능한 PDB 파일에서 원본 문서에 대한 정보를 표시하는 방법을 보여줍니다.

static string ReadDocumentPath(MetadataReader reader, Document doc)
{
    BlobReader blob = reader.GetBlobReader(doc.Name);

    // Read path separator character
    var separator = (char)blob.ReadByte();
    var sb = new StringBuilder(blob.Length * 2);

    // Read path segments
    while (true)
    {
        BlobHandle bh = blob.ReadBlobHandle();

        if (!bh.IsNil)
        {
            byte[] nameBytes = reader.GetBlobBytes(bh);
            sb.Append(Encoding.UTF8.GetString(nameBytes));
        }

        if (blob.Offset >= blob.Length) break;

        sb.Append(separator);
    }

    return sb.ToString();
}

public static void ReadPdbDocuments(string pdbPath)
{
    // 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();

    // Display information about documents in each MethodDebugInformation table entry
    foreach (MethodDebugInformationHandle h in reader.MethodDebugInformation)
    {
        MethodDebugInformation mdi = reader.GetMethodDebugInformation(h);

        if (mdi.Document.IsNil) continue;

        int token = MetadataTokens.GetToken(h);
        Console.WriteLine($"MethodDebugInformation 0x{token.ToString("X")}");

        Document doc = reader.GetDocument(mdi.Document);
        Console.WriteLine($"File: {ReadDocumentPath(reader, doc)}");
        Guid guidLang = reader.GetGuid(doc.Language);
        Console.WriteLine($"Language: {guidLang}");
        Guid guidHashAlg = reader.GetGuid(doc.HashAlgorithm);
        Console.WriteLine($"Hash algorithm: {guidHashAlg}");
        Console.WriteLine();
    }
}

설명

자세한 내용은 이식 가능한 PDB v1.0: 형식 사양을 참조하세요.

속성

Hash

문서 콘텐츠 해시를 가져옵니다.

HashAlgorithm

Hash(SHA1, SHA256 등)를 계산하는 데 사용되는 해시 알고리즘을 가져옵니다.

Language

소스 코드 언어(C#, VB, F# 등)를 가져옵니다.

Name

문서 이름 Blob을 가져옵니다.

적용 대상