Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
#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;
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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static int Start(string bannerText, string helpText, string[] args)
return Start(InitialSessionState.CreateDefault2(), bannerText, helpText, args);
}

/// <summary>Entry point in to ConsoleShell. Used to create a custom Powershell console application</summary>
/// <summary>Entry point in to ConsoleShell. Used to create a custom Powershell console application.</summary>
/// <param name="initialSessionState">InitialSessionState to be used by the ConsoleHost.</param>
/// <param name="bannerText">Banner text to be displayed by ConsoleHost.</param>
/// <param name="helpText">Help text for the shell.</param>
Expand All @@ -49,4 +49,3 @@ public static int Start(InitialSessionState initialSessionState, string bannerTe
}
}
}

23 changes: 13 additions & 10 deletions src/System.Management.Automation/DscSupport/CimDSCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
internal class DscClassCacheEntry
{
/// <summary>
/// Store the RunAs Credentials that this DSC resource will use
/// Store the RunAs Credentials that this DSC resource will use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @amitsara
Please make sure we follow comment style in the future.

/// </summary>
public DSCResourceRunAsCredential DscResRunAsCred;

Expand All @@ -487,17 +487,17 @@ internal class DscClassCacheEntry
public bool IsImportedImplicitly;

/// <summary>
/// A CimClass instance for this resource
/// A CimClass instance for this resource.
/// </summary>
public Microsoft.Management.Infrastructure.CimClass CimClassInstance;

/// <summary>
/// Default constructor to initiale variables with default values
/// Initializes variables with default values.
/// </summary>
public DscClassCacheEntry() : this(DSCResourceRunAsCredential.Default, false, null) { }

/// <summary>
/// Constructor used in code to initialze all values
/// Initializes all values.
/// </summary>
/// <param name="aDSCResourceRunAsCredential"></param>
/// <param name="aIsImportedImplicitly"></param>
Expand Down Expand Up @@ -547,7 +547,7 @@ public static class DscClassCache

/// <summary>
/// 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.
/// </summary>
private static Dictionary<string, DscClassCacheEntry> ClassCache
{
Expand Down Expand Up @@ -977,6 +977,7 @@ public static List<CimClass> ImportClasses(string path, Tuple<string, Version> 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))
Expand Down Expand Up @@ -1005,6 +1006,7 @@ public static List<CimClass> ImportClasses(string path, Tuple<string, Version> 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)
{
Expand Down Expand Up @@ -1077,15 +1079,15 @@ public static void ClearCache()
/// <returns></returns>
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);
}

/// <summary>
/// Finds resources in the that which matches the specified class and module name.
/// </summary>
/// <param name="moduleName">Module name.</param>
/// <param name="className">Resource type name.</param>
/// <param name="resourceName">Resource friendly name</param>
/// <param name="resourceName">Resource friendly name.</param>
/// <returns>List of found resources in the form of Dictionary{moduleQualifiedName, cimClass}, otherwise empty list.</returns>
private static List<KeyValuePair<string, DscClassCacheEntry>> FindResourceInCache(string moduleName, string className, string resourceName)
{
Expand Down Expand Up @@ -1119,7 +1121,7 @@ private static List<DscClassCacheEntry> 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);
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -3283,9 +3286,9 @@ public static bool ImportCimKeywordsFromModule(PSModuleInfo module, string resou

return false;
}

/// <summary>
/// Clear the 'IsImportedImplicitly' flag when explicitly importing a resource
/// Clear the 'IsImportedImplicitly' flag when explicitly importing a resource.
/// </summary>
/// <param name="module"></param>
/// <param name="cimClass"></param>
Expand Down