diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs index 42b8a06b845..628723b089a 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs @@ -418,7 +418,6 @@ public static bool TryExecute(this RoutedCommand command, object parameter, IInp public static T GetOptionalTemplateChild(Control templateParent, string childName) where T : FrameworkElement { ArgumentNullException.ThrowIfNull(templateParent); - ArgumentException.ThrowIfNullOrEmpty(childName); object templatePart = templateParent.Template.FindName(childName, templateParent); 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 70f03f5ddef..9417a9de5d7 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 @@ -578,7 +578,7 @@ protected override void ProcessRecord() // Disable writing to the OutFile. OutFile = null; } - + // Detect insecure redirection if (!AllowInsecureRedirect && response.RequestMessage.RequestUri.Scheme == "https" && response.Headers.Location?.Scheme == "http") { @@ -586,7 +586,7 @@ protected override void ProcessRecord() er.ErrorDetails = new ErrorDetails(WebCmdletStrings.InsecureRedirection); ThrowTerminatingError(er); } - + if (ShouldCheckHttpStatus && !_isSuccess) { string message = string.Format( @@ -928,7 +928,7 @@ internal virtual void PrepareSession() // We silently ignore header if value is null. if (value is not null) { - // Add the header value (or overwrite it if already present) + // Add the header value (or overwrite it if already present). WebSession.Headers[key] = value.ToString(); } } @@ -942,7 +942,7 @@ internal virtual void PrepareSession() WebSession.RetryIntervalInSeconds = RetryIntervalSec; } } - + internal virtual HttpClient GetHttpClient(bool handleRedirect) { HttpClientHandler handler = new(); @@ -1286,7 +1286,7 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM requestWithoutRange.Version, requestWithoutRange.Method, requestContentLength); - + WriteVerbose(reqVerboseMsg); response.Dispose(); @@ -1303,9 +1303,9 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM // If the status code is 429 get the retry interval from the Headers. // Ignore broken header and its value. - if (response.StatusCode is HttpStatusCode.Conflict && response.Headers.TryGetValues(HttpKnownHeaderNames.RetryAfter, out IEnumerable retryAfter)) + if (response.StatusCode is HttpStatusCode.Conflict && response.Headers.TryGetValues(HttpKnownHeaderNames.RetryAfter, out IEnumerable retryAfter)) { - try + try { IEnumerator enumerator = retryAfter.GetEnumerator(); if (enumerator.MoveNext()) @@ -1318,7 +1318,7 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM // Ignore broken header. } } - + string retryMessage = string.Format( CultureInfo.CurrentCulture, WebCmdletStrings.RetryVerboseMsg, @@ -1388,7 +1388,7 @@ private static Uri CheckProtocol(Uri uri) } private string QualifyFilePath(string path) => PathUtils.ResolveFilePath(filePath: path, command: this, isLiteralPath: true); - + private static string FormatDictionary(IDictionary content) { ArgumentNullException.ThrowIfNull(content); @@ -1485,7 +1485,7 @@ internal void SetRequestContent(HttpRequestMessage request, string content) { ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(content); - + Encoding encoding = null; if (ContentType is not null) { @@ -1565,7 +1565,7 @@ internal void SetRequestContent(HttpRequestMessage request, MultipartFormDataCon { ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(multipartContent); - + // Content headers will be set by MultipartFormDataContent which will throw unless we clear them first WebSession.ContentHeaders.Clear(); @@ -1735,7 +1735,8 @@ private static string FormatErrorMessage(string error, string contentType) XmlDocument doc = new(); doc.LoadXml(error); - XmlWriterSettings settings = new XmlWriterSettings { + XmlWriterSettings settings = new XmlWriterSettings + { Indent = true, NewLineOnAttributes = true, OmitXmlDeclaration = true