From 19e10d1dfd70a0d1293eab2fdb8f84cd9f734db0 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 19 Jun 2019 09:46:58 +0500 Subject: [PATCH 1/4] Fix ConsoleShell.cs --- src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs index 51db1e5f36c..5f34692cd02 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs @@ -25,7 +25,7 @@ public static int Start(string bannerText, string helpText, string[] args) return Start(InitialSessionState.CreateDefault2(), bannerText, helpText, args); } - /// Entry point in to ConsoleShell. Used to create a custom Powershell console application + /// Entry point in to ConsoleShell. Used to create a custom Powershell console application. /// InitialSessionState to be used by the ConsoleHost. /// Banner text to be displayed by ConsoleHost. /// Help text for the shell. @@ -49,4 +49,3 @@ public static int Start(InitialSessionState initialSessionState, string bannerTe } } } - From 7610ddfd74a8bf61589f285365aaab7be10b7c66 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 19 Jun 2019 10:02:52 +0500 Subject: [PATCH 2/4] Fix CimDSCParser.cs --- .../DscSupport/CimDSCParser.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index 3079155097f..44ca0a7d498 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -476,7 +476,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal internal class DscClassCacheEntry { /// - /// Store the RunAs Credentials that this DSC resource will use + /// Store the RunAs Credentials that this DSC resource will use. /// public DSCResourceRunAsCredential DscResRunAsCred; @@ -487,17 +487,17 @@ internal class DscClassCacheEntry public bool IsImportedImplicitly; /// - /// A CimClass instance for this resource + /// A CimClass instance for this resource. /// public Microsoft.Management.Infrastructure.CimClass CimClassInstance; /// - /// Default constructor to initiale variables with default values + /// Initializes variables with default values. /// public DscClassCacheEntry() : this(DSCResourceRunAsCredential.Default, false, null) { } /// - /// Constructor used in code to initialze all values + /// Initializes all values. /// /// /// @@ -547,7 +547,7 @@ public static class DscClassCache /// /// DSC class cache for this runspace. - /// Cache stores the DSCRunAsBehavior, cim class and boolean to indicate if an Inbox resource has been implicitly imported. + /// Cache stores the DSCRunAsBehavior, cim class and boolean to indicate if an Inbox resource has been implicitly imported. /// private static Dictionary ClassCache { @@ -977,6 +977,7 @@ public static List ImportClasses(string path, Tuple m if (ClassCache.TryGetValue(moduleQualifiedResourceName, out cimClassInfo)) { CimClass cimClass = cimClassInfo.CimClassInstance; + // If this is a nested object and we already have exactly same nested object, we will // allow sharing of nested objects. if (!IsSameNestedObject(cimClass, c)) @@ -1005,6 +1006,7 @@ public static List ImportClasses(string path, Tuple m if (resourceList.Count > 0 && !string.IsNullOrEmpty(resourceList[0].Key)) { ClassCache.Remove(resourceList[0].Key); + // keyword is already defined and it is a Inbox resource, remove it if (DynamicKeyword.ContainsKeyword(friendlyName) && resourceList[0].Value.IsImportedImplicitly) { @@ -1077,7 +1079,7 @@ public static void ClearCache() /// private static string GetModuleQualifiedResourceName(string moduleName, string moduleVersion, string className, string resourceName) { - return String.Format(CultureInfo.InvariantCulture, "{0}\\{1}\\{2}\\{3}", moduleName, moduleVersion, className, resourceName); + return string.Format(CultureInfo.InvariantCulture, "{0}\\{1}\\{2}\\{3}", moduleName, moduleVersion, className, resourceName); } /// @@ -1085,7 +1087,7 @@ private static string GetModuleQualifiedResourceName(string moduleName, string m /// /// Module name. /// Resource type name. - /// Resource friendly name + /// Resource friendly name. /// List of found resources in the form of Dictionary{moduleQualifiedName, cimClass}, otherwise empty list. private static List> FindResourceInCache(string moduleName, string className, string resourceName) { @@ -1119,7 +1121,7 @@ private static List GetCachedClasses() var moduleQualifiedName = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", module.Name, module.Version.ToString()); foreach (var dscClassCacheEntry in ClassCache) { - if(dscClassCacheEntry.Key.StartsWith(moduleQualifiedName, StringComparison.OrdinalIgnoreCase)) + if (dscClassCacheEntry.Key.StartsWith(moduleQualifiedName, StringComparison.OrdinalIgnoreCase)) { cachedClasses.Add(dscClassCacheEntry.Value.CimClassInstance); } @@ -3154,6 +3156,7 @@ private static void ProcessMofForDynamicKeywords(PSModuleInfo module, ICollectio if (resourceList.Count > 0 && !string.IsNullOrEmpty(resourceList[0].Key)) { ClassCache.Remove(resourceList[0].Key); + // keyword is already defined and it is a Inbox resource, remove it if (DynamicKeyword.ContainsKeyword(friendlyName) && resourceList[0].Value.IsImportedImplicitly) { @@ -3283,9 +3286,9 @@ public static bool ImportCimKeywordsFromModule(PSModuleInfo module, string resou return false; } - + /// - /// Clear the 'IsImportedImplicitly' flag when explicitly importing a resource + /// Clear the 'IsImportedImplicitly' flag when explicitly importing a resource. /// /// /// From c29c5f24c7e0bc2a29d1658d75e0c605c8f5d623 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 19 Jun 2019 12:05:22 +0500 Subject: [PATCH 3/4] Fix ConsoleHost.cs --- .../host/msh/ConsoleHost.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index a0689ba60a3..5ac33b7428f 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -4,33 +4,33 @@ #pragma warning disable 1634, 1691 using System; -using System.Diagnostics.CodeAnalysis; -using System.Text; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; -using System.Reflection; using System.Management.Automation; using System.Management.Automation.Host; using System.Management.Automation.Internal; -using System.Management.Automation.Runspaces; +using System.Management.Automation.Language; using System.Management.Automation.Remoting; -using System.Management.Automation.Security; -using System.Threading; +using System.Management.Automation.Runspaces; +using System.Management.Automation.Tracing; +using System.Reflection; using System.Runtime.InteropServices; -using System.Management.Automation.Language; +using System.Text; +using System.Threading; +using System.Threading.Tasks; -using Dbg = System.Management.Automation.Diagnostics; using ConsoleHandle = Microsoft.Win32.SafeHandles.SafeFileHandle; -using System.Management.Automation.Tracing; -using System.Threading.Tasks; +using Dbg = System.Management.Automation.Diagnostics; +using Debugger = System.Management.Automation.Debugger; + #if LEGACYTELEMETRY using Microsoft.PowerShell.Telemetry.Internal; #endif -using Debugger = System.Management.Automation.Debugger; namespace Microsoft.PowerShell { From 824ee14f5ce47ef2be77acabea8103058114f944 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 19 Jun 2019 12:29:48 +0500 Subject: [PATCH 4/4] Fix typo --- src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 41f7c5ba996..bd9a411df92 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -19,6 +19,7 @@ using System.Management.Automation.Runspaces; using System.Management.Automation.Tracing; using System.Reflection; +using System.Runtime; using System.Runtime.InteropServices; using System.Text; using System.Threading;