@@ -75,10 +75,10 @@ internal static List<string> GetValuesFromTestLibrary(
7575 ITestOutputHelper log ,
7676 TestAssetsManager testAssetsManager ,
7777 string itemTypeOrPropertyName ,
78- Action < GetValuesCommand > setup = null ,
78+ Action < GetValuesCommand > setup = null ,
7979 string [ ] msbuildArgs = null ,
80- GetValuesCommand . ValueType valueType = GetValuesCommand . ValueType . Item ,
81- [ CallerMemberName ] string callingMethod = "" ,
80+ GetValuesCommand . ValueType valueType = GetValuesCommand . ValueType . Item ,
81+ [ CallerMemberName ] string callingMethod = "" ,
8282 Action < XDocument > projectChanges = null ,
8383 string identifier = null )
8484 {
@@ -316,14 +316,14 @@ public void It_implicitly_defines_compilation_constants_for_the_configuration(st
316316 [ InlineData ( "netstandard1.6" , new [ ] { "NETSTANDARD" , "NETSTANDARD1_6" , "NETSTANDARD1_0_OR_GREATER" , "NETSTANDARD1_1_OR_GREATER" , "NETSTANDARD1_2_OR_GREATER" ,
317317 "NETSTANDARD1_3_OR_GREATER" , "NETSTANDARD1_4_OR_GREATER" , "NETSTANDARD1_5_OR_GREATER" , "NETSTANDARD1_6_OR_GREATER" } ) ]
318318 [ InlineData ( "net45" , new [ ] { "NETFRAMEWORK" , "NET45" , "NET20_OR_GREATER" , "NET30_OR_GREATER" , "NET35_OR_GREATER" , "NET40_OR_GREATER" , "NET45_OR_GREATER" } ) ]
319- [ InlineData ( "net461" , new [ ] { "NETFRAMEWORK" , "NET461" , "NET20_OR_GREATER" , "NET30_OR_GREATER" , "NET35_OR_GREATER" , "NET40_OR_GREATER" , "NET45_OR_GREATER" ,
319+ [ InlineData ( "net461" , new [ ] { "NETFRAMEWORK" , "NET461" , "NET20_OR_GREATER" , "NET30_OR_GREATER" , "NET35_OR_GREATER" , "NET40_OR_GREATER" , "NET45_OR_GREATER" ,
320320 "NET451_OR_GREATER" , "NET452_OR_GREATER" , "NET46_OR_GREATER" , "NET461_OR_GREATER" } ) ]
321- [ InlineData ( "net48" , new [ ] { "NETFRAMEWORK" , "NET48" , "NET20_OR_GREATER" , "NET30_OR_GREATER" , "NET35_OR_GREATER" , "NET40_OR_GREATER" , "NET45_OR_GREATER" ,
321+ [ InlineData ( "net48" , new [ ] { "NETFRAMEWORK" , "NET48" , "NET20_OR_GREATER" , "NET30_OR_GREATER" , "NET35_OR_GREATER" , "NET40_OR_GREATER" , "NET45_OR_GREATER" ,
322322 "NET451_OR_GREATER" , "NET452_OR_GREATER" , "NET46_OR_GREATER" , "NET461_OR_GREATER" , "NET462_OR_GREATER" , "NET47_OR_GREATER" , "NET471_OR_GREATER" , "NET472_OR_GREATER" , "NET48_OR_GREATER" } ) ]
323323 [ InlineData ( "netcoreapp1.0" , new [ ] { "NETCOREAPP" , "NETCOREAPP1_0" , "NETCOREAPP1_0_OR_GREATER" } ) ]
324- [ InlineData ( "netcoreapp3.0" , new [ ] { "NETCOREAPP" , "NETCOREAPP3_0" , "NETCOREAPP1_0_OR_GREATER" , "NETCOREAPP1_1_OR_GREATER" , "NETCOREAPP2_0_OR_GREATER" ,
324+ [ InlineData ( "netcoreapp3.0" , new [ ] { "NETCOREAPP" , "NETCOREAPP3_0" , "NETCOREAPP1_0_OR_GREATER" , "NETCOREAPP1_1_OR_GREATER" , "NETCOREAPP2_0_OR_GREATER" ,
325325 "NETCOREAPP2_1_OR_GREATER" , "NETCOREAPP2_2_OR_GREATER" , "NETCOREAPP3_0_OR_GREATER" } ) ]
326- [ InlineData ( "net5.0" , new [ ] { "NETCOREAPP" , "NETCOREAPP1_0_OR_GREATER" , "NETCOREAPP1_1_OR_GREATER" , "NETCOREAPP2_0_OR_GREATER" , "NETCOREAPP2_1_OR_GREATER" ,
326+ [ InlineData ( "net5.0" , new [ ] { "NETCOREAPP" , "NETCOREAPP1_0_OR_GREATER" , "NETCOREAPP1_1_OR_GREATER" , "NETCOREAPP2_0_OR_GREATER" , "NETCOREAPP2_1_OR_GREATER" ,
327327 "NETCOREAPP2_2_OR_GREATER" , "NETCOREAPP3_0_OR_GREATER" , "NETCOREAPP3_1_OR_GREATER" , "NET" , "NET5_0" , "NET5_0_OR_GREATER" } ) ]
328328 [ InlineData ( ".NETPortable,Version=v4.5,Profile=Profile78" , new string [ ] { } ) ]
329329 [ InlineData ( ".NETFramework,Version=v4.0,Profile=Client" , new string [ ] { "NETFRAMEWORK" , "NET40" , "NET20_OR_GREATER" , "NET30_OR_GREATER" , "NET35_OR_GREATER" , "NET40_OR_GREATER" } ) ]
@@ -366,7 +366,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_framework
366366 targetFrameworkProperties . Single ( ) . SetValue ( targetFramework ) ;
367367 }
368368 } ) ;
369-
369+
370370 var libraryProjectDirectory = Path . Combine ( testAsset . TestRoot , "TestLibrary" ) ;
371371
372372 var getValuesCommand = new GetValuesCommand ( Log , libraryProjectDirectory ,
@@ -423,7 +423,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform(
423423 }
424424 } ) ;
425425
426- AssertDefinedConstantsOutput ( testAsset , targetFramework ,
426+ AssertDefinedConstantsOutput ( testAsset , targetFramework ,
427427 new [ ] { "NETCOREAPP" , "NETCOREAPP1_0_OR_GREATER" , "NETCOREAPP1_1_OR_GREATER" , "NETCOREAPP2_0_OR_GREATER" , "NETCOREAPP2_1_OR_GREATER" , "NETCOREAPP2_2_OR_GREATER" , "NETCOREAPP3_0_OR_GREATER" , "NETCOREAPP3_1_OR_GREATER" , "NET" , "NET5_0" , "NET5_0_OR_GREATER" }
428428 . Concat ( expectedDefines ) . ToArray ( ) ) ;
429429 }
@@ -841,6 +841,59 @@ public void It_marks_package_references_as_externally_resolved(bool? markAsExter
841841 }
842842 }
843843
844+ [ Theory ]
845+ [ InlineData ( "net5.0" , false , false , false , null ) ] // Pre .NET 6.0 predefinedCulturesOnly is not supported.
846+ [ InlineData ( "net5.0" , true , false , false , null ) ] // Pre .NET 6.0 predefinedCulturesOnly is not supported.
847+ [ InlineData ( "net5.0" , false , true , true , "True" ) ] // Pre .NET 6.0 predefinedCulturesOnly can end up in the runtime config file but with no effect at runtime.
848+ [ InlineData ( "net5.0" , true , true , true , "True" ) ] // Pre .NET 6.0 predefinedCulturesOnly can end up in the runtime config file but with no effect at runtime.
849+ [ InlineData ( "net6.0" , false , false , false , null ) ] // predefinedCulturesOnly will not be included in the runtime config file if invariant is not defined.
850+ [ InlineData ( "net6.0" , false , false , true , "False" ) ] // predefinedCulturesOnly explicitly defined as false.
851+ [ InlineData ( "net6.0" , false , true , true , "True" ) ] // predefinedCulturesOnly explicitly defined as true.
852+ [ InlineData ( "net6.0" , true , false , false , "True" ) ] // predefinedCulturesOnly default value is true when Invariant is true.
853+ [ InlineData ( "net6.0" , true , false , true , "False" ) ] // predefinedCulturesOnly explicitly defined as false.
854+ [ InlineData ( "net6.0" , true , true , true , "True" ) ] // predefinedCulturesOnly explicitly defined as true.
855+ public void It_can_implicitly_define_predefined_Cultures_only ( string targetFramework , bool invariantValue , bool predefinedCulturesOnlyValue , bool definePredefinedCulturesOnly , string expectedPredefinedValue )
856+ {
857+ var testProj = new TestProject ( )
858+ {
859+ Name = "CheckPredefineCulturesOnly" ,
860+ TargetFrameworks = targetFramework ,
861+ IsExe = true ,
862+ } ;
863+
864+ testProj . AdditionalProperties [ "InvariantGlobalization" ] = invariantValue ? "true" : "false" ;
865+
866+ if ( definePredefinedCulturesOnly )
867+ {
868+ testProj . AdditionalProperties [ "PredefinedCulturesOnly" ] = predefinedCulturesOnlyValue ? "true" : "false" ;
869+ }
870+
871+ var testAsset = _testAssetsManager . CreateTestProject ( testProj , identifier : $ "{ targetFramework } { invariantValue } { predefinedCulturesOnlyValue } { definePredefinedCulturesOnly } ") ;
872+ var buildCommand = new BuildCommand ( testAsset ) ;
873+ buildCommand
874+ . Execute ( )
875+ . Should ( )
876+ . Pass ( ) ;
877+
878+ string runtimeConfigName = $ "{ testProj . Name } .runtimeconfig.json";
879+ var outputDirectory = buildCommand . GetOutputDirectory ( testProj . TargetFrameworks ) ;
880+ outputDirectory . Should ( ) . HaveFile ( runtimeConfigName ) ;
881+
882+ string runtimeConfigFile = Path . Combine ( outputDirectory . FullName , runtimeConfigName ) ;
883+ string runtimeConfigContents = File . ReadAllText ( runtimeConfigFile ) ;
884+ JObject runtimeConfig = JObject . Parse ( runtimeConfigContents ) ;
885+ JToken predefinedCulturesOnly = runtimeConfig [ "runtimeOptions" ] [ "configProperties" ] [ "System.Globalization.PredefinedCulturesOnly" ] ;
886+
887+ if ( expectedPredefinedValue is null )
888+ {
889+ predefinedCulturesOnly . Should ( ) . BeNull ( ) ;
890+ }
891+ else
892+ {
893+ predefinedCulturesOnly . Value < string > ( ) . Should ( ) . Be ( expectedPredefinedValue ) ;
894+ }
895+ }
896+
844897 [ Theory ]
845898 [ InlineData ( "netcoreapp2.2" , null , false , null , false ) ]
846899 [ InlineData ( "netcoreapp3.0" , null , true , null , true ) ]
@@ -905,8 +958,6 @@ public void It_can_build_with_dynamic_loading_enabled(string targetFramework, st
905958 {
906959 rollForward . Should ( ) . BeNull ( ) ;
907960 }
908-
909-
910961 }
911962
912963 [ Theory ]
0 commit comments