Skip to content

File-based apps: add support for #:include#52347

Merged
jjonescz merged 19 commits intodotnet:release/10.0.3xxfrom
jjonescz:sprint-include
Feb 24, 2026
Merged

File-based apps: add support for #:include#52347
jjonescz merged 19 commits intodotnet:release/10.0.3xxfrom
jjonescz:sprint-include

Conversation

@jjonescz
Copy link
Member

@jjonescz jjonescz commented Jan 7, 2026

Resolves #48174.
Fixes part of #50912 (changes to files are detected, new file additions are not, except for #:include).

@jjonescz jjonescz marked this pull request as ready for review January 8, 2026 17:59
@jjonescz jjonescz requested a review from a team as a code owner January 8, 2026 17:59
VirtualProjectBuilder.WriteProjectFile(
csprojWriter,
directives,
evaluatedDirectives,
Copy link
Member Author

Choose a reason for hiding this comment

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

I've noticed the run-api doesn't evaluate directives, so I've fixed that, and added tests for it.

<value>Unrecognized directive '{0}'.</value>
<comment>{0} is the directive name like 'package' or 'sdk'.</comment>
</data>
<data name="EmptyTempPath" xml:space="preserve">
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not used in the package, so moved out.


public readonly struct ParseInfo
{
public required SourceFile SourceFile { get; init; }
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to know source file that directives come from to evaluate relative paths in #:include/#:exclude directives, so moved this from ParseContext to ParseInfo.

}

internal delegate void ErrorReporter(SourceFile sourceFile, TextSpan textSpan, string message);
internal delegate void ErrorReporter(SourceFile sourceFile, TextSpan textSpan, string message, Exception? innerException = null);
Copy link
Member Author

Choose a reason for hiding this comment

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

The inner exception used to be passed but got lost in this refactoring: #51995, so I've restored it.

}

public static void RemoveDirectivesFromFile(ImmutableArray<CSharpDirective> directives, SourceText text, string filePath)
public static void RemoveDirectivesFromFile(ImmutableArray<CSharpDirective> directives, SourceFile sourceFile, string targetFilePath)
Copy link
Member Author

Choose a reason for hiding this comment

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

This function did not used to save the file if not modified - I don't think that was intentional but it worked thanks to the project convert command copying all Compile items anyway. It all works differently (better) now.


private static void Convert(string inputCSharp, out string actualProject, out string? actualCSharp, bool force, string? filePath,
bool collectDiagnostics, out ImmutableArray<SimpleDiagnostic>.Builder? actualDiagnostics)
private static void Convert(
Copy link
Member Author

Choose a reason for hiding this comment

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

Unified the helpers here.

@jjonescz jjonescz requested a review from a team January 8, 2026 17:59
@mmitche mmitche deleted the branch dotnet:release/10.0.3xx January 17, 2026 00:38
@mmitche mmitche closed this Jan 17, 2026
@DamianEdwards
Copy link
Member

@mmitche @jjonescz was this closed intentionally?

@jjonescz
Copy link
Member Author

I don't know why this should be closed, reopening.

@jjonescz jjonescz reopened this Jan 19, 2026
@jjonescz jjonescz changed the base branch from release/10.0.2xx to release/10.0.3xx January 19, 2026 09:28
Relative paths are resolved relative to the file containing the directive.

This is currently gated under a feature flag that can be enabled by setting the MSBuild property `ExperimentalFileBasedProgramEnableIncludeDirective=true`.
This directive is currently gated under a feature flag that can be enabled by setting the MSBuild property `ExperimentalFileBasedProgramEnableIncludeDirective=true`.
Copy link
Member

Choose a reason for hiding this comment

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

Suitably verbose property name :shipit:

@mmitche
Copy link
Member

mmitche commented Jan 20, 2026

It got closed unintentionally because the base branch (3xx) got re-created.

@jjonescz
Copy link
Member Author

@333fred @RikkiGibson @MiYanni this is ready for reviews, thanks :)

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Done reviewing the implementation. I have not looked at the tests.

@jjonescz
Copy link
Member Author

@333fred for another look, thanks

@jjonescz jjonescz enabled auto-merge (squash) February 24, 2026 09:53
@jjonescz jjonescz merged commit 32c9942 into dotnet:release/10.0.3xx Feb 24, 2026
28 checks passed
@jjonescz jjonescz deleted the sprint-include branch February 24, 2026 12:49
tmat added a commit to tmat/dotnet that referenced this pull request Mar 12, 2026
commit 3d009596d1c130ded9be7576d45a4e3cc8a31d41
Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Date:   Thu Mar 12 08:10:03 2026 -0700

    [sdk] Source update 6e514f6 → 8cbac4a
    Diff: https://github.com/dotnet/sdk/compare/6e514f6189902a6422a6ab91324804c37035315b..8cbac4a5cdf27c2bb606a282cc47e60a7c4ced45

    From: dotnet/sdk@6e514f6
    To: dotnet/sdk@8cbac4a

    [[ commit created by automation ]]

```
C:\sdk>darc vmr forwardflow --build 303236 --vmr C:\dotnet
info: Flowing build 20260224.4 (303236) of commit 8cbac4a...
info: Making sure commit '8cbac4a5cdf27c2bb606a282cc47e60a7c4ced45' is present in repository 'C:\sdk'...
info: Flowing sdk's commit 8cbac4a to VMR at C:\dotnet...
info: Last flow was back flow: d346a57 -> f284d9f49aec157d49233ab5785cbcf78ed1ea58
info: Current flow is in the opposite direction
info: Creating a working branch darc/forward/8cbac4a-d346a57
info: Synchronizing sdk from 6e514f6189902a6422a6ab91324804c37035315b to https://github.com/dotnet/sdk / 8cbac4a5cdf27c2bb606a282cc47e60a7c4ced45
info: Updating VMR sdk from 6e514f6 to 8cbac4a..
info: Rebasing darc/forward/8cbac4a-d346a57 onto UpdateSdk1...
info: Auto-resolving expected conflicts...
info: Successfully auto-resolved 1 expected conflicts
info: Resolving dependency updates in source 6e514f6189902a6422a6ab91324804c37035315b..HEAD and target d346a57..UpdateSdk1
info: Changes staged in C:\dotnet
info: PRs from original repository included in this codeflow update:
      - dotnet/sdk#53090
      - dotnet/sdk#52347
      - dotnet/sdk#53100
      - dotnet/sdk#53056
```
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.

7 participants