diff --git a/documentation/general/dotnet-run-file.md b/documentation/general/dotnet-run-file.md index 9c9ed03ab167..dfcb07822795 100644 --- a/documentation/general/dotnet-run-file.md +++ b/documentation/general/dotnet-run-file.md @@ -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. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs b/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs index bee6360deaaf..65fd17f44bdb 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs @@ -693,11 +693,7 @@ public enum IncludeOrExcludeKind /// 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); - public const string ExperimentalFileBasedProgramEnableItemMapping = nameof(ExperimentalFileBasedProgramEnableItemMapping); - public const string MappingPropertyName = "FileBasedProgramsItemMapping"; public static string DefaultMappingString => ".cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content"; diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/InternalAPI.Unshipped.txt b/src/Cli/Microsoft.DotNet.FileBasedPrograms/InternalAPI.Unshipped.txt index bbf3d44bc01b..d3a08eaa3a3e 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/InternalAPI.Unshipped.txt +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/InternalAPI.Unshipped.txt @@ -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! diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.es.xlf b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.es.xlf index 3d3f76062d7b..1e8f0b7167a2 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.es.xlf +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.es.xlf @@ -64,7 +64,7 @@ The '#:ref' directive is invalid: {0} - The '#:ref' directive is invalid: {0} + La directiva "#:ref" no es válida: {0} {Locked="#:ref"}{0} is the inner error message. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.fr.xlf b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.fr.xlf index c3cb53dfa9e0..61d4881186ad 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.fr.xlf +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.fr.xlf @@ -64,7 +64,7 @@ The '#:ref' directive is invalid: {0} - The '#:ref' directive is invalid: {0} + La directive « #:ref » est invalide : {0} {Locked="#:ref"}{0} is the inner error message. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.ko.xlf b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.ko.xlf index 75f293801c3a..5226d09c601e 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.ko.xlf +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.ko.xlf @@ -64,7 +64,7 @@ The '#:ref' directive is invalid: {0} - The '#:ref' directive is invalid: {0} + ‘#:ref’ 지시문이 잘못되었습니다: {0} {Locked="#:ref"}{0} is the inner error message. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.pl.xlf b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.pl.xlf index 70bc479286d5..206da655e6ed 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.pl.xlf +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.pl.xlf @@ -64,7 +64,7 @@ The '#:ref' directive is invalid: {0} - The '#:ref' directive is invalid: {0} + Dyrektywa „#:ref” jest nieprawidłowa: {0} {Locked="#:ref"}{0} is the inner error message. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.tr.xlf b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.tr.xlf index 3a2e8533ee02..5db8e086b974 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.tr.xlf +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.tr.xlf @@ -64,7 +64,7 @@ The '#:ref' directive is invalid: {0} - The '#:ref' directive is invalid: {0} + '#:ref' yönergesi geçersiz: {0} {Locked="#:ref"}{0} is the inner error message. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.zh-Hans.xlf b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.zh-Hans.xlf index 1cd4525ecc9c..9abb7769ed62 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.zh-Hans.xlf +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/xlf/FileBasedProgramsResources.zh-Hans.xlf @@ -64,7 +64,7 @@ The '#:ref' directive is invalid: {0} - The '#:ref' directive is invalid: {0} + "#:ref" 指令无效: {0} {Locked="#:ref"}{0} is the inner error message. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf index 50ac257b0f42..e07f0214c790 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf index cf217b15cdeb..18a5eeff1d7d 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ Das Tool "{1}" (Version {2}) wurde erfolgreich installiert. Der Eintrag wird der Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Mehrere Dateien, auf die verwiesen wird, werden in dasselbe Verzeichnis konvertiert: „{0}“ {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf index fb2de6eee99c..61cf2fafbf85 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ La herramienta "{1}" (versión "{2}") se instaló correctamente. Se ha agregado Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Varios archivos a los que se hace referencia se convertirían en el mismo directorio: "{0}" {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf index 06cfb885c868..d59257a44347 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ L'outil '{1}' (version '{2}') a été correctement installé. L'entrée est ajou Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Plusieurs fichiers référencés seraient convertis dans le même dossier : « {0} » {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf index ec71ee5e9c87..4ffd173f2e8b 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ Lo strumento '{1}' versione '{2}' è stato installato. La voce è stata aggiunta Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Più file a cui si fa riferimento verranno convertiti nella stessa directory: '{0}' {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf index d129d876345f..e1255a3658c2 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf index 06af364db1f7..6ae7735085da 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + 참조된 여러 파일이 동일한 디렉터리 '{0}'으(로) 변환됩니다. {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf index 65737b51140a..75795f96f4bf 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ Narzędzie „{1}” (wersja „{2}”) zostało pomyślnie zainstalowane. Wpis Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Wiele odwoływanych plików zostałoby przekonwertowanych do tego samego katalogu: „{0}” {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf index 35e1bec6efbe..6c0de7f3dfea 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ A ferramenta '{1}' (versão '{2}') foi instalada com êxito. A entrada foi adici Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Vários arquivos referenciados seriam convertidos no mesmo diretório: '{0}' {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf index b9158636ca3b..af8d83fda6fa 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf index 6ece903c03dd..c30b005d8895 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + Birden fazla başvurulan dosya aynı dizine dönüştürülecek: '{0}' {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf index 4e8c3ce5f26b..443e3fb2b543 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf @@ -1,4 +1,4 @@ - + @@ -1258,7 +1258,7 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man Multiple referenced files would be converted into the same directory: '{0}' - Multiple referenced files would be converted into the same directory: '{0}' + 多个引用的文件将转换到同一目录: {0} {0} is the target directory path. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf index 4e539b59c7a8..76e4c11c4e0f 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/Cli/dotnet/ToolPackage/ToolConfigurationDeserializer.cs b/src/Cli/dotnet/ToolPackage/ToolConfigurationDeserializer.cs index b7b8e87e55eb..fa7ffc59589f 100644 --- a/src/Cli/dotnet/ToolPackage/ToolConfigurationDeserializer.cs +++ b/src/Cli/dotnet/ToolPackage/ToolConfigurationDeserializer.cs @@ -71,7 +71,7 @@ public static ToolConfiguration Deserialize(string pathToXml, IFileSystem fileSy .AsReadOnly(); // Also error out if there are no RID-specific packages and the runner is empty - if (string.IsNullOrEmpty(runner) && !ridSpecificPackages.Any()) + if (string.IsNullOrEmpty(runner) && (ridSpecificPackages == null || !ridSpecificPackages.Any())) { throw new ToolConfigurationException( string.Format( diff --git a/src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs b/src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs index 78ffdbcbf176..50f18abe9265 100644 --- a/src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs +++ b/src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs @@ -252,12 +252,10 @@ private ImmutableArray 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( @@ -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) @@ -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); diff --git a/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs b/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs index c0e03300da4e..b06c4aae98f6 100644 --- a/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs +++ b/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs @@ -448,8 +448,7 @@ public void RefDirective_DuplicateFolderName_ViaInclude() <{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>true - true - true + <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true """); @@ -1689,15 +1688,6 @@ public void Directives_IncludeExclude() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - true - - - """); - VerifyConversion( baseDirectory: testInstance.Path, evaluateDirectives: true, @@ -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 @@ -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"); """); @@ -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"); """); @@ -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 @@ -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"); """); diff --git a/test/dotnet.Tests/CommandTests/Run/RunFileTests.cs b/test/dotnet.Tests/CommandTests/Run/RunFileTests.cs index 02d4fbd7f110..26e16204fc0e 100644 --- a/test/dotnet.Tests/CommandTests/Run/RunFileTests.cs +++ b/test/dotnet.Tests/CommandTests/Run/RunFileTests.cs @@ -1247,10 +1247,10 @@ public static class B public static string M() => "String from Util"; } """); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ + File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), $""" - true + <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true @@ -1979,14 +1979,6 @@ public void BinaryLog_EvaluationData_MultiFile() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - - - """); - File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), $""" #!/usr/bin/env dotnet @@ -2152,15 +2144,6 @@ public void MissingShebangWarning() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - true - - - """); - // Single-file program without shebang should NOT produce CA2266 // (the warning only fires when there are multiple files via #:include). File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """ @@ -3919,7 +3902,6 @@ public void RefDirective_WithInclude() <{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>true - <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective}>true """); @@ -4099,7 +4081,6 @@ public void RefDirective_DuplicateRefFromIncludedFiles() <{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>true - <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective}>true <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true @@ -4158,7 +4139,6 @@ public void RefDirective_DuplicateRefFromIncludedFiles_Subdirectories() <{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>true - <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective}>true <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true @@ -4224,7 +4204,6 @@ public void RefDirective_IncludeAndRefSameFile() <{CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective}>true - <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective}>true <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true @@ -4261,15 +4240,6 @@ public void IncludeDirective( { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - true - - - """); - File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), $""" #!/usr/bin/env dotnet #:include {includePattern} @@ -4292,14 +4262,6 @@ public void IncludeDirective_WorkingDirectory() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - - - """); - var srcDir = Path.Join(testInstance.Path, "src"); Directory.CreateDirectory(srcDir); @@ -4335,7 +4297,6 @@ static class B { public static string M() => "Hello from B"; } new DirectoryInfo(testInstance.Path) .Should().HaveSubtree(""" - Directory.Build.props src/ src/A.cs src/A/ @@ -4379,11 +4340,10 @@ public void IncludeDirective_Transitive() Directory.CreateDirectory(Path.Join(testInstance.Path, "dir1/dir2")); Directory.CreateDirectory(Path.Join(testInstance.Path, "dir3")); - File.WriteAllText(Path.Join(testInstance.Path, "dir1/Directory.Build.props"), """ + File.WriteAllText(Path.Join(testInstance.Path, "dir1/Directory.Build.props"), $""" - true - true + <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true """); @@ -4497,14 +4457,6 @@ public void IncludeDirective_FileNotFound() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - - - """); - var programPath = Path.Join(testInstance.Path, "A.cs"); File.WriteAllText(programPath, """ @@ -4530,14 +4482,6 @@ public void IncludeDirective_UpToDate_Glob(string glob) { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - - - """); - var programPath = Path.Join(testInstance.Path, "Program.cs"); File.WriteAllText(programPath, $""" #!/usr/bin/env dotnet @@ -4597,14 +4541,6 @@ public void IncludeDirective_UpToDate_NoGlob() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - - - """); - var programPath = Path.Join(testInstance.Path, "Program.cs"); File.WriteAllText(programPath, $""" #!/usr/bin/env dotnet @@ -4662,11 +4598,10 @@ public void IncludeDirective_UpToDate_ProjectReference() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ + File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), $""" - true - true + <{CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives}>true """); @@ -4730,51 +4665,30 @@ class UtilClass Build(testInstance, BuildLevel.All, expectedOutput: expectedOutput, workDir: appDir); } + /// + /// Transitive directives (directives in non-entry-point files) are gated behind a feature flag. + /// [Fact] public void IncludeDirective_FeatureFlags() { var testInstance = _testAssetsManager.CreateTestDirectory(); - var programPath = Path.Join(testInstance.Path, "Program.cs"); - File.WriteAllText(programPath, $""" + File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """ #!/usr/bin/env dotnet - #:include *.cs - {s_programDependingOnUtil} + #:include Util.cs + Console.WriteLine(Util.M()); """); var utilPath = Path.Join(testInstance.Path, "Util.cs"); - File.WriteAllText(utilPath, $""" - #:exclude Other.cs - {s_util} + File.WriteAllText(utilPath, """ + #:property DefineConstants=MY_CONST + static class Util { public static string M() => "Hello from Util"; } """); new DotnetCommand(Log, "run", "Program.cs") .WithWorkingDirectory(testInstance.Path) .Execute() .Should().Fail() - .And.HaveStdErr($""" - {DirectiveError(programPath, 2, Resources.ExperimentalFeatureDisabled, CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective)} - - {CliCommandStrings.RunCommandException} - """); - - new DotnetCommand(Log, "run", "Program.cs") - .WithWorkingDirectory(testInstance.Path) - .WithEnvironmentVariable(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective, "true") - .Execute() - .Should().Fail() - .And.HaveStdErr($""" - {DirectiveError(utilPath, 1, Resources.ExperimentalFeatureDisabled, CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableExcludeDirective)} - - {CliCommandStrings.RunCommandException} - """); - - new DotnetCommand(Log, "run", "Program.cs") - .WithWorkingDirectory(testInstance.Path) - .WithEnvironmentVariable(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective, "true") - .WithEnvironmentVariable(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableExcludeDirective, "true") - .Execute() - .Should().Fail() .And.HaveStdErr($""" {DirectiveError(utilPath, 1, Resources.ExperimentalFeatureDisabled, CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives)} @@ -4783,12 +4697,10 @@ public void IncludeDirective_FeatureFlags() new DotnetCommand(Log, "run", "Program.cs") .WithWorkingDirectory(testInstance.Path) - .WithEnvironmentVariable(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableIncludeDirective, "true") - .WithEnvironmentVariable(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableExcludeDirective, "true") .WithEnvironmentVariable(CSharpDirective.IncludeOrExclude.ExperimentalFileBasedProgramEnableTransitiveDirectives, "true") .Execute() .Should().Pass() - .And.HaveStdOut("Hello, String from Util"); + .And.HaveStdOut("Hello from Util"); } [Fact] @@ -4796,15 +4708,6 @@ public void IncludeDirective_CustomMapping() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - true - - - """); - var programPath = Path.Join(testInstance.Path, "Program.cs"); File.WriteAllText(programPath, $""" #!/usr/bin/env dotnet @@ -4859,15 +4762,6 @@ public void IncludeDirective_CustomMapping_ParseErrors() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - true - - - """); - var programPath = Path.Join(testInstance.Path, "Program.cs"); File.WriteAllText(programPath, """ #:property FileBasedProgramsItemMapping=x @@ -7029,14 +6923,6 @@ public void Api_Evaluation() { var testInstance = _testAssetsManager.CreateTestDirectory(); - File.WriteAllText(Path.Join(testInstance.Path, "Directory.Build.props"), """ - - - true - - - """); - var programPath = Path.Join(testInstance.Path, "A.cs"); File.WriteAllText(programPath, """ #:property P1=cs