From 4f79085cd9057d50e79a53a42507cb230a447791 Mon Sep 17 00:00:00 2001 From: Alexandros Kritikos Date: Mon, 16 Mar 2026 18:33:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Adds=20Deterministic=20Build=20a?= =?UTF-8?q?nd=20Source=20Paths=20Check=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/DeterministicTest/Program.cs | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 samples/DeterministicTest/Program.cs diff --git a/samples/DeterministicTest/Program.cs b/samples/DeterministicTest/Program.cs new file mode 100644 index 0000000..efa7783 --- /dev/null +++ b/samples/DeterministicTest/Program.cs @@ -0,0 +1,62 @@ +using System.Reflection; +using System.Reflection.Metadata; + +var assembly = typeof(Program).Assembly; + +Console.WriteLine("=== Deterministic Build Check ==="); +Console.WriteLine(); + +var name = assembly.GetName(); +Console.WriteLine($"Assembly: {name.Name}"); +Console.WriteLine($"Version: {name.Version}"); + +var infoVersion = assembly.GetCustomAttribute(); +Console.WriteLine($"Info Version: {infoVersion?.InformationalVersion}"); + +var fileVersion = assembly.GetCustomAttribute(); +Console.WriteLine($"File Version: {fileVersion?.Version}"); + +var mvid = assembly.ManifestModule.ModuleVersionId; +Console.WriteLine($"MVID: {mvid}"); + +Console.WriteLine(); +Console.WriteLine("=== DeterministicSourcePaths Check ==="); +Console.WriteLine(); + +var assemblyPath = assembly.Location; +if (!string.IsNullOrEmpty(assemblyPath)) +{ + var pdbPath = Path.ChangeExtension(assemblyPath, ".pdb"); + if (File.Exists(pdbPath)) + { + using var pdbStream = File.OpenRead(pdbPath); + using var pdbProvider = MetadataReaderProvider.FromPortablePdbStream(pdbStream); + var pdbReader = pdbProvider.GetMetadataReader(); + + Console.WriteLine("Source paths found in PDB:"); + foreach (var docHandle in pdbReader.Documents) + { + var doc = pdbReader.GetDocument(docHandle); + var docName = pdbReader.GetString(doc.Name); + Console.WriteLine($" {docName}"); + } + + Console.WriteLine(); + Console.WriteLine("If DeterministicSourcePaths=true, paths will be mapped"); + Console.WriteLine("(e.g. /_/src/...) instead of showing full local paths."); + } + else + { + Console.WriteLine($"PDB not found at: {pdbPath}"); + Console.WriteLine("Build with debug symbols to check source paths."); + } +} +else +{ + Console.WriteLine("Assembly location not available (single-file publish?)."); +} + +Console.WriteLine(); +Console.WriteLine("--- Instructions ---"); +Console.WriteLine("1. Build twice without changes, compare MVID for Deterministic."); +Console.WriteLine("2. Check PDB source paths for DeterministicSourcePaths.");