File-based apps: add support for #:include#52347
File-based apps: add support for #:include#52347jjonescz merged 19 commits intodotnet:release/10.0.3xxfrom
#:include#52347Conversation
bf9dc98 to
d13a3f2
Compare
d13a3f2 to
c06c1fc
Compare
c06c1fc to
d64bb1a
Compare
| VirtualProjectBuilder.WriteProjectFile( | ||
| csprojWriter, | ||
| directives, | ||
| evaluatedDirectives, |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
This is not used in the package, so moved out.
|
|
||
| public readonly struct ParseInfo | ||
| { | ||
| public required SourceFile SourceFile { get; init; } |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Unified the helpers here.
src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs
Outdated
Show resolved
Hide resolved
|
I don't know why this should be closed, reopening. |
| 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`. |
There was a problem hiding this comment.
Suitably verbose property name ![]()
|
It got closed unintentionally because the base branch (3xx) got re-created. |
|
@333fred @RikkiGibson @MiYanni this is ready for reviews, thanks :) |
333fred
left a comment
There was a problem hiding this comment.
Done reviewing the implementation. I have not looked at the tests.
src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs
Outdated
Show resolved
Hide resolved
src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs
Outdated
Show resolved
Hide resolved
|
@333fred for another look, thanks |
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
```
Resolves #48174.
Fixes part of #50912 (changes to files are detected, new file additions are not, except for
#:include).