From ae14cdbd0729239120c67fbaecc3a99a59bf5f1c Mon Sep 17 00:00:00 2001 From: Matt Connew Date: Thu, 20 Apr 2023 16:32:52 -0700 Subject: [PATCH] Change NetNamedPipe from net6.0-windows to net6.0 in preference to SupportedOSPlatform and throwing if not on Windows --- .../src/Resources/strings.resx | 32 +------------------ .../System.ServiceModel.NetNamedPipe.csproj | 2 +- .../NamedPipeConnectionPoolSettings.cs | 2 ++ .../NamedPipeTransportBindingElement.cs | 11 ++++++- .../NamedPipeTransportSecurity.cs | 8 +++++ .../ServiceModel/NetNamedPipeBinding.cs | 8 +++++ .../ServiceModel/NetNamedPipeSecurity.cs | 8 +++++ 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/System.ServiceModel.NetNamedPipe/src/Resources/strings.resx b/src/System.ServiceModel.NetNamedPipe/src/Resources/strings.resx index 7a9c43576205..9b4bdd49b11f 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/Resources/strings.resx +++ b/src/System.ServiceModel.NetNamedPipe/src/Resources/strings.resx @@ -126,12 +126,6 @@ The value of this argument must be non-negative. - - The Session value '{0}' is invalid. Please specify 'CurrentSession','ServiceSession' or a valid non-negative Windows Session Id. - - - The package full name '{0}' is invalid. - The specified channel type {0} is not supported by this channel manager. @@ -150,12 +144,6 @@ The pipe endpoint '{0}' could not be found on your local machine. - - Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. - - - Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. - URIs used with pipes must use the scheme: 'net.pipe'. @@ -198,9 +186,6 @@ The shutdown indicator was not received from the pipe. The application on the other end of the pipe may not have sent it. The pipe will still be closed. - - Cannot claim lock within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. - The operation cannot be completed because the pipe was closed. This may have been caused by the application on the other end of the pipe exiting. @@ -225,22 +210,7 @@ An attempt to connect to the named pipe endpoint at '{1}' failed. Another attempt will be made with {0} remaining in the overall timeout. - - Activity boundary - - - Insufficient memory avaliable to complete the operation. - - - Process action '{0}'. - - - Client cannot determine the Service Principal Name based on the identity in the target address '{0}' for the purpose of SspiNegotiation/Kerberos. The target address identity must be a UPN identity (like acmedomain\alice) or SPN identity (like host/bobs-machine). - - - The value of this argument must be positive. - NetNamedPipe is not supported on this platform. - + \ No newline at end of file diff --git a/src/System.ServiceModel.NetNamedPipe/src/System.ServiceModel.NetNamedPipe.csproj b/src/System.ServiceModel.NetNamedPipe/src/System.ServiceModel.NetNamedPipe.csproj index 3d8948453f5c..90b4b901c619 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/System.ServiceModel.NetNamedPipe.csproj +++ b/src/System.ServiceModel.NetNamedPipe/src/System.ServiceModel.NetNamedPipe.csproj @@ -6,7 +6,7 @@ true true $(Ship_WcfPackages) - net6.0-windows + net6.0 System.ServiceModel true Provides the types that permit SOAP messages to be exchanged using named pipes (example: NetNamedPipeBinding). diff --git a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeConnectionPoolSettings.cs b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeConnectionPoolSettings.cs index 84e0394dd3b2..0bb1c0c1dfd0 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeConnectionPoolSettings.cs +++ b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeConnectionPoolSettings.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime; +using System.Runtime.Versioning; namespace System.ServiceModel.Channels { + [SupportedOSPlatform("windows")] public sealed class NamedPipeConnectionPoolSettings { private string _groupName; diff --git a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeTransportBindingElement.cs b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeTransportBindingElement.cs index 566666bb5a4f..5cef9c132031 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeTransportBindingElement.cs +++ b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/NamedPipeTransportBindingElement.cs @@ -2,16 +2,25 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Security.Principal; namespace System.ServiceModel.Channels { + [SupportedOSPlatform("windows")] public class NamedPipeTransportBindingElement : ConnectionOrientedTransportBindingElement { private readonly List _allowedUsers = new List(); private readonly NamedPipeConnectionPoolSettings _connectionPoolSettings = new NamedPipeConnectionPoolSettings(); - public NamedPipeTransportBindingElement() : base() { } + public NamedPipeTransportBindingElement() : base() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.PlatformNotSupported_NetNamedPipe)); + } + } protected NamedPipeTransportBindingElement(NamedPipeTransportBindingElement elementToBeCloned) : base(elementToBeCloned) diff --git a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NamedPipeTransportSecurity.cs b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NamedPipeTransportSecurity.cs index 4781ed30e8db..93db2644cd36 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NamedPipeTransportSecurity.cs +++ b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NamedPipeTransportSecurity.cs @@ -3,11 +3,14 @@ using System.ComponentModel; using System.Net.Security; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.ServiceModel.Channels; using System.ServiceModel.Security; namespace System.ServiceModel { + [SupportedOSPlatform("windows")] public sealed class NamedPipeTransportSecurity { internal const ProtectionLevel DefaultProtectionLevel = ProtectionLevel.EncryptAndSign; @@ -15,6 +18,11 @@ public sealed class NamedPipeTransportSecurity public NamedPipeTransportSecurity() { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.PlatformNotSupported_NetNamedPipe)); + } + _protectionLevel = DefaultProtectionLevel; } diff --git a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeBinding.cs b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeBinding.cs index 2632d99f4cb3..785640a9436e 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeBinding.cs +++ b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeBinding.cs @@ -2,11 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.ServiceModel.Channels; using System.Xml; namespace System.ServiceModel { + [SupportedOSPlatform("windows")] public class NetNamedPipeBinding : Binding { // private BindingElements @@ -16,6 +19,11 @@ public class NetNamedPipeBinding : Binding public NetNamedPipeBinding() : base() { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.PlatformNotSupported_NetNamedPipe)); + } + Initialize(); } diff --git a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeSecurity.cs b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeSecurity.cs index e2a972ae2961..faccac0c5a84 100644 --- a/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeSecurity.cs +++ b/src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/NetNamedPipeSecurity.cs @@ -2,10 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.ServiceModel.Channels; namespace System.ServiceModel { + [SupportedOSPlatform("windows")] public sealed class NetNamedPipeSecurity { internal const NetNamedPipeSecurityMode DefaultMode = NetNamedPipeSecurityMode.Transport; @@ -14,6 +17,11 @@ public sealed class NetNamedPipeSecurity public NetNamedPipeSecurity() { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.PlatformNotSupported_NetNamedPipe)); + } + _mode = DefaultMode; }