Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Automatically generate embedded file contents for optimized run-file path - #53086

#53086
Merged
jjonescz merged 4 commits into
dotnet:release/10.0.3xxdotnet/sdk:release/10.0.3xxfrom
jjonescz:53074-sprint-genjjonescz/dotnet-sdk:53074-sprint-genCopy head branch name to clipboard
Mar 9, 2026
Merged

Automatically generate embedded file contents for optimized run-file path#53086
jjonescz merged 4 commits into
dotnet:release/10.0.3xxdotnet/sdk:release/10.0.3xxfrom
jjonescz:53074-sprint-genjjonescz/dotnet-sdk:53074-sprint-genCopy head branch name to clipboard

Conversation

@jjonescz

Copy link
Copy Markdown
Member

Resolves #53074.

@jjonescz
jjonescz requested a review from nagilson February 19, 2026 16:26
@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Feb 19, 2026

@nagilson nagilson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you so much for taking action on this and keeping our repo maintainable.

I have seen several times before that some unintended changes tried to slip through here

I agree that the test is a good idea still. I wonder if we could also keep the hardcoded one and do something else besides failing the build - e.g. sending a notification to your team? Or having a workflow that triggers when the file changes and then it pings.

Anything that blocks the repo builds like this would be fine in a smaller or isolated repo with just roslyn stuff but it in the SDK if we let every team do this pattern the repo would break basically every day. I commend the error message your test had because it was readable and easy to know what to do.

@jjonescz

jjonescz commented Feb 19, 2026

Copy link
Copy Markdown
Member Author

I'm not completely against just removing the generated files from Git and generating them during build instead if this is causing unreasonable maintenance pain.

I'm not sure how would we even implement "not fail test, ping team instead" or something similar while not spending too much time on such infra for this single test (maybe we could use the existing Build Analysis infrastructure?), and furthermore it would allow SDK to be in an inconsistent state if we allowed merge when the test fails, that doesn't sound very good.

@jjonescz
jjonescz marked this pull request as ready for review February 19, 2026 18:12
@jjonescz
jjonescz requested review from a team and Copilot February 19, 2026 18:12

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 PR implements automatic generation of embedded file content templates for the optimized dotnet run path, addressing issue #53074. Previously, the editorconfig template and other auxiliary file contents in CSharpCompilerCommand.cs were hardcoded, requiring manual updates when MSBuild added new CompilerVisibleProperty values. This change extends the existing CscArguments test to capture and auto-generate all file content methods.

Changes:

  • Extended CscArguments test to generate file content methods (editorconfig, assembly info, global usings, runtime config, assembly attributes) from MSBuild-emitted files
  • Replaced hardcoded file content templates in CSharpCompilerCommand.cs with calls to generated methods
  • Added internal properties (BaseDirectoryWithTrailingSeparator, FileNameWithoutExtension, TargetFramework) to support template generation
  • Updated error message to reference the CscArguments test for regeneration

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Extends CscArguments test to generate file content methods by discovering emitted files, applying string replacements, and generating interpolated string methods. Updates error message to reference test for regeneration.
src/Cli/dotnet/Commands/Run/CSharpCompilerCommand.cs Removes hardcoded file content templates, adds internal properties for template generation, replaces inline templates with calls to generated methods
src/Cli/dotnet/Commands/Run/CSharpCompilerCommand.Generated.cs Adds five generated file content methods (RuntimeConfig, AssemblyAttributes, AssemblyInfo, GeneratedMSBuildEditorConfig, GlobalUsings) with proper string interpolation

Comment thread test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jjonescz

Copy link
Copy Markdown
Member Author

@RikkiGibson for another review, thanks

@RikkiGibson RikkiGibson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but had a question.

var generatedMethodName = GetGeneratedMethodName(emittedFileName);
if (generatedMethodName is null)
{
Log.WriteLine($"Skipping unrecognized file '{emittedFile}'.");

@RikkiGibson RikkiGibson Mar 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens if a new/unknown file gets added to the "default project build", where the file is an input to the compiler? Is there a risk that we will skip the file, not notice, and get wrong semantics in the optimized csc build case? It feels like we might want to fail this test in that case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The test below (CscVsMSBuild) should catch that.

@jjonescz
jjonescz merged commit d71a4a1 into dotnet:release/10.0.3xx Mar 9, 2026
28 checks passed
@jjonescz
jjonescz deleted the 53074-sprint-gen branch March 9, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-run-file Items related to the "dotnet run <file>" effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.