Skip to content
Closed
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
14 changes: 7 additions & 7 deletions src/System.Management.Automation/DscSupport/CimDSCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,10 @@ internal List<CimClass> ParseSchemaMof(string filePath)
{
string superClassName = c.CimSuperClassName;
string className = c.CimSystemProperties.ClassName;
if ((superClassName != null) && (superClassName.Equals("OMI_BaseResource", StringComparison.OrdinalIgnoreCase)))
if ((superClassName != null) && superClassName.Equals("OMI_BaseResource", StringComparison.OrdinalIgnoreCase))
{
// Get the name of the file without schema.mof extension
if (!(className.Equals(fileNameDefiningClass, StringComparison.OrdinalIgnoreCase)))
if (!className.Equals(fileNameDefiningClass, StringComparison.OrdinalIgnoreCase))
{
PSInvalidOperationException e = PSTraceSource.NewInvalidOperationException(
ParserStrings.ClassNameNotSameAsDefiningFile, className, fileNameDefiningClass);
Expand Down Expand Up @@ -1110,9 +1110,9 @@ private static List<KeyValuePair<string, DscClassCacheEntry>> FindResourceInCach
let cachedClassName = splittedName[IndexClassName]
let cachedModuleName = splittedName[IndexModuleName]
let cachedResourceName = splittedName[IndexFriendlyName]
where (string.Equals(cachedResourceName, resourceName, StringComparison.OrdinalIgnoreCase)
where string.Equals(cachedResourceName, resourceName, StringComparison.OrdinalIgnoreCase)
|| (string.Equals(cachedClassName, className, StringComparison.OrdinalIgnoreCase)
&& string.Equals(cachedModuleName, moduleName, StringComparison.OrdinalIgnoreCase)))
&& string.Equals(cachedModuleName, moduleName, StringComparison.OrdinalIgnoreCase))
select cacheEntry).ToList();
}

Expand Down Expand Up @@ -2439,7 +2439,7 @@ private static bool GetResourceMethodsLineNumber(TypeDefinitionAst typeDefinitio
}

// All 3 methods (Get/Set/Test) position should be found.
return (methodsLinePosition.Count == 3);
return methodsLinePosition.Count == 3;
}

/// <summary>
Expand Down Expand Up @@ -2661,7 +2661,7 @@ private static bool ImportKeywordsFromScriptFile(string fileName, PSModuleInfo m
bool skip = true;
foreach (var toImport in resourcesToImport)
{
if ((WildcardPattern.Get(toImport, WildcardOptions.IgnoreCase)).IsMatch(resourceDefnAst.Name))
if (WildcardPattern.Get(toImport, WildcardOptions.IgnoreCase).IsMatch(resourceDefnAst.Name))
{
skip = false;
break;
Expand Down Expand Up @@ -3136,7 +3136,7 @@ private static bool ImportKeywordsFromAssembly(PSModuleInfo module,

foreach (var toImport in resourcesToImport)
{
if ((WildcardPattern.Get(toImport, WildcardOptions.IgnoreCase)).IsMatch(r.Name))
if (WildcardPattern.Get(toImport, WildcardOptions.IgnoreCase).IsMatch(r.Name))
{
skip = false;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ protected void ProcessUnknownAttribute(XmlAttribute a)

protected static bool IsFilteredOutNode(XmlNode n)
{
return (n is XmlComment || n is XmlWhitespace);
return n is XmlComment || n is XmlWhitespace;
}

protected bool VerifyNodeHasNoChildren(XmlNode n)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ internal static EnumerableExpansion GetEnumerableExpansionFromType(PSPropertyExp

if (match.BestMatch != null)
{
return ((EnumerableExpansionDirective)(match.BestMatch)).enumerableExpansion;
return ((EnumerableExpansionDirective)match.BestMatch).enumerableExpansion;
}
else
{
Expand Down Expand Up @@ -315,7 +315,7 @@ internal static FormatShape GetShapeFromType(PSPropertyExpressionFactory express

if (match.BestMatch != null)
{
return ((FormatShapeSelectionOnType)(match.BestMatch)).formatShape;
return ((FormatShapeSelectionOnType)match.BestMatch).formatShape;
}
else
{
Expand Down Expand Up @@ -413,7 +413,7 @@ private static ViewDefinition GetView(PSPropertyExpressionFactory expressionFact
{
ActiveTracer.WriteLine(
"NOT MATCH {0} NAME: {1}",
ControlBase.GetControlShapeName(vd.mainControl), (vd != null ? vd.name : string.Empty));
ControlBase.GetControlShapeName(vd.mainControl), vd != null ? vd.name : string.Empty);
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ protected int GetSplitLengthInternalHelper(string str, int offset, int displayCe
int charactersAdded = 0; // number of characters that fit
int currCharDisplayLen; // scratch variable

int k = (head) ? offset : str.Length - 1;
int kFinal = (head) ? str.Length - 1 : offset;
int k = head ? offset : str.Length - 1;
int kFinal = head ? str.Length - 1 : offset;
while (true)
{
if ((head && (k > kFinal)) || ((!head) && (k < kFinal)))
Expand All @@ -130,7 +130,7 @@ protected int GetSplitLengthInternalHelper(string str, int offset, int displayCe
break;
}

k = (head) ? (k + 1) : (k - 1);
k = head ? (k + 1) : (k - 1);
}

return charactersAdded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ private static string GetObjectName(object x, PSPropertyExpressionFactory expres
// check if the underlying object is of primitive type
// if so just return its value
if (x is PSObject &&
(LanguagePrimitives.IsBoolOrSwitchParameterType((((PSObject)x).BaseObject).GetType()) ||
LanguagePrimitives.IsNumeric(((((PSObject)x).BaseObject).GetType()).GetTypeCode()) ||
(LanguagePrimitives.IsBoolOrSwitchParameterType(((PSObject)x).BaseObject.GetType()) ||
LanguagePrimitives.IsNumeric( ((PSObject)x).BaseObject.GetType().GetTypeCode()) ||
LanguagePrimitives.IsNull(x)))
{
objName = x.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,12 @@ private PSObject IfHashtableWrapAsPSCustomObject(PSObject target, out bool wrapp
if (PSObject.Base(target) is Hashtable targetAsHash)
{
wrapped = true;
return (PSObject)(LanguagePrimitives.ConvertPSObjectToType(
return (PSObject)LanguagePrimitives.ConvertPSObjectToType(
targetAsHash,
typeof(PSObject),
recursion: false,
formatProvider: null,
ignoreUnknownMembers: true));
ignoreUnknownMembers: true);
}

return target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private Dictionary<string, ParameterMetadata> GetCommonParameters()

foreach (ParameterMetadata parameter in commonParameters.Values)
{
if ((parameter.ParameterSets.Count == 1) && (parameter.ParameterSets.ContainsKey(ParameterAttribute.AllParameterSets)))
if ((parameter.ParameterSets.Count == 1) && parameter.ParameterSets.ContainsKey(ParameterAttribute.AllParameterSets))
{
ParameterSetMetadata oldParameterSetMetadata = parameter.ParameterSets[ParameterAttribute.AllParameterSets];

Expand Down Expand Up @@ -908,7 +908,7 @@ private static void EnsureOrderOfPositionalParameters(

if ((maxBeforePosition >= 0) && (minAfterPosition <= maxBeforePosition))
{
int delta = (1001 - minAfterPosition % 1000);
int delta = 1001 - minAfterPosition % 1000;
foreach (ParameterMetadata afterParameter in afterParameters.Values)
{
foreach (ParameterSetMetadata afterParameterSet in afterParameter.ParameterSets.Values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public override bool IsSettable(PSAdaptedProperty adaptedProperty)
return false;
}

bool isReadOnly = ((cimProperty.Flags & CimFlags.ReadOnly) == CimFlags.ReadOnly);
bool isReadOnly = (cimProperty.Flags & CimFlags.ReadOnly) == CimFlags.ReadOnly;
bool isSettable = !isReadOnly;
return isSettable;
}
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/COM/ComAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected override T GetMember<T>(object obj, string memberName)

ComMethod method;
if (typeof(T).IsAssignableFrom(typeof(PSMethod)) &&
(_comTypeInfo != null) && (_comTypeInfo.Methods.TryGetValue(memberName, out method)))
(_comTypeInfo != null) && _comTypeInfo.Methods.TryGetValue(memberName, out method))
{
PSMethod mshMethod = new PSMethod(method.Name, this, obj, method);
return mshMethod as T;
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/COM/ComInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ private static unsafe void MakeByRefVariant(IntPtr srcVariantPtr, IntPtr destVar
break;

case VarEnum.VT_DECIMAL:
destVariant->_typeUnion._unionTypes._byref = new IntPtr(&(srcVariant->_decimal));
destVariant->_typeUnion._unionTypes._byref = new IntPtr(& srcVariant->_decimal);
break;

default:
// All the other cases start at the same offset (it's a Union) so using &_i4 should work.
// This is the same code as in CLR implementation. It could be &_i1, &_i2 and etc. CLR implementation just prefer using &_i4.
destVariant->_typeUnion._unionTypes._byref = new IntPtr(&(srcVariant->_typeUnion._unionTypes._i4));
destVariant->_typeUnion._unionTypes._byref = new IntPtr(& srcVariant->_typeUnion._unionTypes._i4);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/COM/ComTypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ internal static ComTypeInfo GetDispatchTypeInfo(object comObject)
{
COM.TYPEATTR typeattr = GetTypeAttr(typeinfo);

if ((typeattr.typekind == COM.TYPEKIND.TKIND_INTERFACE))
if (typeattr.typekind == COM.TYPEKIND.TKIND_INTERFACE)
{
// We have typeinfo for custom interface. Get typeinfo for Dispatch interface.
typeinfo = GetDispatchTypeInfoFromCustomInterfaceTypeInfo(typeinfo);
}

if ((typeattr.typekind == COM.TYPEKIND.TKIND_COCLASS))
if (typeattr.typekind == COM.TYPEKIND.TKIND_COCLASS)
{
// We have typeinfo for the COClass. Find the default interface and get typeinfo for default interface.
typeinfo = GetDispatchTypeInfoFromCoClassTypeInfo(typeinfo);
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/CmdletInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public override ReadOnlyCollection<PSTypeName> OutputType
var arg = Arguments[i] as string;
if (arg != null &&
(arg.Equals("-Path", StringComparison.OrdinalIgnoreCase) ||
(arg.Equals("-LiteralPath", StringComparison.OrdinalIgnoreCase))))
arg.Equals("-LiteralPath", StringComparison.OrdinalIgnoreCase)))
{
var path = Arguments[i + 1] as string;
if (path != null)
Expand Down Expand Up @@ -548,7 +548,7 @@ internal override bool ImplementsDynamicParameters
{
if (ImplementingType != null)
{
return (ImplementingType.GetInterface(nameof(IDynamicParameters), true) != null);
return ImplementingType.GetInterface(nameof(IDynamicParameters), true) != null;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ internal void BindCommandLineParameters(Collection<CommandParameterInternal> arg
Collection<MergedCompiledCommandParameter> missingMandatoryParameters;

// We shouldn't prompt for mandatory parameters if this command is private.
bool promptForMandatoryParameters = (Command.CommandInfo.Visibility == SessionStateEntryVisibility.Public);
bool promptForMandatoryParameters = Command.CommandInfo.Visibility == SessionStateEntryVisibility.Public;
HandleUnboundMandatoryParameters(validParameterSetCount, true, promptForMandatoryParameters, isPipelineInputExpected, out missingMandatoryParameters);

if (DefaultParameterBinder is ScriptParameterBinder)
Expand Down Expand Up @@ -1798,8 +1798,8 @@ private Collection<MergedCompiledCommandParameter> GetMissingMandatoryParameters

if (newMandatoryParameterSetFlag != uint.MaxValue)
{
parameterMandatorySets |= (_currentParameterSetFlag & newMandatoryParameterSetFlag);
commandMandatorySets |= (_currentParameterSetFlag & parameterMandatorySets);
parameterMandatorySets |= _currentParameterSetFlag & newMandatoryParameterSetFlag;
commandMandatorySets |= _currentParameterSetFlag & parameterMandatorySets;
}
else
{
Expand Down Expand Up @@ -1836,7 +1836,7 @@ private Collection<MergedCompiledCommandParameter> GetMissingMandatoryParameters
availableParameterSetFlags = uint.MaxValue;
}

commandMandatorySets = (_currentParameterSetFlag & availableParameterSetFlags);
commandMandatorySets = _currentParameterSetFlag & availableParameterSetFlags;
}

// First we need to see if there are multiple valid parameter sets, and if one is
Expand Down Expand Up @@ -2446,7 +2446,7 @@ private void IgnoreOtherMandatoryParameterSets(uint otherMandatorySetsToBeIgnore
}
else
{
_currentParameterSetFlag &= (~otherMandatorySetsToBeIgnored);
_currentParameterSetFlag &= ~otherMandatorySetsToBeIgnored;
}
}

Expand Down Expand Up @@ -2679,7 +2679,7 @@ Cmdlet command
.Where(p => p.IsMandatory);
foreach (ParameterSetSpecificMetadata parameterSetMetadata in parameterSetMetadatasForUnboundMandatoryParameters)
{
remainingParameterSetsWithNoMandatoryUnboundParameters &= (~parameterSetMetadata.ParameterSetFlag);
remainingParameterSetsWithNoMandatoryUnboundParameters &= ~parameterSetMetadata.ParameterSetFlag;
}

int finalParameterSetCount = ValidParameterSetCount(remainingParameterSetsWithNoMandatoryUnboundParameters);
Expand Down Expand Up @@ -3372,7 +3372,7 @@ private bool BindUnboundParametersForBindingState(

if (!aParameterWasBound)
{
validParameterSets &= ~(defaultParameterSetFlag);
validParameterSets &= ~defaultParameterSetFlag;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ internal bool IsStopping
get
{
MshCommandRuntime mcr = this.commandRuntime as MshCommandRuntime;
return (mcr != null && mcr.IsStopping);
return mcr != null && mcr.IsStopping;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ private class LastWordFinder
{
internal static string FindLastWord(string sentence, out int replacementIndexOut, out char closingQuote)
{
return (new LastWordFinder(sentence)).FindLastWord(out replacementIndexOut, out closingQuote);
return new LastWordFinder(sentence).FindLastWord(out replacementIndexOut, out closingQuote);
}

private LastWordFinder(string sentence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ private static bool CompleteAgainstSwitchFile(Ast lastAst, Token tokenBeforeCurs
return false;
}

return (errorStatement.Kind.Kind.Equals(TokenKind.Switch) &&
errorStatement.Flags.TryGetValue("file", out fileConditionTuple) && fileConditionTuple.Item2 == pipeline);
return errorStatement.Kind.Kind.Equals(TokenKind.Switch) &&
errorStatement.Flags.TryGetValue("file", out fileConditionTuple) && fileConditionTuple.Item2 == pipeline;
}

return false;
Expand Down Expand Up @@ -591,7 +591,7 @@ internal List<CompletionResult> GetResultHelper(CompletionContext completionCont
if (lastAst is ErrorExpressionAst && lastAst.Parent is FileRedirectionAst)
{
completionContext.WordToComplete = string.Empty;
completionContext.ReplacementIndex = (replacementIndex += tokenAtCursor.Text.Length);
completionContext.ReplacementIndex = replacementIndex += tokenAtCursor.Text.Length;
completionContext.ReplacementLength = replacementLength = 0;
result = new List<CompletionResult>(CompletionCompleters.CompleteFilename(completionContext));
}
Expand Down Expand Up @@ -1935,7 +1935,7 @@ private List<CompletionResult> GetResultForIdentifier(CompletionContext completi

var isSingleDash = tokenAtCursorText.Length == 1 && tokenAtCursorText[0].IsDash();
var isDoubleDash = tokenAtCursorText.Length == 2 && tokenAtCursorText[0].IsDash() && tokenAtCursorText[1].IsDash();
var isParentCommandOrDynamicKeyword = (lastAst.Parent is CommandAst || lastAst.Parent is DynamicKeywordStatementAst);
var isParentCommandOrDynamicKeyword = lastAst.Parent is CommandAst || lastAst.Parent is DynamicKeywordStatementAst;
if ((isSingleDash || isDoubleDash) && isParentCommandOrDynamicKeyword)
{
// When it's the content of a quoted string, we only handle variable/member completion
Expand All @@ -1954,7 +1954,7 @@ private List<CompletionResult> GetResultForIdentifier(CompletionContext completi
}

TokenKind memberOperator = TokenKind.Unknown;
bool isMemberCompletion = (lastAst.Parent is MemberExpressionAst);
bool isMemberCompletion = lastAst.Parent is MemberExpressionAst;
bool isStatic = isMemberCompletion && ((MemberExpressionAst)lastAst.Parent).Static;
bool isWildcard = false;

Expand Down Expand Up @@ -2006,7 +2006,7 @@ private List<CompletionResult> GetResultForIdentifier(CompletionContext completi

if (isMemberCompletion)
{
result = CompletionCompleters.CompleteMember(completionContext, @static: (isStatic || memberOperator == TokenKind.ColonColon));
result = CompletionCompleters.CompleteMember(completionContext, @static: isStatic || memberOperator == TokenKind.ColonColon);

// If the last token was just a '.', we tried to complete members. That may
// have failed because it wasn't really an attempt to complete a member, in
Expand Down
Loading