From 51e11aaedfde46ed5844d98ca87d414348325a06 Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 28 Oct 2021 23:22:09 +0500 Subject: [PATCH] Remove unnecessary call to `ToArray` (#16307) --- src/System.Management.Automation/CoreCLR/CorePsPlatform.cs | 2 +- .../engine/InitialSessionState.cs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index 859aa8ecfe..dd0877710d 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -184,7 +184,7 @@ namespace System.Management.Automation #endif // format files - internal static readonly List FormatFileNames = new() + internal static readonly string[] FormatFileNames = new string[] { "Certificate.format.ps1xml", "Diagnostics.format.ps1xml", diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 815f7ea562..05eb871053 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -1434,9 +1434,6 @@ namespace System.Management.Automation.Runspaces return iss; } - // Porting note: moved to Platform so we have one list to maintain - private static readonly string[] s_PSCoreFormatFileNames = Platform.FormatFileNames.ToArray(); - private static void IncludePowerShellCoreFormats(InitialSessionState iss) { string psHome = Utils.DefaultPowerShellAppBase; @@ -1446,7 +1443,7 @@ namespace System.Management.Automation.Runspaces } iss.Formats.Clear(); - foreach (var coreFormat in s_PSCoreFormatFileNames) + foreach (var coreFormat in Platform.FormatFileNames) { iss.Formats.Add(new SessionStateFormatEntry(Path.Combine(psHome, coreFormat))); }