Skip to content

Ignore embedded debug format for metadata-only emit - #85028

Merged
jaredpar merged 7 commits into
dotnet:mainfrom
jaredpar:jaredpar-fix-refonly-embedded-debug
Sep 10, 2026
Merged

Ignore embedded debug format for metadata-only emit#85028
jaredpar merged 7 commits into
dotnet:mainfrom
jaredpar:jaredpar-fix-refonly-embedded-debug

Conversation

@jaredpar

@jaredpar jaredpar commented Aug 25, 2026

Copy link
Copy Markdown
Member

Fixes #78721

Summary

Metadata-only output cannot have an associated PDB. However, /refonly /debug:embedded synthesized a PDB path and emitted a CodeView debug-directory entry even though no PDB was produced.

This change:

  • allows EmitMetadataOnly with DebugInformationFormat.Embedded instead of throwing, bringing the public API into alignment with command-line behavior;
  • suppresses the effective PDB path for metadata-only output, preventing PDB-related debug-directory entries;
  • preserves the Reproducible entry for deterministic builds; and
  • adds coverage for both the public emit API and the /refonly /debug:embedded command-line path.

Testing

  • CompilationEmitTests.EmitMetadataOnly_IgnoreEmbeddedPdb
  • CommandLineTests.RefOnly_EmbeddedDebugInformation
Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 86e95881-607e-4eb5-a88c-8dcf3dea2ca4
@azure-pipelines

Copy link
Copy Markdown
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.

@jaredpar
jaredpar marked this pull request as ready for review August 25, 2026 23:47
@jaredpar
jaredpar requested a review from a team as a code owner August 25, 2026 23:47
Copilot AI lite review requested due to automatic review settings August 25, 2026 23:47
@jaredpar

Copy link
Copy Markdown
Member Author

@dotnet/roslyn-compiler PTAL

@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Embedded argument 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:embedded command-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

Comment thread src/Compilers/Core/Portable/Compilation/Compilation.cs
Comment on lines +12058 to +12066
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));
}
Comment thread src/Compilers/Core/Portable/Compilation/Compilation.cs
Comment thread src/Compilers/Core/Portable/Compilation/Compilation.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 86e95881-607e-4eb5-a88c-8dcf3dea2ca4
Copilot AI review requested due to automatic review settings August 27, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 17/17 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@jjonescz

Copy link
Copy Markdown
Member

Looks like there are real assert failures that are failing tests in CI.

Copilot AI review requested due to automatic review settings August 29, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Review tier: Lite
Findings: 1 Low severity

Pre-existing issues (1)
Severity Finding
Low severity 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

Copilot AI review requested due to automatic review settings August 31, 2026 17:28
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity · 1 Low severity

New issues introduced by this change (1)
Severity Finding
High severity src/​Compilers/​CSharp/​Test/​Emit/​Emit/​CompilationEmitTests.csEmitToArray auto-creates a discrete PDB stream for Debug compilations unless the debug format is…
Pre-existing issues (1)
Severity Finding
Low severity 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

Comment thread src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs Outdated
Copilot AI review requested due to automatic review settings August 31, 2026 17:52
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Review tier: Lite
Findings: 1 High severity · 2 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity 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
High severity src/​Compilers/​CSharp/​Test/​Emit/​Emit/​CompilationEmitTests.csEmitToArray auto-creates a discrete PDB stream for Debug compilations unless the debug format is… View comment
Low severity 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.pdb non-existence check would make the test fail for regressions that start writing a PDB again.
            CleanupAllGeneratedFiles(dir.Path);

Comment thread src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
@jaredpar
jaredpar marked this pull request as draft August 31, 2026 23:24
jaredpar and others added 2 commits August 31, 2026 16:30
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
@jaredpar
jaredpar marked this pull request as ready for review September 8, 2026 20:48
Copilot AI review requested due to automatic review settings September 8, 2026 20:48
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Low severity

Pre-existing issues (1)
Severity Finding
Low severity 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
Low severity 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
High severity src/​Compilers/​CSharp/​Test/​Emit/​Emit/​CompilationEmitTests.csEmitToArray auto-creates a discrete PDB stream for Debug compilations unless the debug format is… View resolved comment

@jaredpar
jaredpar merged commit a6e73e2 into dotnet:main Sep 10, 2026
22 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RefOnly + embedded symbols produce ref assemblies with debug metadata

4 participants