Ignore embedded debug format for metadata-only emit - #85028
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 86e95881-607e-4eb5-a88c-8dcf3dea2ca4
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@dotnet/roslyn-compiler PTAL |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This pull request adjusts Roslyn’s emit pipeline so metadata-only outputs (reference assemblies) don’t synthesize a PDB path or emit PDB-related debug directory entries when /debug:embedded is requested, aligning EmitMetadataOnly behavior with the command-line /refonly path.
Changes:
- Removes the
EmitMetadataOnly+DebugInformationFormat.Embeddedargument exception so the public emit API no longer throws for this combination. - Clears the effective PDB path during metadata-only serialization to prevent emitting
CodeView(and related) debug-directory entries when no PDB exists. - Adds regression tests for both the public emit API and
/refonly /debug:embeddedcommand-line behavior.
Show a summary per file
| File | Description |
|---|---|
| src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs | Updates the metadata-only embedded-debug test to assert successful emit and validate debug directory contents. |
| src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs | Adds a /refonly /debug:embedded test verifying the debug directory only contains Reproducible. |
| src/Compilers/Core/Portable/Compilation/Compilation.cs | Removes the embedded+metadata-only throw and suppresses the PDB path for metadata-only emit to avoid PDB-related debug directory entries. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
| Assert.Equal(0, csc.Run(outWriter)); | ||
| Assert.Equal("", outWriter.ToString()); | ||
|
|
||
| using (var peReader = new PEReader(File.OpenRead(Path.Combine(dir.Path, "a.dll")))) | ||
| { | ||
| AssertEx.Equal( | ||
| new[] { DebugDirectoryEntryType.Reproducible }, | ||
| peReader.ReadDebugDirectory().Select(entry => entry.Type)); | ||
| } |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 86e95881-607e-4eb5-a88c-8dcf3dea2ca4
|
Looks like there are real assert failures that are failing tests in CI. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs — This test verifies the debug directory entries, but it doesn't assert that no PDB is produced on… View comment |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs — EmitToArray auto-creates a discrete PDB stream for Debug compilations unless the debug format is… |
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs — This test verifies the debug directory entries, but it doesn't assert that no PDB is produced on… View comment |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs — This change affects the shared command-line emit path (CommonCompiler) and thus applies to both… |
Pre-existing issues (2)
| Severity | Finding |
|---|---|
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs — EmitToArray auto-creates a discrete PDB stream for Debug compilations unless the debug format is… View comment |
|
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs — This test verifies the debug directory entries, but it doesn't assert that no PDB is produced on… View comment |
Suppressed comments (1)
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs:12068
- The new command-line regression test validates the debug directory contents, but it doesn’t assert that no standalone PDB file was produced. Since the underlying issue is specifically “CodeView entry with no PDB”, adding an explicit
a.pdbnon-existence check would make the test fail for regressions that start writing a PDB again.
CleanupAllGeneratedFiles(dir.Path);
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 55832284-ffad-4c9a-81d5-0e63a7b79265
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The behavior change is localized, consistent across API and CLI, and is covered by targeted C# and VB regression tests.
Review tier: Lite
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs — This test verifies the debug directory entries, but it doesn't assert that no PDB is produced on… View comment |
Issues resolved since last review (2)
| Severity | Finding |
|---|---|
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs — This change affects the shared command-line emit path (CommonCompiler) and thus applies to both… View resolved comment |
|
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs — EmitToArray auto-creates a discrete PDB stream for Debug compilations unless the debug format is… View resolved comment |


Fixes #78721
Summary
Metadata-only output cannot have an associated PDB. However,
/refonly /debug:embeddedsynthesized a PDB path and emitted aCodeViewdebug-directory entry even though no PDB was produced.This change:
EmitMetadataOnlywithDebugInformationFormat.Embeddedinstead of throwing, bringing the public API into alignment with command-line behavior;Reproducibleentry for deterministic builds; and/refonly /debug:embeddedcommand-line path.Testing
CompilationEmitTests.EmitMetadataOnly_IgnoreEmbeddedPdbCommandLineTests.RefOnly_EmbeddedDebugInformationMicrosoft Reviewers: Open in CodeFlow