Document Struct
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The source document in the debug metadata.
public value class Document
public readonly struct Document
public struct Document
type Document = struct
Public Structure Document
- Inheritance
Examples
This example shows how to display information about source documents in the Portable PDB file:
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();
}
}
Remarks
For more information, see Portable PDB v1.0: Format Specification.
Properties
Hash |
Gets the document content hash. |
HashAlgorithm |
Gets the hash algorithm used to calculate the Hash (SHA1, SHA256, etc.). |
Language |
Gets the source code language (C#, VB, F#, etc.). |
Name |
Gets the document name blob. |
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기