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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public ShowCommandCommandInfo(PSObject other)
var parameterSets = (other.Members["ParameterSets"].Value as PSObject).BaseObject as System.Collections.ArrayList;
this.ParameterSets = GetObjectEnumerable(parameterSets).Cast<PSObject>().Select(x => new ShowCommandParameterSetInfo(x)).ToList().AsReadOnly();

if (other.Members["Module"] != null && other.Members["Module"].Value as PSObject != null)
if (other.Members["Module"]?.Value is PSObject)
{
this.Module = new ShowCommandModuleInfo(other.Members["Module"].Value as PSObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ internal long SetRequestContent(HttpRequestMessage request, XmlNode xmlNode)

byte[] bytes = null;
XmlDocument doc = xmlNode as XmlDocument;
if (doc != null && (doc.FirstChild as XmlDeclaration) != null)
if (doc?.FirstChild is XmlDeclaration)
{
XmlDeclaration decl = doc.FirstChild as XmlDeclaration;
Encoding encoding = Encoding.GetEncoding(decl.Encoding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ protected override void ProcessRecord()
ThrowTerminatingError(e.ErrorRecord);
}

if ((hashtable[ConfigFileConstants.FunctionValueToken] as ScriptBlock) == null)
if (hashtable[ConfigFileConstants.FunctionValueToken] is not ScriptBlock)
{
PSArgumentException e = new PSArgumentException(StringUtil.Format(RemotingErrorIdStrings.DISCKeyMustBeScriptBlock,
ConfigFileConstants.FunctionValueToken, ConfigFileConstants.FunctionDefinitions, _path));
Expand Down Expand Up @@ -1714,7 +1714,7 @@ protected override void ProcessRecord()
ThrowTerminatingError(e.ErrorRecord);
}

if ((hashtable[ConfigFileConstants.FunctionValueToken] as ScriptBlock) == null)
if (hashtable[ConfigFileConstants.FunctionValueToken] is not ScriptBlock)
{
PSArgumentException e = new PSArgumentException(StringUtil.Format(RemotingErrorIdStrings.DISCKeyMustBeScriptBlock,
ConfigFileConstants.FunctionValueToken, ConfigFileConstants.FunctionDefinitions, _path));
Expand Down Expand Up @@ -1951,7 +1951,7 @@ internal static string CombineHashtable(IDictionary table, StreamWriter writer,
sb.AppendFormat("{0," + (4 * (indent + 1)) + "}", string.Empty);
sb.Append(QuoteName(key));
sb.Append(" = ");
if ((table[key] as ScriptBlock) != null)
if (table[key] is ScriptBlock)
{
sb.Append(WrapScriptBlock(table[key].ToString()));
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ private static bool FunctionDefinitionsTypeValidationCallback(string key, object
return false;
}

if ((hashtable[FunctionValueToken] as ScriptBlock) == null)
if (hashtable[FunctionValueToken] is not ScriptBlock)
{
cmdlet.WriteVerbose(StringUtil.Format(RemotingErrorIdStrings.DISCKeyMustBeScriptBlock, FunctionValueToken, key, path));
return false;
Expand Down Expand Up @@ -2221,7 +2221,7 @@ public override InitialSessionState GetInitialSessionState(PSSenderInfo senderIn
foreach (Hashtable variable in variables)
{
if (variable.ContainsKey(ConfigFileConstants.VariableValueToken) &&
((variable[ConfigFileConstants.VariableValueToken] as ScriptBlock) != null))
variable[ConfigFileConstants.VariableValueToken] is ScriptBlock)
{
iss.DynamicVariablesToDefine.Add(variable);
continue;
Expand Down