Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions documentation/general/dotnet-run-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,13 @@ The directives are processed as follows:
where `{0}` is the directive's value and `{1}` is determined by its extension.
The mapping can be customized by setting the MSBuild property `FileBasedProgramsItemMapping`
which is by default set to `.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content`.
(The mapping customization is currently gated under a feature flag that can be enabled by setting the MSBuild property `ExperimentalFileBasedProgramEnableItemMapping=true`.)

It is an error if the value is empty.

Relative paths are resolved relative to the file containing the directive.

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

- Each `#:exclude` is injected similarly to `#:include` but with `Remove="{0}"` instead of `Include="{0}"`.

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

- Other directive kinds result in an error, reserving them for future use.

Directive values support MSBuild variables (like `$(..)`) normally as they are translated literally and left to MSBuild engine to process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,7 @@ public enum IncludeOrExcludeKind
/// </summary>
public sealed class IncludeOrExclude(in ParseInfo info) : Named(info)
{
public const string ExperimentalFileBasedProgramEnableIncludeDirective = nameof(ExperimentalFileBasedProgramEnableIncludeDirective);
public const string ExperimentalFileBasedProgramEnableExcludeDirective = nameof(ExperimentalFileBasedProgramEnableExcludeDirective);
public const string ExperimentalFileBasedProgramEnableTransitiveDirectives = nameof(ExperimentalFileBasedProgramEnableTransitiveDirectives);

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.

do want to call out that I think the editor still needs changes to handle transitive directives properly. So today it will see #: and assume the file is an entry point (depending on the order things load in).

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.

I am comfortable with moving forward on that change and just making sure we expedite it properly. But may want to extract this bit to separate PR, if our goal was to only remove experimental flags for these, for scenarios where we expect editor tooling to work.

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.

@DamianEdwards what would you like to do about the transitive feature flag given IDE doesn't implement support for that yet?

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.

@RikkiGibson what's the plan for integrating your entry-point detection changes? Is that the change you're referring to when you said:

I am comfortable with moving forward on that change and just making sure we expedite it properly.

I am concerned about missing the boat here a bit as the next train is 10.0.400 (or 11 previews) and that's not until August+. It would be super unfortunate if we're able to get the editor experience changes done well before then but we can't enable it by default in the SDK.

That said, pulling the removal of flag on the transitive directive feature in the SDK into a separate PR seems like the prudent thing to do given the current state.

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.

public const string ExperimentalFileBasedProgramEnableItemMapping = nameof(ExperimentalFileBasedProgramEnableItemMapping);

public const string MappingPropertyName = "FileBasedProgramsItemMapping";

public static string DefaultMappingString => ".cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const Microsoft.DotNet.FileBasedPrograms.CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableExcludeDirective = "ExperimentalFileBasedProgramEnableExcludeDirective" -> string!
const Microsoft.DotNet.FileBasedPrograms.CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective = "ExperimentalFileBasedProgramEnableIncludeDirective" -> string!
const Microsoft.DotNet.FileBasedPrograms.CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableItemMapping = "ExperimentalFileBasedProgramEnableItemMapping" -> string!
const Microsoft.DotNet.FileBasedPrograms.CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives = "ExperimentalFileBasedProgramEnableTransitiveDirectives" -> string!
const Microsoft.DotNet.FileBasedPrograms.CSharpDirective.IncludeOrExclude.MappingPropertyName = "FileBasedProgramsItemMapping" -> string!
const Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective = "ExperimentalFileBasedProgramEnableRefDirective" -> string!
Expand Down
25 changes: 4 additions & 21 deletions src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,10 @@ private ImmutableArray<CSharpDirective> EvaluateDirectives(

internal ImmutableArray<(string Extension, string ItemType)> GetItemMapping(ProjectInstance project, ErrorReporter reportError)
{
return MSBuildUtilities.ConvertStringToBool(project.GetPropertyValue(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableItemMapping))
? CSharpDirective.IncludeOrExclude.ParseMapping(
project.GetPropertyValue(CSharpDirective.IncludeOrExclude.MappingPropertyName),
EntryPointSourceFile,
reportError)
: CSharpDirective.IncludeOrExclude.DefaultMapping;
return CSharpDirective.IncludeOrExclude.ParseMapping(
project.GetPropertyValue(CSharpDirective.IncludeOrExclude.MappingPropertyName),
EntryPointSourceFile,
reportError);
}

public static ProjectInstance CreateProjectInstance(
Expand Down Expand Up @@ -439,8 +437,6 @@ private void CheckDirectives(
ErrorReporter reportError)
{
bool? refEnabled = null;
bool? includeEnabled = null;
bool? excludeEnabled = null;
bool? transitiveEnabled = null;

foreach (var directive in directives)
Expand All @@ -450,19 +446,6 @@ private void CheckDirectives(
CheckFlagEnabled(ref refEnabled, CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective, directive);
}

if (directive is CSharpDirective.IncludeOrExclude includeOrExcludeDirective)
{
if (includeOrExcludeDirective.Kind == CSharpDirective.IncludeOrExcludeKind.Include)
{
CheckFlagEnabled(ref includeEnabled, CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective, directive);
}
else
{
Debug.Assert(includeOrExcludeDirective.Kind == CSharpDirective.IncludeOrExcludeKind.Exclude);
CheckFlagEnabled(ref excludeEnabled, CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableExcludeDirective, directive);
}
}

if (directive.Info.SourceFile.Path != EntryPointSourceFile.Path)
{
CheckFlagEnabled(ref transitiveEnabled, CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives, directive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,7 @@ public void RefDirective_DuplicateFolderName_ViaInclude()
<Project>
<PropertyGroup>
<{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>true</{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>
<ExperimentalFileBasedProgramEnableIncludeDirective>true</ExperimentalFileBasedProgramEnableIncludeDirective>
<ExperimentalFileBasedProgramEnableTransitiveDirectives>true</ExperimentalFileBasedProgramEnableTransitiveDirectives>
<{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true</{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>
</PropertyGroup>
</Project>
""");
Expand Down Expand Up @@ -1689,15 +1688,6 @@ public void Directives_IncludeExclude()
{
var testInstance = _testAssetsManager.CreateTestDirectory();

File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """
<Project>
<PropertyGroup>
<ExperimentalFileBasedProgramEnableIncludeDirective>true</ExperimentalFileBasedProgramEnableIncludeDirective>
<ExperimentalFileBasedProgramEnableExcludeDirective>true</ExperimentalFileBasedProgramEnableExcludeDirective>
</PropertyGroup>
</Project>
""");

VerifyConversion(
baseDirectory: testInstance.Path,
evaluateDirectives: true,
Expand Down Expand Up @@ -1742,8 +1732,6 @@ public void Directives_IncludeExclude_FilesCopied()
{
var testInstance = _testAssetsManager.CreateTestDirectory();
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """
#:property ExperimentalFileBasedProgramEnableIncludeDirective=true
#:property ExperimentalFileBasedProgramEnableExcludeDirective=true
#:include **/*.cs
#:include *.json
#:exclude my.json
Expand Down Expand Up @@ -2632,7 +2620,6 @@ public void DeleteSource_WithIncludeDirective()

// Create entry point file with #:include directive
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """
#:property ExperimentalFileBasedProgramEnableIncludeDirective=true
#:include Util.cs
Console.WriteLine("Test");
""");
Expand Down Expand Up @@ -2662,7 +2649,6 @@ public void DeleteSource_WithIncludeDirective_NotDeleted()

// Create entry point file with #:include directive
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """
#:property ExperimentalFileBasedProgramEnableIncludeDirective=true
#:include Util.cs
Console.WriteLine("Test");
""");
Expand Down Expand Up @@ -2693,7 +2679,6 @@ public void DeleteSource_WithIncludeDirective_MultipleFiles()

// Create entry point file with multiple #:include directives
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """
#:property ExperimentalFileBasedProgramEnableIncludeDirective=true
#:include Util.cs
#:include Helper.cs
#:include config.json
Expand Down Expand Up @@ -2730,9 +2715,8 @@ public void DeleteSource_WithIncludeDirective_Transitive()
var testInstance = _testAssetsManager.CreateTestDirectory();

// Create entry point file with #:include directive
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """
#:property ExperimentalFileBasedProgramEnableIncludeDirective=true
#:property ExperimentalFileBasedProgramEnableTransitiveDirectives=true
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), $"""
#:property {CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}=true
#:include Util.cs
Console.WriteLine("Test");
""");
Expand Down
Loading
Loading