Fix SA1028: Code should not contain trailing whitespace. Part 1. (#26203)

This commit is contained in:
xtqqczze authored and GitHub committed 2025-10-16 12:58:28 +05:00
1 parent 250144e92d
commit a10ff105c9
74 files changed
+151 -151

No files matched your search

@@ -60,7 +60,7 @@ namespace Microsoft.Management.UI.Internal
: this()
{
ArgumentNullException.ThrowIfNull(columns);
ArgumentNullException.ThrowIfNull(availableColumns);
// Add visible columns to Selected list, preserving order
@@ -49,7 +49,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected CimJobException(
SerializationInfo info,
StreamingContext context)
@@ -315,7 +315,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
public override void AddQueryOption(string optionName, object optionValue)
{
ArgumentException.ThrowIfNullOrEmpty(optionName);
ArgumentNullException.ThrowIfNull(optionValue);
ArgumentNullException.ThrowIfNull(optionValue);
this.queryOptions[optionName] = optionValue;
}
@@ -132,7 +132,7 @@ namespace Microsoft.PowerShell.Commands
internal static T[] GetAll<T>(CimSession session, string nameSpace, string wmiClassName) where T : class, new()
{
ArgumentException.ThrowIfNullOrEmpty(wmiClassName);
var rv = new List<T>();
try
@@ -555,7 +555,7 @@ namespace Microsoft.PowerShell.Commands
}
}
if (!usernamematch)
if (!usernamematch)
{
return usernamematch;
}
@@ -595,7 +595,7 @@ namespace Microsoft.PowerShell.Commands
}
}
if (!datematch)
if (!datematch)
{
return datematch;
}
@@ -3685,7 +3685,7 @@ namespace Microsoft.PowerShell.Commands
/// Secure Memory Overwrite.
/// </summary>
SecureMemoryOverwrite = 4,
/// <summary>
/// UEFI Code Readonly.
/// </summary>
@@ -81,7 +81,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
[Parameter]
public string RelativeBasePath
{
{
get
{
return _relativeBasePath;
@@ -200,7 +200,7 @@ namespace Microsoft.PowerShell.Commands
{
WriteObject(result);
}
continue;
}
@@ -475,7 +475,7 @@ namespace Microsoft.PowerShell.Commands
break;
}
if (proxyType != null)
if (proxyType != null)
{
break;
}
@@ -959,7 +959,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns>Converted string.</returns>
internal string ConvertPropertyNamesCSV(IList<string> propertyNames)
{
ArgumentNullException.ThrowIfNull(propertyNames);
ArgumentNullException.ThrowIfNull(propertyNames);
_outputString.Clear();
bool first = true;
@@ -994,7 +994,7 @@ namespace Microsoft.PowerShell.Commands
AppendStringWithEscapeAlways(_outputString, propertyName);
break;
case BaseCsvWritingCommand.QuoteKind.AsNeeded:
if (propertyName.AsSpan().IndexOfAny(_delimiter, '\n', '"') != -1)
{
AppendStringWithEscapeAlways(_outputString, propertyName);
@@ -1023,7 +1023,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns></returns>
internal string ConvertPSObjectToCSV(PSObject mshObject, IList<string> propertyNames)
{
ArgumentNullException.ThrowIfNull(propertyNames);
ArgumentNullException.ThrowIfNull(propertyNames);
_outputString.Clear();
bool first = true;
@@ -1109,7 +1109,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns>ToString() value.</returns>
internal static string GetToStringValueForProperty(PSPropertyInfo property)
{
ArgumentNullException.ThrowIfNull(property);
ArgumentNullException.ThrowIfNull(property);
string value = null;
try
@@ -1271,7 +1271,7 @@ namespace Microsoft.PowerShell.Commands
internal ImportCsvHelper(PSCmdlet cmdlet, char delimiter, IList<string> header, string typeName, StreamReader streamReader)
{
ArgumentNullException.ThrowIfNull(cmdlet);
ArgumentNullException.ThrowIfNull(cmdlet);
ArgumentNullException.ThrowIfNull(streamReader);
_cmdlet = cmdlet;
@@ -158,7 +158,7 @@ namespace Microsoft.PowerShell.Commands
ThrowTerminatingError(
new ErrorRecord(nse, "CannotDefineSupportedCommand", ErrorCategory.PermissionDenied, null));
}
SystemPolicy.LogWDACAuditMessage(
context: Context,
title: ImportLocalizedDataStrings.WDACLogTitle,
@@ -824,7 +824,7 @@ namespace Microsoft.PowerShell.Commands
string errorId = (IsMeasuringGeneric) ? "GenericMeasurePropertyNotFound" : "TextMeasurePropertyNotFound";
WritePropertyNotFoundError(propertyName, errorId);
}
continue;
}
@@ -196,12 +196,12 @@ namespace Microsoft.PowerShell.Commands
{
ThrowTerminatingError(
new ErrorRecord(
new PSNotSupportedException(NewObjectStrings.CannotCreateTypeConstrainedLanguage),
new PSNotSupportedException(NewObjectStrings.CannotCreateTypeConstrainedLanguage),
"CannotCreateTypeConstrainedLanguage",
ErrorCategory.PermissionDenied,
targetObject: null));
}
SystemPolicy.LogWDACAuditMessage(
context: Context,
title: NewObjectStrings.TypeWDACLogTitle,
@@ -45,7 +45,7 @@ namespace Microsoft.PowerShell.Commands
{
ErrorRecord error = new(ex, "StringNotRecognizedAsGuid", ErrorCategory.InvalidArgument, null);
WriteError(error);
}
}
}
else
{
@@ -110,7 +110,7 @@ namespace Microsoft.PowerShell.Commands
case "Milliseconds":
sleepTime = Milliseconds;
break;
case "FromTimeSpan":
if (Duration.TotalMilliseconds > int.MaxValue)
{
@@ -46,6 +46,6 @@ namespace Microsoft.PowerShell.Commands
/// <inheritdoc/>
public HttpVersionCompletionsAttribute() : base(AllowedVersions)
{
}
}
}
}
@@ -98,7 +98,7 @@ namespace Microsoft.PowerShell.Commands
_cancellationSource.Dispose();
}
}
private readonly List<object> _inputObjects = new();
/// <summary>
@@ -31,7 +31,7 @@ namespace Microsoft.PowerShell.Commands
return false;
}
// _proxyAddress cannot be null as it is set in the constructor
// _proxyAddress cannot be null as it is set in the constructor
return other._credentials == _credentials
&& _proxyAddress.Equals(other._proxyAddress)
&& BypassProxyOnLocal == other.BypassProxyOnLocal;
@@ -330,7 +330,7 @@ namespace Microsoft.PowerShell.Commands
bool writeError,
Collection<PSTraceSource> matchingSources)
{
ArgumentNullException.ThrowIfNull(cmdlet);
ArgumentNullException.ThrowIfNull(cmdlet);
ArgumentNullException.ThrowIfNull(matchingSources);
_cmdlet = cmdlet;
@@ -4,18 +4,18 @@
namespace Microsoft.PowerShell
{
/// <summary>
/// HRESULT Wrapper
/// </summary>
/// HRESULT Wrapper
/// </summary>
internal enum HResult
{
/// <summary>
/// S_OK
/// </summary>
/// <summary>
/// S_OK
/// </summary>
Ok = 0x0000,
/// <summary>
/// S_FALSE.
/// </summary>
/// </summary>
False = 0x0001,
/// <summary>
@@ -15,7 +15,7 @@ namespace Microsoft.PowerShell
/// <summary>
/// Executor wraps a Pipeline instance, and provides helper methods for executing commands in that pipeline. It is used to
/// provide bookkeeping and structure to the use of pipeline in such a way that they can be interrupted and cancelled by a
/// break event handler, and to track nesting of pipelines (which happens with interrupted input loops (aka subshells) and
/// break event handler, and to track nesting of pipelines (which happens with interrupted input loops (aka subshells) and
/// use of tab-completion in prompts). The bookkeeping is necessary because the break handler is static and global, and
/// there is no means for tying a break handler to an instance of an object.
///
@@ -25,7 +25,7 @@ namespace Microsoft.PowerShell.Commands
{
return;
}
try
{
string outFilename = Host.UI.StopTranscribing();
+1 -1
View File
@@ -514,7 +514,7 @@ namespace Microsoft.WSMan.Management
try
{
XmlDocument xmldoc = new XmlDocument();
// push the xml string with credssp enabled
xmldoc.LoadXml(m_SessionObj.Put(helper.CredSSP_RUri, newxmlcontent, 0));
@@ -3252,7 +3252,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
string tempSchemaFilepath = schemaFiles.FirstOrDefault();
Debug.Assert(schemaFiles.Count() == 1, "A valid DSCResource module can have only one schema mof file");
if (tempSchemaFilepath is not null)
{
var classes = GetCachedClassByFileName(tempSchemaFilepath) ?? ImportClasses(tempSchemaFilepath, new Tuple<string, Version>(module.Name, module.Version), errors);
@@ -20,7 +20,7 @@ namespace System.Management.Automation.Runspaces
/// <summary>
/// This exception is used by Formattable constructor to indicate errors
/// occurred during construction time.
/// </summary>
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FormatTable")]
public class FormatTableLoadException : RuntimeException
{
@@ -760,7 +760,7 @@ namespace Microsoft.PowerShell.Cmdletization.Xml
{
WriteXsiType(@"CmdletParameterMetadataForGetCmdletFilteringParameter", @"http://schemas.microsoft.com/cmdlets-over-objects/2009/11");
}
if (o.@IsMandatorySpecified)
{
WriteAttribute(@"IsMandatory", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMandatory)));
@@ -1503,7 +1503,7 @@ namespace System.Management.Automation
{
return false;
}
if (inferredTypes.Count == 0)
{
return false;
@@ -2613,7 +2613,7 @@ namespace System.Management.Automation
return result;
}
private static List<CompletionResult> CompleteUsingKeywords(int cursorOffset, Token[] tokens, ref int replacementIndex, ref int replacementLength)
{
var result = new List<CompletionResult>();
@@ -448,12 +448,12 @@ namespace System.Management.Automation
// eg: Host<Tab> finds Microsoft.PowerShell.Host
// If the user has entered a manual wildcard, or a module name that contains a "." we assume they only want results that matches the input exactly.
bool shortNameSearch = wordToComplete.Length > 0 && !WildcardPattern.ContainsWildcardCharacters(wordToComplete) && !wordToComplete.Contains('.');
if (!wordToComplete.EndsWith('*'))
{
wordToComplete += "*";
}
string[] moduleNames;
WildcardPattern shortNamePattern;
if (shortNameSearch)
@@ -848,7 +848,7 @@ namespace System.Management.Automation
[NotNullWhen(true)] out string? message)
{
message = null;
if (attr.HelpMessage is not null)
{
message = attr.HelpMessage;
@@ -926,7 +926,7 @@ namespace System.Management.Automation
addCommonParameters = false;
break;
}
if (helpMessage is null && TryGetParameterHelpMessage(pattr, commandAssembly, out string attrHelpMessage))
{
helpMessage = $" - {attrHelpMessage}";
@@ -4772,7 +4772,7 @@ namespace System.Management.Automation
var resultType = isContainer
? CompletionResultType.ProviderContainer
: CompletionResultType.ProviderItem;
bool leafQuotesNeeded;
var completionText = NewPathCompletionText(
basePath,
@@ -4996,7 +4996,7 @@ namespace System.Management.Automation
for (int i = 0; i < path.Length; i++)
{
// on Windows, we need to preserve the expanded home path as native commands don't understand it
#if UNIX
#if UNIX
if (i == homeIndex)
{
_ = sb.Append('~');
@@ -8628,7 +8628,7 @@ namespace System.Management.Automation
/// <param name="parametersToAdd">The parameters to add.</param>
/// <returns>Collection of command info objects.</returns>
internal static Collection<CommandInfo> GetCommandInfo(
IDictionary fakeBoundParameters,
IDictionary fakeBoundParameters,
params string[] parametersToAdd)
{
using var ps = PowerShell.Create(RunspaceMode.CurrentRunspace);
@@ -129,7 +129,7 @@ namespace System.Management.Automation
/// <c>true</c> if the value matches the word as a wildcard pattern; otherwise, <c>false</c>.
/// </returns>
/// <remarks>
/// Wildcard pattern matching allows for flexible matching, where wilcards can represent
/// Wildcard pattern matching allows for flexible matching, where wilcards can represent
/// multiple characters in the input. This strategy is case-insensitive.
/// </remarks>
internal static readonly MatchStrategy WildcardPatternMatchIgnoreCase = (value, wordToComplete)
@@ -141,11 +141,11 @@ namespace System.Management.Automation
/// Determines if the given value matches the specified word considering wildcard characters literally.
/// </summary>
/// <returns>
/// <c>true</c> if the value matches either the literal normalized word or the wildcard pattern with escaping;
/// <c>true</c> if the value matches either the literal normalized word or the wildcard pattern with escaping;
/// otherwise, <c>false</c>.
/// </returns>
/// <remarks>
/// This strategy first attempts a literal prefix match for performance and, if unsuccessful, escapes the word to complete to
/// This strategy first attempts a literal prefix match for performance and, if unsuccessful, escapes the word to complete to
/// handle any problematic wildcard characters before performing a wildcard match.
/// </remarks>
internal static readonly MatchStrategy WildcardPatternEscapeMatch = (value, wordToComplete)
@@ -111,7 +111,7 @@ namespace System.Management.Automation
sessionState.IsProviderLoaded(fileSystemProviderName);
string? environmentCurrentDirectory = null;
try
{
environmentCurrentDirectory = Directory.GetCurrentDirectory();
@@ -951,7 +951,7 @@ namespace System.Management.Automation
if (result != null)
{
var formatString = result switch
var formatString = result switch
{
FilterInfo => "Filter found: {0}",
ConfigurationInfo => "Configuration found: {0}",
@@ -2050,7 +2050,7 @@ namespace System.Management.Automation
{
return obj is PSEventSubscriber es && Equals(es);
}
/// <summary>
/// Determines if two PSEventSubscriber instances are equal
/// </summary>
@@ -1694,7 +1694,7 @@ namespace Microsoft.PowerShell.Commands
}
/// <summary>
/// Provides argument completion for Noun parameter.
/// Provides argument completion for Noun parameter.
/// </summary>
public class NounArgumentCompleter : IArgumentCompleter
{
@@ -2943,9 +2943,9 @@ namespace System.Management.Automation
}
if (resultType == typeof(BigInteger))
{
{
NumberStyles style = NumberStyles.Integer | NumberStyles.AllowThousands;
return BigInteger.Parse(strToConvert, style, NumberFormatInfo.InvariantInfo);
}
// Fallback conversion for regular numeric types.
@@ -604,7 +604,7 @@ namespace Microsoft.PowerShell.Commands
string parameterName,
string wordToComplete,
CommandAst commandAst,
IDictionary fakeBoundParameters)
IDictionary fakeBoundParameters)
=> CompletionHelpers.GetMatchingResults(wordToComplete, possibleCompletionValues: Utils.AllowedEditionValues);
}
}
@@ -6168,7 +6168,7 @@ namespace Microsoft.PowerShell.Commands
}
}
}
private static void RemoveNestedModuleFunctions(
ExecutionContext context,
PSModuleInfo module,
@@ -7276,7 +7276,7 @@ namespace Microsoft.PowerShell.Commands
targetSessionState.ExecutionContext);
// Note that the module 'func' and the function table 'functionInfo' instances are now linked
// together (see 'CopiedCommand' in CommandInfo class), so setting visibility on one also
// together (see 'CopiedCommand' in CommandInfo class), so setting visibility on one also
// sets it on the other.
SetCommandVisibility(isImportModulePrivate, functionInfo);
functionInfo.Module = sourceModule;
@@ -500,7 +500,7 @@ namespace System.Management.Automation
afterPrev -= arrayExtent.StartOffset;
beforeNext -= arrayExtent.StartOffset;
if (arrayText[afterPrev] == ',')
if (arrayText[afterPrev] == ',')
{
return ", ";
}
@@ -509,7 +509,7 @@ namespace System.Management.Automation
{
return " ,";
}
return " , ";
}
@@ -2084,8 +2084,8 @@ namespace System.Management.Automation
else
{
tuple.Item1.Add(breakpoint.SequencePointIndex, new List<LineBreakpoint> { breakpoint });
}
}
// We need to keep track of any breakpoints that are bound in each script because they may
// need to be rebound if the script changes.
var boundBreakpoints = _boundBreakpoints[currentScriptFile].Item2;
@@ -2099,7 +2099,7 @@ namespace System.Management.Automation
}
// Here could check if all breakpoints for the current functionContext were bound, but because there is no atomic
// api for conditional removal we either need to lock, or do some trickery that has possibility of race conditions.
// api for conditional removal we either need to lock, or do some trickery that has possibility of race conditions.
// Instead we keep the item in the dictionary with 0 breakpoint count. This should not be a big issue,
// because it is single entry per file that had breakpoints, so there won't be thousands of files in a session.
}
@@ -1557,11 +1557,11 @@ namespace System.Management.Automation.Runspaces
/// </summary>
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected RunspaceOpenModuleLoadException(SerializationInfo info, StreamingContext context)
{
throw new NotSupportedException();
}
}
#endregion Serialization
}
@@ -952,7 +952,7 @@ namespace System.Management.Automation.PSTasks
iss.LanguageMode = PSLanguageMode.FullLanguage;
break;
}
runspace = RunspaceFactory.CreateRunspace(iss);
runspace.Name = runspaceName;
_activeRunspaces.TryAdd(runspace.Id, runspace);
@@ -85,7 +85,7 @@ namespace System.Management.Automation.Runspaces
/// The <see cref="StreamingContext"/> that contains contextual information
/// about the source or destination.
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
private InvalidPipelineStateException(SerializationInfo info, StreamingContext context)
{
throw new NotSupportedException();
@@ -96,7 +96,7 @@ namespace System.Management.Automation
/// The <see cref="StreamingContext"/> that contains contextual information
/// about the source or destination.
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected
InvalidPowerShellStateException(SerializationInfo info, StreamingContext context)
{
@@ -3736,7 +3736,7 @@ namespace System.Management.Automation
/// </exception>
/// <remarks>
/// When used with <see cref="PowerShell.Invoke()"/>, that call will return a partial result.
/// When used with <see cref="PowerShell.InvokeAsync"/>, that call will throw a <see cref="System.Management.Automation.PipelineStoppedException"/>.
/// When used with <see cref="PowerShell.InvokeAsync"/>, that call will throw a <see cref="System.Management.Automation.PipelineStoppedException"/>.
/// </remarks>
public void Stop()
{
@@ -3796,7 +3796,7 @@ namespace System.Management.Automation
/// </exception>
/// <remarks>
/// When used with <see cref="PowerShell.Invoke()"/>, that call will return a partial result.
/// When used with <see cref="PowerShell.InvokeAsync"/>, that call will throw a <see cref="System.Management.Automation.PipelineStoppedException"/>.
/// When used with <see cref="PowerShell.InvokeAsync"/>, that call will throw a <see cref="System.Management.Automation.PipelineStoppedException"/>.
/// </remarks>
public void EndStop(IAsyncResult asyncResult)
{
@@ -3850,7 +3850,7 @@ namespace System.Management.Automation
/// </exception>
/// <remarks>
/// When used with <see cref="PowerShell.Invoke()"/>, that call will return a partial result.
/// When used with <see cref="PowerShell.InvokeAsync"/>, that call will throw a <see cref="System.Management.Automation.PipelineStoppedException"/>.
/// When used with <see cref="PowerShell.InvokeAsync"/>, that call will throw a <see cref="System.Management.Automation.PipelineStoppedException"/>.
/// </remarks>
public Task StopAsync(AsyncCallback callback, object state)
=> Task.Factory.FromAsync(BeginStop(callback, state), _endStopMethod);
@@ -90,7 +90,7 @@ namespace System.Management.Automation.Runspaces
/// The <see cref="StreamingContext"/> that contains
/// contextual information about the source or destination.
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected
InvalidRunspacePoolStateException(SerializationInfo info, StreamingContext context)
{
@@ -812,7 +812,7 @@ namespace System.Management.Automation.Runspaces.Internal
EnqueueCheckAndStartRequestServicingThread(null, false);
}
}
/// <summary>
/// Release all resources.
/// </summary>
@@ -335,7 +335,7 @@ namespace System.Management.Automation
foundStart = true;
continue;
}
if (foundStart && pattern[index] is ']')
{
result = true;
@@ -524,7 +524,7 @@ namespace System.Management.Automation
/// </summary>
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected WildcardPatternException(SerializationInfo info,
StreamingContext context)
{
@@ -327,8 +327,8 @@ namespace System.Management.Automation
bool isTrustedInput,
ExecutionContext context)
{
// Using variables for Foreach-Object -Parallel use are restricted to be within the
// Foreach-Object -Parallel call scope. This will filter the using variable map to variables
// Using variables for Foreach-Object -Parallel use are restricted to be within the
// Foreach-Object -Parallel call scope. This will filter the using variable map to variables
// only within the current (outer) Foreach-Object -Parallel call scope.
var usingAsts = UsingExpressionAstSearcher.FindAllUsingExpressions(scriptBlock.Ast).ToList();
UsingExpressionAst usingAst = null;
@@ -358,11 +358,11 @@ namespace System.Management.Automation
if (rte.ErrorRecord.FullyQualifiedErrorId.Equals("VariableIsUndefined", StringComparison.Ordinal))
{
throw InterpreterError.NewInterpreterException(
targetObject: null,
targetObject: null,
exceptionType: typeof(RuntimeException),
errorPosition: usingAst.Extent,
errorPosition: usingAst.Extent,
resourceIdAndErrorId: "UsingVariableIsUndefined",
resourceString: AutomationExceptions.UsingVariableIsUndefined,
resourceString: AutomationExceptions.UsingVariableIsUndefined,
args: rte.ErrorRecord.TargetObject);
}
}
@@ -435,7 +435,7 @@ namespace System.Management.Automation
/*
Example:
$Test1 = "Hello"
1 | ForEach-Object -Parallel {
1 | ForEach-Object -Parallel {
$using:Test1
$Test2 = "Goodbye"
1 | ForEach-Object -Parallel {
@@ -450,7 +450,7 @@ namespace System.Management.Automation
while (currentParent != scriptblockAst)
{
// Look for Foreach-Object outer commands
if (currentParent is CommandAst commandAst &&
if (currentParent is CommandAst commandAst &&
FindForEachInCommand(commandAst))
{
// Using Ast is outside the invoking foreach scope.
@@ -1835,7 +1835,7 @@ namespace Microsoft.PowerShell.Commands
WriteError(new ErrorRecord(
invalidCast,
invalidCast.GetType().FullName,
ErrorCategory.ReadError,
ErrorCategory.ReadError,
path));
}
}
@@ -171,7 +171,7 @@ namespace System.Management.Automation.Runspaces
/// </summary>
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSSnapInException(SerializationInfo info,
StreamingContext context)
{
@@ -78,7 +78,7 @@ namespace System.Management.Automation
/// <param name="context">
/// streaming context
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected CommandNotFoundException(SerializationInfo info,
StreamingContext context)
{
@@ -336,13 +336,13 @@ namespace System.Management.Automation
/// <param name="context">
/// streaming context
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ScriptRequiresException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
#endregion Serialization
#region Properties
@@ -24,7 +24,7 @@ namespace System.Management.Automation
/// <param name="info">The serialization information to use when initializing this object.</param>
/// <param name="context">The streaming context to use when initializing this object.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ApplicationFailedException(SerializationInfo info,
StreamingContext context)
{
@@ -114,12 +114,12 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected CmdletInvocationException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
}
#endregion Serialization
#endregion ctor
@@ -154,7 +154,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ProviderInvocationException"/>.
/// This is generally reported from the standard provider navigation cmdlets
/// such as get-childitem.
/// </summary>
/// </summary>
public class CmdletProviderInvocationException : CmdletInvocationException
{
#region ctor
@@ -193,7 +193,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected CmdletProviderInvocationException(SerializationInfo info,
StreamingContext context)
{
@@ -281,7 +281,7 @@ namespace System.Management.Automation
/// Catching this exception is optional; if the cmdlet or providers chooses not to
/// handle PipelineStoppedException and instead allow it to propagate to the
/// PowerShell Engine's call to ProcessRecord, the PowerShell Engine will handle it properly.
/// </remarks>
/// </remarks>
public class PipelineStoppedException : RuntimeException
{
#region ctor
@@ -304,7 +304,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PipelineStoppedException(SerializationInfo info,
StreamingContext context)
{
@@ -342,7 +342,7 @@ namespace System.Management.Automation
/// to an asynchronous pipeline source and the pipeline has already
/// been stopped.
/// </summary>
/// <seealso cref="System.Management.Automation.Runspaces.Pipeline.Input"/>
/// <seealso cref="System.Management.Automation.Runspaces.Pipeline.Input"/>
public class PipelineClosedException : RuntimeException
{
#region ctor
@@ -387,7 +387,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PipelineClosedException(SerializationInfo info,
StreamingContext context)
{
@@ -405,7 +405,7 @@ namespace System.Management.Automation
/// <remarks>
/// For example, if $WarningPreference is "Stop", the command will fail with
/// this error if a cmdlet calls WriteWarning.
/// </remarks>
/// </remarks>
public class ActionPreferenceStopException : RuntimeException
{
#region ctor
@@ -467,12 +467,12 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ActionPreferenceStopException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
}
#endregion Serialization
/// <summary>
@@ -612,7 +612,7 @@ namespace System.Management.Automation
/// <param name="context">Streaming context.</param>
/// <returns>Doesn't return.</returns>
/// <exception cref="NotImplementedException">Always.</exception>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ParentContainsErrorRecordException(
SerializationInfo info, StreamingContext context)
{
@@ -648,7 +648,7 @@ namespace System.Management.Automation
/// The redirected object is available as
/// <see cref="System.Management.Automation.ErrorRecord.TargetObject"/>
/// in the ErrorRecord which contains this exception.
/// </remarks>
/// </remarks>
public class RedirectedException : RuntimeException
{
#region constructors
@@ -697,7 +697,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected RedirectedException(SerializationInfo info,
StreamingContext context)
{
@@ -719,7 +719,7 @@ namespace System.Management.Automation
/// call depth to prevent stack overflows. The maximum call depth is configurable
/// but generally high enough that scripts which are not deeply recursive
/// should not have a problem.
/// </remarks>
/// </remarks>
public class ScriptCallDepthException : SystemException, IContainsErrorRecord
{
#region ctor
@@ -765,7 +765,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ScriptCallDepthException(SerializationInfo info,
StreamingContext context)
{
@@ -860,11 +860,11 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PipelineDepthException(SerializationInfo info,
StreamingContext context)
StreamingContext context)
{
throw new NotSupportedException();
throw new NotSupportedException();
}
#endregion Serialization
@@ -918,7 +918,7 @@ namespace System.Management.Automation
///
/// Note that HaltCommandException does not define IContainsErrorRecord.
/// This is because it is not reported to the user.
/// </remarks>
/// </remarks>
public class HaltCommandException : SystemException
{
#region ctor
@@ -963,7 +963,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected HaltCommandException(SerializationInfo info,
StreamingContext context)
{
@@ -100,7 +100,7 @@ namespace System.Management.Automation.Host
/// <param name="context">
/// The contextual information about the source or destination.
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected
HostException(SerializationInfo info, StreamingContext context)
{
@@ -120,7 +120,7 @@ namespace System.Management.Automation.Host
/// <summary>
/// Defines the exception thrown when an error occurs from prompting for a command parameter.
/// </summary>
/// </summary>
public
class PromptingException : HostException
{
@@ -209,7 +209,7 @@ namespace System.Management.Automation.Host
/// <param name="context">
/// The contextual information about the source or destination.
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected
PromptingException(SerializationInfo info, StreamingContext context)
{
@@ -68,7 +68,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSArgumentException(SerializationInfo info,
StreamingContext context)
{
@@ -79,12 +79,12 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSArgumentNullException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
}
#endregion Serialization
#endregion ctor
@@ -67,13 +67,13 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSArgumentOutOfRangeException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
#endregion Serialization
/// <summary>
@@ -38,7 +38,7 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSInvalidOperationException(SerializationInfo info,
StreamingContext context)
{
@@ -38,12 +38,12 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSNotImplementedException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
}
#endregion Serialization
/// <summary>
@@ -38,13 +38,13 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected PSNotSupportedException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
#endregion Serialization
/// <summary>
@@ -297,7 +297,7 @@ namespace System.Management.Automation
/// <param name="context">
/// streaming context
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ParameterBindingException(
SerializationInfo info,
StreamingContext context)
@@ -486,7 +486,7 @@ namespace System.Management.Automation
#endregion Private
}
internal class ParameterBindingValidationException : ParameterBindingException
{
#region Preferred constructors
@@ -654,7 +654,7 @@ namespace System.Management.Automation
/// <param name="context">
/// streaming context
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ParameterBindingValidationException(
SerializationInfo info,
StreamingContext context)
@@ -844,7 +844,7 @@ namespace System.Management.Automation
/// <param name="context">
/// streaming context
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ParameterBindingArgumentTransformationException(
SerializationInfo info,
StreamingContext context)
@@ -854,7 +854,7 @@ namespace System.Management.Automation
#endregion serialization
}
internal class ParameterBindingParameterDefaultValueException : ParameterBindingException
{
#region Preferred constructors
@@ -1018,7 +1018,7 @@ namespace System.Management.Automation
/// <param name="context">
/// streaming context
/// </param>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected ParameterBindingParameterDefaultValueException(
SerializationInfo info,
StreamingContext context)
@@ -40,12 +40,12 @@ namespace System.Management.Automation
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
/// <returns>Constructed object.</returns>
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
[Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")]
protected RuntimeException(SerializationInfo info,
StreamingContext context)
{
throw new NotSupportedException();
}
}
#endregion Serialization
/// <summary>
@@ -21,7 +21,7 @@ namespace System.Management.Automation.Tracing
public EtwActivityReverterMethodInvoker(IEtwEventCorrelator eventCorrelator)
{
ArgumentNullException.ThrowIfNull(eventCorrelator);
ArgumentNullException.ThrowIfNull(eventCorrelator);
_eventCorrelator = eventCorrelator;
_invoker = DoInvoke;
@@ -132,7 +132,7 @@ namespace System.Management.Automation.Tracing
}
else
{
// When state is Start log the CommandLine which has arguments for completeness.
// When state is Start log the CommandLine which has arguments for completeness.
payload.AppendLine(StringUtil.Format(EtwLoggingStrings.CommandStateChange, logContext.CommandLine, newState.ToString()));
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ namespace Engine
// believe that there is no need to run many ops in each iteration. However, the subsequent runs
// of this method is much faster than the first run, and this causes 'MinIterationTime' warnings
// to our benchmarks and make the benchmark results not reliable.
// Calling this method once in 'GlobalSetup' is a workaround.
// Calling this method once in 'GlobalSetup' is a workaround.
// See https://github.com/dotnet/BenchmarkDotNet/issues/837#issuecomment-828600157
CompileFunction();
}
@@ -13,7 +13,7 @@ namespace BenchmarkDotNet.Extensions
public static int ToExitCode(this IEnumerable<Summary> summaries)
{
// an empty summary means that initial filtering and validation did not allow to run
if (!summaries.Any())
if (!summaries.Any())
return 1;
// if anything has failed, it's an error
@@ -10,13 +10,13 @@ public class PartitionFilter : IFilter
private readonly int? _partitionsCount;
private readonly int? _partitionIndex; // indexed from 0
private int _counter = 0;
public PartitionFilter(int? partitionCount, int? partitionIndex)
{
_partitionsCount = partitionCount;
_partitionIndex = partitionIndex;
}
public bool Predicate(BenchmarkCase benchmarkCase)
{
if (!_partitionsCount.HasValue || !_partitionIndex.HasValue)
@@ -14,9 +14,9 @@ namespace BenchmarkDotNet.Extensions
public class TooManyTestCasesValidator : IValidator
{
private const int Limit = 16;
public static readonly IValidator FailOnError = new TooManyTestCasesValidator();
public bool TreatsWarningsAsErrors => true;
public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters)
@@ -30,7 +30,7 @@ namespace BenchmarkDotNet.Extensions
{
public bool Equals(BenchmarkCase x, BenchmarkCase y)
=> Enumerable.SequenceEqual(
x.Parameters.Items.Select(argument => argument.Value),
x.Parameters.Items.Select(argument => argument.Value),
y.Parameters.Items.Select(argument => argument.Value));
public int GetHashCode(BenchmarkCase obj)
@@ -33,7 +33,7 @@ namespace BenchmarkDotNet.Extensions
// of random-sized memory by BDN engine
T[] result = new T[count];
var random = new Random(Seed);
var random = new Random(Seed);
var uniqueValues = new HashSet<T>();
@@ -49,12 +49,12 @@ namespace BenchmarkDotNet.Extensions
return result;
}
public static T[] Array<T>(int count)
{
var result = new T[count];
var random = new Random(Seed);
var random = new Random(Seed);
if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
{
+4 -4
View File
@@ -44,7 +44,7 @@ namespace Reporting
{
ret.Init();
}
return ret;
}
@@ -66,7 +66,7 @@ namespace Reporting
{
var split = kvp.Split('=');
run.Configurations.Add(split[0], split[1]);
}
}
}
os = new Os()
@@ -91,7 +91,7 @@ namespace Reporting
public string GetJson()
{
if (!InLab)
{
{
return null;
}
var jsonobj = new
@@ -122,7 +122,7 @@ namespace Reporting
ret.AppendLine($"{LeftJustify("Metric", counterWidth)}|{LeftJustify("Average",resultWidth)}|{LeftJustify("Min", resultWidth)}|{LeftJustify("Max",resultWidth)}");
ret.AppendLine($"{new String('-', counterWidth)}|{new String('-', resultWidth)}|{new String('-', resultWidth)}|{new String('-', resultWidth)}");
ret.AppendLine(Print(defaultCounter, counterWidth, resultWidth));
foreach(var counter in topCounters)
{
@@ -191,7 +191,7 @@ namespace ResultsComparer
private static void ExportToXml((string id, Benchmark baseResult, Benchmark diffResult, EquivalenceTestConclusion conclusion)[] notSame, FileInfo xmlPath)
{
if (xmlPath == null)
{
{
Console.WriteLine("No file given");
return;
}
@@ -151,7 +151,7 @@ namespace ExperimentalFeatureTest
[Parameter]
public string FileName { get; set; }
[Experimental("ExpTest.FeatureOne", ExperimentAction.Show)]
[Parameter]
public string Destination { get; set; }
+1 -1
View File
@@ -22,7 +22,7 @@ namespace PSTests.Parallel
string publicKey = cryptoClient.GetPublicKeyAsBase64EncodedString();
cryptoServer.ImportPublicKeyFromBase64EncodedString(publicKey); // sent to and imported by server
// generate, export, import session key
// generate, export, import session key
cryptoServer.GenerateSessionKey(); // server provides the session key?
string sessionKey = cryptoServer.SafeExportSessionKey();
cryptoClient.ImportSessionKeyFromBase64EncodedString(sessionKey);
+1 -1
View File
@@ -43,7 +43,7 @@ namespace PSTests.Parallel
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
protected virtual void Dispose(bool disposing)
{
+1 -1
View File
@@ -99,7 +99,7 @@ namespace PSTests.Sequential
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
protected virtual void Dispose(bool disposing)
{