Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ protected void GetCimInstanceInternal(CimBaseCommand cmdlet)
case CimBaseCommand.CimInstanceSessionSet:
{
CimInstance instance = GetCimInstanceParameter(cmdlet);
nameSpace = ConstValue.GetNamespace(instance.CimSystemProperties.Namespace);
foreach (CimSessionProxy proxy in proxys)
if (instance != null)
{
proxy.GetInstanceAsync(nameSpace, instance);
nameSpace = ConstValue.GetNamespace(instance.CimSystemProperties.Namespace);
foreach (CimSessionProxy proxy in proxys)
{
proxy.GetInstanceAsync(nameSpace, instance);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal static class DebugHelper
/// <summary>
/// Whether the log been initialized.
/// </summary>
private static bool logInitialized = false;
private static volatile bool logInitialized = false;

internal static bool GenerateVerboseMessage { get; set; } = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public SwitchParameter Oldest
private const string queryOpenerTemplate = "<Query Id=\"{0}\" Path=\"{1}\"><Select Path=\"{1}\">*";
private const string queryCloser = "</Query>";
private const string SelectCloser = "</Select>";
private const string suppressOpener = "<Suppress>*";
private const string suppressOpener = "<Suppress Path=\"{1}\">*";
private const string suppressCloser = "</Suppress>";
private const char propOpen = '[';
private const char propClose = ']';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,23 @@ protected override void BeginProcessing()

switch (Context.LanguageMode)
{
case PSLanguageMode.ConstrainedLanguage:
if (!CoreTypes.Contains(type))
case PSLanguageMode.ConstrainedLanguage:
if (System.Management.Automation.Security.SystemPolicy.GetSystemLockdownPolicy() != System.Management.Automation.Security.SystemEnforcementMode.Audit)
{
if ((ComObject != null) || (Strict.IsPresent))
{
if (SystemPolicy.GetSystemLockdownPolicy() != SystemEnforcementMode.Audit)
{
ThrowTerminatingError(
new ErrorRecord(
new PSNotSupportedException(NewObjectStrings.CannotCreateTypeConstrainedLanguage),
"CannotCreateTypeConstrainedLanguage",
ErrorCategory.PermissionDenied,
targetObject: null));
}
ThrowTerminatingError(
new ErrorRecord(
new PSNotSupportedException(NewObjectStrings.CannotCreateTypeConstrainedLanguage),
"CannotCreateTypeConstrainedLanguage",
ErrorCategory.PermissionDenied,
targetObject: null));
}
}

break;
case PSLanguageMode.FullLanguage:
break;

SystemPolicy.LogWDACAuditMessage(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public ShowCommandCommandInfo(PSObject other)
{
// Simple case - the objects are still live because they came from in-proc. Just cast them back
this.CommandType = (CommandTypes)(other.Members["CommandType"].Value);
this.Module = other.Members["Module"].Value as ShowCommandModuleInfo;
this.Module = other.Members["Module"]?.Value as ShowCommandModuleInfo;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,14 @@ internal LocalRunspace LocalRunspace
{
get
{
if (_isRunspacePushed)
if (RunspaceRef == null)
{
return RunspaceRef.OldRunspace as LocalRunspace;
return null;
}

if (RunspaceRef == null)
if (_isRunspacePushed)
{
return null;
return RunspaceRef.OldRunspace as LocalRunspace;
}

return RunspaceRef.Runspace as LocalRunspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ private static ViewDefinition GetView(PSPropertyExpressionFactory expressionFact
{
ActiveTracer.WriteLine(
"NOT MATCH {0} NAME: {1}",
ControlBase.GetControlShapeName(vd.mainControl), (vd != null ? vd.name : string.Empty));
(vd != null ? ControlBase.GetControlShapeName(vd.mainControl) : "null"), (vd != null ? vd.name : string.Empty));
continue;
}

Expand Down
18 changes: 9 additions & 9 deletions src/System.Management.Automation/engine/hostifaces/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -782,47 +782,47 @@ public enum PipelineResultTypes
/// <summary>
/// Default streaming behavior.
/// </summary>
None,
None = 0,

/// <summary>
/// Success output.
/// </summary>
Output,
Output = 1,

/// <summary>
/// Error output.
/// </summary>
Error,
Error = 2,

/// <summary>
/// Warning information stream.
/// </summary>
Warning,
Warning = 4,

/// <summary>
/// Verbose information stream.
/// </summary>
Verbose,
Verbose = 8,

/// <summary>
/// Debug information stream.
/// </summary>
Debug,
Debug = 16,

/// <summary>
/// Information information stream.
/// </summary>
Information,
Information = 32,

/// <summary>
/// All streams.
/// </summary>
All,
All = Output | Error | Warning | Verbose | Debug | Information,

/// <summary>
/// Redirect to nothing.
/// </summary>
Null
Null = 0
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/utils/StringUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ internal static string VtSubstring(this string str, int startOffset, int length,
}
else
{
int capacity = length + prependStr?.Length ?? 0 + appendStr?.Length ?? 0;
int capacity = length + (prependStr?.Length ?? 0) + (appendStr?.Length ?? 0);
return new StringBuilder(prependStr, capacity)
.Append(str, startOffset, length)
.Append(appendStr)
Expand Down