diff options
author | Morgan Brown <morganbr@users.noreply.github.com> | 2017-05-25 22:38:09 +0300 |
---|---|---|
committer | Dan Moseley <danmose@microsoft.com> | 2017-05-25 22:38:09 +0300 |
commit | a82f54bd51e22ec3eb14eb5d8f572f022becb8e3 (patch) | |
tree | f6b2b5497c076e4222ae4bbca64d37d34727ccba /src/System.Net.Security | |
parent | 5391ceb55562c785446b176f242e4c67258a5072 (diff) |
ISerializable cleanup (#20220)
* Changes to throw PlatformNotSupportedException from ISerializable.GetObjectData and serialization constructors on non-serializable types. Also removes private serialization constructors and some unneeded code that was used to support serializing non-serializable types. A few tests testing GetObjectData implementations are also removed.
* Address code review comments.
* Change exceptions' GetObjectData to just call base rather than throw. This makes them behave consistently with exceptions that didn't override GetObjectData.
Diffstat (limited to 'src/System.Net.Security')
2 files changed, 10 insertions, 20 deletions
diff --git a/src/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs b/src/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs index ce8f3a8a2d..cd53d16c7e 100644 --- a/src/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs +++ b/src/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs @@ -16,7 +16,10 @@ namespace System.Security.Authentication public AuthenticationException() { } public AuthenticationException(string message) : base(message) { } public AuthenticationException(string message, Exception innerException) : base(message, innerException) { } - protected AuthenticationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } + protected AuthenticationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) + { + throw new PlatformNotSupportedException(); + } } /// <summary> @@ -31,6 +34,9 @@ namespace System.Security.Authentication public InvalidCredentialException() { } public InvalidCredentialException(string message) : base(message) { } public InvalidCredentialException(string message, Exception innerException) : base(message, innerException) { } - protected InvalidCredentialException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } + protected InvalidCredentialException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) + { + throw new PlatformNotSupportedException(); + } } } diff --git a/src/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs b/src/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs index 35d4124284..e1c06da328 100644 --- a/src/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs +++ b/src/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs @@ -79,28 +79,12 @@ namespace System.Security.Authentication.ExtendedProtection protected ExtendedProtectionPolicy(SerializationInfo info, StreamingContext context) { - _policyEnforcement = (PolicyEnforcement)info.GetInt32(policyEnforcementName); - _protectionScenario = (ProtectionScenario)info.GetInt32(protectionScenarioName); - _customServiceNames = (ServiceNameCollection)info.GetValue(customServiceNamesName, typeof(ServiceNameCollection)); - - byte[] channelBindingData = (byte[])info.GetValue(customChannelBindingName, typeof(byte[])); - if (channelBindingData != null) - { - throw new PlatformNotSupportedException(); - } + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - if (_customChannelBinding != null) - { - throw new PlatformNotSupportedException(); - } - - info.AddValue(policyEnforcementName, (int)_policyEnforcement); - info.AddValue(protectionScenarioName, (int)_protectionScenario); - info.AddValue(customServiceNamesName, _customServiceNames, typeof(ServiceNameCollection)); - info.AddValue(customChannelBindingName, null, typeof(byte[])); + throw new PlatformNotSupportedException(); } public ServiceNameCollection CustomServiceNames |