diff options
120 files changed, 342 insertions, 1090 deletions
diff --git a/src/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs b/src/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs index 7d2b544290..9ca96f67ef 100644 --- a/src/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs +++ b/src/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs @@ -36,6 +36,7 @@ namespace System.Net.NetworkInformation protected NetworkInformationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } internal NetworkInformationException(SocketError socketError) : base((int)socketError) diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderException.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderException.cs index 4a17629335..4a886ed75e 100644 --- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderException.cs +++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderException.cs @@ -49,6 +49,7 @@ namespace Microsoft.CSharp.RuntimeBinder protected RuntimeBinderException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs index e284770bce..a08e045aaa 100644 --- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs +++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs @@ -49,6 +49,7 @@ namespace Microsoft.CSharp.RuntimeBinder protected RuntimeBinderInternalCompilerException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/Microsoft.Win32.Primitives/src/System/ComponentModel/Win32Exception.cs b/src/Microsoft.Win32.Primitives/src/System/ComponentModel/Win32Exception.cs index 831fc4a5f8..24548b18f1 100644 --- a/src/Microsoft.Win32.Primitives/src/System/ComponentModel/Win32Exception.cs +++ b/src/Microsoft.Win32.Primitives/src/System/ComponentModel/Win32Exception.cs @@ -63,17 +63,11 @@ namespace System.ComponentModel protected Win32Exception(SerializationInfo info, StreamingContext context) : base(info, context) { - nativeErrorCode = info.GetInt32(nameof(NativeErrorCode)); + throw new PlatformNotSupportedException(); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue(nameof(NativeErrorCode), nativeErrorCode); base.GetObjectData(info, context); } diff --git a/src/Microsoft.Win32.Primitives/tests/Win32Exception.cs b/src/Microsoft.Win32.Primitives/tests/Win32Exception.cs index d7dd9206ff..097703161e 100644 --- a/src/Microsoft.Win32.Primitives/tests/Win32Exception.cs +++ b/src/Microsoft.Win32.Primitives/tests/Win32Exception.cs @@ -101,12 +101,5 @@ namespace System.ComponentModel.Tests Assert.Equal(expected: "Unknown error (0x23)", actual: ex.Message); } } - - [Fact] - public static void GetObjectData_InvalidArgs_Throws() - { - var e = new Win32Exception(); - AssertExtensions.Throws<ArgumentNullException>("info", () => e.GetObjectData(null, default(StreamingContext))); - } } } diff --git a/src/System.CodeDom/src/System/CodeDom/CodeNamespace.cs b/src/System.CodeDom/src/System/CodeDom/CodeNamespace.cs index b762675e74..ae13f78f75 100644 --- a/src/System.CodeDom/src/System/CodeDom/CodeNamespace.cs +++ b/src/System.CodeDom/src/System/CodeDom/CodeNamespace.cs @@ -29,8 +29,6 @@ namespace System.CodeDom Name = name; } - private CodeNamespace(SerializationInfo info, StreamingContext context) { } - public CodeTypeDeclarationCollection Types { get diff --git a/src/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs b/src/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs index bd266f132a..4b9a7a9286 100644 --- a/src/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs +++ b/src/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs @@ -215,7 +215,10 @@ namespace System.CodeDom.Compiler private sealed class ConfigurationErrorsException : SystemException { public ConfigurationErrorsException(string message) : base(message) { } - public ConfigurationErrorsException(SerializationInfo info, StreamingContext context) : base(info, context) { } + public ConfigurationErrorsException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } } } } diff --git a/src/System.CodeDom/tests/CodeObjects/CodeNamespaceTests.cs b/src/System.CodeDom/tests/CodeObjects/CodeNamespaceTests.cs index b1934b340d..fad448749a 100644 --- a/src/System.CodeDom/tests/CodeObjects/CodeNamespaceTests.cs +++ b/src/System.CodeDom/tests/CodeObjects/CodeNamespaceTests.cs @@ -32,18 +32,6 @@ namespace System.CodeDom.Tests Assert.Empty(codeNamespace.Comments); } - [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Cannot do internal Reflection on framework types.")] - public void Ctor_SerializationInfo_StreamingContext() - { - ConstructorInfo constructor = typeof(CodeNamespace).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(SerializationInfo), typeof(StreamingContext) }, null); - var codeNamespace = (CodeNamespace)constructor.Invoke(new object[] { default(SerializationInfo), default(StreamingContext) }); - Assert.Empty(codeNamespace.Name); - Assert.Empty(codeNamespace.Types); - Assert.Empty(codeNamespace.Imports); - Assert.Empty(codeNamespace.Comments); - } - [Theory] [MemberData(nameof(String_TestData))] public void Name_Set_Get_ReturnsExpected(string value) diff --git a/src/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs b/src/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs index 92b311ee4b..9646c9ff36 100644 --- a/src/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs +++ b/src/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs @@ -21,6 +21,7 @@ namespace System.Collections.Specialized /// and <see cref='System.Object' qualify='true'/> values that can be accessed either with the hash code of /// the key or with the index.</para> /// </devdoc> + [Serializable] public abstract class NameObjectCollectionBase : ICollection, ISerializable, IDeserializationCallback { // const names used for serialization diff --git a/src/System.Collections/src/System/Collections/Generic/LinkedList.cs b/src/System.Collections/src/System/Collections/Generic/LinkedList.cs index be75acd9b9..374a4a252f 100644 --- a/src/System.Collections/src/System/Collections/Generic/LinkedList.cs +++ b/src/System.Collections/src/System/Collections/Generic/LinkedList.cs @@ -563,12 +563,7 @@ namespace System.Collections.Generic private Enumerator(SerializationInfo info, StreamingContext context) { - _siInfo = info; - _list = null; - _version = 0; - _node = null; - _current = default(T); - _index = 0; + throw new PlatformNotSupportedException(); } public T Current @@ -630,15 +625,7 @@ namespace System.Collections.Generic void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue(LinkedListName, _list); - info.AddValue(VersionName, _version); - info.AddValue(CurrentValueName, _current); - info.AddValue(IndexName, _index); + throw new PlatformNotSupportedException(); } void IDeserializationCallback.OnDeserialization(Object sender) diff --git a/src/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs b/src/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs index d9175d0aa5..ab997651d1 100644 --- a/src/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs +++ b/src/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs @@ -45,12 +45,6 @@ namespace System.Collections.Generic VersionCheckImpl(); } - private TreeSubSet(SerializationInfo info, StreamingContext context) - { - _siInfo = info; - OnDeserializationImpl(info); - } - internal override bool AddIfNotPresent(T item) { if (!IsWithinRange(item)) @@ -349,17 +343,7 @@ namespace System.Collections.Generic protected override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue(MaxName, _max, typeof(T)); - info.AddValue(MinName, _min, typeof(T)); - info.AddValue(LowerBoundActiveName, _lBoundActive); - info.AddValue(UpperBoundActiveName, _uBoundActive); - - base.GetObjectData(info, context); + throw new PlatformNotSupportedException(); } void IDeserializationCallback.OnDeserialization(Object sender) diff --git a/src/System.Collections/src/System/Collections/Generic/SortedSet.cs b/src/System.Collections/src/System/Collections/Generic/SortedSet.cs index 8c8cbf8058..31d193bd27 100644 --- a/src/System.Collections/src/System/Collections/Generic/SortedSet.cs +++ b/src/System.Collections/src/System/Collections/Generic/SortedSet.cs @@ -1896,33 +1896,9 @@ namespace System.Collections.Generic Initialize(); } - private Enumerator(SerializationInfo info, StreamingContext context) - { - _tree = null; - _version = -1; - _current = null; - _reverse = false; - _stack = null; - _siInfo = info; - } - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - GetObjectData(info, context); - } - - private void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue(TreeName, _tree, typeof(SortedSet<T>)); - info.AddValue(EnumVersionName, _version); - info.AddValue(ReverseName, _reverse); - info.AddValue(EnumStartName, !NotStartedOrEnded); - info.AddValue(NodeValueName, (_current == null ? s_dummyNode.Item : _current.Item), typeof(T)); + throw new PlatformNotSupportedException(); } void IDeserializationCallback.OnDeserialization(Object sender) diff --git a/src/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs b/src/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs index 96b08c0173..088adef363 100644 --- a/src/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs +++ b/src/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs @@ -77,6 +77,7 @@ namespace System.ComponentModel.DataAnnotations protected ValidationException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs index 02995bb3a6..6490279d60 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs @@ -70,6 +70,7 @@ namespace System.ComponentModel.Design /// </summary> protected CheckoutException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs index ed67146f86..df9ab63f95 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs @@ -38,6 +38,7 @@ namespace System.ComponentModel protected InvalidAsynchronousStateException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidEnumArgumentException.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidEnumArgumentException.cs index 8cb6a72e7e..21464c5ddd 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidEnumArgumentException.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidEnumArgumentException.cs @@ -61,6 +61,7 @@ namespace System.ComponentModel /// </summary> protected InvalidEnumArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs index 1e31faabef..2c8ffecf85 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs @@ -58,8 +58,7 @@ namespace System.ComponentModel /// </summary> protected LicenseException(SerializationInfo info, StreamingContext context) : base(info, context) { - LicensedType = (Type)info.GetValue("type", typeof(Type)); - _instance = info.GetValue("instance", typeof(object)); + throw new PlatformNotSupportedException(); } /// <summary> @@ -68,19 +67,10 @@ namespace System.ComponentModel public Type LicensedType { get; } /// <summary> - /// Need this since Exception implements ISerializable and we have fields to save out. + /// Need this since Exception implements ISerializable. /// </summary> - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue("type", LicensedType); - info.AddValue("instance", _instance); - base.GetObjectData(info, context); } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs index a1e4f23f7c..f15a1d8ac8 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs @@ -66,8 +66,7 @@ namespace System.ComponentModel /// </summary> protected WarningException(SerializationInfo info, StreamingContext context) : base(info, context) { - HelpUrl = (string)info.GetValue("helpUrl", typeof(string)); - HelpTopic = (string)info.GetValue("helpTopic", typeof(string)); + throw new PlatformNotSupportedException(); } /// <summary> @@ -83,19 +82,10 @@ namespace System.ComponentModel public string HelpTopic { get; } /// <summary> - /// Need this since Exception implements ISerializable and we have fields to save out. + /// Need this since Exception implements ISerializable. /// </summary> - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue("helpUrl", HelpUrl); - info.AddValue("helpTopic", HelpTopic); - base.GetObjectData(info, context); } } diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs index ef3595266d..d59cec4e0d 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs @@ -103,37 +103,7 @@ namespace System.Configuration protected ConfigurationErrorsException(SerializationInfo info, StreamingContext context) : base(info, context) { - int firstLine; - int count; - - // Retrieve out members - string firstFilename = info.GetString(SerializationParamFilename); - firstLine = info.GetInt32(SerializationParamLine); - - Init(firstFilename, firstLine); - - // Retrieve errors for _errors object - count = info.GetInt32(SerializationParamErrorCount); - - if (count == 0) return; - _errors = new ConfigurationException[count]; - - for (int i = 0; i < count; i++) - { - string numPrefix = i.ToString(CultureInfo.InvariantCulture); - - string currentType = info.GetString(numPrefix + SerializationParamErrorType); - Type currentExceptionType = Type.GetType(currentType, true); - - // Only allow our exception types - if ((currentExceptionType != typeof(ConfigurationException)) && - (currentExceptionType != typeof(ConfigurationErrorsException))) - throw ExceptionUtil.UnexpectedError("ConfigurationErrorsException"); - - _errors[i] = (ConfigurationException) - info.GetValue(numPrefix + SerializationParamErrorData, - currentExceptionType); - } + throw new PlatformNotSupportedException(); } // The message includes the file/line number information. @@ -196,35 +166,7 @@ namespace System.Configuration public override void GetObjectData(SerializationInfo info, StreamingContext context) { - int subErrors = 0; - - // call base implementation base.GetObjectData(info, context); - - // Serialize our members - info.AddValue(SerializationParamFilename, Filename); - info.AddValue(SerializationParamLine, Line); - - // Serialize rest of errors, along with count - // (since first error duplicates this error, only worry if - // there is more than one) - if ((_errors != null) && - (_errors.Length > 1)) - { - subErrors = _errors.Length; - - for (int i = 0; i < _errors.Length; i++) - { - string numPrefix = i.ToString(CultureInfo.InvariantCulture); - - info.AddValue(numPrefix + SerializationParamErrorData, - _errors[i]); - info.AddValue(numPrefix + SerializationParamErrorType, - _errors[i].GetType()); - } - } - - info.AddValue(SerializationParamErrorCount, subErrors); } // Get file and linenumber from an XML Node in a DOM diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationException.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationException.cs index f371a119cc..d03a43f223 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationException.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationException.cs @@ -25,7 +25,7 @@ namespace System.Configuration protected ConfigurationException(SerializationInfo info, StreamingContext context) : base(info, context) { - Init(info.GetString("filename"), info.GetInt32("line")); + throw new PlatformNotSupportedException(); } [Obsolete("This class is obsolete, to create a new exception create a System.Configuration!System.Configuration.ConfigurationErrorsException")] @@ -92,8 +92,6 @@ namespace System.Configuration public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("filename", _filename); - info.AddValue("line", _line); } [Obsolete("This class is obsolete, use System.Configuration!System.Configuration.ConfigurationErrorsException.GetFilename instead")] diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionCollection.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionCollection.cs index fafbc81e3f..320eb4381e 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionCollection.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionCollection.cs @@ -30,6 +30,7 @@ namespace System.Configuration private ConfigurationSectionCollection(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } public ConfigurationSection this[string name] => Get(name); diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionGroupCollection.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionGroupCollection.cs index 75355af0a2..5059228bcc 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionGroupCollection.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionGroupCollection.cs @@ -27,11 +27,6 @@ namespace System.Configuration } } - private ConfigurationSectionGroupCollection(SerializationInfo serializationInfo, StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - } - // Indexer via name public ConfigurationSectionGroup this[string name] => Get(name); @@ -140,4 +135,4 @@ namespace System.Configuration Remove(GetKey(index)); } } -}
\ No newline at end of file +} diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/PropertyInformationCollection.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/PropertyInformationCollection.cs index 93a15effbb..067af4ba50 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/PropertyInformationCollection.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/PropertyInformationCollection.cs @@ -19,11 +19,6 @@ namespace System.Configuration IsReadOnly = true; } - private PropertyInformationCollection(SerializationInfo serializationInfo, StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - } - public PropertyInformation this[string propertyName] { get @@ -61,4 +56,4 @@ namespace System.Configuration for (int i = 0; i < c; i++) yield return this[i]; } } -}
\ No newline at end of file +} diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs index e6117a95e3..45eb51765a 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs @@ -20,6 +20,8 @@ namespace System.Configuration.Provider protected ProviderException(SerializationInfo info, StreamingContext context) : base(info, context) - { } + { + throw new PlatformNotSupportedException(); + } } }
\ No newline at end of file diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs index 5ec38b5099..54427e8131 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs @@ -16,6 +16,7 @@ namespace System.Configuration protected SettingsAttributeDictionary(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs index ceb820d8b7..5b2e36b015 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs @@ -14,6 +14,7 @@ namespace System.Configuration protected SettingsContext(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs index 8cf18ad57f..485ab107d1 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs @@ -21,6 +21,7 @@ namespace System.Configuration protected SettingsPropertyIsReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public SettingsPropertyIsReadOnlyException() diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs index d300bec38a..1afe1783ef 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs @@ -21,6 +21,7 @@ namespace System.Configuration protected SettingsPropertyNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public SettingsPropertyNotFoundException() diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs index cebb08bde1..8dd9bf575e 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs @@ -21,6 +21,7 @@ namespace System.Configuration protected SettingsPropertyWrongTypeException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public SettingsPropertyWrongTypeException() diff --git a/src/System.Data.Common/src/System/Data/Common/DbException.cs b/src/System.Data.Common/src/System/Data/Common/DbException.cs index beaf2c6eb8..d296804903 100644 --- a/src/System.Data.Common/src/System/Data/Common/DbException.cs +++ b/src/System.Data.Common/src/System/Data/Common/DbException.cs @@ -14,6 +14,9 @@ namespace System.Data.Common protected DbException(string message, int errorCode) : base(message, errorCode) { } - protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } + protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } } } diff --git a/src/System.Data.Common/src/System/Data/DBConcurrencyException.cs b/src/System.Data.Common/src/System/Data/DBConcurrencyException.cs index beb7c5e0a8..6550eb09cb 100644 --- a/src/System.Data.Common/src/System/Data/DBConcurrencyException.cs +++ b/src/System.Data.Common/src/System/Data/DBConcurrencyException.cs @@ -29,17 +29,8 @@ namespace System.Data _dataRows = dataRows; } - // runtime will call even if private... - private DBConcurrencyException(SerializationInfo si, StreamingContext sc) : base(si, sc) - { - } - public override void GetObjectData(SerializationInfo si, StreamingContext context) { - if (null == si) - { - throw new ArgumentNullException(nameof(si)); - } base.GetObjectData(si, context); } diff --git a/src/System.Data.Common/src/System/Data/DataException.cs b/src/System.Data.Common/src/System/Data/DataException.cs index 4cecfb3851..244e67a990 100644 --- a/src/System.Data.Common/src/System/Data/DataException.cs +++ b/src/System.Data.Common/src/System/Data/DataException.cs @@ -11,7 +11,10 @@ namespace System.Data { public class DataException : SystemException { - protected DataException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected DataException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public DataException() : base(SR.DataSet_DefaultDataException) { @@ -28,7 +31,10 @@ namespace System.Data public class ConstraintException : DataException { - protected ConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public ConstraintException() : base(SR.DataSet_DefaultConstraintException) { @@ -48,7 +54,10 @@ namespace System.Data public class DeletedRowInaccessibleException : DataException { - protected DeletedRowInaccessibleException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected DeletedRowInaccessibleException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } /// <summary> /// Initializes a new instance of the <see cref='System.Data.DeletedRowInaccessibleException'/> class. @@ -74,7 +83,10 @@ namespace System.Data public class DuplicateNameException : DataException { - protected DuplicateNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected DuplicateNameException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public DuplicateNameException() : base(SR.DataSet_DefaultDuplicateNameException) { @@ -94,7 +106,10 @@ namespace System.Data public class InRowChangingEventException : DataException { - protected InRowChangingEventException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected InRowChangingEventException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public InRowChangingEventException() : base(SR.DataSet_DefaultInRowChangingEventException) { @@ -114,7 +129,10 @@ namespace System.Data public class InvalidConstraintException : DataException { - protected InvalidConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected InvalidConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public InvalidConstraintException() : base(SR.DataSet_DefaultInvalidConstraintException) { @@ -134,7 +152,10 @@ namespace System.Data public class MissingPrimaryKeyException : DataException { - protected MissingPrimaryKeyException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected MissingPrimaryKeyException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public MissingPrimaryKeyException() : base(SR.DataSet_DefaultMissingPrimaryKeyException) { @@ -154,7 +175,10 @@ namespace System.Data public class NoNullAllowedException : DataException { - protected NoNullAllowedException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected NoNullAllowedException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public NoNullAllowedException() : base(SR.DataSet_DefaultNoNullAllowedException) { @@ -174,7 +198,10 @@ namespace System.Data public class ReadOnlyException : DataException { - protected ReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public ReadOnlyException() : base(SR.DataSet_DefaultReadOnlyException) { @@ -194,7 +221,10 @@ namespace System.Data public class RowNotInTableException : DataException { - protected RowNotInTableException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected RowNotInTableException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public RowNotInTableException() : base(SR.DataSet_DefaultRowNotInTableException) { @@ -214,7 +244,10 @@ namespace System.Data public class VersionNotFoundException : DataException { - protected VersionNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected VersionNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public VersionNotFoundException() : base(SR.DataSet_DefaultVersionNotFoundException) { diff --git a/src/System.Data.Common/src/System/Data/Filter/FilterException.cs b/src/System.Data.Common/src/System/Data/Filter/FilterException.cs index ea9f7a0685..a24a4f8fad 100644 --- a/src/System.Data.Common/src/System/Data/Filter/FilterException.cs +++ b/src/System.Data.Common/src/System/Data/Filter/FilterException.cs @@ -13,6 +13,7 @@ namespace System.Data protected InvalidExpressionException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public InvalidExpressionException() : base() { } @@ -26,7 +27,9 @@ namespace System.Data protected EvaluateException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } + public EvaluateException() : base() { } public EvaluateException(string s) : base(s) { } @@ -38,6 +41,7 @@ namespace System.Data protected SyntaxErrorException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public SyntaxErrorException() : base() { } diff --git a/src/System.Data.Common/src/System/Data/SQLTypes/SQLBytes.cs b/src/System.Data.Common/src/System/Data/SQLTypes/SQLBytes.cs index 3a0e6a3d87..235c0691a0 100644 --- a/src/System.Data.Common/src/System/Data/SQLTypes/SQLBytes.cs +++ b/src/System.Data.Common/src/System/Data/SQLTypes/SQLBytes.cs @@ -104,28 +104,6 @@ namespace System.Data.SqlTypes AssertValid(); } - // Constructor required for serialization. Deserializes as a Buffer. If the bits have been tampered with - // then this will throw a SerializationException or a InvalidCastException. - private SqlBytes(SerializationInfo info, StreamingContext context) - { - _stream = null; - _rgbWorkBuf = null; - - if (info.GetBoolean("IsNull")) - { - _state = SqlBytesCharsState.Null; - _rgbBuf = null; - } - else - { - _state = SqlBytesCharsState.Buffer; - _rgbBuf = (byte[])info.GetValue("data", typeof(byte[])); - _lCurLen = _rgbBuf.Length; - } - - AssertValid(); - } - // -------------------------------------------------------------- // Public properties @@ -590,25 +568,7 @@ namespace System.Data.SqlTypes // array is serialized, except for Null, in which case this state is kept. void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - switch (_state) - { - case SqlBytesCharsState.Null: - info.AddValue("IsNull", true); - break; - - case SqlBytesCharsState.Buffer: - info.AddValue("IsNull", false); - info.AddValue("data", _rgbBuf); - break; - - case SqlBytesCharsState.Stream: - CopyStreamToBuffer(); - goto case SqlBytesCharsState.Buffer; - - default: - Debug.Assert(false); - goto case SqlBytesCharsState.Null; - } + throw new PlatformNotSupportedException(); } // -------------------------------------------------------------- diff --git a/src/System.Data.Common/src/System/Data/SQLTypes/SQLChars.cs b/src/System.Data.Common/src/System/Data/SQLTypes/SQLChars.cs index 0c3dd6deff..7c7c25f7d8 100644 --- a/src/System.Data.Common/src/System/Data/SQLTypes/SQLChars.cs +++ b/src/System.Data.Common/src/System/Data/SQLTypes/SQLChars.cs @@ -96,28 +96,6 @@ namespace System.Data.SqlTypes AssertValid(); } - // Constructor required for serialization. Deserializes as a Buffer. If the bits have been tampered with - // then this will throw a SerializationException or a InvalidCastException. - private SqlChars(SerializationInfo info, StreamingContext context) - { - _stream = null; - _rgchWorkBuf = null; - - if (info.GetBoolean("IsNull")) - { - _state = SqlBytesCharsState.Null; - _rgchBuf = null; - } - else - { - _state = SqlBytesCharsState.Buffer; - _rgchBuf = (char[])info.GetValue("data", typeof(char[])); - _lCurLen = _rgchBuf.Length; - } - - AssertValid(); - } - // -------------------------------------------------------------- // Public properties // -------------------------------------------------------------- @@ -575,25 +553,7 @@ namespace System.Data.SqlTypes // array is serialized, except for Null, in which case this state is kept. void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - switch (_state) - { - case SqlBytesCharsState.Null: - info.AddValue("IsNull", true); - break; - - case SqlBytesCharsState.Buffer: - info.AddValue("IsNull", false); - info.AddValue("data", _rgchBuf); - break; - - case SqlBytesCharsState.Stream: - CopyStreamToBuffer(); - goto case SqlBytesCharsState.Buffer; - - default: - Debug.Assert(false); - goto case SqlBytesCharsState.Null; - } + throw new PlatformNotSupportedException(); } // -------------------------------------------------------------- diff --git a/src/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs b/src/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs index 68fb993b2d..7117157c97 100644 --- a/src/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs +++ b/src/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs @@ -44,6 +44,7 @@ namespace System.Data.SqlTypes // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity /> protected SqlTypeException(SerializationInfo si, StreamingContext sc) : base(SqlTypeExceptionSerialization(si, sc), sc) { + throw new PlatformNotSupportedException(); } private static SerializationInfo SqlTypeExceptionSerialization(SerializationInfo si, StreamingContext sc) @@ -75,12 +76,6 @@ namespace System.Data.SqlTypes HResult = HResults.SqlNullValue; } - // runtime will call even if private... - // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity /> - private SqlNullValueException(SerializationInfo si, StreamingContext sc) : base(SqlNullValueExceptionSerialization(si, sc), sc) - { - } - private static SerializationInfo SqlNullValueExceptionSerialization(SerializationInfo si, StreamingContext sc) { if ((null != si) && (1 == si.MemberCount)) @@ -110,12 +105,6 @@ namespace System.Data.SqlTypes HResult = HResults.SqlTruncate; } - // runtime will call even if private... - // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity /> - private SqlTruncateException(SerializationInfo si, StreamingContext sc) : base(SqlTruncateExceptionSerialization(si, sc), sc) - { - } - private static SerializationInfo SqlTruncateExceptionSerialization(SerializationInfo si, StreamingContext sc) { if ((null != si) && (1 == si.MemberCount)) @@ -144,12 +133,6 @@ namespace System.Data.SqlTypes { HResult = HResults.SqlNullValue; } - - // runtime will call even if private... - // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity /> - private SqlNotFilledException(SerializationInfo si, StreamingContext sc) : base(si, sc) - { - } } // SqlNotFilledException public sealed class SqlAlreadyFilledException : SqlTypeException @@ -168,11 +151,5 @@ namespace System.Data.SqlTypes { HResult = HResults.SqlNullValue; } - - // runtime will call even if private... - // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity /> - private SqlAlreadyFilledException(SerializationInfo si, StreamingContext sc) : base(si, sc) - { - } } // SqlNotFilledException } diff --git a/src/System.Data.Common/src/System/Data/SimpleType.cs b/src/System.Data.Common/src/System/Data/SimpleType.cs index 644bee96ad..9a1e8134e9 100644 --- a/src/System.Data.Common/src/System/Data/SimpleType.cs +++ b/src/System.Data.Common/src/System/Data/SimpleType.cs @@ -43,39 +43,9 @@ namespace System.Data LoadTypeValues(node); } - private SimpleType(SerializationInfo info, StreamingContext context) - { - _baseType = info.GetString("SimpleType.BaseType"); - _baseSimpleType = (SimpleType)info.GetValue("SimpleType.BaseSimpleType", typeof(SimpleType)); - - if (info.GetBoolean("SimpleType.XmlBaseType.XmlQualifiedNameExists")) - { - string xmlQNName = info.GetString("SimpleType.XmlBaseType.Name"); - string xmlQNNamespace = info.GetString("SimpleType.XmlBaseType.Namespace"); - _xmlBaseType = new XmlQualifiedName(xmlQNName, xmlQNNamespace); - } - else - { - _xmlBaseType = null; - } - _name = info.GetString("SimpleType.Name"); - _ns = info.GetString("SimpleType.NS"); - _maxLength = info.GetInt32("SimpleType.MaxLength"); - _length = info.GetInt32("SimpleType.Length"); - } - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("SimpleType.BaseType", _baseType); - info.AddValue("SimpleType.BaseSimpleType", _baseSimpleType); - XmlQualifiedName xmlQN = (_xmlBaseType as XmlQualifiedName); - info.AddValue("SimpleType.XmlBaseType.XmlQualifiedNameExists", xmlQN != null ? true : false); - info.AddValue("SimpleType.XmlBaseType.Name", xmlQN != null ? xmlQN.Name : null); - info.AddValue("SimpleType.XmlBaseType.Namespace", xmlQN != null ? xmlQN.Namespace : null); - info.AddValue("SimpleType.Name", _name); - info.AddValue("SimpleType.NS", _ns); - info.AddValue("SimpleType.MaxLength", _maxLength); - info.AddValue("SimpleType.Length", _length); + throw new PlatformNotSupportedException(); } internal void LoadTypeValues(XmlSchemaSimpleType node) diff --git a/src/System.Data.Common/src/System/Data/StrongTypingException.cs b/src/System.Data.Common/src/System/Data/StrongTypingException.cs index d73d3960bf..6ac93109cb 100644 --- a/src/System.Data.Common/src/System/Data/StrongTypingException.cs +++ b/src/System.Data.Common/src/System/Data/StrongTypingException.cs @@ -14,7 +14,9 @@ namespace System.Data protected StrongTypingException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } + public StrongTypingException() : base() { HResult = HResults.StrongTyping; diff --git a/src/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs b/src/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs index bd1850de8c..e5540f009e 100644 --- a/src/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs +++ b/src/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs @@ -12,8 +12,6 @@ namespace System.Data.Odbc { private OdbcErrorCollection _odbcErrors = new OdbcErrorCollection(); - private ODBC32.RETCODE _retcode; // DO NOT REMOVE! only needed for serialization purposes, because Everett had it. - internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); @@ -36,14 +34,6 @@ namespace System.Data.Odbc HResult = HResults.OdbcException; } - // runtime will call even if private... - private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc) - { - _retcode = (ODBC32.RETCODE)si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE)); - _odbcErrors = (OdbcErrorCollection)si.GetValue("odbcErrors", typeof(OdbcErrorCollection)); - HResult = HResults.OdbcException; - } - public OdbcErrorCollection Errors { get @@ -52,16 +42,8 @@ namespace System.Data.Odbc } } - [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo si, StreamingContext context) { - // MDAC 72003 - if (null == si) - { - throw new ArgumentNullException("si"); - } - si.AddValue("odbcRetcode", _retcode, typeof(ODBC32.RETCODE)); - si.AddValue("odbcErrors", _odbcErrors, typeof(OdbcErrorCollection)); base.GetObjectData(si, context); } diff --git a/src/System.Data.SqlClient/src/System/Data/OperationAbortedException.cs b/src/System.Data.SqlClient/src/System/Data/OperationAbortedException.cs index 5c0eae810c..2a24138405 100644 --- a/src/System.Data.SqlClient/src/System/Data/OperationAbortedException.cs +++ b/src/System.Data.SqlClient/src/System/Data/OperationAbortedException.cs @@ -12,10 +12,6 @@ namespace System.Data HResult = unchecked((int)0x80131936); } - private OperationAbortedException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - internal static OperationAbortedException Aborted(Exception inner) { OperationAbortedException e; diff --git a/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlException.cs b/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlException.cs index 1cc952503c..bcd7063847 100644 --- a/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlException.cs +++ b/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlException.cs @@ -32,22 +32,8 @@ namespace System.Data.SqlClient _clientConnectionId = conId; } - private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc) - { - HResult = SqlExceptionHResult; - _errors = (SqlErrorCollection)si.GetValue("Errors", typeof(SqlErrorCollection)); - _clientConnectionId = (Guid)si.GetValue("ClientConnectionId", typeof(Guid)); - } - public override void GetObjectData(SerializationInfo si, StreamingContext context) { - if (null == si) - { - throw new ArgumentNullException(nameof(si)); - } - - si.AddValue("Errors", _errors, typeof(SqlErrorCollection)); - si.AddValue("ClientConnectionId", _clientConnectionId, typeof(Guid)); base.GetObjectData(si, context); } diff --git a/src/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs b/src/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs index 83e48ec120..b6d6ec97ca 100644 --- a/src/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs +++ b/src/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs @@ -24,7 +24,9 @@ namespace System.DirectoryServices.AccountManagement protected PrincipalException(SerializationInfo info, StreamingContext context) : base(info, context) - { } + { + throw new PlatformNotSupportedException(); + } } public class MultipleMatchesException : PrincipalException @@ -39,7 +41,9 @@ namespace System.DirectoryServices.AccountManagement protected MultipleMatchesException(SerializationInfo info, StreamingContext context) : base(info, context) - { } + { + throw new PlatformNotSupportedException(); + } } public class NoMatchingPrincipalException : PrincipalException @@ -54,7 +58,9 @@ namespace System.DirectoryServices.AccountManagement protected NoMatchingPrincipalException(SerializationInfo info, StreamingContext context) : base(info, context) - { } + { + throw new PlatformNotSupportedException(); + } } public class PasswordException : PrincipalException @@ -69,7 +75,9 @@ namespace System.DirectoryServices.AccountManagement protected PasswordException(SerializationInfo info, StreamingContext context) : base(info, context) - { } + { + throw new PlatformNotSupportedException(); + } } public class PrincipalExistsException : PrincipalException @@ -84,7 +92,9 @@ namespace System.DirectoryServices.AccountManagement protected PrincipalExistsException(SerializationInfo info, StreamingContext context) : base(info, context) - { } + { + throw new PlatformNotSupportedException(); + } } public class PrincipalServerDownException : PrincipalException @@ -117,16 +127,11 @@ namespace System.DirectoryServices.AccountManagement protected PrincipalServerDownException(SerializationInfo info, StreamingContext context) : base(info, context) { - _errorCode = info.GetInt32("errorCode"); - _serverName = (string)info.GetValue("serverName", typeof(String)); + throw new PlatformNotSupportedException(); } - [System.Security.SecurityCritical] - [SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("errorCode", _errorCode); - info.AddValue("serverName", _serverName, typeof(String)); base.GetObjectData(info, context); } } @@ -155,14 +160,11 @@ namespace System.DirectoryServices.AccountManagement protected PrincipalOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { - _errorCode = info.GetInt32("errorCode"); + throw new PlatformNotSupportedException(); } - [System.Security.SecurityCritical] - [SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("errorCode", _errorCode); base.GetObjectData(info, context); } diff --git a/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs b/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs index 19be872474..38c9f0906f 100644 --- a/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs +++ b/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs @@ -12,6 +12,7 @@ namespace System.DirectoryServices.Protocols { protected DirectoryException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public DirectoryException(string message, Exception inner) : base(message, inner) @@ -32,6 +33,7 @@ namespace System.DirectoryServices.Protocols internal DirectoryResponse response = null; protected DirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public DirectoryOperationException() : base() { } @@ -62,8 +64,7 @@ namespace System.DirectoryServices.Protocols return response; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -74,6 +75,7 @@ namespace System.DirectoryServices.Protocols { protected BerConversionException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public BerConversionException() : base(String.Format(CultureInfo.CurrentCulture, SR.BerConversionError)) diff --git a/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs b/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs index cac0680a9f..37cd96279d 100644 --- a/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs +++ b/src/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs @@ -80,6 +80,7 @@ namespace System.DirectoryServices.Protocols internal PartialResultsCollection results = new PartialResultsCollection(); protected LdapException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public LdapException() : base() { } @@ -132,8 +133,7 @@ namespace System.DirectoryServices.Protocols return this.results; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -144,6 +144,7 @@ namespace System.DirectoryServices.Protocols { protected TlsOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public TlsOperationException() : base() { } diff --git a/src/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs b/src/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs index 81b83264a1..fbe71c90bf 100644 --- a/src/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs +++ b/src/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs @@ -92,7 +92,10 @@ namespace System.DirectoryServices.ActiveDirectory public ActiveDirectoryObjectNotFoundException() : base() { } - protected ActiveDirectoryObjectNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ActiveDirectoryObjectNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public Type Type { @@ -137,7 +140,10 @@ namespace System.DirectoryServices.ActiveDirectory public ActiveDirectoryOperationException() : base(SR.DSUnknownFailure) { } - protected ActiveDirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ActiveDirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public int ErrorCode { @@ -146,8 +152,7 @@ namespace System.DirectoryServices.ActiveDirectory return _errorCode; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -177,7 +182,10 @@ namespace System.DirectoryServices.ActiveDirectory public ActiveDirectoryServerDownException() : base() { } - protected ActiveDirectoryServerDownException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ActiveDirectoryServerDownException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public int ErrorCode { @@ -207,8 +215,7 @@ namespace System.DirectoryServices.ActiveDirectory return s; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -223,7 +230,10 @@ namespace System.DirectoryServices.ActiveDirectory public ActiveDirectoryObjectExistsException() : base() { } - protected ActiveDirectoryObjectExistsException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ActiveDirectoryObjectExistsException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } } public class SyncFromAllServersOperationException : ActiveDirectoryOperationException, ISerializable @@ -241,7 +251,10 @@ namespace System.DirectoryServices.ActiveDirectory public SyncFromAllServersOperationException() : base(SR.DSSyncAllFailure) { } - protected SyncFromAllServersOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected SyncFromAllServersOperationException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public SyncFromAllServersErrorInformation[] ErrorInformation { @@ -257,8 +270,7 @@ namespace System.DirectoryServices.ActiveDirectory return tempError; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -280,7 +292,10 @@ namespace System.DirectoryServices.ActiveDirectory public ForestTrustCollisionException() : base(SR.ForestTrustCollision) { } - protected ForestTrustCollisionException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected ForestTrustCollisionException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public ForestTrustRelationshipCollisionCollection Collisions { @@ -289,8 +304,7 @@ namespace System.DirectoryServices.ActiveDirectory return _collisions; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs b/src/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs index 12d83a3c06..aab6826907 100644 --- a/src/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs +++ b/src/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs @@ -20,7 +20,10 @@ namespace System.DirectoryServices public DirectoryServicesCOMException() { } public DirectoryServicesCOMException(string message) : base(message) { } public DirectoryServicesCOMException(string message, Exception inner) : base(message, inner) { } - protected DirectoryServicesCOMException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected DirectoryServicesCOMException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } internal DirectoryServicesCOMException(string extendedMessage, int extendedError, COMException e) : base(e.Message, e.ErrorCode) { @@ -43,8 +46,7 @@ namespace System.DirectoryServices return _extendedmessage; } } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/System.IO.Compression/src/System/IO/Compression/ZLibException.Serialization.cs b/src/System.IO.Compression/src/System/IO/Compression/ZLibException.Serialization.cs index d8f12883b6..1c55355154 100644 --- a/src/System.IO.Compression/src/System/IO/Compression/ZLibException.Serialization.cs +++ b/src/System.IO.Compression/src/System/IO/Compression/ZLibException.Serialization.cs @@ -15,17 +15,12 @@ namespace System.IO.Compression /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param> protected ZLibException(SerializationInfo info, StreamingContext context) : base(info, context) { - _zlibErrorContext = info.GetString("zlibErrorContext"); - _zlibErrorCode = (ZLibNative.ErrorCode)info.GetInt32("zlibErrorCode"); - _zlibErrorMessage = info.GetString("zlibErrorMessage"); + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) { base.GetObjectData(si, context); - si.AddValue("zlibErrorContext", _zlibErrorContext); - si.AddValue("zlibErrorCode", (int)_zlibErrorCode); - si.AddValue("zlibErrorMessage", _zlibErrorMessage); } } } diff --git a/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.cs b/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.cs index 6ab7412d89..a1d17d9ad6 100644 --- a/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.cs +++ b/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.cs @@ -23,11 +23,12 @@ namespace System.IO private DriveInfo(SerializationInfo info, StreamingContext context) : this((string)info.GetValue("_name", typeof(string))) { + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("_name", _name, typeof(String)); + throw new PlatformNotSupportedException(); } public string Name => _name; diff --git a/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs b/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs index a732424959..4a47fd8e71 100644 --- a/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs +++ b/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs @@ -29,6 +29,7 @@ namespace System.IO protected DriveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.IO.FileSystem.Watcher/src/System/IO/InternalBufferOverflowException.cs b/src/System.IO.FileSystem.Watcher/src/System/IO/InternalBufferOverflowException.cs index 8953c8bd77..b0b0100289 100644 --- a/src/System.IO.FileSystem.Watcher/src/System/IO/InternalBufferOverflowException.cs +++ b/src/System.IO.FileSystem.Watcher/src/System/IO/InternalBufferOverflowException.cs @@ -37,6 +37,9 @@ namespace System.IO } protected InternalBufferOverflowException(SerializationInfo info, StreamingContext context) - : base(info, context) { } + : base(info, context) + { + throw new PlatformNotSupportedException(); + } } } diff --git a/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs b/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs index 016ce14ffe..03c7311565 100644 --- a/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs +++ b/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs @@ -35,11 +35,6 @@ namespace System.IO DisplayPath = GetDisplayName(OriginalPath); } - private DirectoryInfo(SerializationInfo info, StreamingContext context) : base(info, context) - { - DisplayPath = GetDisplayName(OriginalPath); - } - public override String Name { get diff --git a/src/System.IO.FileSystem/src/System/IO/FileInfo.cs b/src/System.IO.FileSystem/src/System/IO/FileInfo.cs index 6c2d275dcc..8ff606c857 100644 --- a/src/System.IO.FileSystem/src/System/IO/FileInfo.cs +++ b/src/System.IO.FileSystem/src/System/IO/FileInfo.cs @@ -32,12 +32,6 @@ namespace System.IO Init(fileName); } - private FileInfo(SerializationInfo info, StreamingContext context) : base(info, context) - { - _name = Path.GetFileName(OriginalPath); - DisplayPath = GetDisplayPath(OriginalPath); - } - [System.Security.SecurityCritical] private void Init(String fileName) { diff --git a/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs b/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs index c22ead4a42..31a8432b74 100644 --- a/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs +++ b/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs @@ -26,19 +26,12 @@ namespace System.IO protected FileSystemInfo(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - FullPath = Path.GetFullPath(info.GetString(nameof(FullPath))); - OriginalPath = info.GetString(nameof(OriginalPath)); + throw new PlatformNotSupportedException(); } public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue(nameof(OriginalPath), OriginalPath, typeof(String)); - info.AddValue(nameof(FullPath), FullPath, typeof(String)); + throw new PlatformNotSupportedException(); } // Full path of the directory/file diff --git a/src/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.Serialization.cs b/src/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.Serialization.cs index 159c1117e5..c0058083c8 100644 --- a/src/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.Serialization.cs +++ b/src/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.Serialization.cs @@ -11,6 +11,7 @@ namespace System.IO.IsolatedStorage { protected IsolatedStorageException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Net.HttpListener/src/System/Net/HttpListenerException.cs b/src/System.Net.HttpListener/src/System/Net/HttpListenerException.cs index c5f6dc6641..d0b5af1375 100644 --- a/src/System.Net.HttpListener/src/System/Net/HttpListenerException.cs +++ b/src/System.Net.HttpListener/src/System/Net/HttpListenerException.cs @@ -28,7 +28,7 @@ namespace System.Net protected HttpListenerException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { - if (NetEventSource.IsEnabled) NetEventSource.Info(this, NativeErrorCode.ToString() + ":" + Message); + throw new PlatformNotSupportedException(); } // the base class returns the HResult with this property diff --git a/src/System.Net.Mail/src/System/Net/Mail/SmtpException.cs b/src/System.Net.Mail/src/System/Net/Mail/SmtpException.cs index 4eeafff5a5..1b6aa7231e 100644 --- a/src/System.Net.Mail/src/System/Net/Mail/SmtpException.cs +++ b/src/System.Net.Mail/src/System/Net/Mail/SmtpException.cs @@ -95,10 +95,9 @@ namespace System.Net.Mail protected SmtpException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { - _statusCode = (SmtpStatusCode)serializationInfo.GetInt32("Status"); + throw new PlatformNotSupportedException(); } - internal SmtpException(SmtpStatusCode statusCode, string serverMessage, bool serverResponse) : base(GetMessageForStatus(statusCode, serverMessage)) { _statusCode = statusCode; @@ -110,13 +109,12 @@ namespace System.Net.Mail void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + base.GetObjectData(serializationInfo, streamingContext); } public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); - serializationInfo.AddValue("Status", (int)_statusCode, typeof(int)); } public SmtpStatusCode StatusCode diff --git a/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs b/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs index dd37b26347..3b9813d91a 100644 --- a/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs +++ b/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs @@ -22,10 +22,9 @@ namespace System.Net.Mail protected SmtpFailedRecipientException(SerializationInfo info, StreamingContext context) : base(info, context) { - _failedRecipient = info.GetString("failedRecipient"); + throw new PlatformNotSupportedException(); } - public SmtpFailedRecipientException(SmtpStatusCode statusCode, string failedRecipient) : base(statusCode) { _failedRecipient = failedRecipient; @@ -52,13 +51,12 @@ namespace System.Net.Mail [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.dll is still using pre-v4 security model and needs this demand")] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + base.GetObjectData(serializationInfo, streamingContext); } public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); - serializationInfo.AddValue("failedRecipient", _failedRecipient, typeof(string)); } } } diff --git a/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs b/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs index de65f570b6..9d1de650f7 100644 --- a/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs +++ b/src/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs @@ -30,10 +30,9 @@ namespace System.Net.Mail protected SmtpFailedRecipientsException(SerializationInfo info, StreamingContext context) : base(info, context) { - _innerExceptions = (SmtpFailedRecipientException[])info.GetValue("innerExceptions", typeof(SmtpFailedRecipientException[])); + throw new PlatformNotSupportedException(); } - public SmtpFailedRecipientsException(string message, SmtpFailedRecipientException[] innerExceptions) : base(message, innerExceptions != null && innerExceptions.Length > 0 ? innerExceptions[0].FailedRecipient : null, innerExceptions != null && innerExceptions.Length > 0 ? innerExceptions[0] : null) @@ -70,13 +69,12 @@ namespace System.Net.Mail [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.dll is still using pre-v4 security model and needs this demand")] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + base.GetObjectData(serializationInfo, streamingContext); } public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); - serializationInfo.AddValue("innerExceptions", _innerExceptions, typeof(SmtpFailedRecipientException[])); } } } diff --git a/src/System.Net.Mail/tests/Functional/SmtpExceptionTest.cs b/src/System.Net.Mail/tests/Functional/SmtpExceptionTest.cs index c54026106c..d343e0f28e 100644 --- a/src/System.Net.Mail/tests/Functional/SmtpExceptionTest.cs +++ b/src/System.Net.Mail/tests/Functional/SmtpExceptionTest.cs @@ -86,24 +86,6 @@ namespace System.Net.Mail.Tests } [Fact] - public void TestConstructorWithSerialization() - { - string msg = "MESSAGE"; - Exception inner = new ArgumentException("whatever"); - SerializationInfo si = new SerializationInfo(typeof(SmtpException), new FormatterConverter()); - - new Exception(msg, inner).GetObjectData(si, new StreamingContext()); - si.AddValue("Status", (int)SmtpStatusCode.ServiceReady); - - SmtpException se = new MySmtpException(si, new StreamingContext()); - Assert.NotNull(se.Data); - Assert.Equal(0, se.Data.Keys.Count); - Assert.Same(inner, se.InnerException); - Assert.Same(msg, se.Message); - Assert.Equal(SmtpStatusCode.ServiceReady, se.StatusCode); - } - - [Fact] public void TestConstructorThrowsNull() { Assert.Throws<ArgumentNullException>(() => new MySmtpException((SerializationInfo)null, new StreamingContext())); diff --git a/src/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs b/src/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs index aa447a7001..ee56c2e996 100644 --- a/src/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs +++ b/src/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs @@ -21,6 +21,7 @@ namespace System.Net.NetworkInformation protected PingException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Net.Primitives/src/System/Net/CookieException.cs b/src/System.Net.Primitives/src/System/Net/CookieException.cs index 328544a6ac..d2c6870e96 100644 --- a/src/System.Net.Primitives/src/System/Net/CookieException.cs +++ b/src/System.Net.Primitives/src/System/Net/CookieException.cs @@ -23,11 +23,12 @@ namespace System.Net protected CookieException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + base.GetObjectData(serializationInfo, streamingContext); } public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) diff --git a/src/System.Net.Primitives/src/System/Net/SocketException.cs b/src/System.Net.Primitives/src/System/Net/SocketException.cs index 38d75893fd..c2ad7246ae 100644 --- a/src/System.Net.Primitives/src/System/Net/SocketException.cs +++ b/src/System.Net.Primitives/src/System/Net/SocketException.cs @@ -43,7 +43,7 @@ namespace System.Net.Sockets protected SocketException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { - if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}"); + throw new PlatformNotSupportedException(); } public override int ErrorCode => base.NativeErrorCode; diff --git a/src/System.Net.Requests/src/System/Net/FileWebRequest.cs b/src/System.Net.Requests/src/System/Net/FileWebRequest.cs index 8f05eb266d..b59292a13d 100644 --- a/src/System.Net.Requests/src/System/Net/FileWebRequest.cs +++ b/src/System.Net.Requests/src/System/Net/FileWebRequest.cs @@ -39,14 +39,7 @@ namespace System.Net [Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")] protected FileWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { - _headers = (WebHeaderCollection)serializationInfo.GetValue("headers", typeof(WebHeaderCollection)); - Proxy = (IWebProxy)serializationInfo.GetValue("proxy", typeof(IWebProxy)); - _uri = (Uri)serializationInfo.GetValue("uri", typeof(Uri)); - ConnectionGroupName = serializationInfo.GetString("connectionGroupName"); - _method = serializationInfo.GetString("method"); - _contentLength = serializationInfo.GetInt64("contentLength"); - _timeout = serializationInfo.GetInt32("timeout"); - _fileAccess = (FileAccess)serializationInfo.GetInt32("fileAccess"); + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) => @@ -54,16 +47,7 @@ namespace System.Net protected override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - serializationInfo.AddValue("headers", _headers, typeof(WebHeaderCollection)); - serializationInfo.AddValue("proxy", Proxy, typeof(IWebProxy)); - serializationInfo.AddValue("uri", _uri, typeof(Uri)); - serializationInfo.AddValue("connectionGroupName", ConnectionGroupName); - serializationInfo.AddValue("method", _method); - serializationInfo.AddValue("contentLength", _contentLength); - serializationInfo.AddValue("timeout", _timeout); - serializationInfo.AddValue("fileAccess", _fileAccess); - serializationInfo.AddValue("preauthenticate", false); - base.GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } internal bool Aborted => _aborted != 0; diff --git a/src/System.Net.Requests/src/System/Net/FileWebResponse.cs b/src/System.Net.Requests/src/System/Net/FileWebResponse.cs index 4059f67faa..0ce16c58c8 100644 --- a/src/System.Net.Requests/src/System/Net/FileWebResponse.cs +++ b/src/System.Net.Requests/src/System/Net/FileWebResponse.cs @@ -49,24 +49,17 @@ namespace System.Net [Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")] protected FileWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { - _headers = (WebHeaderCollection)serializationInfo.GetValue("headers", typeof(WebHeaderCollection)); - _uri = (Uri)serializationInfo.GetValue("uri", typeof(Uri)); - _contentLength = serializationInfo.GetInt64("contentLength"); - _fileAccess = (FileAccess)serializationInfo.GetInt32("fileAccess"); + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } protected override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - serializationInfo.AddValue("headers", _headers, typeof(WebHeaderCollection)); - serializationInfo.AddValue("uri", _uri, typeof(Uri)); - serializationInfo.AddValue("contentLength", _contentLength); - serializationInfo.AddValue("fileAccess", _fileAccess); - base.GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } public override long ContentLength diff --git a/src/System.Net.Requests/src/System/Net/ProtocolViolationException.cs b/src/System.Net.Requests/src/System/Net/ProtocolViolationException.cs index 1df1a2e8ef..d7833d2db6 100644 --- a/src/System.Net.Requests/src/System/Net/ProtocolViolationException.cs +++ b/src/System.Net.Requests/src/System/Net/ProtocolViolationException.cs @@ -36,6 +36,7 @@ namespace System.Net protected ProtocolViolationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) diff --git a/src/System.Net.Requests/src/System/Net/WebException.cs b/src/System.Net.Requests/src/System/Net/WebException.cs index ff5ca3321c..4342f45949 100644 --- a/src/System.Net.Requests/src/System/Net/WebException.cs +++ b/src/System.Net.Requests/src/System/Net/WebException.cs @@ -52,6 +52,7 @@ namespace System.Net protected WebException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } public WebExceptionStatus Status @@ -72,7 +73,7 @@ namespace System.Net void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + base.GetObjectData(serializationInfo, streamingContext); } public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) diff --git a/src/System.Net.Requests/src/System/Net/WebRequest.cs b/src/System.Net.Requests/src/System/Net/WebRequest.cs index 55d3c3fd2c..d739492ca8 100644 --- a/src/System.Net.Requests/src/System/Net/WebRequest.cs +++ b/src/System.Net.Requests/src/System/Net/WebRequest.cs @@ -34,14 +34,20 @@ namespace System.Net protected WebRequest() { } - protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) { } + protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) + { + throw new PlatformNotSupportedException(); + } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } - protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { } + protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) + { + throw new PlatformNotSupportedException(); + } // Create a WebRequest. // diff --git a/src/System.Net.Requests/src/System/Net/WebResponse.cs b/src/System.Net.Requests/src/System/Net/WebResponse.cs index ce1e47d9da..e565db9933 100644 --- a/src/System.Net.Requests/src/System/Net/WebResponse.cs +++ b/src/System.Net.Requests/src/System/Net/WebResponse.cs @@ -26,15 +26,17 @@ namespace System.Net protected WebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) { + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { + throw new PlatformNotSupportedException(); } public virtual void Close() 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 diff --git a/src/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs b/src/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs index f6595a4223..761a45e65e 100644 --- a/src/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs +++ b/src/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs @@ -38,14 +38,7 @@ namespace System.Net protected WebHeaderCollection(SerializationInfo serializationInfo, StreamingContext streamingContext) { - int count = serializationInfo.GetInt32("Count"); - for (int i = 0; i < count; i++) - { - string headerName = serializationInfo.GetString(i.ToString(NumberFormatInfo.InvariantInfo)); - string headerValue = serializationInfo.GetString((i + count).ToString(NumberFormatInfo.InvariantInfo)); - if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Add() key:[{headerName}], value:[{headerValue}]"); - InnerCollection.Add(headerName, headerValue); - } + throw new PlatformNotSupportedException(); } private bool AllowHttpRequestHeader @@ -187,20 +180,12 @@ namespace System.Net public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - // - // for now disregard streamingContext. - // - serializationInfo.AddValue("Count", Count); - for (int i = 0; i < Count; i++) - { - serializationInfo.AddValue(i.ToString(NumberFormatInfo.InvariantInfo), GetKey(i)); - serializationInfo.AddValue((i + Count).ToString(NumberFormatInfo.InvariantInfo), Get(i)); - } + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } public void Remove(HttpRequestHeader header) diff --git a/src/System.Net.WebProxy/src/System/Net/WebProxy.cs b/src/System.Net.WebProxy/src/System/Net/WebProxy.cs index 74b24e1131..b2bff48b75 100644 --- a/src/System.Net.WebProxy/src/System/Net/WebProxy.cs +++ b/src/System.Net.WebProxy/src/System/Net/WebProxy.cs @@ -207,23 +207,17 @@ namespace System.Net protected WebProxy(SerializationInfo serializationInfo, StreamingContext streamingContext) { - BypassProxyOnLocal = serializationInfo.GetBoolean("_BypassOnLocal"); - Address = (Uri)serializationInfo.GetValue("_ProxyAddress", typeof(Uri)); - _bypassList = (ArrayList)serializationInfo.GetValue("_BypassList", typeof(ArrayList)); - UseDefaultCredentials = serializationInfo.GetBoolean("_UseDefaultCredentials"); + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - GetObjectData(serializationInfo, streamingContext); + throw new PlatformNotSupportedException(); } protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { - serializationInfo.AddValue("_BypassOnLocal", BypassProxyOnLocal); - serializationInfo.AddValue("_ProxyAddress", Address); - serializationInfo.AddValue("_BypassList", _bypassList); - serializationInfo.AddValue("_UseDefaultCredentials", UseDefaultCredentials); + throw new PlatformNotSupportedException(); } [Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")] diff --git a/src/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs b/src/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs index 17caae4a7e..9e79b5d217 100644 --- a/src/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs +++ b/src/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs @@ -122,19 +122,8 @@ namespace System.Net.WebSockets { } - private WebSocketException(SerializationInfo serializationInfo, StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - _webSocketErrorCode = (WebSocketError)serializationInfo.GetInt32(nameof(WebSocketErrorCode)); - } - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - info.AddValue(nameof(WebSocketErrorCode), (int)_webSocketErrorCode); base.GetObjectData(info, context); } diff --git a/src/System.Private.Uri/src/System/UriFormatException.cs b/src/System.Private.Uri/src/System/UriFormatException.cs index 429091350f..c3789a0529 100644 --- a/src/System.Private.Uri/src/System/UriFormatException.cs +++ b/src/System.Private.Uri/src/System/UriFormatException.cs @@ -25,9 +25,11 @@ namespace System protected UriFormatException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { + throw new PlatformNotSupportedException(); } - void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { + void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) + { base.GetObjectData(serializationInfo, streamingContext); } }; // class UriFormatException diff --git a/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs b/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs index c330510dd4..efc95cbeb8 100644 --- a/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs +++ b/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs @@ -189,28 +189,9 @@ namespace System.Xml.Linq /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> to populate with data</param> /// <param name="context">The destination for this serialization</param> - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) throw new ArgumentNullException(nameof(info)); - info.AddValue("name", ToString()); - info.SetType(typeof(NameSerializer)); - } - } - - internal sealed class NameSerializer : IObjectReference, ISerializable - { - string _expandedName; - - private NameSerializer(SerializationInfo info, StreamingContext context) { - if (info == null) throw new ArgumentNullException(nameof(info)); - _expandedName = info.GetString("name"); - } - - object IObjectReference.GetRealObject(StreamingContext context) { - return XName.Get(_expandedName); - } - - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - throw new NotSupportedException(); // nop + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs b/src/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs index 29cae9c6d1..d16397a464 100644 --- a/src/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs +++ b/src/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs @@ -14,7 +14,10 @@ namespace System.Xml.Schema public class XmlSchemaInferenceException : XmlSchemaException { - protected XmlSchemaInferenceException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected XmlSchemaInferenceException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public override void GetObjectData(SerializationInfo info, StreamingContext context) { diff --git a/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs b/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs index aef6ee372d..9c7bc09e59 100644 --- a/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs +++ b/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs @@ -31,44 +31,13 @@ namespace System.Xml.Schema /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.XmlSchemaException5"]/*' /> protected XmlSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) { - _res = (string)info.GetValue("res", typeof(string)); - _args = (string[])info.GetValue("args", typeof(string[])); - _sourceUri = (string)info.GetValue("sourceUri", typeof(string)); - _lineNumber = (int)info.GetValue("lineNumber", typeof(int)); - _linePosition = (int)info.GetValue("linePosition", typeof(int)); - - // deserialize optional members - string version = null; - foreach (SerializationEntry e in info) - { - if (e.Name == "version") - { - version = (string)e.Value; - } - } - - if (version == null) - { - // deserializing V1 exception - _message = CreateMessage(_res, _args); - } - else - { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - _message = null; - } + throw new PlatformNotSupportedException(); } /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.GetObjectData"]/*' /> - public override void GetObjectData(SerializationInfo info, StreamingContext context) + public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("res", _res); - info.AddValue("args", _args); - info.AddValue("sourceUri", _sourceUri); - info.AddValue("lineNumber", _lineNumber); - info.AddValue("linePosition", _linePosition); - info.AddValue("version", "2.0"); } /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.XmlSchemaException1"]/*' /> diff --git a/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs b/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs index 8c5c89b22d..73d84e25f2 100644 --- a/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs +++ b/src/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs @@ -17,7 +17,10 @@ namespace System.Xml.Schema private Object _sourceNodeObject; /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.XmlSchemaException5"]/*' /> - protected XmlSchemaValidationException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected XmlSchemaValidationException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.GetObjectData"]/*' /> public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/src/System.Private.Xml/src/System/Xml/XPath/XPathException.cs b/src/System.Private.Xml/src/System/Xml/XPath/XPathException.cs index 8d7a3a8794..241d4d2c06 100644 --- a/src/System.Private.Xml/src/System/Xml/XPath/XPathException.cs +++ b/src/System.Private.Xml/src/System/Xml/XPath/XPathException.cs @@ -23,37 +23,12 @@ namespace System.Xml.XPath protected XPathException(SerializationInfo info, StreamingContext context) : base(info, context) { - _res = (string)info.GetValue("res", typeof(string)); - _args = (string[])info.GetValue("args", typeof(string[])); - - // deserialize optional members - string version = null; - foreach (SerializationEntry e in info) - { - if (e.Name == "version") - { - version = (string)e.Value; - } - } - - if (version == null) - { - // deserializing V1 exception - _message = CreateMessage(_res, _args); - } - else - { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - _message = null; - } + throw new PlatformNotSupportedException(); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("res", _res); - info.AddValue("args", _args); - info.AddValue("version", "2.0"); } public XPathException() : this(string.Empty, (Exception)null) { } diff --git a/src/System.Private.Xml/src/System/Xml/XmlException.cs b/src/System.Private.Xml/src/System/Xml/XmlException.cs index 10b9f9959c..609a3c3fad 100644 --- a/src/System.Private.Xml/src/System/Xml/XmlException.cs +++ b/src/System.Private.Xml/src/System/Xml/XmlException.cs @@ -31,48 +31,12 @@ namespace System.Xml protected XmlException(SerializationInfo info, StreamingContext context) : base(info, context) { - _res = (string)info.GetValue("_res", typeof(string)); - _args = (string[])info.GetValue("_args", typeof(string[])); - _lineNumber = (int)info.GetValue("_lineNumber", typeof(int)); - _linePosition = (int)info.GetValue("_linePosition", typeof(int)); - - // deserialize optional members - _sourceUri = string.Empty; - string version = null; - foreach (SerializationEntry e in info) - { - switch (e.Name) - { - case "sourceUri": - _sourceUri = (string)e.Value; - break; - case "version": - version = (string)e.Value; - break; - } - } - - if (version == null) - { - // deserializing V1 exception - _message = CreateMessage(_res, _args, _lineNumber, _linePosition); - } - else - { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - _message = null; - } + throw new PlatformNotSupportedException(); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("res", _res); - info.AddValue("args", _args); - info.AddValue("lineNumber", _lineNumber); - info.AddValue("linePosition", _linePosition); - info.AddValue("sourceUri", _sourceUri); - info.AddValue("version", "2.0"); } //provided to meet the ECMA standards diff --git a/src/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs b/src/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs index 8c47cc2ebb..2ee0f166a1 100644 --- a/src/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs +++ b/src/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs @@ -12,54 +12,18 @@ namespace System.Xml.Xsl public class XsltException : SystemException { private string _res; - private string[] _args; private string _sourceUri; private int _lineNumber; private int _linePosition; - // message != null for V1 & V2 exceptions deserialized in Whidbey - // message == null for created V2 exceptions; the exception message is stored in Exception._message - private string _message; - protected XsltException(SerializationInfo info, StreamingContext context) : base(info, context) { - _res = (string)info.GetValue("res", typeof(string)); - _args = (string[])info.GetValue("args", typeof(string[])); - _sourceUri = (string)info.GetValue("sourceUri", typeof(string)); - _lineNumber = (int)info.GetValue("lineNumber", typeof(int)); - _linePosition = (int)info.GetValue("linePosition", typeof(int)); - - // deserialize optional members - string version = null; - foreach (SerializationEntry e in info) - { - if (e.Name == "version") - { - version = (string)e.Value; - } - } - - if (version == null) - { - // deserializing V1 exception - _message = CreateMessage(_res, _args, _sourceUri, _lineNumber, _linePosition); - } - else - { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - _message = null; - } + throw new PlatformNotSupportedException(); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("res", _res); - info.AddValue("args", _args); - info.AddValue("sourceUri", _sourceUri); - info.AddValue("lineNumber", _lineNumber); - info.AddValue("linePosition", _linePosition); - info.AddValue("version", "2.0"); } public XsltException() : this(string.Empty, (Exception)null) { } @@ -110,7 +74,7 @@ namespace System.Xml.Xsl { get { - return (_message == null) ? base.Message : _message; + return base.Message; } } @@ -144,7 +108,10 @@ namespace System.Xml.Xsl public class XsltCompileException : XsltException { - protected XsltCompileException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected XsltCompileException(SerializationInfo info, StreamingContext context) : base(info, context) + { + throw new PlatformNotSupportedException(); + } public override void GetObjectData(SerializationInfo info, StreamingContext context) { diff --git a/src/System.Runtime.Extensions/src/System/AppDomainUnloadedException.cs b/src/System.Runtime.Extensions/src/System/AppDomainUnloadedException.cs index b5c28457db..48d5dc7230 100644 --- a/src/System.Runtime.Extensions/src/System/AppDomainUnloadedException.cs +++ b/src/System.Runtime.Extensions/src/System/AppDomainUnloadedException.cs @@ -32,6 +32,7 @@ namespace System // protected AppDomainUnloadedException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } }
\ No newline at end of file diff --git a/src/System.Runtime.Extensions/src/System/CannotUnloadAppDomainException.cs b/src/System.Runtime.Extensions/src/System/CannotUnloadAppDomainException.cs index 4777fed99a..871a6fd97f 100644 --- a/src/System.Runtime.Extensions/src/System/CannotUnloadAppDomainException.cs +++ b/src/System.Runtime.Extensions/src/System/CannotUnloadAppDomainException.cs @@ -32,6 +32,7 @@ namespace System // protected CannotUnloadAppDomainException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Runtime.Extensions/src/System/Collections/Hashtable.cs b/src/System.Runtime.Extensions/src/System/Collections/Hashtable.cs index 15b6829dcf..145f063718 100644 --- a/src/System.Runtime.Extensions/src/System/Collections/Hashtable.cs +++ b/src/System.Runtime.Extensions/src/System/Collections/Hashtable.cs @@ -1403,27 +1403,12 @@ namespace System.Collections internal SyncHashtable(SerializationInfo info, StreamingContext context) : base(info, context) { - _table = (Hashtable)info.GetValue("ParentTable", typeof(Hashtable)); - if (_table == null) - { - throw new SerializationException(SR.Serialization_InsufficientState); - } + throw new PlatformNotSupportedException(); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - Contract.EndContractBlock(); - - // Our serialization code hasn't been fully tweaked to be safe - // for a concurrent writer. - lock (_table.SyncRoot) - { - info.AddValue("ParentTable", _table, typeof(Hashtable)); - } + throw new PlatformNotSupportedException(); } public override int Count diff --git a/src/System.Runtime.Extensions/src/System/Context.cs b/src/System.Runtime.Extensions/src/System/Context.cs index 093ce41dd6..9e9f1ce3c0 100644 --- a/src/System.Runtime.Extensions/src/System/Context.cs +++ b/src/System.Runtime.Extensions/src/System/Context.cs @@ -30,7 +30,7 @@ namespace System protected ContextMarshalException(SerializationInfo info, StreamingContext context): base(info, context) { - HResult = HResults.COR_E_CONTEXTMARSHAL; + throw new PlatformNotSupportedException(); } } diff --git a/src/System.Runtime.Extensions/src/System/IO/InvalidDataException.cs b/src/System.Runtime.Extensions/src/System/IO/InvalidDataException.cs index c3093598e5..57f9fdeff2 100644 --- a/src/System.Runtime.Extensions/src/System/IO/InvalidDataException.cs +++ b/src/System.Runtime.Extensions/src/System/IO/InvalidDataException.cs @@ -22,9 +22,5 @@ namespace System.IO : base(message, innerException) { } - - private InvalidDataException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } diff --git a/src/System.Runtime.Extensions/src/System/OperatingSystem.cs b/src/System.Runtime.Extensions/src/System/OperatingSystem.cs index 8ecaba24ae..5820c7e3c6 100644 --- a/src/System.Runtime.Extensions/src/System/OperatingSystem.cs +++ b/src/System.Runtime.Extensions/src/System/OperatingSystem.cs @@ -35,23 +35,9 @@ namespace System _servicePack = servicePack; } - private OperatingSystem(SerializationInfo info, StreamingContext context) - { - _version = (Version)info.GetValue("_version", typeof(Version)); - _platform = (PlatformID)info.GetValue("_platform", typeof(PlatformID)); - _servicePack = info.GetString("_servicePack"); - } - public void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue("_version", _version); - info.AddValue("_platform", _platform); - info.AddValue("_servicePack", _servicePack); + throw new PlatformNotSupportedException(); } public PlatformID Platform => _platform; diff --git a/src/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs b/src/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs index 8aa6b1714c..ae167e7c48 100644 --- a/src/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs +++ b/src/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs @@ -50,12 +50,5 @@ namespace System.Tests Assert.Equal(os.Version, os2.Version); Assert.Equal(os.VersionString, os2.VersionString); } - - [Fact] - public static void GetObjectData_InvalidArgs_Throws() - { - var os = new OperatingSystem(PlatformID.Win32NT, new Version(10, 0)); - AssertExtensions.Throws<ArgumentNullException>("info", () => os.GetObjectData(null, new StreamingContext())); - } } } diff --git a/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.Serialization.cs b/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.Serialization.cs index 678e608b7e..7b581bd7cf 100644 --- a/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.Serialization.cs +++ b/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.Serialization.cs @@ -11,6 +11,7 @@ namespace System.Runtime.Serialization protected InvalidDataContractException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs b/src/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs index 9b4ee6c2d2..cdff814c92 100644 --- a/src/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs +++ b/src/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs @@ -29,20 +29,9 @@ namespace System.Security.AccessControl _privilegeName = privilege; } - private PrivilegeNotHeldException(SerializationInfo info, StreamingContext context) : base(info, context) - { - _privilegeName = info.GetString(nameof(PrivilegeName)); - } - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - base.GetObjectData(info, context); - info.AddValue(nameof(PrivilegeName), _privilegeName, typeof(string)); } public string PrivilegeName diff --git a/src/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs b/src/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs index a6aaf11c29..2be94d75da 100644 --- a/src/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs +++ b/src/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs @@ -258,12 +258,7 @@ namespace System.Security.Claims protected ClaimsIdentity(SerializationInfo info, StreamingContext context) { - if (null == info) - { - throw new ArgumentNullException(nameof(info)); - } - - Deserialize(info, context, true); + throw new PlatformNotSupportedException(); } /// <summary> @@ -1057,31 +1052,7 @@ namespace System.Security.Claims /// <exception cref="ArgumentNullException">Thrown if the info parameter is null.</exception> protected virtual void GetObjectData(SerializationInfo info, StreamingContext context) { - if (null == info) - { - throw new ArgumentNullException(nameof(info)); - } - - const string Version = "1.0"; - info.AddValue(VersionKey, Version); - if (!string.IsNullOrEmpty(_authenticationType)) - { - info.AddValue(AuthenticationTypeKey, _authenticationType); - } - - info.AddValue(NameClaimTypeKey, _nameClaimType); - info.AddValue(RoleClaimTypeKey, _roleClaimType); - - if (!string.IsNullOrEmpty(_label)) - { - info.AddValue(LabelKey, _label); - } - - // actor - if (_actor != null || _bootstrapContext != null || (_instanceClaims != null && _instanceClaims.Count > 0)) - { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_Serialization); // BinaryFormatter needed - } + throw new PlatformNotSupportedException(); } private void Deserialize(SerializationInfo info, StreamingContext context, bool useContext) diff --git a/src/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs b/src/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs index 03490b1f1f..7d241de1bd 100644 --- a/src/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs +++ b/src/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs @@ -33,10 +33,7 @@ namespace System.Security.Claims protected ClaimsPrincipal(SerializationInfo info, StreamingContext context) { - if (null == info) - { - throw new ArgumentNullException(nameof(info)); - } + throw new PlatformNotSupportedException(); } /// <summary> @@ -620,15 +617,7 @@ namespace System.Security.Claims protected virtual void GetObjectData(SerializationInfo info, StreamingContext context) { - if (null == info) - { - throw new ArgumentNullException(nameof(info)); - } - - if (_identities.Count > 0) - { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_Serialization); // BinaryFormatter and WindowsIdentity would be needed - } + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs b/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs index d6a20b46f9..31cdd8b3f0 100644 --- a/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs +++ b/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs @@ -32,6 +32,7 @@ namespace System.Security.Cryptography protected CryptographicUnexpectedOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs index 91a812623d..f6e9080464 100644 --- a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs +++ b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs @@ -164,14 +164,7 @@ namespace System.Security.Cryptography.X509Certificates [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2229", Justification = "Public API has already shipped.")] public X509Certificate(SerializationInfo info, StreamingContext context) : this() { - byte[] rawData = (byte[])info.GetValue("RawData", typeof(byte[])); - if (rawData != null) - { - using (var safePasswordHandle = new SafePasswordHandle((string)null)) - { - Pal = CertificatePal.FromBlob(rawData, safePasswordHandle, X509KeyStorageFlags.DefaultKeySet); - } - } + throw new PlatformNotSupportedException(); } public static X509Certificate CreateFromCertFile(string filename) @@ -186,7 +179,7 @@ namespace System.Security.Cryptography.X509Certificates void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("RawData", Pal?.RawData); + throw new PlatformNotSupportedException(); } void IDeserializationCallback.OnDeserialization(object sender) { } diff --git a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs index b4bb77e1b3..1b0ac1ddc6 100644 --- a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs +++ b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs @@ -115,6 +115,7 @@ namespace System.Security.Cryptography.X509Certificates protected X509Certificate2(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } public bool Archived diff --git a/src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs b/src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs index 59bf3640bc..7ecfdd6bc3 100644 --- a/src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs +++ b/src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs @@ -22,6 +22,8 @@ namespace System.Security.Cryptography.Xml // exception propagates from a remoting server to the client. protected CryptoSignedXmlRecursionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - { } + { + throw new PlatformNotSupportedException(); + } } } diff --git a/src/System.Security.Permissions/src/System/ApplicationIdentity.cs b/src/System.Security.Permissions/src/System/ApplicationIdentity.cs index 2904a43826..6aadb987e5 100644 --- a/src/System.Security.Permissions/src/System/ApplicationIdentity.cs +++ b/src/System.Security.Permissions/src/System/ApplicationIdentity.cs @@ -11,10 +11,17 @@ namespace System { private ApplicationIdentity() { } public ApplicationIdentity(string applicationIdentityFullName) { } - private ApplicationIdentity(SerializationInfo info, StreamingContext context) { } + private ApplicationIdentity(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + public string FullName { get { return null; } } public string CodeBase { get { return null; } } public override string ToString() { return null; } - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { } + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } } } diff --git a/src/System.Security.Permissions/src/System/Security/HostProtectionException.cs b/src/System.Security.Permissions/src/System/Security/HostProtectionException.cs index 93fac0909b..ba9b55e13c 100644 --- a/src/System.Security.Permissions/src/System/Security/HostProtectionException.cs +++ b/src/System.Security.Permissions/src/System/Security/HostProtectionException.cs @@ -10,7 +10,11 @@ namespace System.Security public partial class HostProtectionException : System.SystemException { public HostProtectionException() { } - protected HostProtectionException(SerializationInfo info, StreamingContext context) { } + protected HostProtectionException(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + public HostProtectionException(string message) { } public HostProtectionException(string message, Exception e) { } public HostProtectionException(string message, HostProtectionResource protectedResources, HostProtectionResource demandedResources) { } diff --git a/src/System.Security.Permissions/src/System/Security/Policy/Hash.cs b/src/System.Security.Permissions/src/System/Security/Policy/Hash.cs index ec4e62bab4..e8bf589c28 100644 --- a/src/System.Security.Permissions/src/System/Security/Policy/Hash.cs +++ b/src/System.Security.Permissions/src/System/Security/Policy/Hash.cs @@ -10,7 +10,6 @@ namespace System.Security.Policy public sealed partial class Hash : EvidenceBase, System.Runtime.Serialization.ISerializable { public Hash(System.Reflection.Assembly assembly) { } - private Hash(SerializationInfo info, StreamingContext context) { } public byte[] MD5 { get { return null; } } public byte[] SHA1 { get { return null; } } public byte[] SHA256 { get { return null; } } @@ -18,7 +17,11 @@ namespace System.Security.Policy public static Hash CreateSHA1(byte[] sha1) { return default(Hash); } public static Hash CreateSHA256(byte[] sha256) { return default(Hash); } public byte[] GenerateHash(HashAlgorithm hashAlg) { return null; } - public void GetObjectData(SerializationInfo info, StreamingContext context) { } + public void GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + public override string ToString() => base.ToString(); } } diff --git a/src/System.Security.Permissions/src/System/Security/Policy/HashMembershipCondition.cs b/src/System.Security.Permissions/src/System/Security/Policy/HashMembershipCondition.cs index c1ebdf0a37..5af6b46f94 100644 --- a/src/System.Security.Permissions/src/System/Security/Policy/HashMembershipCondition.cs +++ b/src/System.Security.Permissions/src/System/Security/Policy/HashMembershipCondition.cs @@ -10,7 +10,6 @@ namespace System.Security.Policy public sealed partial class HashMembershipCondition : IDeserializationCallback, ISerializable, ISecurityEncodable, ISecurityPolicyEncodable, IMembershipCondition { public HashMembershipCondition(HashAlgorithm hashAlg, byte[] value) { } - private HashMembershipCondition(SerializationInfo info, StreamingContext context) { } public HashAlgorithm HashAlgorithm { get; set; } public byte[] HashValue { get; set; } public bool Check(Evidence evidence) { return false; } @@ -20,7 +19,11 @@ namespace System.Security.Policy public void FromXml(SecurityElement e, PolicyLevel level) { } public override int GetHashCode() => base.GetHashCode(); void IDeserializationCallback.OnDeserialization(object sender) { } - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { } + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + public override string ToString() => base.ToString(); public SecurityElement ToXml() { return default(SecurityElement); } public SecurityElement ToXml(PolicyLevel level) { return default(SecurityElement); } diff --git a/src/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs b/src/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs index 431d84d654..a125ca84e4 100644 --- a/src/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs +++ b/src/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs @@ -9,7 +9,11 @@ namespace System.Security.Policy public partial class PolicyException : System.SystemException { public PolicyException() { } - protected PolicyException(SerializationInfo info, StreamingContext context) { } + protected PolicyException(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + public PolicyException(string message) { } public PolicyException(string message, Exception exception) { } } diff --git a/src/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs b/src/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs index 656837c8fb..8554181d6d 100644 --- a/src/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs +++ b/src/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs @@ -13,6 +13,5 @@ namespace System.Security public XmlSyntaxException(int lineNumber, string message) { } public XmlSyntaxException(string message) { } public XmlSyntaxException(string message, Exception inner) { } - private XmlSyntaxException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } diff --git a/src/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs b/src/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs index 85b2de4e64..b7f0d0c69a 100644 --- a/src/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs +++ b/src/System.Security.Principal.Windows/src/System/Security/Principal/IdentityNotMappedException.cs @@ -31,10 +31,6 @@ namespace System.Security.Principal _unmappedIdentities = unmappedIdentities; } - private IdentityNotMappedException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs b/src/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs index 101088a5d8..711220afdf 100644 --- a/src/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs +++ b/src/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs @@ -239,20 +239,12 @@ namespace System.Security.Principal [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2229", Justification = "Public API has already shipped.")] public WindowsIdentity(SerializationInfo info, StreamingContext context) { - _claimsInitialized = false; - - IntPtr userToken = (IntPtr)info.GetValue("m_userToken", typeof(IntPtr)); - if (userToken != IntPtr.Zero) - { - CreateFromToken(userToken); - } + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - // TODO: Add back when ClaimsIdentity is serializable - // base.GetObjectData(info, context); - info.AddValue("m_userToken", _safeTokenHandle.DangerousGetHandle()); + throw new PlatformNotSupportedException(); } void IDeserializationCallback.OnDeserialization(object sender) { } diff --git a/src/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs b/src/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs index 340be7d613..600d37744c 100644 --- a/src/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs +++ b/src/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs @@ -30,6 +30,7 @@ namespace System.ServiceProcess protected TimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs b/src/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs index a968344b48..fdbcfaf06f 100644 --- a/src/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs +++ b/src/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs @@ -80,8 +80,7 @@ namespace System.Text void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - CodePageEncodingSurrogate.SerializeEncoding(this, info, context); - info.SetType(typeof(CodePageEncodingSurrogate)); + throw new PlatformNotSupportedException(); } // Just a helper as we cannot use 'this' when calling 'base(...)' diff --git a/src/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs b/src/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs index da680d8210..1142871621 100644 --- a/src/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs +++ b/src/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs @@ -47,44 +47,7 @@ namespace System.Text void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue(DecoderNLSSurrogate.EncodingKey, m_encoding); - info.AddValue(DecoderNLSSurrogate.DecoderFallbackKey, m_fallback); - info.SetType(typeof(DecoderNLSSurrogate)); - } - - internal sealed class DecoderNLSSurrogate : IObjectReference, ISerializable - { - internal const string EncodingKey = "Encoding"; - internal const string DecoderFallbackKey = "DecoderFallback"; - - private readonly Encoding _encoding; - private readonly DecoderFallback _fallback; - - internal DecoderNLSSurrogate(SerializationInfo info, StreamingContext context) - { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - _encoding = (Encoding)info.GetValue(EncodingKey, typeof(Encoding)); - _fallback = (DecoderFallback)info.GetValue(DecoderFallbackKey, typeof(DecoderFallback)); - } - - public object GetRealObject(StreamingContext context) - { - Decoder decoder = _encoding.GetDecoder(); - if (_fallback != null) - { - decoder.Fallback = _fallback; - } - return decoder; - } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - // This should never be called. If it is, there's a bug in the formatter being used. - throw new NotSupportedException(); - } + throw new PlatformNotSupportedException(); } internal new DecoderFallback Fallback diff --git a/src/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs b/src/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs index 0d3167e04f..49fb977d41 100644 --- a/src/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs +++ b/src/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs @@ -42,58 +42,9 @@ namespace System.Text void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue(EncoderNLSSurrogate.EncodingKey, m_encoding); - info.AddValue(EncoderNLSSurrogate.DecoderFallbackKey, m_fallback); - info.AddValue(EncoderNLSSurrogate.CharLeftOverKey, charLeftOver); - info.SetType(typeof(EncoderNLSSurrogate)); + throw new PlatformNotSupportedException(); } - - internal sealed class EncoderNLSSurrogate : ISerializable, IObjectReference - { - internal const string EncodingKey = "Encoding"; - internal const string DecoderFallbackKey = "EncoderFallback"; - internal const string CharLeftOverKey = "CharLeftOver"; - - private readonly Encoding _encoding; - private readonly EncoderFallback _fallback; - private char _charLeftOver; - - internal EncoderNLSSurrogate(SerializationInfo info, StreamingContext context) - { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - _encoding = (Encoding)info.GetValue(EncodingKey, typeof(Encoding)); - _fallback = (EncoderFallback)info.GetValue(DecoderFallbackKey, typeof(EncoderFallback)); - _charLeftOver = (char)info.GetValue(CharLeftOverKey, typeof(char)); - } - - public object GetRealObject(StreamingContext context) - { - Encoder encoder = _encoding.GetEncoder(); - if (_fallback != null) - { - encoder.Fallback = _fallback; - if (_charLeftOver != default(char)) - { - EncoderNLS encoderNls = encoder as EncoderNLS; - if (encoderNls != null) - { - encoderNls.charLeftOver = _charLeftOver; - } - } - } - return encoder; - } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - // This should never be called. If it is, there's a bug in the formatter being used. - throw new NotSupportedException(); - } - } - + internal new EncoderFallback Fallback { get { return m_fallback; } diff --git a/src/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs b/src/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs index 01f9a9955b..93c4e2c7de 100644 --- a/src/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs +++ b/src/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs @@ -578,62 +578,5 @@ namespace System.Text return _webName; } } - - protected sealed class CodePageEncodingSurrogate : ISerializable, IObjectReference - { - internal const string CodePageKey = "CodePage"; - internal const string IsReadOnlyKey = "IsReadOnly"; - internal const string EncoderFallbackKey = "EncoderFallback"; - internal const string DecoderFallbackKey = "DecoderFallback"; - - private readonly int _codePage; - private readonly bool _isReadOnly; - private readonly EncoderFallback _encoderFallback; - private readonly DecoderFallback _decoderFallback; - - internal CodePageEncodingSurrogate(SerializationInfo info, StreamingContext context) - { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - _codePage = (int)info.GetValue(CodePageKey, typeof(int)); - _isReadOnly = (bool)info.GetValue(IsReadOnlyKey, typeof(bool)); - _encoderFallback = (EncoderFallback)info.GetValue(EncoderFallbackKey, typeof(EncoderFallback)); - _decoderFallback = (DecoderFallback)info.GetValue(DecoderFallbackKey, typeof(DecoderFallback)); - } - - internal static void SerializeEncoding(Encoding e, SerializationInfo info, StreamingContext context) - { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - info.AddValue(CodePageKey, e.CodePage); - info.AddValue(IsReadOnlyKey, e.IsReadOnly); - info.AddValue(EncoderFallbackKey, e.EncoderFallback); - info.AddValue(DecoderFallbackKey, e.DecoderFallback); - } - - public object GetRealObject(StreamingContext context) - { - Encoding realEncoding = GetEncoding(_codePage); - if (!_isReadOnly) - { - realEncoding = (Encoding)realEncoding.Clone(); - realEncoding.EncoderFallback = _encoderFallback; - realEncoding.DecoderFallback = _decoderFallback; - } - return realEncoding; - } - - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) - { - // This should never be called. If it is, there's a bug in the formatter being used. - throw new NotSupportedException(); - } - } } } diff --git a/src/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs b/src/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs index 2fea3a906d..1917907cd8 100644 --- a/src/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs +++ b/src/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs @@ -81,8 +81,7 @@ namespace System.Text void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - CodePageEncodingSurrogate.SerializeEncoding(this, info, context); - info.SetType(typeof(CodePageEncodingSurrogate)); + throw new PlatformNotSupportedException(); } // Our MaxByteCount is 4 times the input size. That could be because diff --git a/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs b/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs index 988919bb7a..9b6c128d08 100644 --- a/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs +++ b/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs @@ -138,26 +138,12 @@ namespace System.Text.RegularExpressions protected Regex(SerializationInfo info, StreamingContext context) : this(info.GetString("pattern"), (RegexOptions)info.GetInt32("options")) { - try - { - long timeoutTicks = info.GetInt64("matchTimeout"); - TimeSpan timeout = new TimeSpan(timeoutTicks); - ValidateMatchTimeout(timeout); - internalMatchTimeout = timeout; - } - catch (SerializationException) - { - // If this occurs, then assume that this object was serialized using a version - // before timeout was added. In that case just do not set a timeout - // (keep default value) - } + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) { - si.AddValue("pattern", ToString()); - si.AddValue("options", Options); - si.AddValue("matchTimeout", MatchTimeout.Ticks); + throw new PlatformNotSupportedException(); } private Regex(string pattern, RegexOptions options, TimeSpan matchTimeout, bool useCache) diff --git a/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs b/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs index 6ad07ac85c..5b9e751e6f 100644 --- a/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs +++ b/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs @@ -52,17 +52,12 @@ namespace System.Text.RegularExpressions protected RegexMatchTimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { - Input = info.GetString("regexInput"); - Pattern = info.GetString("regexPattern"); - MatchTimeout = new TimeSpan(info.GetInt64("timeoutTicks")); + throw new PlatformNotSupportedException(); } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("regexInput", Input); - info.AddValue("regexPattern", Pattern); - info.AddValue("timeoutTicks", MatchTimeout.Ticks); } public string Input { get; } = string.Empty; diff --git a/src/System.Threading.Thread/src/System/Threading/CompressedStack.cs b/src/System.Threading.Thread/src/System/Threading/CompressedStack.cs index c57a1429b1..7f209f5920 100644 --- a/src/System.Threading.Thread/src/System/Threading/CompressedStack.cs +++ b/src/System.Threading.Thread/src/System/Threading/CompressedStack.cs @@ -12,16 +12,9 @@ namespace System.Threading { } - private CompressedStack(SerializationInfo info, StreamingContext context) - { - } - public void GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } + throw new PlatformNotSupportedException(); } public static CompressedStack Capture() diff --git a/src/System.Threading.Thread/src/System/Threading/ThreadAbortException.cs b/src/System.Threading.Thread/src/System/Threading/ThreadAbortException.cs index c1514b4872..00e5853b8c 100644 --- a/src/System.Threading.Thread/src/System/Threading/ThreadAbortException.cs +++ b/src/System.Threading.Thread/src/System/Threading/ThreadAbortException.cs @@ -13,10 +13,6 @@ namespace System.Threading { } - private ThreadAbortException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public object ExceptionState => null; } } diff --git a/src/System.Threading/src/System/Threading/Barrier.cs b/src/System.Threading/src/System/Threading/Barrier.cs index e25749da27..afc9154a01 100644 --- a/src/System.Threading/src/System/Threading/Barrier.cs +++ b/src/System.Threading/src/System/Threading/Barrier.cs @@ -66,6 +66,7 @@ namespace System.Threading protected BarrierPostPhaseException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } diff --git a/src/System.Threading/src/System/Threading/ReaderWriterLock.cs b/src/System.Threading/src/System/Threading/ReaderWriterLock.cs index 29322bfa1e..a2073f4c39 100644 --- a/src/System.Threading/src/System/Threading/ReaderWriterLock.cs +++ b/src/System.Threading/src/System/Threading/ReaderWriterLock.cs @@ -1141,11 +1141,6 @@ namespace System.Threading { HResult = errorHResult; } - - private ReaderWriterLockApplicationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } private static ApplicationException GetTimeoutException() diff --git a/src/System.Transactions.Local/src/System/Transactions/DistributedTransaction.cs b/src/System.Transactions.Local/src/System/Transactions/DistributedTransaction.cs index 5044315271..fe853f8732 100644 --- a/src/System.Transactions.Local/src/System/Transactions/DistributedTransaction.cs +++ b/src/System.Transactions.Local/src/System/Transactions/DistributedTransaction.cs @@ -65,12 +65,13 @@ namespace System.Transactions.Distributed protected DistributedTransaction(SerializationInfo serializationInfo, StreamingContext context) { - if (serializationInfo == null) - { - throw new ArgumentNullException(nameof(serializationInfo)); - } + //if (serializationInfo == null) + //{ + // throw new ArgumentNullException(nameof(serializationInfo)); + //} - throw NotSupported(); + //throw NotSupported(); + throw new PlatformNotSupportedException(); } internal Exception InnerException { get; set; } @@ -131,12 +132,14 @@ namespace System.Transactions.Distributed void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext context) { - if (serializationInfo == null) - { - throw new ArgumentNullException(nameof(serializationInfo)); - } + //if (serializationInfo == null) + //{ + // throw new ArgumentNullException(nameof(serializationInfo)); + //} - throw NotSupported(); + //throw NotSupported(); + + throw new PlatformNotSupportedException(); } internal static Exception NotSupported() diff --git a/src/System.Transactions.Local/src/System/Transactions/Transaction.cs b/src/System.Transactions.Local/src/System/Transactions/Transaction.cs index f7e7eacff0..32b02522f4 100644 --- a/src/System.Transactions.Local/src/System/Transactions/Transaction.cs +++ b/src/System.Transactions.Local/src/System/Transactions/Transaction.cs @@ -907,37 +907,39 @@ namespace System.Transactions SerializationInfo serializationInfo, StreamingContext context) { - TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; - if (etwLog.IsEnabled()) - { - etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this); - } - - if (Disposed) - { - throw new ObjectDisposedException(nameof(Transaction)); - } - - if (serializationInfo == null) - { - throw new ArgumentNullException(nameof(serializationInfo)); - } - - if (_complete) - { - throw TransactionException.CreateTransactionCompletedException(DistributedTxId); - } - - lock (_internalTransaction) - { - _internalTransaction.State.GetObjectData(_internalTransaction, serializationInfo, context); - } - - if (etwLog.IsEnabled()) - { - etwLog.TransactionSerialized(this, "Transaction"); - etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this); - } + //TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; + //if (etwLog.IsEnabled()) + //{ + // etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this); + //} + + //if (Disposed) + //{ + // throw new ObjectDisposedException(nameof(Transaction)); + //} + + //if (serializationInfo == null) + //{ + // throw new ArgumentNullException(nameof(serializationInfo)); + //} + + //if (_complete) + //{ + // throw TransactionException.CreateTransactionCompletedException(DistributedTxId); + //} + + //lock (_internalTransaction) + //{ + // _internalTransaction.State.GetObjectData(_internalTransaction, serializationInfo, context); + //} + + //if (etwLog.IsEnabled()) + //{ + // etwLog.TransactionSerialized(this, "Transaction"); + // etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this); + //} + + throw new PlatformNotSupportedException(); } /// <summary> diff --git a/src/System.Transactions.Local/src/System/Transactions/TransactionException.cs b/src/System.Transactions.Local/src/System/Transactions/TransactionException.cs index 48715382fa..aade4ab5f4 100644 --- a/src/System.Transactions.Local/src/System/Transactions/TransactionException.cs +++ b/src/System.Transactions.Local/src/System/Transactions/TransactionException.cs @@ -99,6 +99,7 @@ namespace System.Transactions /// <param name="context"></param> protected TransactionException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } internal static TransactionException Create(string message, Guid distributedTxId) @@ -239,6 +240,7 @@ namespace System.Transactions /// <param name="context"></param> protected TransactionAbortedException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } @@ -298,6 +300,7 @@ namespace System.Transactions /// <param name="context"></param> protected TransactionInDoubtException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } @@ -356,6 +359,7 @@ namespace System.Transactions /// <param name="context"></param> protected TransactionManagerCommunicationException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } @@ -393,6 +397,7 @@ namespace System.Transactions /// <param name="context"></param> protected TransactionPromotionException(SerializationInfo info, StreamingContext context) : base(info, context) { + throw new PlatformNotSupportedException(); } } } diff --git a/src/System.Transactions.Local/src/System/Transactions/TransactionState.cs b/src/System.Transactions.Local/src/System/Transactions/TransactionState.cs index 4660c929b4..473aaf607d 100644 --- a/src/System.Transactions.Local/src/System/Transactions/TransactionState.cs +++ b/src/System.Transactions.Local/src/System/Transactions/TransactionState.cs @@ -2078,7 +2078,6 @@ namespace System.Transactions serializableTx.GetObjectData(serializationInfo, context); } - internal override void ChangeStatePromotedAborted(InternalTransaction tx) { TransactionStatePromotedAborted.EnterState(tx); |