From 7a67ecc921047e4edbd76b100a16a3810b958708 Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Mon, 23 Nov 2020 02:44:38 +0000 Subject: [PATCH] Fix CA1822: Mark members as static part 4 https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822 --- .../commands/utility/AddType.cs | 14 +++--- .../utility/ConvertFrom-SddlString.cs | 8 +-- .../commands/utility/ConvertTo-Html.cs | 4 +- .../commands/utility/CustomSerialization.cs | 6 +-- .../commands/utility/DebugRunspaceCommand.cs | 2 +- .../FormatAndOutput/OutGridView/TableView.cs | 2 +- .../commands/utility/Get-PSBreakpoint.cs | 2 +- .../commands/utility/GetRandomCommand.cs | 8 +-- .../utility/ImplicitRemotingCommands.cs | 50 +++++++++---------- .../commands/utility/Join-String.cs | 2 +- .../commands/utility/Measure-Object.cs | 2 +- .../commands/utility/UnblockFile.cs | 2 +- .../commands/utility/Update-TypeData.cs | 6 +-- .../BasicHtmlWebResponseObject.Common.cs | 6 +-- .../Common/InvokeRestMethodCommand.Common.cs | 8 +-- .../Common/WebRequestPSCmdlet.Common.cs | 10 ++-- .../Common/WebResponseObject.Common.cs | 2 +- 17 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index d3c61582de9..242e5b1c5c5 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -470,7 +470,7 @@ private string GenerateTypeSource(string typeNamespace, string typeName, string } // Get the -FromMember template for a given language - private string GetMethodTemplate(Language language) + private static string GetMethodTemplate(Language language) { switch (language) { @@ -486,7 +486,7 @@ private string GetMethodTemplate(Language language) } // Get the -FromMember namespace template for a given language - private string GetNamespaceTemplate(Language language) + private static string GetNamespaceTemplate(Language language) { switch (language) { @@ -502,7 +502,7 @@ private string GetNamespaceTemplate(Language language) } // Get the -FromMember namespace template for a given language - private string GetUsingTemplate(Language language) + private static string GetUsingTemplate(Language language) { switch (language) { @@ -840,7 +840,7 @@ private string ResolveAssemblyName(string assembly, bool isForReferenceAssembly) // However, this does give us a massive usability improvement, as users can just say // Add-Type -AssemblyName Forms (instead of System.Windows.Forms) // This is just long, not unmaintainable. - private Assembly LoadAssemblyHelper(string assemblyName) + private static Assembly LoadAssemblyHelper(string assemblyName) { Assembly loadedAssembly = null; @@ -898,7 +898,7 @@ private void WriteTypes(Assembly assembly) #region SourceCodeProcessing - private OutputKind OutputAssemblyTypeToOutputKind(OutputAssemblyType outputType) + private static OutputKind OutputAssemblyTypeToOutputKind(OutputAssemblyType outputType) { switch (outputType) { @@ -1136,7 +1136,7 @@ public override void VisitNamedType(INamedTypeSymbol symbol) } } - private void CacheNewTypes(ConcurrentBag newTypes) + private static void CacheNewTypes(ConcurrentBag newTypes) { foreach (var typeName in newTypes) { @@ -1266,7 +1266,7 @@ private void HandleCompilerErrors(ImmutableArray compilerDiagnostics } } - private string BuildErrorMessage(Diagnostic diagnisticRecord) + private static string BuildErrorMessage(Diagnostic diagnisticRecord) { var location = diagnisticRecord.Location; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFrom-SddlString.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFrom-SddlString.cs index 1e64dfe7754..c61dcd351af 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFrom-SddlString.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFrom-SddlString.cs @@ -45,7 +45,7 @@ public AccessRightTypeNames Type private AccessRightTypeNames _type; private bool _isTypeSet = false; - private string ConvertToNTAccount(SecurityIdentifier securityIdentifier) + private static string ConvertToNTAccount(SecurityIdentifier securityIdentifier) { try { @@ -57,7 +57,7 @@ private string ConvertToNTAccount(SecurityIdentifier securityIdentifier) } } - private List GetApplicableAccessRights(int accessMask, AccessRightTypeNames? typeName) + private static List GetApplicableAccessRights(int accessMask, AccessRightTypeNames? typeName) { List typesToExamine = new List(); List foundAccessRightNames = new List(); @@ -95,7 +95,7 @@ private List GetApplicableAccessRights(int accessMask, AccessRightTypeNa return foundAccessRightNames; } - private Type GetRealAccessRightType(AccessRightTypeNames typeName) + private static Type GetRealAccessRightType(AccessRightTypeNames typeName) { switch (typeName) { @@ -116,7 +116,7 @@ private Type GetRealAccessRightType(AccessRightTypeNames typeName) } } - private string[] ConvertAccessControlListToStrings(CommonAcl acl, AccessRightTypeNames? typeName) + private static string[] ConvertAccessControlListToStrings(CommonAcl acl, AccessRightTypeNames? typeName) { if (acl == null || acl.Count == 0) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs index e118aeaf41b..979881242cb 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs @@ -608,7 +608,7 @@ private void WriteListEntry() /// /// To write the Property name. /// - private void WritePropertyName(StringBuilder Listtag, MshParameter p) + private static void WritePropertyName(StringBuilder Listtag, MshParameter p) { // for writing the property name string label = p.GetEntry(ConvertHTMLParameterDefinitionKeys.LabelEntryKey) as string; @@ -653,7 +653,7 @@ private void WritePropertyValue(StringBuilder Listtag, MshParameter p) /// /// To write the Table header for the object property names. /// - private void WriteTableHeader(StringBuilder THtag, List resolvedNameMshParameters) + private static void WriteTableHeader(StringBuilder THtag, List resolvedNameMshParameters) { // write the property names foreach (MshParameter p in resolvedNameMshParameters) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs index bb9de345b5b..c949f0e1aa1 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs @@ -442,7 +442,7 @@ private bool HandleKnownContainerTypes(object source, string property, int depth /// /// /// - private void GetKnownContainerTypeInfo( + private static void GetKnownContainerTypeInfo( object source, out ContainerType ct, out IDictionary dictionary, out IEnumerable enumerable) { Dbg.Assert(source != null, "caller should validate the parameter"); @@ -676,7 +676,7 @@ private void WriteStartOfPSObject( /// /// /// - private bool PSObjectHasNotes(PSObject source) + private static bool PSObjectHasNotes(PSObject source) { if (source.InstanceMembers != null && source.InstanceMembers.Count > 0) { @@ -955,7 +955,7 @@ private void HandlePSObjectAsString(PSObject source, string property, int depth) /// /// string value to use for serializing this PSObject. /// - private string GetStringFromPSObject(PSObject source) + private static string GetStringFromPSObject(PSObject source) { Dbg.Assert(source != null, "caller should have validated the information"); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/DebugRunspaceCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/DebugRunspaceCommand.cs index 1a560a0010d..8111a721b97 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/DebugRunspaceCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/DebugRunspaceCommand.cs @@ -549,7 +549,7 @@ private void EnableHostDebugger(Runspace runspace, bool enabled) } } - private void SetLocalMode(System.Management.Automation.Debugger debugger, bool localMode) + private static void SetLocalMode(System.Management.Automation.Debugger debugger, bool localMode) { ServerRemoteDebugger remoteDebugger = debugger as ServerRemoteDebugger; if (remoteDebugger != null) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs index dc967889e69..0c2481b8eee 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs @@ -191,7 +191,7 @@ internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parent /// /// None. /// This method updates "activeAssociationList" instance property. - private void FilterActiveAssociationList(List activeAssociationList) + private static void FilterActiveAssociationList(List activeAssociationList) { // we got a valid set of properties from the default property set // make sure we do not have too many properties diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Get-PSBreakpoint.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Get-PSBreakpoint.cs index 133c03646f8..86c2aa88541 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Get-PSBreakpoint.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Get-PSBreakpoint.cs @@ -222,7 +222,7 @@ protected override void ProcessRecord() /// Returns the items in the input list that match an item in the filter array according to /// the given selection criterion. /// - private List Filter(List input, T[] filter, FilterSelector selector) + private static List Filter(List input, T[] filter, FilterSelector selector) { List output = new List(); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs index 8830a6793eb..9a39b360ca0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs @@ -217,7 +217,7 @@ private PolymorphicRandomNumberGenerator Generator [Parameter(ParameterSetName = RandomNumberParameterSet)] public object Minimum { get; set; } - private bool IsInt(object o) + private static bool IsInt(object o) { if (o == null || o is int) { @@ -227,7 +227,7 @@ private bool IsInt(object o) return false; } - private bool IsInt64(object o) + private static bool IsInt64(object o) { if (o == null || o is Int64) { @@ -237,7 +237,7 @@ private bool IsInt64(object o) return false; } - private object ProcessOperand(object o) + private static object ProcessOperand(object o) { if (o == null) { @@ -257,7 +257,7 @@ private object ProcessOperand(object o) return baseObject; } - private double ConvertToDouble(object o, double defaultIfNull) + private static double ConvertToDouble(object o, double defaultIfNull) { if (o == null) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index 4aa59024439..f1fe6f04914 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -1306,7 +1306,7 @@ private ParameterMetadata RehydrateParameterMetadata(PSObject deserializedParame parameterType); } - private bool IsProxyForCmdlet(Dictionary parameters) + private static bool IsProxyForCmdlet(Dictionary parameters) { // we are not sending CmdletBinding/DefaultParameterSet over the wire anymore // we need to infer IsProxyForCmdlet from presence of all common parameters @@ -1355,7 +1355,7 @@ private CommandMetadata RehydrateCommandMetadata(PSObject deserializedCommandInf return new CommandMetadata( name: name, commandType: commandType, - isProxyForCmdlet: this.IsProxyForCmdlet(parameters), + isProxyForCmdlet: IsProxyForCmdlet(parameters), defaultParameterSetName: ParameterAttribute.AllParameterSets, supportsShouldProcess: false, confirmImpact: ConfirmImpact.None, @@ -1365,7 +1365,7 @@ private CommandMetadata RehydrateCommandMetadata(PSObject deserializedCommandInf parameters: parameters); } - private int GetCommandTypePriority(CommandTypes commandType) + private static int GetCommandTypePriority(CommandTypes commandType) { switch (commandType) { @@ -1434,8 +1434,8 @@ private void AddRemoteCommandMetadata( CommandMetadata previousCommandWithSameName; if (name2commandMetadata.TryGetValue(commandMetadata.Name, out previousCommandWithSameName)) { - int previousCommandPriority = this.GetCommandTypePriority(previousCommandWithSameName.WrappedCommandType); - int currentCommandPriority = this.GetCommandTypePriority(commandMetadata.WrappedCommandType); + int previousCommandPriority = GetCommandTypePriority(previousCommandWithSameName.WrappedCommandType); + int currentCommandPriority = GetCommandTypePriority(commandMetadata.WrappedCommandType); if (previousCommandPriority < currentCommandPriority) { return; @@ -1975,7 +1975,7 @@ private string GetConnectionString() return null; } - private string EscapeFunctionNameForRemoteHelp(string name) + private static string EscapeFunctionNameForRemoteHelp(string name) { if (name == null) { @@ -2000,7 +2000,7 @@ private string EscapeFunctionNameForRemoteHelp(string name) ############################################################################## "; - private void GenerateSectionSeparator(TextWriter writer) + private static void GenerateSectionSeparator(TextWriter writer) { writer.Write(SectionSeparator); } @@ -2135,7 +2135,7 @@ function Write-PSImplicitRemotingMessage } "; - private void GenerateHelperFunctionsWriteMessage(TextWriter writer) + private static void GenerateHelperFunctionsWriteMessage(TextWriter writer) { if (writer == null) { @@ -2190,7 +2190,7 @@ function Set-PSImplicitRemotingSession if ($PSSessionOverride) {{ Set-PSImplicitRemotingSession $PSSessionOverride }} "; - private void GenerateHelperFunctionsSetImplicitRunspace(TextWriter writer) + private static void GenerateHelperFunctionsSetImplicitRunspace(TextWriter writer) { if (writer == null) { @@ -2767,7 +2767,7 @@ function Get-PSImplicitRemotingClientSideParameters } "; - private void GenerateHelperFunctionsClientSideParameters(TextWriter writer) + private static void GenerateHelperFunctionsClientSideParameters(TextWriter writer) { if (writer == null) { @@ -2781,12 +2781,12 @@ private void GenerateHelperFunctionsClientSideParameters(TextWriter writer) private void GenerateHelperFunctions(TextWriter writer) { - this.GenerateSectionSeparator(writer); - this.GenerateHelperFunctionsWriteMessage(writer); + GenerateSectionSeparator(writer); + GenerateHelperFunctionsWriteMessage(writer); this.GenerateHelperFunctionsGetSessionOption(writer); - this.GenerateHelperFunctionsSetImplicitRunspace(writer); + GenerateHelperFunctionsSetImplicitRunspace(writer); this.GenerateHelperFunctionsGetImplicitRunspace(writer); - this.GenerateHelperFunctionsClientSideParameters(writer); + GenerateHelperFunctionsClientSideParameters(writer); } #endregion @@ -2846,7 +2846,7 @@ private void GenerateHelperFunctions(TextWriter writer) }} "; - private void GenerateCommandProxy(TextWriter writer, CommandMetadata commandMetadata) + private static void GenerateCommandProxy(TextWriter writer, CommandMetadata commandMetadata) { if (writer == null) { @@ -2854,7 +2854,7 @@ private void GenerateCommandProxy(TextWriter writer, CommandMetadata commandMeta } string functionNameForString = CodeGeneration.EscapeSingleQuotedStringContent(commandMetadata.Name); - string functionNameForHelp = this.EscapeFunctionNameForRemoteHelp(commandMetadata.Name); + string functionNameForHelp = EscapeFunctionNameForRemoteHelp(commandMetadata.Name); writer.Write( CommandProxyTemplate, /* 0 */ functionNameForString, @@ -2868,7 +2868,7 @@ private void GenerateCommandProxy(TextWriter writer, CommandMetadata commandMeta /* 8 */ commandMetadata.WrappedAnyCmdlet); } - private void GenerateCommandProxy(TextWriter writer, IEnumerable listOfCommandMetadata) + private static void GenerateCommandProxy(TextWriter writer, IEnumerable listOfCommandMetadata) { if (writer == null) { @@ -2880,7 +2880,7 @@ private void GenerateCommandProxy(TextWriter writer, IEnumerable listOfCommandMetadata) + private static void GenerateExportDeclaration(TextWriter writer, IEnumerable listOfCommandMetadata) { if (writer == null) { @@ -2907,14 +2907,14 @@ private void GenerateExportDeclaration(TextWriter writer, IEnumerable listOfCommandNames = GetListOfCommandNames(listOfCommandMetadata); string exportString = GenerateArrayString(listOfCommandNames); writer.Write(ExportFunctionsTemplate, exportString); } - private List GetListOfCommandNames(IEnumerable listOfCommandMetadata) + private static List GetListOfCommandNames(IEnumerable listOfCommandMetadata) { if (listOfCommandMetadata == null) { @@ -2930,7 +2930,7 @@ private List GetListOfCommandNames(IEnumerable listOfCo return listOfCommandNames; } - private string GenerateArrayString(IEnumerable listOfStrings) + private static string GenerateArrayString(IEnumerable listOfStrings) { if (listOfStrings == null) { @@ -2968,9 +2968,9 @@ private string GenerateArrayString(IEnumerable listOfStrings) & $script:ExportModuleMember -Alias {0} "; - private void GenerateAliases(TextWriter writer, Dictionary alias2resolvedCommandName) + private static void GenerateAliases(TextWriter writer, Dictionary alias2resolvedCommandName) { - this.GenerateSectionSeparator(writer); + GenerateSectionSeparator(writer); foreach (KeyValuePair pair in alias2resolvedCommandName) { @@ -2991,7 +2991,7 @@ private void GenerateAliases(TextWriter writer, Dictionary alias #region Generating format.ps1xml file - private void GenerateFormatFile(TextWriter writer, List listOfFormatData) + private static void GenerateFormatFile(TextWriter writer, List listOfFormatData) { if (writer == null) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs index 652e32652ce..c1bcabef814 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs @@ -177,7 +177,7 @@ public IEnumerable CompleteArgument( return null; } - private IEnumerable CompleteFormatString(string wordToComplete) + private static IEnumerable CompleteFormatString(string wordToComplete) { var res = new List(); void AddMatching(string completionText) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs index 46c1f7062c7..f1ab1b7059d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs @@ -617,7 +617,7 @@ private void AnalyzeValue(string propertyName, object objValue) /// If true is passed in then the minimum of the two values would be returned. /// If false is passed in then maximum of the two values will be returned. /// - private object Compare(object objValue, object statMinOrMaxValue, bool isMin) + private static object Compare(object objValue, object statMinOrMaxValue, bool isMin) { object currentValue = objValue; object statValue = statMinOrMaxValue; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UnblockFile.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UnblockFile.cs index fad330212ed..10cac91fa57 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UnblockFile.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UnblockFile.cs @@ -196,7 +196,7 @@ private bool IsValidFileForUnblocking(string resolvedpath) } #if UNIX - private bool IsBlocked(string path) + private static bool IsBlocked(string path) { uint valueSize = 1024; IntPtr value = Marshal.AllocHGlobal((int)valueSize); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs index 603aeb6000c..9f7e10b4dc7 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs @@ -570,7 +570,7 @@ private void GetMembers(Dictionary members) } } - private T GetParameterType(object sourceValue) + private static T GetParameterType(object sourceValue) { return (T)LanguagePrimitives.ConvertTo(sourceValue, typeof(T), CultureInfo.InvariantCulture); } @@ -746,7 +746,7 @@ private CodeMethodData GetCodeMethod() /// /// /// - private ErrorRecord NewError(string errorId, string template, object targetObject, params object[] args) + private static ErrorRecord NewError(string errorId, string template, object targetObject, params object[] args) { string message = string.Format(CultureInfo.CurrentCulture, template, args); ErrorRecord errorRecord = new ErrorRecord( @@ -1255,7 +1255,7 @@ protected override void EndProcessing() this.Context.TypeTable.ClearConsolidatedMembers(); } - private ErrorRecord NewError(string errorId, string template, object targetObject, params object[] args) + private static ErrorRecord NewError(string errorId, string template, object targetObject, params object[] args) { string message = string.Format(CultureInfo.CurrentCulture, template, args); ErrorRecord errorRecord = new ErrorRecord( diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/BasicHtmlWebResponseObject.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/BasicHtmlWebResponseObject.Common.cs index 1d33957d624..a05937ddbc1 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/BasicHtmlWebResponseObject.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/BasicHtmlWebResponseObject.Common.cs @@ -186,7 +186,7 @@ protected void InitializeContent() } } - private PSObject CreateHtmlObject(string html, string tagName) + private static PSObject CreateHtmlObject(string html, string tagName) { PSObject elementObject = new PSObject(); @@ -198,7 +198,7 @@ private PSObject CreateHtmlObject(string html, string tagName) return elementObject; } - private void EnsureHtmlParser() + private static void EnsureHtmlParser() { if (s_tagRegex == null) { @@ -244,7 +244,7 @@ private void InitializeRawContent(HttpResponseMessage baseResponse) this.RawContent = raw.ToString(); } - private void ParseAttributes(string outerHtml, PSObject elementObject) + private static void ParseAttributes(string outerHtml, PSObject elementObject) { // We might get an empty input for a directive from the HTML file if (!string.IsNullOrEmpty(outerHtml)) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs index ba1e69c080f..85073a911cd 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs @@ -143,7 +143,7 @@ private bool TryProcessFeedStream(Stream responseStream) } // Mostly cribbed from Serialization.cs#GetXmlReaderSettingsForCliXml() - private XmlReaderSettings GetSecureXmlReaderSettings() + private static XmlReaderSettings GetSecureXmlReaderSettings() { XmlReaderSettings xrs = new XmlReaderSettings(); @@ -159,7 +159,7 @@ private XmlReaderSettings GetSecureXmlReaderSettings() return xrs; } - private bool TryConvertToXml(string xml, out object doc, ref Exception exRef) + private static bool TryConvertToXml(string xml, out object doc, ref Exception exRef) { try { @@ -181,7 +181,7 @@ private bool TryConvertToXml(string xml, out object doc, ref Exception exRef) return (doc != null); } - private bool TryConvertToJson(string json, out object obj, ref Exception exRef) + private static bool TryConvertToJson(string json, out object obj, ref Exception exRef) { bool converted = false; try @@ -478,7 +478,7 @@ internal override void ProcessResponse(HttpResponseMessage response) #region Helper Methods - private RestReturnType CheckReturnType(HttpResponseMessage response) + private static RestReturnType CheckReturnType(HttpResponseMessage response) { if (response == null) { throw new ArgumentNullException(nameof(response)); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 0809b686e1b..c0522aadcaf 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -754,7 +754,7 @@ private Uri PrepareUri(Uri uri) return uri; } - private Uri CheckProtocol(Uri uri) + private static Uri CheckProtocol(Uri uri) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } @@ -772,7 +772,7 @@ private string QualifyFilePath(string path) return resolvedFilePath; } - private string FormatDictionary(IDictionary content) + private static string FormatDictionary(IDictionary content) { if (content == null) throw new ArgumentNullException(nameof(content)); @@ -1919,7 +1919,7 @@ private void AddMultipartContent(object fieldName, object fieldValue, MultipartF /// /// The Field Name to use for the /// The Field Value to use for the - private StringContent GetMultipartStringContent(object fieldName, object fieldValue) + private static StringContent GetMultipartStringContent(object fieldName, object fieldValue) { var contentDisposition = new ContentDispositionHeaderValue("form-data"); // .NET does not enclose field names in quotes, however, modern browsers and curl do. @@ -1936,7 +1936,7 @@ private StringContent GetMultipartStringContent(object fieldName, object fieldVa /// /// The Field Name to use for the /// The to use for the - private StreamContent GetMultipartStreamContent(object fieldName, Stream stream) + private static StreamContent GetMultipartStreamContent(object fieldName, Stream stream) { var contentDisposition = new ContentDispositionHeaderValue("form-data"); // .NET does not enclose field names in quotes, however, modern browsers and curl do. @@ -1954,7 +1954,7 @@ private StreamContent GetMultipartStreamContent(object fieldName, Stream stream) /// /// The Field Name to use for the /// The file to use for the - private StreamContent GetMultipartFileContent(object fieldName, FileInfo file) + private static StreamContent GetMultipartFileContent(object fieldName, FileInfo file) { var result = GetMultipartStreamContent(fieldName: fieldName, stream: new FileStream(file.FullName, FileMode.Open)); // .NET does not enclose field names in quotes, however, modern browsers and curl do. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs index 70c5721dbc1..8cf2c605186 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs @@ -76,7 +76,7 @@ private void InitializeContent() this.Content = this.RawContentStream.ToArray(); } - private bool IsPrintable(char c) + private static bool IsPrintable(char c) { return (char.IsLetterOrDigit(c) || char.IsPunctuation(c) || char.IsSeparator(c) || char.IsSymbol(c) || char.IsWhiteSpace(c)); }