Skip to content

Commit 6adbe4d

Browse files
committed
Remove reflection from TargetFrameworkName retrieval (forwarded to AppDomain on NetFX)
1 parent cc2eee2 commit 6adbe4d

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/Microsoft.DotNet.Wpf/src/Common/src/System/AppContextDefaultValues.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,7 @@ private static void ParseTargetFrameworkName(out string identifier, out string p
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.

0 commit comments

Comments
 (0)