@@ -19,15 +19,19 @@ internal static partial class AppContextDefaultValues
1919 {
2020 public static void PopulateDefaultValues ( )
2121 {
22- string platformIdentifier , profile ;
23- int version ;
24-
25- ParseTargetFrameworkName ( out platformIdentifier , out profile , out version ) ;
22+ #if NETFX
23+ // Get Target Framework information
24+ ParseTargetFrameworkName ( out string platformIdentifier , out string profile , out int version ) ;
2625
2726 // Call into each library to populate their default switches
2827 PopulateDefaultValuesPartial ( platformIdentifier , profile , version ) ;
28+ #else
29+ // Call into each library to populate their default switches
30+ // ".NETCoreApp,Version=v3.0"
31+ PopulateDefaultValuesPartial ( ".NETCoreApp" , string . Empty , 30000 ) ;
32+ #endif
2933 }
30-
34+ #if NETFX
3135 /// <summary>
3236 /// We have this separate method for getting the parsed elements out of the TargetFrameworkName so we can
3337 /// more easily support this on other platforms.
@@ -67,29 +71,10 @@ private static void ParseTargetFrameworkName(out string identifier, out string p
6771 /// <summary>
6872 /// This is equivalent to calling <code>AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName</code>
6973 /// </summary>
70- /// <remarks>
71- /// <code>AppDomain.CurrentDomain.SetupInformation</code> is not available until .NET Core 3.0, but we
72- /// have a need to run this code in .NET Core 2.2, we attempt to obtain this information via Reflection.
73- /// </remarks>
7474 /// <returns>TargetFrameworkMoniker on .NET Framework and .NET Core 3.0+; null on .NET Core 2.2 or older runtimes</returns>
7575 private static string GetTargetFrameworkMoniker ( )
7676 {
77- try
78- {
79- var pSetupInformation = typeof ( AppDomain ) . GetProperty ( "SetupInformation" ) ;
80- object appDomainSetup = pSetupInformation ? . GetValue ( AppDomain . CurrentDomain ) ;
81- Type tAppDomainSetup = Type . GetType ( "System.AppDomainSetup" ) ;
82- var pTargetFrameworkName = tAppDomainSetup ? . GetProperty ( "TargetFrameworkName" ) ;
83-
84- return
85- appDomainSetup != null ?
86- pTargetFrameworkName ? . GetValue ( appDomainSetup ) as string :
87- null ;
88- }
89- catch ( Exception )
90- {
91- return null ;
92- }
77+ return AppContext . TargetFrameworkName ;
9378 }
9479
9580 // This code was a constructor copied from the FrameworkName class, which is located in System.dll.
@@ -196,7 +181,7 @@ private static bool TryParseFrameworkName(String frameworkName, out String ident
196181
197182 return true ;
198183 }
199-
184+ #endif
200185 // This is a partial method. Platforms (such as Desktop) can provide an implementation of it that will read override value
201186 // from whatever mechanism is available on that platform. If no implementation is provided, the compiler is going to remove the calls
202187 // to it from the code
0 commit comments