Document Structure
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Document source dans les métadonnées de débogage.
public value class Document
public readonly struct Document
public struct Document
type Document = struct
Public Structure Document
- Héritage
Exemples
Cet exemple montre comment afficher des informations sur les documents sources dans le fichier PDB portable :
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();
}
}
Remarques
Pour plus d’informations, consultez Portable PDB v1.0 : Spécification de format.
Propriétés
Hash |
Obtient le hachage du contenu du document. |
HashAlgorithm |
Obtient l’algorithme de hachage utilisé pour calculer Hash (SHA1, SHA256, etc.). |
Language |
Obtient le langage du code source (C#, VB, F#, etc.). |
Name |
Obtient l’objet blob du nom du document. |
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Prochainement : Tout au long de l'année 2024, nous supprimerons progressivement les GitHub Issues en tant que mécanisme de retour d'information pour le contenu et nous les remplacerons par un nouveau système de retour d'information. Pour plus d’informations, voir:Soumettre et afficher des commentaires pour