From ba5bdeeabfdf26b8e19aad87b244327fde6e6556 Mon Sep 17 00:00:00 2001 From: Jonathan Malek Date: Wed, 30 Nov 2016 00:01:28 -0800 Subject: [PATCH 1/3] Wrapping a call to Registry in a #if !CORECLR --- .../commands/utility/WebCmdlet/Common/ContentHelper.Common.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs index def92d90342..c8f1a7f3063 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs @@ -87,6 +87,7 @@ private static bool CheckIsText(string contentType) || CheckIsXml(contentType) || CheckIsJson(contentType); + #if !CORECLR // Registry access not supported on CoreCLR if (!isText) { // Media types registered with Windows as having a perceived type of text, are text @@ -109,6 +110,7 @@ private static bool CheckIsText(string contentType) } } } + #endif return (isText); } @@ -135,7 +137,7 @@ private static bool CheckIsJson(string contentType) // the correct type for JSON content, as specified in RFC 4627 bool isJson = contentType.Equals("application/json", StringComparison.OrdinalIgnoreCase); - // add in these other "javascript" related types that + // add in these other "javascript" related types that // sometimes get sent down as the mime type for JSON content isJson |= contentType.Equals("text/json", StringComparison.OrdinalIgnoreCase) || contentType.Equals("application/x-javascript", StringComparison.OrdinalIgnoreCase) From 4041f3a0cff7f3e93befc8fcdf3d0d2f9dd6d99b Mon Sep 17 00:00:00 2001 From: Jonathan Malek Date: Wed, 30 Nov 2016 16:19:05 -0800 Subject: [PATCH 2/3] Replacing check for CORECLR with a check for Platform.IsWindows. --- .../utility/WebCmdlet/Common/ContentHelper.Common.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs index c8f1a7f3063..55a7462765a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs @@ -87,8 +87,8 @@ private static bool CheckIsText(string contentType) || CheckIsXml(contentType) || CheckIsJson(contentType); - #if !CORECLR // Registry access not supported on CoreCLR - if (!isText) + // Further content type analysis is available on Windows + if (Platform.IsWindows && !isText) { // Media types registered with Windows as having a perceived type of text, are text using (RegistryKey contentTypeKey = Registry.ClassesRoot.OpenSubKey(@"MIME\Database\Content Type\" + contentType)) @@ -110,7 +110,6 @@ private static bool CheckIsText(string contentType) } } } - #endif return (isText); } From 27506c3ba2ca18f443775b281f5212fc298aa54a Mon Sep 17 00:00:00 2001 From: Jonathan Malek Date: Wed, 30 Nov 2016 16:38:06 -0800 Subject: [PATCH 3/3] And the required namespace --- .../commands/utility/WebCmdlet/Common/ContentHelper.Common.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs index 55a7462765a..dc3a673ef46 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/ContentHelper.Common.cs @@ -3,6 +3,7 @@ --********************************************************************/ using System; +using System.Management.Automation; using System.Text; using Microsoft.Win32;