diff --git a/Directory.Build.props b/Directory.Build.props index ad6a2e5a52d39a..e47cbeb69b8c8d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -443,8 +443,8 @@ true - - $(NoWarn);SYSLIB0011 + + $(NoWarn);SYSLIB0011;SYSLIB0050;SYSLIB0051 $(NoWarn);IL2121 diff --git a/docs/project/list-of-diagnostics.md b/docs/project/list-of-diagnostics.md index a39981b4e9fdfd..4ed4d318fd746a 100644 --- a/docs/project/list-of-diagnostics.md +++ b/docs/project/list-of-diagnostics.md @@ -104,8 +104,8 @@ The PR that reveals the implementation of the ` GetCustomAttributesData() #endregion #region Public Virtuals + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs index 9fe38d5fe89af1..bc3b9cb9696d5c 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; @@ -667,6 +668,8 @@ internal static void RegisterCollectibleTypeDependency(RuntimeType type, Runtime RegisterCollectibleTypeDependency(new QCallTypeHandle(ref type), new QCallAssembly(ref assembly!)); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); @@ -777,6 +780,8 @@ private static IntPtr GetValueInternal(RuntimeMethodHandle rmh) } // ISerializable interface + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); @@ -1222,6 +1227,8 @@ internal static RuntimeType GetApproxDeclaringType(IRuntimeFieldInfo field) internal static extern LoaderAllocator GetLoaderAllocator(RuntimeFieldHandleInternal method); // ISerializable interface + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/MulticastDelegate.cs index 739ae037dbb36a..057db98ff670a9 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; @@ -408,6 +409,8 @@ protected override MethodInfo GetMethodImpl() return base.GetMethodImpl(); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(SR.Serialization_DelegatesNotSupported); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/RuntimeAssemblyInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/RuntimeAssemblyInfo.cs index 93c1252f62222b..bda0e77b3d4a33 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/RuntimeAssemblyInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/RuntimeAssemblyInfo.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -37,6 +38,8 @@ public sealed override string FullName } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public sealed override void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs index 098f960d29dbe4..58dd95e4ef74b1 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs @@ -63,10 +63,12 @@ public sealed override IEnumerable CustomAttributes } FieldAttributes attributes = Attributes; +#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete if (0 != (attributes & FieldAttributes.NotSerialized)) { yield return new RuntimePseudoCustomAttributeData(typeof(NonSerializedAttribute), null); } +#pragma warning restore SYSLIB0050 } } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Modules/RuntimeModule.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Modules/RuntimeModule.cs index 832628114097b5..d8c86e83cc91ea 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Modules/RuntimeModule.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Modules/RuntimeModule.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -55,6 +56,8 @@ public sealed override int GetHashCode() return Assembly.GetHashCode(); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public sealed override void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeArrayTypeInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeArrayTypeInfo.cs index f46dd9aa16f4c2..cbaf544c1b696d 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeArrayTypeInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeArrayTypeInfo.cs @@ -40,7 +40,9 @@ public sealed override int GetArrayRank() protected sealed override TypeAttributes GetAttributeFlagsImpl() { +#pragma warning disable SYSLIB0050 // TypeAttributes.Serializable is obsolete return TypeAttributes.AutoLayout | TypeAttributes.AnsiClass | TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Serializable; +#pragma warning restore SYSLIB0050 } internal sealed override IEnumerable SyntheticConstructors diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeNamedTypeInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeNamedTypeInfo.cs index 4e96a263cc0c50..988085b047c3fb 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeNamedTypeInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeNamedTypeInfo.cs @@ -42,8 +42,10 @@ public sealed override IEnumerable CustomAttributes if (0 != (attributes & TypeAttributes.Import)) yield return new RuntimePseudoCustomAttributeData(typeof(ComImportAttribute), null); +#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete if (0 != (attributes & TypeAttributes.Serializable)) yield return new RuntimePseudoCustomAttributeData(typeof(SerializableAttribute), null); +#pragma warning restore SYSLIB0050 } } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs index 527f040f10d360..7f8b164ba2b356 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -80,6 +81,8 @@ public override int GetHashCode() return !left.Equals(right); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs index 27e6c489030af9..ba7843ba7c75e8 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -119,6 +120,8 @@ public IntPtr GetFunctionPointer() return ReflectionAugments.ReflectionCoreCallbacks.GetFunctionPointer(this, declaringType); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs index ffd6d9de72bc19..cdf98172819758 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; @@ -107,6 +108,8 @@ public ModuleHandle GetModuleHandle() return type.Module.ModuleHandle; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackDecodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackDecodingException.cs index b0225bb6f9a140..ed2859df574455 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackDecodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackDecodingException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net.Http.HPack @@ -21,6 +22,8 @@ public HPackDecodingException(string message, Exception innerException) : base(m { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public HPackDecodingException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs index 287497b7ee115b..b83ca6502e8c55 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net.Http.HPack @@ -18,16 +19,26 @@ public HuffmanDecodingException(string message) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private HuffmanDecodingException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs index 760403267f45a1..5de0efff935d4f 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net.Http.QPack @@ -20,6 +21,9 @@ public QPackDecodingException(string message, Exception innerException) : base(m { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private QPackDecodingException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs index 6b5647e18e2e4d..7e6eb6f1b79280 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net.Http.QPack @@ -17,6 +18,9 @@ public QPackEncodingException(string message, Exception innerException) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private QPackEncodingException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs b/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs index 7c831aa2c43a83..14d23cad452391 100644 --- a/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs +++ b/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs @@ -35,6 +35,10 @@ public NetworkInformationException(int errorCode) : base(errorCode) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected NetworkInformationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } diff --git a/src/libraries/Common/src/System/Obsoletions.cs b/src/libraries/Common/src/System/Obsoletions.cs index 0358334a36537a..3f35696bfe4301 100644 --- a/src/libraries/Common/src/System/Obsoletions.cs +++ b/src/libraries/Common/src/System/Obsoletions.cs @@ -160,10 +160,10 @@ internal static class Obsoletions internal const string JsonSerializerOptionsAddContextMessage = "JsonSerializerOptions.AddContext is obsolete. To register a JsonSerializerContext, use either the TypeInfoResolver or TypeInfoResolverChain properties."; internal const string JsonSerializerOptionsAddContextDiagId = "SYSLIB0049"; - internal const string LegacyFormatterMessage = "(reserved for serialization work)"; + internal const string LegacyFormatterMessage = "Formatter-based serialization is obsolete and should not be used."; internal const string LegacyFormatterDiagId = "SYSLIB0050"; - internal const string LegacyFormatterImplMessage = "(reserved for serialization work)"; + internal const string LegacyFormatterImplMessage = "This API supports obsolete formatter-based serialization. It should not be called or extended by application code."; internal const string LegacyFormatterImplDiagId = "SYSLIB0051"; } } diff --git a/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs b/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs index b41fe846066263..3081a8bc239bad 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Security.Cryptography; #if !NETCOREAPP3_1_OR_GREATER @@ -43,11 +44,7 @@ public static CryptographicException ToCryptographicException(this int hr) [Serializable] private sealed class WindowsCryptographicException : CryptographicException { - private WindowsCryptographicException(SerializationInfo info, StreamingContext context) - { - Debug.Fail("This should never be called; we swap the active type during serialization."); - throw new NotImplementedException(); - } + // No need for a serialization ctor: we swap the active type during serialization. public WindowsCryptographicException(int hr, string message) : base(message) @@ -55,6 +52,10 @@ public WindowsCryptographicException(int hr, string message) HResult = hr; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { // This exception shouldn't be serialized since it's a private implementation diff --git a/src/libraries/Common/tests/Common.Tests.csproj b/src/libraries/Common/tests/Common.Tests.csproj index 5ed2a1ea9b5eae..2982390a3206dd 100644 --- a/src/libraries/Common/tests/Common.Tests.csproj +++ b/src/libraries/Common/tests/Common.Tests.csproj @@ -107,6 +107,7 @@ + throw Unexpected; public override bool IsSecuritySafeCritical => throw Unexpected; public override bool IsSecurityTransparent => throw Unexpected; +#if NET8_0_OR_GREATER + [Obsolete("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] +#endif public override bool IsSerializable => throw Unexpected; public override bool IsSubclassOf(Type c) => throw Unexpected; protected override bool IsValueTypeImpl() => throw Unexpected; diff --git a/src/libraries/Microsoft.CSharp/ref/Microsoft.CSharp.cs b/src/libraries/Microsoft.CSharp/ref/Microsoft.CSharp.cs index 38ddafe717632e..619bb40feb9d36 100644 --- a/src/libraries/Microsoft.CSharp/ref/Microsoft.CSharp.cs +++ b/src/libraries/Microsoft.CSharp/ref/Microsoft.CSharp.cs @@ -68,6 +68,8 @@ public enum CSharpBinderFlags public partial class RuntimeBinderException : System.Exception { public RuntimeBinderException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected RuntimeBinderException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RuntimeBinderException(string? message) { } public RuntimeBinderException(string? message, System.Exception? innerException) { } @@ -75,6 +77,8 @@ public RuntimeBinderException(string? message, System.Exception? innerException) public partial class RuntimeBinderInternalCompilerException : System.Exception { public RuntimeBinderInternalCompilerException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected RuntimeBinderInternalCompilerException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RuntimeBinderInternalCompilerException(string? message) { } public RuntimeBinderInternalCompilerException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft.CSharp.csproj b/src/libraries/Microsoft.CSharp/src/Microsoft.CSharp.csproj index d127968096df0c..ccee74eabc4ac9 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft.CSharp.csproj +++ b/src/libraries/Microsoft.CSharp/src/Microsoft.CSharp.csproj @@ -168,6 +168,8 @@ + /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected RuntimeBinderException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs index babe0e5e4c281d..16f19cfff84991 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderInternalCompilerException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Runtime.Serialization; namespace Microsoft.CSharp.RuntimeBinder @@ -46,6 +47,8 @@ public RuntimeBinderInternalCompilerException(string? message, Exception? innerE /// /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected RuntimeBinderInternalCompilerException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs index c8b88f3218c45f..bb5f8b675a08dc 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs @@ -11,6 +11,9 @@ namespace Microsoft.Extensions.Hosting [Serializable] public sealed class HostAbortedException : Exception { +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private HostAbortedException(SerializationInfo info, StreamingContext context) : base(info, context) { } /// diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Microsoft.Extensions.Hosting.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Microsoft.Extensions.Hosting.Abstractions.csproj index 8ff8abe585f6de..598d4bd69cbd53 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Microsoft.Extensions.Hosting.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Microsoft.Extensions.Hosting.Abstractions.csproj @@ -10,6 +10,7 @@ + diff --git a/src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.cs b/src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.cs index 554e10b8ba2075..b9f446cabedd5c 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/ref/Microsoft.VisualBasic.Core.cs @@ -1296,7 +1296,8 @@ public static void WriteAllText(string file, string text, bool append, System.Te public partial class MalformedLineException : System.Exception { public MalformedLineException() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MalformedLineException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MalformedLineException(string? message) { } public MalformedLineException(string? message, System.Exception? innerException) { } @@ -1304,7 +1305,8 @@ public MalformedLineException(string? message, long lineNumber) { } public MalformedLineException(string? message, long lineNumber, System.Exception? innerException) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Always)] public long LineNumber { get { throw null; } set { } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/MalformedLineException.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/MalformedLineException.vb index adcab1329dd581..396397b615ec1d 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/MalformedLineException.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/FileIO/MalformedLineException.vb @@ -73,7 +73,9 @@ Namespace Microsoft.VisualBasic.FileIO ''' ''' ''' - + ' [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + + Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) MyBase.New(info, context) @@ -105,7 +107,9 @@ Namespace Microsoft.VisualBasic.FileIO ''' ''' ''' - + ' [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + + Public Overrides Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) If info IsNot Nothing Then ' Fix FxCop violation ValidateArgumentsOfPublicMethods. info.AddValue(LINE_NUMBER_PROPERTY, m_LineNumber, GetType(Long)) diff --git a/src/libraries/Microsoft.Win32.Primitives/ref/Microsoft.Win32.Primitives.cs b/src/libraries/Microsoft.Win32.Primitives/ref/Microsoft.Win32.Primitives.cs index 7403f5ae4ff2cb..042ad4bbf0de6f 100644 --- a/src/libraries/Microsoft.Win32.Primitives/ref/Microsoft.Win32.Primitives.cs +++ b/src/libraries/Microsoft.Win32.Primitives/ref/Microsoft.Win32.Primitives.cs @@ -6,15 +6,19 @@ namespace System.ComponentModel { - public partial class Win32Exception : System.Runtime.InteropServices.ExternalException, System.Runtime.Serialization.ISerializable + public partial class Win32Exception : System.Runtime.InteropServices.ExternalException { public Win32Exception() { } public Win32Exception(int error) { } public Win32Exception(int error, string? message) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected Win32Exception(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public Win32Exception(string? message) { } public Win32Exception(string? message, System.Exception? innerException) { } public int NativeErrorCode { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs b/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs index 037dcf84df7a42..b7ef07bf1e3dfe 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeDomProvider.cs @@ -215,10 +215,6 @@ private ICodeParser CreateParserHelper() private sealed class ConfigurationErrorsException : SystemException { public ConfigurationErrorsException(string message) : base(message) { } - public ConfigurationErrorsException(SerializationInfo info, StreamingContext context) : base(info, context) - { - throw new PlatformNotSupportedException(); - } } } } diff --git a/src/libraries/System.Collections.Specialized/ref/System.Collections.Specialized.cs b/src/libraries/System.Collections.Specialized/ref/System.Collections.Specialized.cs index 00fc77efe910c2..b91fe8eb10820d 100644 --- a/src/libraries/System.Collections.Specialized/ref/System.Collections.Specialized.cs +++ b/src/libraries/System.Collections.Specialized/ref/System.Collections.Specialized.cs @@ -96,6 +96,8 @@ protected NameObjectCollectionBase(int capacity) { } protected NameObjectCollectionBase(int capacity, System.Collections.IEqualityComparer? equalityComparer) { } [System.ObsoleteAttribute("This constructor has been deprecated. Use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")] protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NameObjectCollectionBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual int Count { get { throw null; } } protected bool IsReadOnly { get { throw null; } set { } } @@ -116,6 +118,8 @@ protected void BaseRemoveAt(int index) { } protected void BaseSet(int index, object? value) { } protected void BaseSet(string? name, object? value) { } public virtual System.Collections.IEnumerator GetEnumerator() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual void OnDeserialization(object? sender) { } void System.Collections.ICollection.CopyTo(System.Array array, int index) { } @@ -143,6 +147,8 @@ public NameValueCollection(int capacity, System.Collections.IEqualityComparer? e [System.ObsoleteAttribute("This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.")] public NameValueCollection(int capacity, System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer) { } public NameValueCollection(int capacity, System.Collections.Specialized.NameValueCollection col) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NameValueCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual string?[] AllKeys { get { throw null; } } public string? this[int index] { get { throw null; } } @@ -167,6 +173,8 @@ public OrderedDictionary() { } public OrderedDictionary(System.Collections.IEqualityComparer? comparer) { } public OrderedDictionary(int capacity) { } public OrderedDictionary(int capacity, System.Collections.IEqualityComparer? comparer) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected OrderedDictionary(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } @@ -183,6 +191,8 @@ public void Clear() { } public bool Contains(object key) { throw null; } public void CopyTo(System.Array array, int index) { } public virtual System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void Insert(int index, object key, object? value) { } protected virtual void OnDeserialization(object? sender) { } diff --git a/src/libraries/System.Collections.Specialized/src/System.Collections.Specialized.csproj b/src/libraries/System.Collections.Specialized/src/System.Collections.Specialized.csproj index 7a340228a3533d..72b32ed04ee5fa 100644 --- a/src/libraries/System.Collections.Specialized/src/System.Collections.Specialized.csproj +++ b/src/libraries/System.Collections.Specialized/src/System.Collections.Specialized.csproj @@ -14,6 +14,8 @@ + diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs index 0d979fce371016..88f03f90401658 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs @@ -10,6 +10,7 @@ #pragma warning disable 618 // obsolete types, namely IHashCodeProvider +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.Serialization; @@ -77,11 +78,15 @@ protected NameObjectCollectionBase(int capacity) Reset(capacity); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NameObjectCollectionBase(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs index cb8814663043fa..6337a341d21192 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs @@ -7,6 +7,7 @@ * */ +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; using System.Text; @@ -89,6 +90,8 @@ public NameValueCollection(int capacity, IHashCodeProvider? hashProvider, ICompa { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NameValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs index 82a0c188c6bff7..7e445ce3e5fc3e 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; @@ -64,6 +65,8 @@ private OrderedDictionary(OrderedDictionary dictionary) _initialCapacity = dictionary._initialCapacity; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected OrderedDictionary(SerializationInfo info, StreamingContext context) { // We can't do anything with the keys and values until the entire graph has been deserialized @@ -376,6 +379,8 @@ IEnumerator IEnumerable.GetEnumerator() #endregion #region ISerializable implementation + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); diff --git a/src/libraries/System.Collections/ref/System.Collections.cs b/src/libraries/System.Collections/ref/System.Collections.cs index ed0eda8dd458b0..b0272046b38412 100644 --- a/src/libraries/System.Collections/ref/System.Collections.cs +++ b/src/libraries/System.Collections/ref/System.Collections.cs @@ -57,6 +57,8 @@ public partial class LinkedList : System.Collections.Generic.ICollection, { public LinkedList() { } public LinkedList(System.Collections.Generic.IEnumerable collection) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected LinkedList(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public int Count { get { throw null; } } public System.Collections.Generic.LinkedListNode? First { get { throw null; } } @@ -78,6 +80,8 @@ public void CopyTo(T[] array, int index) { } public System.Collections.Generic.LinkedListNode? Find(T value) { throw null; } public System.Collections.Generic.LinkedListNode? FindLast(T value) { throw null; } public System.Collections.Generic.LinkedList.Enumerator GetEnumerator() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual void OnDeserialization(object? sender) { } public void Remove(System.Collections.Generic.LinkedListNode node) { } @@ -313,6 +317,8 @@ public SortedSet() { } public SortedSet(System.Collections.Generic.IComparer? comparer) { } public SortedSet(System.Collections.Generic.IEnumerable collection) { } public SortedSet(System.Collections.Generic.IEnumerable collection, System.Collections.Generic.IComparer? comparer) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SortedSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Collections.Generic.IComparer Comparer { get { throw null; } } public int Count { get { throw null; } } @@ -435,6 +441,8 @@ public Dictionary(System.Collections.Generic.IEnumerable? comparer) { } public Dictionary(int capacity) { } public Dictionary(int capacity, System.Collections.Generic.IEqualityComparer? comparer) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected Dictionary(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Collections.Generic.IEqualityComparer Comparer { get { throw null; } } public int Count { get { throw null; } } @@ -459,6 +467,8 @@ public void Clear() { } public bool ContainsValue(TValue value) { throw null; } public int EnsureCapacity(int capacity) { throw null; } public System.Collections.Generic.Dictionary.Enumerator GetEnumerator() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual void OnDeserialization(object? sender) { } public bool Remove(TKey key) { throw null; } @@ -566,6 +576,8 @@ public HashSet(System.Collections.Generic.IEnumerable collection, System.Coll public HashSet(System.Collections.Generic.IEqualityComparer? comparer) { } public HashSet(int capacity) { } public HashSet(int capacity, System.Collections.Generic.IEqualityComparer? comparer) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected HashSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Collections.Generic.IEqualityComparer Comparer { get { throw null; } } public int Count { get { throw null; } } @@ -580,6 +592,8 @@ public void CopyTo(T[] array, int arrayIndex, int count) { } public int EnsureCapacity(int capacity) { throw null; } public void ExceptWith(System.Collections.Generic.IEnumerable other) { } public System.Collections.Generic.HashSet.Enumerator GetEnumerator() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void IntersectWith(System.Collections.Generic.IEnumerable other) { } public bool IsProperSubsetOf(System.Collections.Generic.IEnumerable other) { throw null; } diff --git a/src/libraries/System.Collections/src/System.Collections.csproj b/src/libraries/System.Collections/src/System.Collections.csproj index 102ab0ee950ddf..a7e8976d48bfcd 100644 --- a/src/libraries/System.Collections/src/System.Collections.csproj +++ b/src/libraries/System.Collections/src/System.Collections.csproj @@ -29,6 +29,8 @@ Link="Common\System\Collections\Generic\BitHelper.cs" /> + diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/LinkedList.cs b/src/libraries/System.Collections/src/System/Collections/Generic/LinkedList.cs index a50dce3b158946..14dbc030d7a148 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/LinkedList.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/LinkedList.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -38,6 +39,8 @@ public LinkedList(IEnumerable collection) } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected LinkedList(SerializationInfo info, StreamingContext context) { _siInfo = info; @@ -318,6 +321,8 @@ public void RemoveLast() InternalRemoveNode(head.prev!); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs index 64d745a778fcef..78fefca3e0321c 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs @@ -893,6 +893,7 @@ public TreeSet(IComparer? comparer) : base(comparer) { } internal TreeSet(TreeSet set, IComparer? comparer) : base(set, comparer) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private TreeSet(SerializationInfo siInfo, StreamingContext context) : base(siInfo, context) { } internal override bool AddIfNotPresent(T item) diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs index 3282996e5bc5d3..13282ba2137e3b 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -125,6 +126,8 @@ public SortedSet(IEnumerable collection, IComparer? comparer) } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SortedSet(SerializationInfo info, StreamingContext context) => siInfo = info; #endregion diff --git a/src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs b/src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs index 9dc07077afd00d..a46192e9dd95b6 100644 --- a/src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs +++ b/src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs @@ -360,6 +360,8 @@ public partial class ValidationException : System.Exception { public ValidationException() { } public ValidationException(System.ComponentModel.DataAnnotations.ValidationResult validationResult, System.ComponentModel.DataAnnotations.ValidationAttribute? validatingAttribute, object? value) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ValidationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ValidationException(string? message) { } public ValidationException(string? errorMessage, System.ComponentModel.DataAnnotations.ValidationAttribute? validatingAttribute, object? value) { } diff --git a/src/libraries/System.ComponentModel.Annotations/src/System.ComponentModel.Annotations.csproj b/src/libraries/System.ComponentModel.Annotations/src/System.ComponentModel.Annotations.csproj index 7f273f3dc5b1f6..40eb3b829bedfb 100644 --- a/src/libraries/System.ComponentModel.Annotations/src/System.ComponentModel.Annotations.csproj +++ b/src/libraries/System.ComponentModel.Annotations/src/System.ComponentModel.Annotations.csproj @@ -60,6 +60,7 @@ + diff --git a/src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs b/src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs index 8e82711afa3c6f..79cf8bd1046278 100644 --- a/src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs +++ b/src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.ComponentModel.DataAnnotations @@ -74,6 +75,8 @@ public ValidationException(string? message, Exception? innerException) /// /// The SerializationInfo. /// The StreamingContext. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ValidationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs b/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs index 60accaee91e879..b9528f89e7a02b 100644 --- a/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs +++ b/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs @@ -55,6 +55,10 @@ public ChangeRejectedException(string? message, System.Exception? innerException public partial class CompositionContractMismatchException : System.Exception { public CompositionContractMismatchException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected CompositionContractMismatchException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CompositionContractMismatchException(string? message) { } public CompositionContractMismatchException(string? message, System.Exception? innerException) { } @@ -141,6 +145,10 @@ public ImportAttribute(System.Type? contractType) { } public partial class ImportCardinalityMismatchException : System.Exception { public ImportCardinalityMismatchException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ImportCardinalityMismatchException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ImportCardinalityMismatchException(string? message) { } public ImportCardinalityMismatchException(string? message, System.Exception? innerException) { } @@ -535,12 +543,20 @@ protected ComposablePartDefinition() { } public partial class ComposablePartException : System.Exception { public ComposablePartException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ComposablePartException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ComposablePartException(string? message) { } public ComposablePartException(string? message, System.ComponentModel.Composition.Primitives.ICompositionElement? element) { } public ComposablePartException(string? message, System.ComponentModel.Composition.Primitives.ICompositionElement? element, System.Exception? innerException) { } public ComposablePartException(string? message, System.Exception? innerException) { } public System.ComponentModel.Composition.Primitives.ICompositionElement? Element { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class ContractBasedImportDefinition : System.ComponentModel.Composition.Primitives.ImportDefinition diff --git a/src/libraries/System.ComponentModel.Composition/src/System.ComponentModel.Composition.csproj b/src/libraries/System.ComponentModel.Composition/src/System.ComponentModel.Composition.csproj index 87848420f25f37..0c043fd8a11c8a 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System.ComponentModel.Composition.csproj +++ b/src/libraries/System.ComponentModel.Composition/src/System.ComponentModel.Composition.csproj @@ -202,5 +202,7 @@ System.ComponentModel.Composition.ReflectionModel.ReflectionModelServices + diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs index 498ba7b641cc0c..73b8f0b233529c 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.ComponentModel.Composition @@ -76,6 +77,10 @@ public CompositionContractMismatchException(string? message, Exception? innerExc /// /// contains a value that cannot be cast to the correct type. /// +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected CompositionContractMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs index 343039d831319a..898934ac298a25 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; @@ -79,6 +80,10 @@ public ImportCardinalityMismatchException(string? message, Exception? innerExcep /// /// contains a value that cannot be cast to the correct type. /// +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ImportCardinalityMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs index f719cd5b71ef22..95a0369cd02024 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; @@ -46,6 +47,10 @@ public ComposablePartException() /// /// contains a value that cannot be cast to the correct type. /// +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ComposablePartException(SerializationInfo info, StreamingContext context) : base(info, context) { _element = (ICompositionElement?)info.GetValue("Element", typeof(ICompositionElement)); @@ -159,6 +164,10 @@ public ICompositionElement? Element /// /// is . /// +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs b/src/libraries/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs index 2575dcf5013de0..cb865483618587 100644 --- a/src/libraries/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs +++ b/src/libraries/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs @@ -221,6 +221,8 @@ public InitializationEventAttribute(string eventName) { } public partial class InvalidAsynchronousStateException : System.ArgumentException { public InvalidAsynchronousStateException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidAsynchronousStateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidAsynchronousStateException(string? message) { } public InvalidAsynchronousStateException(string? message, System.Exception? innerException) { } @@ -228,6 +230,8 @@ public InvalidAsynchronousStateException(string? message, System.Exception? inne public partial class InvalidEnumArgumentException : System.ArgumentException { public InvalidEnumArgumentException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidEnumArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidEnumArgumentException(string? message) { } public InvalidEnumArgumentException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.ComponentModel.Primitives/src/System.ComponentModel.Primitives.csproj b/src/libraries/System.ComponentModel.Primitives/src/System.ComponentModel.Primitives.csproj index 70b4d97cc473f4..fe840c389fd159 100644 --- a/src/libraries/System.ComponentModel.Primitives/src/System.ComponentModel.Primitives.csproj +++ b/src/libraries/System.ComponentModel.Primitives/src/System.ComponentModel.Primitives.csproj @@ -38,6 +38,7 @@ + diff --git a/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidAsynchronousStateException.cs b/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidAsynchronousStateException.cs index d72bf2d2e1703e..335ade13eff7c8 100644 --- a/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidAsynchronousStateException.cs +++ b/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidAsynchronousStateException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -38,6 +39,8 @@ public InvalidAsynchronousStateException(string? message, Exception? innerExcept { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidAsynchronousStateException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidEnumArgumentException.cs b/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidEnumArgumentException.cs index 567e6a7408cb8a..db2dde302c9c99 100644 --- a/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidEnumArgumentException.cs +++ b/src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/InvalidEnumArgumentException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -56,6 +57,8 @@ public InvalidEnumArgumentException(string? argumentName, int invalidValue, Type /// Need this constructor since Exception implements ISerializable. /// We don't have any fields, so just forward this to base. /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidEnumArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs index 571f81e9f66911..a558073df75981 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs @@ -721,12 +721,16 @@ public virtual void SetSavedLicenseKey(System.Type type, string key) { } } public partial class LicenseException : System.SystemException { + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected LicenseException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public LicenseException(System.Type? type) { } public LicenseException(System.Type? type, object? instance) { } public LicenseException(System.Type? type, object? instance, string? message) { } public LicenseException(System.Type? type, object? instance, string? message, System.Exception? innerException) { } public System.Type? LicensedType { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public sealed partial class LicenseManager @@ -1581,6 +1585,8 @@ public VersionConverter() { } public partial class WarningException : System.SystemException { public WarningException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WarningException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public WarningException(string? message) { } public WarningException(string? message, System.Exception? innerException) { } @@ -1588,6 +1594,8 @@ public WarningException(string? message, string? helpUrl) { } public WarningException(string? message, string? helpUrl, string? helpTopic) { } public string? HelpTopic { get { throw null; } } public string? HelpUrl { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } @@ -1604,6 +1612,8 @@ public partial class CheckoutException : System.Runtime.InteropServices.External { public static readonly System.ComponentModel.Design.CheckoutException Canceled; public CheckoutException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CheckoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CheckoutException(string? message) { } public CheckoutException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index 55ae3dff4e3dbe..f8b998c751ef22 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -99,6 +99,8 @@ + diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs index 7605b016a1af0e..c4a20c0cbe6cab 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/CheckoutException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -50,6 +51,8 @@ public CheckoutException(string? message, int errorCode) : base(message, errorCo /// Need this constructor since Exception implements ISerializable. We don't have any fields, /// so just forward this to base. /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CheckoutException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs index 179b41324198d1..8fad86404e5352 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs @@ -52,9 +52,9 @@ public static void Serialize(Stream o, string cryptoKey, DesigntimeLicenseContex private static void SerializeWithBinaryFormatter(Stream o, string cryptoKey, DesigntimeLicenseContext context) { - var formatter = new BinaryFormatter(); #pragma warning disable SYSLIB0011 #pragma warning disable IL2026 // suppressed in ILLink.Suppressions.LibraryBuild.xml + var formatter = new BinaryFormatter(); formatter.Serialize(o, new object[] { cryptoKey, context._savedLicenseKeys }); #pragma warning restore IL2026 #pragma warning restore SYSLIB0011 diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs index 715ba7b9a8e10a..9e96a64860b981 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -57,6 +58,8 @@ public LicenseException(Type? type, object? instance, string? message, Exception /// /// Need this constructor since Exception implements ISerializable. /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected LicenseException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -69,6 +72,8 @@ protected LicenseException(SerializationInfo info, StreamingContext context) : b /// /// Need this since Exception implements ISerializable. /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs index 211ee6781b85fe..f49b0e12c580b5 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/WarningException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.ComponentModel @@ -58,6 +59,8 @@ public WarningException(string? message, string? helpUrl, string? helpTopic) : b /// /// Need this constructor since Exception implements ISerializable. /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WarningException(SerializationInfo info, StreamingContext context) : base(info, context) { HelpUrl = (string?)info.GetValue("helpUrl", typeof(string)); @@ -74,6 +77,8 @@ protected WarningException(SerializationInfo info, StreamingContext context) : b /// public string? HelpTopic { get; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs b/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs index 7ef3558b7f6649..a3121e8525d77d 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs @@ -268,6 +268,10 @@ public ConfigurationElementProperty(System.Configuration.ConfigurationValidatorB public partial class ConfigurationErrorsException : System.Configuration.ConfigurationException { public ConfigurationErrorsException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ConfigurationErrorsException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ConfigurationErrorsException(string message) { } public ConfigurationErrorsException(string message, System.Exception inner) { } @@ -286,12 +290,20 @@ public ConfigurationErrorsException(string message, System.Xml.XmlReader reader) public static string GetFilename(System.Xml.XmlReader reader) { throw null; } public static int GetLineNumber(System.Xml.XmlNode node) { throw null; } public static int GetLineNumber(System.Xml.XmlReader reader) { throw null; } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class ConfigurationException : System.SystemException { [System.ObsoleteAttribute("ConfigurationException has been deprecated. Use System.Configuration.ConfigurationErrorsException instead.")] public ConfigurationException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ConfigurationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.ObsoleteAttribute("ConfigurationException has been deprecated. Use System.Configuration.ConfigurationErrorsException instead.")] public ConfigurationException(string message) { } @@ -309,6 +321,10 @@ public ConfigurationException(string message, System.Xml.XmlNode node) { } public virtual string Filename { get { throw null; } } public virtual int Line { get { throw null; } } public override string Message { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.ObsoleteAttribute("ConfigurationException has been deprecated. Use System.Configuration.ConfigurationErrorsException.GetFilename instead.")] public static string GetXmlNodeFilename(System.Xml.XmlNode node) { throw null; } @@ -455,6 +471,10 @@ public void CopyTo(System.Configuration.ConfigurationSection[] array, int index) public System.Configuration.ConfigurationSection Get(string name) { throw null; } public override System.Collections.IEnumerator GetEnumerator() { throw null; } public string GetKey(int index) { throw null; } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void Remove(string name) { } public void RemoveAt(int index) { } @@ -487,6 +507,10 @@ public void CopyTo(System.Configuration.ConfigurationSectionGroup[] array, int i public System.Configuration.ConfigurationSectionGroup Get(string name) { throw null; } public override System.Collections.IEnumerator GetEnumerator() { throw null; } public string GetKey(int index) { throw null; } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void Remove(string name) { } public void RemoveAt(int index) { } @@ -864,6 +888,10 @@ internal PropertyInformationCollection() { } public System.Configuration.PropertyInformation this[string propertyName] { get { throw null; } } public void CopyTo(System.Configuration.PropertyInformation[] array, int index) { } public override System.Collections.IEnumerator GetEnumerator() { throw null; } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public enum PropertyValueOrigin @@ -1146,6 +1174,10 @@ public void SetReadOnly() { } public partial class SettingsPropertyIsReadOnlyException : System.Exception { public SettingsPropertyIsReadOnlyException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected SettingsPropertyIsReadOnlyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SettingsPropertyIsReadOnlyException(string message) { } public SettingsPropertyIsReadOnlyException(string message, System.Exception innerException) { } @@ -1153,6 +1185,10 @@ public SettingsPropertyIsReadOnlyException(string message, System.Exception inne public partial class SettingsPropertyNotFoundException : System.Exception { public SettingsPropertyNotFoundException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected SettingsPropertyNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SettingsPropertyNotFoundException(string message) { } public SettingsPropertyNotFoundException(string message, System.Exception innerException) { } @@ -1186,6 +1222,10 @@ public void SetReadOnly() { } public partial class SettingsPropertyWrongTypeException : System.Exception { public SettingsPropertyWrongTypeException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected SettingsPropertyWrongTypeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SettingsPropertyWrongTypeException(string message) { } public SettingsPropertyWrongTypeException(string message, System.Exception innerException) { } @@ -1571,6 +1611,10 @@ void System.Collections.ICollection.CopyTo(System.Array array, int index) { } public partial class ProviderException : System.Exception { public ProviderException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ProviderException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ProviderException(string message) { } public ProviderException(string message, System.Exception innerException) { } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs index 5cc2b89c8aaf90..e78b7ecbd7fa78 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration.Internal; using System.Globalization; using System.IO; @@ -100,6 +101,10 @@ internal ConfigurationErrorsException(ArrayList coll) : coll.CopyTo(_errors, 0); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ConfigurationErrorsException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -191,6 +196,10 @@ private static ConfigurationException GetFirstException(ICollection Get(name); public ConfigurationSection this[int index] => Get(index); diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs index 98341b706b73f5..a0e163d6eb3550 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Provider/ProviderException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Configuration.Provider @@ -19,6 +20,10 @@ public ProviderException(string message, Exception innerException) : base(message, innerException) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ProviderException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs index 48f1364b89f624..5291d82555fbef 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsAttributeDictionary.cs @@ -13,7 +13,6 @@ public SettingsAttributeDictionary() : base() { } public SettingsAttributeDictionary(SettingsAttributeDictionary attributes) : base(attributes) { } protected SettingsAttributeDictionary(SerializationInfo serializationInfo, StreamingContext streamingContext) - : base(serializationInfo, streamingContext) { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs index 0a9a47210536c9..2834f365d12340 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsContext.cs @@ -11,7 +11,6 @@ public class SettingsContext : Hashtable public SettingsContext() : base() { } protected SettingsContext(SerializationInfo serializationInfo, StreamingContext streamingContext) - : base(serializationInfo, streamingContext) { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs index 44bcb81ef60a5a..e8988c01f2f152 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyIsReadOnlyException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Configuration @@ -19,6 +20,10 @@ public SettingsPropertyIsReadOnlyException(string message, Exception innerExcept { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected SettingsPropertyIsReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs index 15ad57f97fc6c5..51cd1c7119beeb 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Configuration @@ -19,6 +20,10 @@ public SettingsPropertyNotFoundException(string message, Exception innerExceptio { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected SettingsPropertyNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs index ade0cb641debb0..9ce44c1c31a936 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyWrongTypeException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Configuration @@ -19,6 +20,10 @@ public SettingsPropertyWrongTypeException(string message, Exception innerExcepti { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected SettingsPropertyWrongTypeException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Data.Common/ref/System.Data.Common.cs b/src/libraries/System.Data.Common/ref/System.Data.Common.cs index c8565ae45e1901..3cbdeed1263ce9 100644 --- a/src/libraries/System.Data.Common/ref/System.Data.Common.cs +++ b/src/libraries/System.Data.Common/ref/System.Data.Common.cs @@ -88,6 +88,8 @@ public void RemoveAt(int index) { } public partial class ConstraintException : System.Data.DataException { public ConstraintException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ConstraintException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ConstraintException(string? s) { } public ConstraintException(string? message, System.Exception? innerException) { } @@ -194,6 +196,8 @@ public void RemoveAt(int index) { } public partial class DataException : System.SystemException { public DataException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DataException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DataException(string? s) { } public DataException(string? s, System.Exception? innerException) { } @@ -494,9 +498,13 @@ public partial class DataSet : System.ComponentModel.MarshalByValueComponent, Sy public DataSet() { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Members from serialized types may use dynamic code generation.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Members from serialized types may use dynamic code generation.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema) { } public DataSet(string dataSetName) { } [System.ComponentModel.DefaultValueAttribute(false)] @@ -548,6 +556,8 @@ public void EndInit() { } public System.Data.DataSet? GetChanges() { throw null; } public System.Data.DataSet? GetChanges(System.Data.DataRowState rowStates) { throw null; } public static System.Xml.Schema.XmlSchemaComplexType GetDataSetSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected virtual System.Xml.Schema.XmlSchema? GetSchemaSerializable() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Members from serialized types may use dynamic code generation.")] @@ -680,6 +690,8 @@ public partial class DataTable : System.ComponentModel.MarshalByValueComponent, protected internal bool fInitInProgress; public DataTable() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DataTable(string? tableName) { } public DataTable(string? tableName, string? tableNamespace) { } @@ -754,6 +766,8 @@ public void EndLoadData() { } public System.Data.DataTable? GetChanges(System.Data.DataRowState rowStates) { throw null; } public static System.Xml.Schema.XmlSchemaComplexType GetDataTableSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; } public System.Data.DataRow[] GetErrors() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected virtual System.Type GetRowType() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] @@ -1166,6 +1180,8 @@ public DBConcurrencyException(string? message, System.Exception? inner, System.D public int RowCount { get { throw null; } } public void CopyToRows(System.Data.DataRow[] array) { } public void CopyToRows(System.Data.DataRow[] array, int arrayIndex) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public enum DbType @@ -1201,6 +1217,8 @@ public enum DbType public partial class DeletedRowInaccessibleException : System.Data.DataException { public DeletedRowInaccessibleException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DeletedRowInaccessibleException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DeletedRowInaccessibleException(string? s) { } public DeletedRowInaccessibleException(string? message, System.Exception? innerException) { } @@ -1208,6 +1226,8 @@ public DeletedRowInaccessibleException(string? message, System.Exception? innerE public partial class DuplicateNameException : System.Data.DataException { public DuplicateNameException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DuplicateNameException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DuplicateNameException(string? s) { } public DuplicateNameException(string? message, System.Exception? innerException) { } @@ -1240,6 +1260,8 @@ internal EnumerableRowCollection() { } public partial class EvaluateException : System.Data.InvalidExpressionException { public EvaluateException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected EvaluateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public EvaluateException(string? s) { } public EvaluateException(string? message, System.Exception? innerException) { } @@ -1421,6 +1443,8 @@ public partial interface IDbTransaction : System.IDisposable public partial class InRowChangingEventException : System.Data.DataException { public InRowChangingEventException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InRowChangingEventException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InRowChangingEventException(string? s) { } public InRowChangingEventException(string? message, System.Exception? innerException) { } @@ -1443,6 +1467,8 @@ public virtual void CopyTo(System.Array ar, int index) { } public partial class InvalidConstraintException : System.Data.DataException { public InvalidConstraintException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidConstraintException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidConstraintException(string? s) { } public InvalidConstraintException(string? message, System.Exception? innerException) { } @@ -1450,6 +1476,8 @@ public InvalidConstraintException(string? message, System.Exception? innerExcept public partial class InvalidExpressionException : System.Data.DataException { public InvalidExpressionException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidExpressionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidExpressionException(string? s) { } public InvalidExpressionException(string? message, System.Exception? innerException) { } @@ -1513,6 +1541,8 @@ public enum MissingMappingAction public partial class MissingPrimaryKeyException : System.Data.DataException { public MissingPrimaryKeyException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MissingPrimaryKeyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MissingPrimaryKeyException(string? s) { } public MissingPrimaryKeyException(string? message, System.Exception? innerException) { } @@ -1527,6 +1557,8 @@ public enum MissingSchemaAction public partial class NoNullAllowedException : System.Data.DataException { public NoNullAllowedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NoNullAllowedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public NoNullAllowedException(string? s) { } public NoNullAllowedException(string? message, System.Exception? innerException) { } @@ -1545,12 +1577,16 @@ public enum ParameterDirection public partial class PropertyCollection : System.Collections.Hashtable, System.ICloneable { public PropertyCollection() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected PropertyCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override object Clone() { throw null; } } public partial class ReadOnlyException : System.Data.DataException { public ReadOnlyException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ReadOnlyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ReadOnlyException(string? s) { } public ReadOnlyException(string? message, System.Exception? innerException) { } @@ -1558,6 +1594,8 @@ public ReadOnlyException(string? message, System.Exception? innerException) { } public partial class RowNotInTableException : System.Data.DataException { public RowNotInTableException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected RowNotInTableException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RowNotInTableException(string? s) { } public RowNotInTableException(string? message, System.Exception? innerException) { } @@ -1643,6 +1681,8 @@ public enum StatementType public partial class StrongTypingException : System.Data.DataException { public StrongTypingException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected StrongTypingException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public StrongTypingException(string? message) { } public StrongTypingException(string? s, System.Exception? innerException) { } @@ -1650,6 +1690,8 @@ public StrongTypingException(string? s, System.Exception? innerException) { } public partial class SyntaxErrorException : System.Data.InvalidExpressionException { public SyntaxErrorException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SyntaxErrorException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SyntaxErrorException(string? s) { } public SyntaxErrorException(string? message, System.Exception? innerException) { } @@ -1669,6 +1711,8 @@ public abstract partial class TypedTableBase : System.Data.DataTable, System. { protected TypedTableBase() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")] + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TypedTableBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Data.EnumerableRowCollection Cast() { throw null; } public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } @@ -1713,6 +1757,8 @@ public enum UpdateStatus public partial class VersionNotFoundException : System.Data.DataException { public VersionNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected VersionNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public VersionNotFoundException(string? s) { } public VersionNotFoundException(string? message, System.Exception? innerException) { } @@ -2450,6 +2496,8 @@ public void Reset() { } public abstract partial class DbException : System.Runtime.InteropServices.ExternalException { protected DbException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected DbException(string? message) { } protected DbException(string? message, System.Exception? innerException) { } @@ -3731,6 +3779,8 @@ public SqlTruncateException(string? message, System.Exception? e) { } public partial class SqlTypeException : System.SystemException { public SqlTypeException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SqlTypeException(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc) { } public SqlTypeException(string? message) { } public SqlTypeException(string? message, System.Exception? e) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbException.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbException.cs index 55b0bce2fddc92..78cc96a4a6b946 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbException.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; + namespace System.Data.Common { [Serializable] @@ -15,6 +17,8 @@ protected DbException(string? message, System.Exception? innerException) : base( protected DbException(string? message, int errorCode) : base(message, errorCode) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs b/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs index 871fc6cd1b9def..e99408d9567903 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DBConcurrencyException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -31,10 +32,13 @@ public DBConcurrencyException(string? message, Exception? inner, DataRow[]? data _dataRows = dataRows; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private DBConcurrencyException(SerializationInfo info, StreamingContext context) : base(info, context) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataException.cs b/src/libraries/System.Data.Common/src/System/Data/DataException.cs index 4068e1aa8f4afb..556dcba9ae9feb 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataException.cs @@ -12,6 +12,8 @@ namespace System.Data [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class DataException : SystemException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DataException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -33,6 +35,8 @@ public DataException(string? s, Exception? innerException) : base(s, innerExcept [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ConstraintException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -57,6 +61,8 @@ public ConstraintException(string? message, Exception? innerException) : base(me [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class DeletedRowInaccessibleException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DeletedRowInaccessibleException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -87,6 +93,8 @@ public DeletedRowInaccessibleException(string? message, Exception? innerExceptio [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class DuplicateNameException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DuplicateNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -111,6 +119,8 @@ public DuplicateNameException(string? message, Exception? innerException) : base [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class InRowChangingEventException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InRowChangingEventException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -135,6 +145,8 @@ public InRowChangingEventException(string? message, Exception? innerException) : [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class InvalidConstraintException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -159,6 +171,8 @@ public InvalidConstraintException(string? message, Exception? innerException) : [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class MissingPrimaryKeyException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MissingPrimaryKeyException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -183,6 +197,8 @@ public MissingPrimaryKeyException(string? message, Exception? innerException) : [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class NoNullAllowedException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NoNullAllowedException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -207,6 +223,8 @@ public NoNullAllowedException(string? message, Exception? innerException) : base [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ReadOnlyException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -231,6 +249,8 @@ public ReadOnlyException(string? message, Exception? innerException) : base(mess [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class RowNotInTableException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected RowNotInTableException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -255,6 +275,8 @@ public RowNotInTableException(string? message, Exception? innerException) : base [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class VersionNotFoundException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected VersionNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs index 66ba6a7950da75..50759ea83a9616 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs @@ -244,6 +244,8 @@ protected void GetSerializationData(SerializationInfo info, StreamingContext con [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "CreateInstanceOfThisType's use of GetType uses only the parameterless constructor, but the annotations preserve all non-public constructors causing a warning for the serialization constructors. Those constructors won't be used here.")] + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DataSet(SerializationInfo info, StreamingContext context) : this(info, context, true) { } @@ -252,6 +254,8 @@ protected DataSet(SerializationInfo info, StreamingContext context) : this(info, [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "CreateInstanceOfThisType's use of GetType uses only the parameterless constructor, but the annotations preserve all non-public constructors causing a warning for the serialization constructors. Those constructors won't be used here.")] + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DataSet(SerializationInfo info, StreamingContext context, bool ConstructSchema) : this() { SerializationFormat remotingFormat = SerializationFormat.Xml; @@ -296,6 +300,8 @@ protected DataSet(SerializationInfo info, StreamingContext context, bool Constru [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Binary serialization is unsafe in general and is planned to be obsoleted. We do not want to mark interface or ctors of this class as unsafe as that would show many unnecessary warnings elsewhere.")] + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { SerializationFormat remotingFormat = RemotingFormat; @@ -338,10 +344,12 @@ private void SerializeDataSet(SerializationInfo info, StreamingContext context, //Tables, Columns, Rows for (int i = 0; i < Tables.Count; i++) { - BinaryFormatter bf = new BinaryFormatter(null, new StreamingContext(context.State, false)); MemoryStream memStream = new MemoryStream(); #pragma warning disable SYSLIB0011 // Issue https://github.com/dotnet/runtime/issues/39289 tracks finding an alternative to BinaryFormatter +#pragma warning disable SYSLIB0050 // StreamingContext ctor is obsolete + BinaryFormatter bf = new BinaryFormatter(null, new StreamingContext(context.State, false)); bf.Serialize(memStream, Tables[i]); +#pragma warning restore SYSLIB0050 #pragma warning restore SYSLIB0011 memStream.Position = 0; info.AddValue(string.Format(CultureInfo.InvariantCulture, "DataSet.Tables_{0}", i), memStream.GetBuffer()); @@ -421,9 +429,11 @@ private void DeserializeDataSetSchema(SerializationInfo info, StreamingContext c byte[] buffer = (byte[])info.GetValue(string.Format(CultureInfo.InvariantCulture, "DataSet.Tables_{0}", i), typeof(byte[]))!; MemoryStream memStream = new MemoryStream(buffer); memStream.Position = 0; - BinaryFormatter bf = new BinaryFormatter(null, new StreamingContext(context.State, false)); #pragma warning disable SYSLIB0011 // Issue https://github.com/dotnet/runtime/issues/39289 tracks finding an alternative to BinaryFormatter +#pragma warning disable SYSLIB0050 // StreamingContext ctor is obsolete + BinaryFormatter bf = new BinaryFormatter(null, new StreamingContext(context.State, false)); DataTable dt = (DataTable)bf.Deserialize(memStream); +#pragma warning restore SYSLIB0050 #pragma warning restore SYSLIB0011 Tables.Add(dt); } diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index d9a7e6bf91e6dc..2da38f233558df 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -195,6 +195,8 @@ public DataTable(string? tableName, string? tableNamespace) : this(tableName) [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "CreateInstance's use of GetType uses only the parameterless constructor. Warnings are about serialization related constructors.")] [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DataTable(SerializationInfo info, StreamingContext context) : this() { bool isSingleTable = context.Context != null ? Convert.ToBoolean(context.Context, CultureInfo.InvariantCulture) : true; @@ -221,6 +223,8 @@ protected DataTable(SerializationInfo info, StreamingContext context) : this() [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Binary serialization is unsafe in general and is planned to be obsoleted. We do not want to mark interface or ctors of this class as unsafe as that would show many unnecessary warnings elsewhere.")] + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { SerializationFormat remotingFormat = RemotingFormat; diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/FilterException.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/FilterException.cs index 13d8f9b8b0fc31..8d8b8878bd5158 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/FilterException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/FilterException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization; @@ -11,6 +12,8 @@ namespace System.Data [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class InvalidExpressionException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidExpressionException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -26,6 +29,8 @@ public InvalidExpressionException(string? message, Exception? innerException) : [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class EvaluateException : InvalidExpressionException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected EvaluateException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -41,6 +46,8 @@ public EvaluateException(string? message, Exception? innerException) : base(mess [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class SyntaxErrorException : InvalidExpressionException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SyntaxErrorException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Data.Common/src/System/Data/PropertyCollection.cs b/src/libraries/System.Data.Common/src/System/Data/PropertyCollection.cs index a1dba9aae1473d..16cebcf3ee2454 100644 --- a/src/libraries/System.Data.Common/src/System/Data/PropertyCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/PropertyCollection.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Data @@ -18,6 +19,8 @@ public PropertyCollection() : base() { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected PropertyCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs index eeff48caa91d20..92c4edfe613059 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Data.SqlTypes @@ -41,10 +42,13 @@ public SqlTypeException(string? message, Exception? e) : base(message, e) HResult = HResults.SqlType; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SqlTypeException(SerializationInfo si, StreamingContext sc) : base(SqlTypeExceptionSerialization(si, sc), sc) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private static SerializationInfo SqlTypeExceptionSerialization(SerializationInfo? si, StreamingContext sc) { if ((null != si) && (1 == si.MemberCount)) @@ -76,10 +80,13 @@ public SqlNullValueException(string? message, Exception? e) : base(message, e) HResult = HResults.SqlNullValue; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] private SqlNullValueException(SerializationInfo si, StreamingContext sc) : base(SqlNullValueExceptionSerialization(si, sc), sc) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private static SerializationInfo SqlNullValueExceptionSerialization(SerializationInfo si, StreamingContext sc) { if ((null != si) && (1 == si.MemberCount)) @@ -111,10 +118,13 @@ public SqlTruncateException(string? message, Exception? e) : base(message, e) HResult = HResults.SqlTruncate; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] private SqlTruncateException(SerializationInfo si, StreamingContext sc) : base(SqlTruncateExceptionSerialization(si, sc), sc) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private static SerializationInfo SqlTruncateExceptionSerialization(SerializationInfo si, StreamingContext sc) { if ((null != si) && (1 == si.MemberCount)) @@ -146,6 +156,7 @@ public SqlNotFilledException(string? message, Exception? e) : base(message, e) HResult = HResults.SqlNullValue; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private SqlNotFilledException(SerializationInfo si, StreamingContext sc) : base(si, sc) { } @@ -170,6 +181,7 @@ public SqlAlreadyFilledException(string? message, Exception? e) : base(message, HResult = HResults.SqlNullValue; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private SqlAlreadyFilledException(SerializationInfo si, StreamingContext sc) : base(si, sc) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/StrongTypingException.cs b/src/libraries/System.Data.Common/src/System/Data/StrongTypingException.cs index f170174a51d61e..4d075a10e7a521 100644 --- a/src/libraries/System.Data.Common/src/System/Data/StrongTypingException.cs +++ b/src/libraries/System.Data.Common/src/System/Data/StrongTypingException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Data @@ -12,8 +13,10 @@ namespace System.Data [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class StrongTypingException : DataException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected StrongTypingException(SerializationInfo info, StreamingContext context) - : base(info, context) + : base(info, context) { } diff --git a/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs b/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs index de17c7d2d82e44..dbc31d9319585d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs +++ b/src/libraries/System.Data.Common/src/System/Data/TypedTableBase.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -31,6 +32,8 @@ protected TypedTableBase() : base() { } [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "DataTable.CreateInstance's use of GetType uses only the parameterless constructor, not this serialization related constructor.")] [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TypedTableBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Data.Odbc/ref/System.Data.Odbc.cs b/src/libraries/System.Data.Odbc/ref/System.Data.Odbc.cs index 7fcc31aa4521f7..9eee7e3847b6b6 100644 --- a/src/libraries/System.Data.Odbc/ref/System.Data.Odbc.cs +++ b/src/libraries/System.Data.Odbc/ref/System.Data.Odbc.cs @@ -221,6 +221,10 @@ public sealed partial class OdbcException : System.Data.Common.DbException internal OdbcException() { } public System.Data.Odbc.OdbcErrorCollection Errors { get { throw null; } } public override string Source { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { } } public sealed partial class OdbcFactory : System.Data.Common.DbProviderFactory diff --git a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj index 5efd5553d36853..96bbcdbfb6ea9a 100644 --- a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj +++ b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj @@ -118,6 +118,8 @@ System.Data.Odbc.OdbcTransaction + diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs index 52b70dc15e8150..b3749cd1c2860f 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Text; @@ -34,6 +35,9 @@ internal OdbcException(string message, OdbcErrorCollection errors) : base(messag HResult = HResults.OdbcException; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc) { // Ignoring ODBC32.RETCODE @@ -49,6 +53,10 @@ public OdbcErrorCollection Errors } } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo si, StreamingContext context) { base.GetObjectData(si, context); diff --git a/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs b/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs index 1a00318b1173aa..c5a31a8183cc84 100644 --- a/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs +++ b/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs @@ -259,6 +259,10 @@ public sealed partial class OleDbException : System.Data.Common.DbException internal OleDbException() { } [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)] public System.Data.OleDb.OleDbErrorCollection Errors { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { } } public sealed partial class OleDbFactory : System.Data.Common.DbProviderFactory diff --git a/src/libraries/System.Data.OleDb/src/OleDbException.cs b/src/libraries/System.Data.OleDb/src/OleDbException.cs index fa0747ad450b04..4cead874d43b10 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbException.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbException.cs @@ -35,6 +35,10 @@ private OleDbException(string? message, Exception? inner, string? source, OleDbH this.oledbErrors = errors; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo si, StreamingContext context) { ArgumentNullException.ThrowIfNull(si); diff --git a/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj b/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj index 0d535399c29a5d..99c375546bd299 100644 --- a/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj +++ b/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj @@ -134,6 +134,8 @@ System.Data.OleDb.OleDbTransaction + diff --git a/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs b/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs index 1c13c599509fb0..007bd0b4c2eff9 100644 --- a/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs +++ b/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs @@ -227,10 +227,18 @@ public partial class EventLogException : System.Exception { public EventLogException() { } protected EventLogException(int errorCode) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected EventLogException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public EventLogException(string message) { } public EventLogException(string message, System.Exception innerException) { } public override string Message { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public sealed partial class EventLogInformation @@ -248,6 +256,10 @@ internal EventLogInformation() { } public partial class EventLogInvalidDataException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogInvalidDataException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected EventLogInvalidDataException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public EventLogInvalidDataException(string message) { } public EventLogInvalidDataException(string message, System.Exception innerException) { } @@ -274,6 +286,10 @@ public enum EventLogMode public partial class EventLogNotFoundException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogNotFoundException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected EventLogNotFoundException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public EventLogNotFoundException(string message) { } public EventLogNotFoundException(string message, System.Exception innerException) { } @@ -287,6 +303,10 @@ protected virtual void Dispose(bool disposing) { } public partial class EventLogProviderDisabledException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogProviderDisabledException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected EventLogProviderDisabledException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public EventLogProviderDisabledException(string message) { } public EventLogProviderDisabledException(string message, System.Exception innerException) { } @@ -319,6 +339,10 @@ public void Seek(System.IO.SeekOrigin origin, long offset) { } public partial class EventLogReadingException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogReadingException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected EventLogReadingException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public EventLogReadingException(string message) { } public EventLogReadingException(string message, System.Exception innerException) { } diff --git a/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj b/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj index c74dea7c375c59..99e2ad2c660aba 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj +++ b/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj @@ -107,6 +107,8 @@ System.Diagnostics.EventLog Link="Common\System\Diagnostics\NetFrameworkUtils.cs" /> + diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs index b35991bb87f0bd..cd1e3e2e4631ec 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs @@ -68,12 +68,20 @@ public override string Message private readonly int _errorCode; +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected EventLogException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { _errorCode = serializationInfo.GetInt32("errorCode"); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); @@ -91,6 +99,10 @@ public EventLogNotFoundException() { } public EventLogNotFoundException(string message) : base(message) { } public EventLogNotFoundException(string message, Exception innerException) : base(message, innerException) { } internal EventLogNotFoundException(int errorCode) : base(errorCode) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected EventLogNotFoundException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } } @@ -106,6 +118,10 @@ public EventLogReadingException() { } public EventLogReadingException(string message) : base(message) { } public EventLogReadingException(string message, Exception innerException) : base(message, innerException) { } internal EventLogReadingException(int errorCode) : base(errorCode) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected EventLogReadingException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } } @@ -121,6 +137,10 @@ public EventLogProviderDisabledException() { } public EventLogProviderDisabledException(string message) : base(message) { } public EventLogProviderDisabledException(string message, Exception innerException) : base(message, innerException) { } internal EventLogProviderDisabledException(int errorCode) : base(errorCode) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected EventLogProviderDisabledException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } } @@ -134,6 +154,10 @@ public EventLogInvalidDataException() { } public EventLogInvalidDataException(string message) : base(message) { } public EventLogInvalidDataException(string message, Exception innerException) : base(message, innerException) { } internal EventLogInvalidDataException(int errorCode) : base(errorCode) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected EventLogInvalidDataException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } } } diff --git a/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.cs b/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.cs index 295d3814394685..dacf67b8841e3b 100644 --- a/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.cs +++ b/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.cs @@ -239,6 +239,8 @@ public EventSourceCreatedEventArgs() { } public partial class EventSourceException : System.Exception { public EventSourceException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected EventSourceException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public EventSourceException(string? message) { } public EventSourceException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs b/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs index 3b9228be10af88..4f7382064d92da 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs @@ -150,24 +150,36 @@ public enum MatchType } public partial class MultipleMatchesException : System.DirectoryServices.AccountManagement.PrincipalException { - public MultipleMatchesException() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - protected MultipleMatchesException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public MultipleMatchesException(string message) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public MultipleMatchesException(string message, System.Exception innerException) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public MultipleMatchesException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif + protected MultipleMatchesException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public MultipleMatchesException(string message) { } + public MultipleMatchesException(string message, System.Exception innerException) { } } public partial class NoMatchingPrincipalException : System.DirectoryServices.AccountManagement.PrincipalException { - public NoMatchingPrincipalException() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - protected NoMatchingPrincipalException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public NoMatchingPrincipalException(string message) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public NoMatchingPrincipalException(string message, System.Exception innerException) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public NoMatchingPrincipalException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif + protected NoMatchingPrincipalException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public NoMatchingPrincipalException(string message) { } + public NoMatchingPrincipalException(string message, System.Exception innerException) { } } public partial class PasswordException : System.DirectoryServices.AccountManagement.PrincipalException { - public PasswordException() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - protected PasswordException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PasswordException(string message) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PasswordException(string message, System.Exception innerException) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public PasswordException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif + protected PasswordException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public PasswordException(string message) { } + public PasswordException(string message, System.Exception innerException) { } } public abstract partial class Principal : System.IDisposable { @@ -263,24 +275,41 @@ public void Dispose() { } } public abstract partial class PrincipalException : System.SystemException { + private protected PrincipalException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected PrincipalException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class PrincipalExistsException : System.DirectoryServices.AccountManagement.PrincipalException { - public PrincipalExistsException() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - protected PrincipalExistsException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalExistsException(string message) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalExistsException(string message, System.Exception innerException) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public PrincipalExistsException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif + protected PrincipalExistsException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context){ } + public PrincipalExistsException(string message){ } + public PrincipalExistsException(string message, System.Exception innerException) { } } public partial class PrincipalOperationException : System.DirectoryServices.AccountManagement.PrincipalException { - public PrincipalOperationException() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - protected PrincipalOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalOperationException(string message) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalOperationException(string message, System.Exception innerException) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalOperationException(string message, System.Exception innerException, int errorCode) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalOperationException(string message, int errorCode) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public PrincipalOperationException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif + protected PrincipalOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public PrincipalOperationException(string message) { } + public PrincipalOperationException(string message, System.Exception innerException) { } + public PrincipalOperationException(string message, System.Exception innerException, int errorCode) { } + public PrincipalOperationException(string message, int errorCode) { } public int ErrorCode { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class PrincipalSearcher : System.IDisposable @@ -304,13 +333,21 @@ public void Dispose() { } } public partial class PrincipalServerDownException : System.DirectoryServices.AccountManagement.PrincipalException { - public PrincipalServerDownException() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public PrincipalServerDownException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected PrincipalServerDownException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalServerDownException(string message) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalServerDownException(string message, System.Exception innerException) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalServerDownException(string message, System.Exception innerException, int errorCode) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalServerDownException(string message, System.Exception innerException, int errorCode, string serverName) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public PrincipalServerDownException(string message, int errorCode) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public PrincipalServerDownException(string message) { } + public PrincipalServerDownException(string message, System.Exception innerException) { } + public PrincipalServerDownException(string message, System.Exception innerException, int errorCode) { } + public PrincipalServerDownException(string message, System.Exception innerException, int errorCode, string serverName) { } + public PrincipalServerDownException(string message, int errorCode) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class PrincipalValueCollection : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System.DirectoryServices.AccountManagement.csproj b/src/libraries/System.DirectoryServices.AccountManagement/src/System.DirectoryServices.AccountManagement.csproj index 7333ffa9cc8cda..2203721d31a805 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System.DirectoryServices.AccountManagement.csproj +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System.DirectoryServices.AccountManagement.csproj @@ -188,6 +188,8 @@ Link="Common\Microsoft\Win32\SafeHandles\SafeLsaPolicyHandle.cs" /> + diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs index 9ef7f1a51f582b..c0286f26442bb7 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs @@ -23,6 +23,10 @@ internal PrincipalException(string message, Exception innerException) : base(message, innerException) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected PrincipalException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -41,6 +45,10 @@ public MultipleMatchesException(string message, Exception innerException) : base(message, innerException) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected MultipleMatchesException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -59,8 +67,11 @@ public NoMatchingPrincipalException(string message, Exception innerException) : base(message, innerException) { } - protected NoMatchingPrincipalException(SerializationInfo info, StreamingContext context) : - base(info, context) +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif + protected NoMatchingPrincipalException(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); } @@ -78,6 +89,10 @@ public PasswordException(string message, Exception innerException) : base(message, innerException) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected PasswordException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -96,6 +111,10 @@ public PrincipalExistsException(string message, Exception innerException) : base(message, innerException) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected PrincipalExistsException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -131,6 +150,10 @@ public PrincipalServerDownException(string message, Exception innerException, in _serverName = serverName; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected PrincipalServerDownException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -138,6 +161,10 @@ protected PrincipalServerDownException(SerializationInfo info, StreamingContext _serverName = (string)info.GetValue("serverName", typeof(string)); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); @@ -169,12 +196,20 @@ public PrincipalOperationException(string message, Exception innerException, int _errorCode = errorCode; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected PrincipalOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { _errorCode = info.GetInt32("errorCode"); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs b/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs index 1b740db20bef22..32262da81be3e2 100644 --- a/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs +++ b/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs @@ -46,6 +46,10 @@ public enum AuthType public partial class BerConversionException : System.DirectoryServices.Protocols.DirectoryException { public BerConversionException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected BerConversionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public BerConversionException(string message) { } public BerConversionException(string message, System.Exception inner) { } @@ -190,6 +194,10 @@ public void Remove(System.DirectoryServices.Protocols.DirectoryControl value) { public partial class DirectoryException : System.Exception { public DirectoryException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected DirectoryException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DirectoryException(string message) { } public DirectoryException(string message, System.Exception inner) { } @@ -212,10 +220,18 @@ public DirectoryOperationException() { } public DirectoryOperationException(System.DirectoryServices.Protocols.DirectoryResponse response) { } public DirectoryOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message) { } public DirectoryOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message, System.Exception inner) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected DirectoryOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DirectoryOperationException(string message) { } public DirectoryOperationException(string message, System.Exception inner) { } public System.DirectoryServices.Protocols.DirectoryResponse Response { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public abstract partial class DirectoryRequest : System.DirectoryServices.Protocols.DirectoryOperation @@ -345,12 +361,20 @@ public LdapException(int errorCode) { } public LdapException(int errorCode, string message) { } public LdapException(int errorCode, string message, System.Exception inner) { } public LdapException(int errorCode, string message, string serverErrorMessage) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected LdapException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public LdapException(string message) { } public LdapException(string message, System.Exception inner) { } public int ErrorCode { get { throw null; } } public System.DirectoryServices.Protocols.PartialResultsCollection PartialResults { get { throw null; } } public string ServerErrorMessage { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public partial class LdapSessionOptions @@ -685,6 +709,10 @@ public TlsOperationException() { } public TlsOperationException(System.DirectoryServices.Protocols.DirectoryResponse response) { } public TlsOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message) { } public TlsOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message, System.Exception inner) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected TlsOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TlsOperationException(string message) { } public TlsOperationException(string message, System.Exception inner) { } diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj b/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj index d340edc61ecb3b..da521e6ac19442 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj +++ b/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj @@ -56,6 +56,9 @@ Common\Interop\Windows\Interop.BOOL.cs + + Common\System\Obsoletions.cs + diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs index e716d36c379faf..8e9e85fcccc7c0 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Text; using System.Runtime.Serialization; @@ -10,6 +11,10 @@ namespace System.DirectoryServices.Protocols [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class DirectoryException : Exception { +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected DirectoryException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -31,6 +36,10 @@ public DirectoryException() : base() [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class DirectoryOperationException : DirectoryException, ISerializable { +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected DirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } public DirectoryOperationException() : base() { } @@ -74,6 +83,10 @@ private static string CreateMessage(DirectoryResponse response, string message) [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class BerConversionException : DirectoryException { +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected BerConversionException(SerializationInfo info, StreamingContext context) : base(info, context) { } public BerConversionException() : base(SR.BerConversionError) diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs index 06d892dd9ab9e2..81b5cd168aa782 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Collections.Generic; using System.Runtime.Serialization; @@ -92,6 +93,10 @@ public class LdapException : DirectoryException, ISerializable { private int _errorCode; +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected LdapException(SerializationInfo info, StreamingContext context) : base(info, context) { } public LdapException() : base() { } @@ -140,6 +145,10 @@ private set [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class TlsOperationException : DirectoryOperationException { +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected TlsOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } public TlsOperationException() : base() { } diff --git a/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs b/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs index 541ac7374ee859..718084c2a9d79d 100644 --- a/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs +++ b/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs @@ -255,11 +255,19 @@ protected override void Dispose(bool disposing) { } public partial class DirectoryServicesCOMException : System.Runtime.InteropServices.COMException, System.Runtime.Serialization.ISerializable { public DirectoryServicesCOMException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected DirectoryServicesCOMException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DirectoryServicesCOMException(string? message) { } public DirectoryServicesCOMException(string? message, System.Exception? inner) { } public int ExtendedError { get { throw null; } } public string? ExtendedErrorMessage { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public partial class DirectorySynchronization @@ -531,6 +539,10 @@ public void Save() { } public partial class ActiveDirectoryObjectExistsException : System.Exception { public ActiveDirectoryObjectExistsException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ActiveDirectoryObjectExistsException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ActiveDirectoryObjectExistsException(string? message) { } public ActiveDirectoryObjectExistsException(string? message, System.Exception? inner) { } @@ -538,23 +550,39 @@ public ActiveDirectoryObjectExistsException(string? message, System.Exception? i public partial class ActiveDirectoryObjectNotFoundException : System.Exception, System.Runtime.Serialization.ISerializable { public ActiveDirectoryObjectNotFoundException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ActiveDirectoryObjectNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ActiveDirectoryObjectNotFoundException(string? message) { } public ActiveDirectoryObjectNotFoundException(string? message, System.Exception? inner) { } public ActiveDirectoryObjectNotFoundException(string? message, System.Type? type, string? name) { } public string? Name { get { throw null; } } public System.Type? Type { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public partial class ActiveDirectoryOperationException : System.Exception, System.Runtime.Serialization.ISerializable { public ActiveDirectoryOperationException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ActiveDirectoryOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ActiveDirectoryOperationException(string? message) { } public ActiveDirectoryOperationException(string? message, System.Exception? inner) { } public ActiveDirectoryOperationException(string? message, System.Exception? inner, int errorCode) { } public ActiveDirectoryOperationException(string? message, int errorCode) { } public int ErrorCode { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public abstract partial class ActiveDirectoryPartition : System.IDisposable @@ -715,6 +743,10 @@ public void Remove(System.DirectoryServices.ActiveDirectory.ActiveDirectorySchem public partial class ActiveDirectoryServerDownException : System.Exception, System.Runtime.Serialization.ISerializable { public ActiveDirectoryServerDownException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ActiveDirectoryServerDownException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ActiveDirectoryServerDownException(string? message) { } public ActiveDirectoryServerDownException(string? message, System.Exception? inner) { } @@ -723,6 +755,10 @@ public ActiveDirectoryServerDownException(string? message, int errorCode, string public int ErrorCode { get { throw null; } } public override string Message { get { throw null; } } public string? Name { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public partial class ActiveDirectorySite : System.IDisposable @@ -1275,11 +1311,19 @@ public enum ForestMode public partial class ForestTrustCollisionException : System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException, System.Runtime.Serialization.ISerializable { public ForestTrustCollisionException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ForestTrustCollisionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ForestTrustCollisionException(string? message) { } public ForestTrustCollisionException(string? message, System.Exception? inner) { } public ForestTrustCollisionException(string? message, System.Exception? inner, System.DirectoryServices.ActiveDirectory.ForestTrustRelationshipCollisionCollection? collisions) { } public System.DirectoryServices.ActiveDirectory.ForestTrustRelationshipCollisionCollection? Collisions { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public enum ForestTrustCollisionType @@ -1659,11 +1703,19 @@ public enum SyncFromAllServersEvent public partial class SyncFromAllServersOperationException : System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException, System.Runtime.Serialization.ISerializable { public SyncFromAllServersOperationException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected SyncFromAllServersOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SyncFromAllServersOperationException(string? message) { } public SyncFromAllServersOperationException(string? message, System.Exception? inner) { } public SyncFromAllServersOperationException(string? message, System.Exception? inner, System.DirectoryServices.ActiveDirectory.SyncFromAllServersErrorInformation[]? errors) { } public System.DirectoryServices.ActiveDirectory.SyncFromAllServersErrorInformation[] ErrorInformation { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } [System.FlagsAttribute] diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs index 950075ba9c8be7..30a01c04ba09ea 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs @@ -47,6 +47,10 @@ public ActiveDirectoryObjectNotFoundException(string? message) : base(message) { public ActiveDirectoryObjectNotFoundException() : base() { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ActiveDirectoryObjectNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -55,6 +59,10 @@ protected ActiveDirectoryObjectNotFoundException(SerializationInfo info, Streami public string? Name { get; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -95,12 +103,20 @@ public ActiveDirectoryOperationException(string? message) : base(message) { } public ActiveDirectoryOperationException() : base(SR.DSUnknownFailure) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ActiveDirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } public int ErrorCode { get; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -129,6 +145,10 @@ public ActiveDirectoryServerDownException(string? message) : base(message) { } public ActiveDirectoryServerDownException() : base() { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ActiveDirectoryServerDownException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -150,6 +170,10 @@ public override string Message } } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -166,6 +190,10 @@ public ActiveDirectoryObjectExistsException(string? message) : base(message) { } public ActiveDirectoryObjectExistsException() : base() { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ActiveDirectoryObjectExistsException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -188,6 +216,10 @@ public SyncFromAllServersOperationException(string? message) : base(message) { } public SyncFromAllServersOperationException() : base(SR.DSSyncAllFailure) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected SyncFromAllServersOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -207,6 +239,10 @@ public SyncFromAllServersErrorInformation[] ErrorInformation } } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); @@ -228,12 +264,20 @@ public ForestTrustCollisionException(string? message) : base(message) { } public ForestTrustCollisionException() : base(SR.ForestTrustCollision) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ForestTrustCollisionException(SerializationInfo info, StreamingContext context) : base(info, context) { } public ForestTrustRelationshipCollisionCollection? Collisions { get; } = new ForestTrustRelationshipCollisionCollection(); +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs index 6ff6d88c562415..00ee0f88f77667 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs @@ -17,6 +17,10 @@ public DirectoryServicesCOMException(string? message) : base(message) { } public DirectoryServicesCOMException(string? message, Exception? inner) : base(message, inner) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected DirectoryServicesCOMException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -31,6 +35,10 @@ internal DirectoryServicesCOMException(string? extendedMessage, int extendedErro public string? ExtendedErrorMessage { get; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs b/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs index 7c4003e2978476..170081a2f3874d 100644 --- a/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs +++ b/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs @@ -45,6 +45,10 @@ namespace System.Formats.Asn1 public partial class AsnContentException : System.Exception { public AsnContentException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected AsnContentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public AsnContentException(string? message) { } public AsnContentException(string? message, System.Exception? inner) { } diff --git a/src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj b/src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj index 53502fc348e684..a899353cd4a050 100644 --- a/src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj +++ b/src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj @@ -53,6 +53,7 @@ System.Formats.Asn1.AsnWriter + diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs index 9e3d03c45e84de..4bbee61211e78a 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Formats.Asn1 @@ -23,6 +24,10 @@ public AsnContentException(string? message, Exception? inner) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected AsnContentException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs b/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs index 54b232c9864a77..ba7c538a80f8e8 100644 --- a/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs +++ b/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs @@ -15,6 +15,10 @@ public enum CborConformanceMode } public partial class CborContentException : System.Exception { +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected CborContentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CborContentException(string? message) { } public CborContentException(string? message, System.Exception? inner) { } diff --git a/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj b/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj index 2e43a07a64d860..0757a3e86d0217 100644 --- a/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj +++ b/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj @@ -13,6 +13,7 @@ System.Formats.Cbor.CborWriter + diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs index 148c26bd447986..68f606dac4e7f0 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Formats.Cbor @@ -36,6 +37,10 @@ public CborContentException(string? message, Exception? inner) /// /// The object that holds the serialized object data. /// The contextual information about the source or destination. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected CborContentException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index 798fccdac5bba4..149604a5e355bc 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -39,6 +39,8 @@ + diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/ZLibException.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/ZLibException.cs index 12355eb4bfe9d1..c9748918a0a7e8 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/ZLibException.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/ZLibException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO.Compression @@ -52,6 +53,10 @@ public ZLibException(string? message, Exception? innerException) : base(message, /// /// The SerializationInfo that holds the serialized object data about the exception being thrown. /// The StreamingContext that contains contextual information about the source or destination. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ZLibException(SerializationInfo info, StreamingContext context) : base(info, context) { _zlibErrorContext = info.GetString("zlibErrorContext"); @@ -59,6 +64,9 @@ protected ZLibException(SerializationInfo info, StreamingContext context) : base _zlibErrorMessage = info.GetString("zlibErrorMessage"); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) { base.GetObjectData(si, context); diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs b/src/libraries/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs index 19e8f51412b35f..8f432526a4afbf 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs +++ b/src/libraries/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs @@ -26,6 +26,8 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public partial class DriveNotFoundException : System.IO.IOException { public DriveNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DriveNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DriveNotFoundException(string? message) { } public DriveNotFoundException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj b/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj index 43823c8111daa1..70ccc2c053a1d3 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj +++ b/src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj @@ -13,6 +13,8 @@ Link="Common\System\HResults.cs" /> + diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs b/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs index 20d3d0d3915983..1d0873a2ba8c3e 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs +++ b/src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -28,6 +29,8 @@ public DriveNotFoundException(string? message, Exception? innerException) HResult = HResults.COR_E_DIRECTORYNOTFOUND; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DriveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.IO.FileSystem.Watcher/ref/System.IO.FileSystem.Watcher.cs b/src/libraries/System.IO.FileSystem.Watcher/ref/System.IO.FileSystem.Watcher.cs index d640d89cfe3888..631b25d68bc1b6 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/ref/System.IO.FileSystem.Watcher.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/ref/System.IO.FileSystem.Watcher.cs @@ -55,6 +55,8 @@ protected void OnRenamed(System.IO.RenamedEventArgs e) { } public partial class InternalBufferOverflowException : System.SystemException { public InternalBufferOverflowException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InternalBufferOverflowException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InternalBufferOverflowException(string? message) { } public InternalBufferOverflowException(string? message, System.Exception? inner) { } diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj b/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj index 15b70f231a8298..f865fd51da017d 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj @@ -31,6 +31,8 @@ Link="Common\System\IO\PathInternal.cs" /> + + diff --git a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs index aae8198f565306..7c42d59b68e034 100644 --- a/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs +++ b/src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO.IsolatedStorage @@ -34,6 +35,8 @@ public IsolatedStorageException(string? message, Exception? inner) HResult = COR_E_ISOSTORE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected IsolatedStorageException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs b/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs index 19809fb07bcc4e..58a03be2fa2f60 100644 --- a/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs +++ b/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs @@ -8,7 +8,15 @@ namespace System.IO { public partial class FileFormatException : System.FormatException { +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected FileFormatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } diff --git a/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj b/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj index 3812ff100aaaf5..fd5fa77c1cea4c 100644 --- a/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj +++ b/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj @@ -40,6 +40,7 @@ + diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs index 6574ee7d0322d4..6bed53f5796374 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -112,6 +113,10 @@ public FileFormatException(Uri? sourceUri, string? message, Exception? innerExce _sourceUri = sourceUri; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected FileFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { string? sourceUriString = info.GetString("SourceUri"); @@ -124,6 +129,10 @@ protected FileFormatException(SerializationInfo info, StreamingContext context) /// /// The object that holds the serialized object data. /// The contextual information about the source or destination. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs index 068f933ed7d40f..2424fd75c352e6 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs @@ -200,6 +200,7 @@ internal TryFaultHandler(int tryStart, int tryEnd, int finallyStart, int finally internal sealed class RethrowException : Exception { public RethrowException() : base() { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] internal RethrowException(SerializationInfo info, StreamingContext context) : base(info, context) { } } diff --git a/src/libraries/System.Management/ref/System.Management.cs b/src/libraries/System.Management/ref/System.Management.cs index 70dbeff2bd2337..a7c68e9ce52f14 100644 --- a/src/libraries/System.Management/ref/System.Management.cs +++ b/src/libraries/System.Management/ref/System.Management.cs @@ -135,6 +135,11 @@ public InvokeMethodOptions(System.Management.ManagementNamedValueCollection cont [System.ComponentModel.ToolboxItemAttribute(false)] public partial class ManagementBaseObject : System.ComponentModel.Component, System.ICloneable, System.Runtime.Serialization.ISerializable { + private protected ManagementBaseObject() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ManagementBaseObject(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual System.Management.ManagementPath ClassPath { get { throw null; } } public object this[string propertyName] { get { throw null; } set { } } @@ -163,6 +168,10 @@ public ManagementClass() { } public ManagementClass(System.Management.ManagementPath path) { } public ManagementClass(System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } public ManagementClass(System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ManagementClass(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ManagementClass(string path) { } public ManagementClass(string path, System.Management.ObjectGetOptions options) { } @@ -233,16 +242,28 @@ public void Stop() { } public partial class ManagementException : System.SystemException { public ManagementException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ManagementException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ManagementException(string message) { } public ManagementException(string message, System.Exception innerException) { } public System.Management.ManagementStatus ErrorCode { get { throw null; } } public System.Management.ManagementBaseObject ErrorInformation { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class ManagementNamedValueCollection : System.Collections.Specialized.NameObjectCollectionBase { public ManagementNamedValueCollection() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ManagementNamedValueCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public object this[string name] { get { throw null; } } public void Add(string name, object value) { } @@ -252,14 +273,18 @@ public void RemoveAll() { } } public partial class ManagementObject : System.Management.ManagementBaseObject, System.ICloneable { - public ManagementObject() : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public ManagementObject(System.Management.ManagementPath path) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public ManagementObject(System.Management.ManagementPath path, System.Management.ObjectGetOptions options) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public ManagementObject(System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - protected ManagementObject(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public ManagementObject(string path) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public ManagementObject(string path, System.Management.ObjectGetOptions options) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } - public ManagementObject(string scopeString, string pathString, System.Management.ObjectGetOptions options) : base (default(System.Runtime.Serialization.SerializationInfo), default(System.Runtime.Serialization.StreamingContext)) { } + public ManagementObject() { } + public ManagementObject(System.Management.ManagementPath path) { } + public ManagementObject(System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } + public ManagementObject(System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif + protected ManagementObject(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public ManagementObject(string path) { } + public ManagementObject(string path, System.Management.ObjectGetOptions options) { } + public ManagementObject(string scopeString, string pathString, System.Management.ObjectGetOptions options) { } public override System.Management.ManagementPath ClassPath { get { throw null; } } public System.Management.ObjectGetOptions Options { get { throw null; } set { } } public virtual System.Management.ManagementPath Path { get { throw null; } set { } } diff --git a/src/libraries/System.Management/src/System.Management.csproj b/src/libraries/System.Management/src/System.Management.csproj index 3c23101e634792..88bb095f348946 100644 --- a/src/libraries/System.Management/src/System.Management.csproj +++ b/src/libraries/System.Management/src/System.Management.csproj @@ -38,6 +38,8 @@ System.Management.SelectQuery Link="Common\Interop\Windows\Ole32\Interop.CoGetObjectContext.cs" /> + diff --git a/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs b/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs index 087c352d87ee59..771c16184465ed 100644 --- a/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs +++ b/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs @@ -15,7 +15,7 @@ namespace WbemUtilities_v1 { } namespace System.Management { #region FreeThreadedInterfaces - internal sealed class IWbemClassObjectFreeThreaded : IDisposable, ISerializable + internal sealed class IWbemClassObjectFreeThreaded : IDisposable { // // This is to force load wminet_utils.dll as a COM component. Since wminet_utils.dll @@ -44,16 +44,6 @@ public static implicit operator IntPtr(IWbemClassObjectFreeThreaded wbemClassObj return wbemClassObject.pWbemClassObject; } - public IWbemClassObjectFreeThreaded(SerializationInfo info, StreamingContext context) - { - throw new PlatformNotSupportedException(); - } - - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new PlatformNotSupportedException(); - } - public void Dispose() { Dispose_(false); diff --git a/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs b/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs index bc5db3b39820f5..c196511a32b0fd 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs @@ -223,6 +223,10 @@ internal IWbemClassObjectFreeThreaded wbemObject /// /// The to populate with data. /// The destination (see ) for this serialization. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ManagementBaseObject(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Management/src/System/Management/ManagementClass.cs b/src/libraries/System.Management/src/System/Management/ManagementClass.cs index 86e691f562bdaa..69a2e70b7b62fb 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementClass.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementClass.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Specialized; +using System.ComponentModel; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.CodeDom; @@ -266,7 +267,11 @@ public ManagementClass(ManagementScope scope, ManagementPath path, ObjectGetOpti public ManagementClass(string scope, string path, ObjectGetOptions options) : base(new ManagementScope(scope), new ManagementPath(path), options) { } - protected ManagementClass(SerializationInfo info, StreamingContext context) : base(info, context) +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif + protected ManagementClass(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Management/src/System/Management/ManagementException.cs b/src/libraries/System.Management/src/System/Management/ManagementException.cs index f573756225f8e9..92a3a66513976c 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementException.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -671,6 +672,10 @@ internal ManagementException(Exception e, string msg, ManagementBaseObject errOb /// /// The to populate with data. /// The destination (see ) for this serialization. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ManagementException(SerializationInfo info, StreamingContext context) : base(info, context) { errorCode = (ManagementStatus)info.GetValue("errorCode", typeof(ManagementStatus)); @@ -715,7 +720,10 @@ public ManagementException(string message, Exception innerException):this(innerE /// /// The to populate with data. /// The destination (see ) for this serialization. - +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs b/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs index 862419ff4631c3..68efddb9bdae59 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Specialized; +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Management @@ -45,7 +46,11 @@ public ManagementNamedValueCollection() /// /// The to populate with data. /// The destination (see ) for this serialization. - protected ManagementNamedValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif + protected ManagementNamedValueCollection(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Management/src/System/Management/ManagementObject.cs b/src/libraries/System.Management/src/System/Management/ManagementObject.cs index 18b70aa9b6ecfe..28eaadc9a39632 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObject.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -461,6 +462,10 @@ public ManagementObject(string scopeString, string pathString, ObjectGetOptions /// /// The to populate with data. /// The destination (see ) for this serialization. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ManagementObject(SerializationInfo info, StreamingContext context) : base(info, context) { ManagementObjectCTOR(null, null, null); diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System.Net.Http.WinHttpHandler.csproj b/src/libraries/System.Net.Http.WinHttpHandler/src/System.Net.Http.WinHttpHandler.csproj index e6dd2f5192891f..404e965fd8f512 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System.Net.Http.WinHttpHandler.csproj +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System.Net.Http.WinHttpHandler.csproj @@ -103,6 +103,8 @@ System.Net.Http.WinHttpHandler Link="Common\System\Net\Logging\NetEventSource.Common.cs" /> + diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs index 54fa11b8fea5a5..fb017ebe43612d 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs @@ -17,6 +17,10 @@ public WinHttpException(int error, string message) : base(error, message) this.HResult = ConvertErrorCodeToHR(error); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public WinHttpException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/System.Net.Http.WinHttpHandler.Unit.Tests.csproj b/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/System.Net.Http.WinHttpHandler.Unit.Tests.csproj index 791b0032f86422..b459c0e2c9545d 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/System.Net.Http.WinHttpHandler.Unit.Tests.csproj +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/System.Net.Http.WinHttpHandler.Unit.Tests.csproj @@ -29,6 +29,8 @@ Link="Common\System\CharArrayHelpers.cs" /> + + diff --git a/src/libraries/System.Net.Http/tests/PerformanceTests/HPackHuffmanBenchmark/HPackHuffmanBenchmark.csproj b/src/libraries/System.Net.Http/tests/PerformanceTests/HPackHuffmanBenchmark/HPackHuffmanBenchmark.csproj index ddec3c81968aab..2241ec7ee9b231 100644 --- a/src/libraries/System.Net.Http/tests/PerformanceTests/HPackHuffmanBenchmark/HPackHuffmanBenchmark.csproj +++ b/src/libraries/System.Net.Http/tests/PerformanceTests/HPackHuffmanBenchmark/HPackHuffmanBenchmark.csproj @@ -12,6 +12,8 @@ Link="Common\System\Net\Http\aspnetcore\Http2\Hpack\Huffman.cs" /> + diff --git a/src/libraries/System.Net.Http/tests/UnitTests/System.Net.Http.Unit.Tests.csproj b/src/libraries/System.Net.Http/tests/UnitTests/System.Net.Http.Unit.Tests.csproj index 42409627be0433..f2d027bfd648e7 100644 --- a/src/libraries/System.Net.Http/tests/UnitTests/System.Net.Http.Unit.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/UnitTests/System.Net.Http.Unit.Tests.csproj @@ -397,6 +397,8 @@ Link="Common\System\Text\ValueStringBuilder.cs" /> + + diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/HttpListenerException.cs b/src/libraries/System.Net.HttpListener/src/System/Net/HttpListenerException.cs index 249e579d47d1b7..e4846e7f577913 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/HttpListenerException.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/HttpListenerException.cs @@ -26,6 +26,8 @@ public HttpListenerException(int errorCode, string message) : base(errorCode, me if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected HttpListenerException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { diff --git a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs index 6c91e785def67d..d35606bfa84304 100644 --- a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs +++ b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs @@ -209,41 +209,50 @@ public enum SmtpDeliveryMethod SpecifiedPickupDirectory = 1, PickupDirectoryFromIis = 2, } - public partial class SmtpException : System.Exception, System.Runtime.Serialization.ISerializable + public partial class SmtpException : System.Exception { public SmtpException() { } public SmtpException(System.Net.Mail.SmtpStatusCode statusCode) { } public SmtpException(System.Net.Mail.SmtpStatusCode statusCode, string? message) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SmtpException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public SmtpException(string? message) { } public SmtpException(string? message, System.Exception? innerException) { } public System.Net.Mail.SmtpStatusCode StatusCode { get { throw null; } set { } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } - void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } - public partial class SmtpFailedRecipientException : System.Net.Mail.SmtpException, System.Runtime.Serialization.ISerializable + public partial class SmtpFailedRecipientException : System.Net.Mail.SmtpException { public SmtpFailedRecipientException() { } public SmtpFailedRecipientException(System.Net.Mail.SmtpStatusCode statusCode, string? failedRecipient) { } public SmtpFailedRecipientException(System.Net.Mail.SmtpStatusCode statusCode, string? failedRecipient, string? serverResponse) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SmtpFailedRecipientException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SmtpFailedRecipientException(string? message) { } public SmtpFailedRecipientException(string? message, System.Exception? innerException) { } public SmtpFailedRecipientException(string? message, string? failedRecipient, System.Exception? innerException) { } public string? FailedRecipient { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } - void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } - public partial class SmtpFailedRecipientsException : System.Net.Mail.SmtpFailedRecipientException, System.Runtime.Serialization.ISerializable + public partial class SmtpFailedRecipientsException : System.Net.Mail.SmtpFailedRecipientException { public SmtpFailedRecipientsException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SmtpFailedRecipientsException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SmtpFailedRecipientsException(string? message) { } public SmtpFailedRecipientsException(string? message, System.Exception? innerException) { } public SmtpFailedRecipientsException(string? message, System.Net.Mail.SmtpFailedRecipientException[] innerExceptions) { } public System.Net.Mail.SmtpFailedRecipientException[] InnerExceptions { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } - void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public enum SmtpStatusCode { diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 7d1afb2d61aa70..a86bca0286a204 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -76,6 +76,8 @@ Link="Common\System\StringExtensions.cs" /> + diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpException.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpException.cs index aa59188d748887..ac504e916f2abc 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpException.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpException.cs @@ -1,13 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net.Mail { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public class SmtpException : Exception, ISerializable + public class SmtpException : Exception { private SmtpStatusCode _statusCode = SmtpStatusCode.GeneralFailure; @@ -92,6 +93,8 @@ public SmtpException(string? message, Exception? innerException) : base(message, { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SmtpException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { _statusCode = (SmtpStatusCode)serializationInfo.GetInt32("Status"); @@ -106,11 +109,8 @@ internal SmtpException(string message, string? serverResponse) : base(message + { } - void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) - { - GetObjectData(serializationInfo, streamingContext); - } - + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs index f3a5d300f0cc90..7060721ffe2919 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -9,7 +10,7 @@ namespace System.Net.Mail { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public class SmtpFailedRecipientException : SmtpException, ISerializable + public class SmtpFailedRecipientException : SmtpException { private readonly string? _failedRecipient; @@ -23,6 +24,8 @@ public SmtpFailedRecipientException(string? message) : base(message) { } public SmtpFailedRecipientException(string? message, Exception? innerException) : base(message, innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SmtpFailedRecipientException(SerializationInfo info, StreamingContext context) : base(info, context) { _failedRecipient = info.GetString("failedRecipient"); @@ -51,11 +54,8 @@ public string? FailedRecipient } } - void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) - { - GetObjectData(serializationInfo, streamingContext); - } - + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs index 6cd03b0efcf99b..19ea0d39c4154e 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -9,7 +10,7 @@ namespace System.Net.Mail { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public class SmtpFailedRecipientsException : SmtpFailedRecipientException, ISerializable + public class SmtpFailedRecipientsException : SmtpFailedRecipientException { private readonly SmtpFailedRecipientException[] _innerExceptions; @@ -29,6 +30,8 @@ public SmtpFailedRecipientsException(string? message, Exception? innerException) _innerExceptions = smtpException == null ? Array.Empty() : new SmtpFailedRecipientException[] { smtpException }; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SmtpFailedRecipientsException(SerializationInfo info, StreamingContext context) : base(info, context) { _innerExceptions = (SmtpFailedRecipientException[])info.GetValue("innerExceptions", typeof(SmtpFailedRecipientException[]))!; @@ -60,11 +63,8 @@ public SmtpFailedRecipientException[] InnerExceptions } } - void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) - { - GetObjectData(serializationInfo, streamingContext); - } - + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index e7eeed8be58c97..1f2f599959a966 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -145,6 +145,8 @@ Link="Common\System\Net\SecurityStatusPal.cs" /> + diff --git a/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs b/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs index da345adb5929c7..8824cccc08e929 100644 --- a/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs +++ b/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs @@ -413,6 +413,8 @@ public partial class NetworkInformationException : System.ComponentModel.Win32Ex { public NetworkInformationException() { } public NetworkInformationException(int errorCode) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NetworkInformationException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public override int ErrorCode { get { throw null; } } } diff --git a/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj b/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj index c9b2bbb83a5af7..2a742d79f71441 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj +++ b/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj @@ -51,6 +51,7 @@ + diff --git a/src/libraries/System.Net.Ping/ref/System.Net.Ping.cs b/src/libraries/System.Net.Ping/ref/System.Net.Ping.cs index d549c5e306575a..4b4c048a4aa031 100644 --- a/src/libraries/System.Net.Ping/ref/System.Net.Ping.cs +++ b/src/libraries/System.Net.Ping/ref/System.Net.Ping.cs @@ -77,6 +77,8 @@ public partial class PingCompletedEventArgs : System.ComponentModel.AsyncComplet public delegate void PingCompletedEventHandler(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e); public partial class PingException : System.InvalidOperationException { + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected PingException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public PingException(string? message) { } public PingException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj b/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj index 16b84ae2ad5af6..9c817f3908a98c 100644 --- a/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj +++ b/src/libraries/System.Net.Ping/src/System.Net.Ping.csproj @@ -19,6 +19,8 @@ + diff --git a/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs b/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs index c3c88d3b5123df..779f6dc08ff429 100644 --- a/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs +++ b/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/PingException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net.NetworkInformation @@ -19,6 +20,8 @@ public PingException(string? message, Exception? innerException) : { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected PingException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { diff --git a/src/libraries/System.Net.Primitives/ref/System.Net.Primitives.cs b/src/libraries/System.Net.Primitives/ref/System.Net.Primitives.cs index 5e329e0b9aa5e5..895312c029ac25 100644 --- a/src/libraries/System.Net.Primitives/ref/System.Net.Primitives.cs +++ b/src/libraries/System.Net.Primitives/ref/System.Net.Primitives.cs @@ -89,7 +89,11 @@ public void SetCookies(System.Uri uri, string cookieHeader) { } public partial class CookieException : System.FormatException, System.Runtime.Serialization.ISerializable { public CookieException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CookieException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } @@ -504,6 +508,8 @@ public partial class SocketException : System.ComponentModel.Win32Exception public SocketException() { } public SocketException(int errorCode) { } public SocketException(int errorCode, string? message) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SocketException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public override int ErrorCode { get { throw null; } } public override string Message { get { throw null; } } diff --git a/src/libraries/System.Net.Primitives/src/System/Net/CookieException.cs b/src/libraries/System.Net.Primitives/src/System/Net/CookieException.cs index fd7f3ade521226..e53dcfda1d56b5 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/CookieException.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/CookieException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net @@ -21,16 +22,21 @@ internal CookieException(string? message, Exception? inner) : base(message, inne { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CookieException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Net.Primitives/src/System/Net/SocketException.cs b/src/libraries/System.Net.Primitives/src/System/Net/SocketException.cs index 6bbc58c0e8cc39..1a9c516563a452 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/SocketException.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/SocketException.cs @@ -51,6 +51,8 @@ internal SocketException(SocketError socketError, string? message) : base(GetNat public SocketError SocketErrorCode => _errorCode; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SocketException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { diff --git a/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj b/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj index fde9a8ab0e3510..a48a8e9eb222c9 100644 --- a/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj +++ b/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj @@ -37,6 +37,8 @@ Link="ProductionCode\Common\System\Text\StringBuilderCache.cs" /> + diff --git a/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj b/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj index df7e660405802b..3bbac4fb7203e7 100644 --- a/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj +++ b/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj @@ -48,6 +48,8 @@ Link="ProductionCode\System\Net\IPAddressParser.cs" /> + diff --git a/src/libraries/System.Net.Requests/ref/System.Net.Requests.cs b/src/libraries/System.Net.Requests/ref/System.Net.Requests.cs index 825698e157c179..02c97895e7c4de 100644 --- a/src/libraries/System.Net.Requests/ref/System.Net.Requests.cs +++ b/src/libraries/System.Net.Requests/ref/System.Net.Requests.cs @@ -34,6 +34,7 @@ public Authorization(string? token, bool finished, string? connectionGroupId) { public partial class FileWebRequest : System.Net.WebRequest, System.Runtime.Serialization.ISerializable { [System.ObsoleteAttribute("Serialization has been deprecated for FileWebRequest.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FileWebRequest(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public override string? ConnectionGroupName { get { throw null; } set { } } public override long ContentLength { get { throw null; } set { } } @@ -63,6 +64,7 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public partial class FileWebResponse : System.Net.WebResponse, System.Runtime.Serialization.ISerializable { [System.ObsoleteAttribute("Serialization has been deprecated for FileWebResponse.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FileWebResponse(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public override long ContentLength { get { throw null; } } public override string ContentType { get { throw null; } } @@ -178,6 +180,7 @@ public GlobalProxySelection() { } public partial class HttpWebRequest : System.Net.WebRequest, System.Runtime.Serialization.ISerializable { [System.ObsoleteAttribute("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected HttpWebRequest(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public string? Accept { get { throw null; } set { } } public System.Uri Address { get { throw null; } } @@ -252,6 +255,7 @@ public partial class HttpWebResponse : System.Net.WebResponse, System.Runtime.Se [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public HttpWebResponse() { } [System.ObsoleteAttribute("Serialization has been deprecated for HttpWebResponse.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected HttpWebResponse(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public string? CharacterSet { get { throw null; } } public string ContentEncoding { get { throw null; } } @@ -295,14 +299,20 @@ public partial interface IWebRequestCreate public partial class ProtocolViolationException : System.InvalidOperationException, System.Runtime.Serialization.ISerializable { public ProtocolViolationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ProtocolViolationException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public ProtocolViolationException(string? message) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public partial class WebException : System.InvalidOperationException, System.Runtime.Serialization.ISerializable { public WebException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WebException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public WebException(string? message) { } public WebException(string? message, System.Exception? innerException) { } @@ -310,6 +320,8 @@ public WebException(string? message, System.Exception? innerException, System.Ne public WebException(string? message, System.Net.WebExceptionStatus status) { } public System.Net.WebResponse? Response { get { throw null; } } public System.Net.WebExceptionStatus Status { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } @@ -342,6 +354,7 @@ public abstract partial class WebRequest : System.MarshalByRefObject, System.Run [System.ObsoleteAttribute("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] protected WebRequest() { } [System.ObsoleteAttribute("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WebRequest(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public System.Net.Security.AuthenticationLevel AuthenticationLevel { get { throw null; } set { } } public virtual System.Net.Cache.RequestCachePolicy? CachePolicy { get { throw null; } set { } } @@ -423,6 +436,7 @@ public abstract partial class WebResponse : System.MarshalByRefObject, System.ID { protected WebResponse() { } [System.ObsoleteAttribute("Serialization has been deprecated for WebResponse.")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WebResponse(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public virtual long ContentLength { get { throw null; } set { } } public virtual string ContentType { get { throw null; } set { } } diff --git a/src/libraries/System.Net.Requests/src/System/Net/FileWebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/FileWebRequest.cs index 42a7f41018fafb..7a938664b5cebc 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FileWebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FileWebRequest.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.IO; using System.Threading; using System.Runtime.Serialization; @@ -36,6 +37,7 @@ internal FileWebRequest(Uri uri) } [Obsolete("Serialization has been deprecated for FileWebRequest.")] + [EditorBrowsable(EditorBrowsableState.Never)] protected FileWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.Requests/src/System/Net/FileWebResponse.cs b/src/libraries/System.Net.Requests/src/System/Net/FileWebResponse.cs index 1a2009c75f5449..c1c26f1705995a 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FileWebResponse.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FileWebResponse.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.IO; using System.Runtime.Serialization; using System.Globalization; @@ -46,6 +47,7 @@ internal FileWebResponse(FileWebRequest request, Uri uri, FileAccess access, boo } [Obsolete("Serialization has been deprecated for FileWebResponse.")] + [EditorBrowsable(EditorBrowsableState.Never)] protected FileWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs index 68cfb32755b34e..5362745761ba1f 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -169,6 +170,7 @@ public bool AreParametersAcceptableForCaching() private const string ChunkedHeader = "chunked"; [Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected HttpWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs b/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs index 3002d360e98554..f7fae7869b1e7f 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/HttpWebResponse.cs @@ -35,6 +35,7 @@ public HttpWebResponse() } [Obsolete("Serialization has been deprecated for HttpWebResponse.")] + [EditorBrowsable(EditorBrowsableState.Never)] protected HttpWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.Requests/src/System/Net/ProtocolViolationException.cs b/src/libraries/System.Net.Requests/src/System/Net/ProtocolViolationException.cs index aa6576cde311bd..3d8ce6d57dc538 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/ProtocolViolationException.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/ProtocolViolationException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Net @@ -34,16 +35,21 @@ public ProtocolViolationException(string? message) : base(message) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ProtocolViolationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Net.Requests/src/System/Net/WebException.cs b/src/libraries/System.Net.Requests/src/System/Net/WebException.cs index 06f2207308a6b2..2e95bb61f2b43a 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/WebException.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/WebException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Net.Http; using System.Net.Sockets; @@ -52,6 +53,8 @@ public WebException(string? message, } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WebException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { @@ -61,11 +64,14 @@ protected WebException(SerializationInfo serializationInfo, StreamingContext str public WebResponse? Response => _response; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs index 8ba5533841f118..168873423c0b1f 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -37,6 +38,7 @@ public WebRequestPrefixElement(string prefix, IWebRequestCreate creator) protected WebRequest() { } [Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs b/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs index 8f43fabf1e5667..5261eb84fde37f 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.IO; using System.Runtime.Serialization; @@ -24,6 +25,7 @@ protected WebResponse() } [Obsolete("Serialization has been deprecated for WebResponse.")] + [EditorBrowsable(EditorBrowsableState.Never)] protected WebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.Security/ref/System.Net.Security.cs b/src/libraries/System.Net.Security/ref/System.Net.Security.cs index 0f32fd2090c56b..c6b5ad00e1904a 100644 --- a/src/libraries/System.Net.Security/ref/System.Net.Security.cs +++ b/src/libraries/System.Net.Security/ref/System.Net.Security.cs @@ -674,6 +674,8 @@ namespace System.Security.Authentication public partial class AuthenticationException : System.SystemException { public AuthenticationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected AuthenticationException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public AuthenticationException(string? message) { } public AuthenticationException(string? message, System.Exception? innerException) { } @@ -681,6 +683,8 @@ public AuthenticationException(string? message, System.Exception? innerException public partial class InvalidCredentialException : System.Security.Authentication.AuthenticationException { public InvalidCredentialException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidCredentialException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public InvalidCredentialException(string? message) { } public InvalidCredentialException(string? message, System.Exception? innerException) { } @@ -690,6 +694,8 @@ namespace System.Security.Authentication.ExtendedProtection { public partial class ExtendedProtectionPolicy : System.Runtime.Serialization.ISerializable { + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ExtendedProtectionPolicy(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ExtendedProtectionPolicy(System.Security.Authentication.ExtendedProtection.PolicyEnforcement policyEnforcement) { } public ExtendedProtectionPolicy(System.Security.Authentication.ExtendedProtection.PolicyEnforcement policyEnforcement, System.Security.Authentication.ExtendedProtection.ChannelBinding customChannelBinding) { } diff --git a/src/libraries/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs b/src/libraries/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs index 560491b73f7b56..b83e75144bbb08 100644 --- a/src/libraries/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs +++ b/src/libraries/System.Net.Security/src/System/Security/Authentication/AuthenticationException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Security.Authentication @@ -20,6 +21,8 @@ public AuthenticationException(string? message) : base(message) { } public AuthenticationException(string? message, Exception? innerException) : base(message, innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected AuthenticationException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } @@ -42,6 +45,8 @@ public InvalidCredentialException(string? message) : base(message) { } public InvalidCredentialException(string? message, Exception? innerException) : base(message, innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidCredentialException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } diff --git a/src/libraries/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs b/src/libraries/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs index 7fcb88eda48737..d0d19339322f76 100644 --- a/src/libraries/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs +++ b/src/libraries/System.Net.Security/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicy.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; +using System.ComponentModel; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Text; @@ -67,6 +68,8 @@ public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement) _protectionScenario = ProtectionScenario.TransportSelected; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ExtendedProtectionPolicy(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.WebHeaderCollection/ref/System.Net.WebHeaderCollection.cs b/src/libraries/System.Net.WebHeaderCollection/ref/System.Net.WebHeaderCollection.cs index 297dc1dd6560be..7b1dbfc2f878a5 100644 --- a/src/libraries/System.Net.WebHeaderCollection/ref/System.Net.WebHeaderCollection.cs +++ b/src/libraries/System.Net.WebHeaderCollection/ref/System.Net.WebHeaderCollection.cs @@ -86,6 +86,8 @@ public enum HttpResponseHeader public partial class WebHeaderCollection : System.Collections.Specialized.NameValueCollection, System.Collections.IEnumerable, System.Runtime.Serialization.ISerializable { public WebHeaderCollection() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WebHeaderCollection(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public override string[] AllKeys { get { throw null; } } public override int Count { get { throw null; } } @@ -102,6 +104,8 @@ public override void Clear() { } public override string? Get(string? name) { throw null; } public override System.Collections.IEnumerator GetEnumerator() { throw null; } public override string GetKey(int index) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public override string[]? GetValues(int index) { throw null; } public override string[]? GetValues(string header) { throw null; } diff --git a/src/libraries/System.Net.WebHeaderCollection/src/System.Net.WebHeaderCollection.csproj b/src/libraries/System.Net.WebHeaderCollection/src/System.Net.WebHeaderCollection.csproj index e787e038e147c9..bb0668ed63149f 100644 --- a/src/libraries/System.Net.WebHeaderCollection/src/System.Net.WebHeaderCollection.csproj +++ b/src/libraries/System.Net.WebHeaderCollection/src/System.Net.WebHeaderCollection.csproj @@ -15,6 +15,8 @@ Link="Common\System\Net\HttpKnownHeaderNames.cs" /> + diff --git a/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs b/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs index f28ca8de82104e..0c8a61f0134ab4 100644 --- a/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs +++ b/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; +using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization; @@ -28,6 +29,8 @@ public class WebHeaderCollection : NameValueCollection, ISerializable private static HeaderInfoTable? _headerInfo; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WebHeaderCollection(SerializationInfo serializationInfo, StreamingContext streamingContext) { throw new PlatformNotSupportedException(); @@ -134,6 +137,8 @@ public void Set(HttpResponseHeader header, string? value) this.Set(header.GetName(), value); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.WebProxy/ref/System.Net.WebProxy.cs b/src/libraries/System.Net.WebProxy/ref/System.Net.WebProxy.cs index 332ad18ed59dc6..73632bfd071161 100644 --- a/src/libraries/System.Net.WebProxy/ref/System.Net.WebProxy.cs +++ b/src/libraries/System.Net.WebProxy/ref/System.Net.WebProxy.cs @@ -15,6 +15,8 @@ public partial interface IWebProxyScript public partial class WebProxy : System.Net.IWebProxy, System.Runtime.Serialization.ISerializable { public WebProxy() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WebProxy(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public WebProxy(string? Address) { } public WebProxy(string? Address, bool BypassOnLocal) { } diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index 68485c90ea3556..9becff3118f39b 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -6,6 +6,7 @@ + diff --git a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs index 94b7e980745566..96d091cc37b50e 100644 --- a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs +++ b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs @@ -3,6 +3,7 @@ using System.Buffers; using System.Collections; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -203,6 +204,8 @@ public bool IsBypassed(Uri host) IsMatchInBypassList(host); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WebProxy(SerializationInfo serializationInfo, StreamingContext streamingContext) => throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs b/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs index 69cd0cba6f1ff4..e3d230708b3f23 100644 --- a/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs +++ b/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs @@ -106,6 +106,8 @@ public WebSocketException(string? message) { } public WebSocketException(string? message, System.Exception? innerException) { } public override int ErrorCode { get { throw null; } } public System.Net.WebSockets.WebSocketError WebSocketErrorCode { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public enum WebSocketMessageType diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index f9ef1c7848c47c..ebb2af8ed9ab71 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -33,6 +33,8 @@ Link="Common\System\IO\Compression\ZLibNative.ZStream.cs" /> + diff --git a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs index d21721fc25420d..4f4c5d5468be14 100644 --- a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs +++ b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs @@ -95,11 +95,15 @@ public WebSocketException(string? message, Exception? innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] private WebSocketException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ManualShimTypeForwards.cs b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ManualShimTypeForwards.cs index 504e6898bb2f91..0a93320ccff1eb 100644 --- a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ManualShimTypeForwards.cs +++ b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ManualShimTypeForwards.cs @@ -25,6 +25,7 @@ internal OrdinalComparer() { } public override int GetHashCode() { throw null; } public override int GetHashCode(string obj) { throw null; } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public sealed partial class UnitySerializationHolder : System.Runtime.Serialization.IObjectReference, System.Runtime.Serialization.ISerializable { public UnitySerializationHolder(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } @@ -90,6 +91,8 @@ public GenericEqualityComparer() { } } public partial class NonRandomizedStringEqualityComparer : System.Collections.Generic.IEqualityComparer, System.Runtime.Serialization.ISerializable { + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NonRandomizedStringEqualityComparer(System.Runtime.Serialization.SerializationInfo information, System.Runtime.Serialization.StreamingContext context) { } public virtual bool Equals(string? x, string? y) { throw null; } public virtual int GetHashCode(string? obj) { throw null; } @@ -139,6 +142,8 @@ public ContractException(System.Diagnostics.Contracts.ContractFailureKind kind, public string Failure { get { throw null; } } public System.Diagnostics.Contracts.ContractFailureKind Kind { get { throw null; } } public string? UserMessage { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 16ad6d3e156b18..ca28dc77499565 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -1447,9 +1447,6 @@ The specified opcode cannot be passed to EmitCall. - - Argument passed in is not serializable. - Uninitialized Strings cannot be created. diff --git a/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs b/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs index 45300b56e958a2..9c98879b7fbe23 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AccessViolationException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public AccessViolationException(string? message, Exception? innerException) HResult = HResults.E_POINTER; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected AccessViolationException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs b/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs index 7c2d694d651194..cedfd4916fa5f2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Runtime.ExceptionServices; @@ -183,6 +184,8 @@ internal AggregateException(string message, List innerExc /// contains contextual information about the source or destination. /// The argument is null. /// The exception could not be deserialized correctly. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected AggregateException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -204,6 +207,8 @@ protected AggregateException(SerializationInfo info, StreamingContext context) : /// The that /// contains contextual information about the source or destination. /// The argument is null. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs b/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs index 13421ea751fdf2..cca4a77821de0b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AppDomainUnloadedException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -27,6 +28,8 @@ public AppDomainUnloadedException(string? message, Exception? innerException) HResult = HResults.COR_E_APPDOMAINUNLOADED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected AppDomainUnloadedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/ApplicationException.cs b/src/libraries/System.Private.CoreLib/src/System/ApplicationException.cs index 192e39ebad1739..230f9bbd09bfee 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ApplicationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ApplicationException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -50,6 +51,8 @@ public ApplicationException(string? message, Exception? innerException) HResult = HResults.COR_E_APPLICATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/ArgumentException.cs b/src/libraries/System.Private.CoreLib/src/System/ArgumentException.cs index 2c2971f805d3ac..e9b41c5af3e8a7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArgumentException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArgumentException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -62,12 +63,16 @@ public ArgumentException(string? message, string? paramName) HResult = HResults.COR_E_ARGUMENT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) { _paramName = info.GetString("ParamName"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs b/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs index c8c7aac72733bb..fb86d3164dd745 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -49,6 +50,8 @@ public ArgumentNullException(string? paramName, string? message) HResult = HResults.E_POINTER; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs b/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs index d2ec8ca54f0878..03f895d5d2b249 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Diagnostics.CodeAnalysis; @@ -59,12 +60,16 @@ public ArgumentOutOfRangeException(string? paramName, object? actualValue, strin HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ArgumentOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) { _actualValue = info.GetValue("ActualValue", typeof(object)); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs b/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs index 33c863cadb227d..fcac02874fb03a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArithmeticException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -45,6 +46,8 @@ public ArithmeticException(string? message, Exception? innerException) HResult = HResults.COR_E_ARITHMETIC; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ArithmeticException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs b/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs index 58cf3f2581e4ae..fb5e015403b1b3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ArrayTypeMismatchException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -45,6 +46,8 @@ public ArrayTypeMismatchException(string? message, Exception? innerException) HResult = HResults.COR_E_ARRAYTYPEMISMATCH; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/BadImageFormatException.cs b/src/libraries/System.Private.CoreLib/src/System/BadImageFormatException.cs index ced884d47d54fa..a6ce855ba7b368 100644 --- a/src/libraries/System.Private.CoreLib/src/System/BadImageFormatException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/BadImageFormatException.cs @@ -10,6 +10,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.IO; using System.Runtime.Serialization; @@ -53,6 +54,8 @@ public BadImageFormatException(string? message, string? fileName, Exception? inn _fileName = fileName; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected BadImageFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -60,6 +63,8 @@ protected BadImageFormatException(SerializationInfo info, StreamingContext conte _fusionLog = info.GetString("BadImageFormat_FusionLog"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs b/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs index d9967a45883d56..4bc63d4414f5d9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/CannotUnloadAppDomainException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -27,6 +28,8 @@ public CannotUnloadAppDomainException(string? message, Exception? innerException HResult = HResults.COR_E_CANNOTUNLOADAPPDOMAIN; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CannotUnloadAppDomainException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Comparer.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Comparer.cs index d676f813f68637..8c518d56c3b937 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Comparer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Comparer.cs @@ -7,6 +7,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Globalization; using System.Runtime.Serialization; @@ -35,6 +36,8 @@ private Comparer(SerializationInfo info, StreamingContext context) _compareInfo = (CompareInfo)info.GetValue("CompareInfo", typeof(CompareInfo))!; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs index fe5f11e025198f..bb470cc9b5fd84 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -156,6 +157,8 @@ private void AddRange(IEnumerable> collection) } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected Dictionary(SerializationInfo info, StreamingContext context) { // We can't do anything with the keys and values until the entire graph has been deserialized @@ -342,6 +345,8 @@ IEnumerator> IEnumerable>. Count == 0 ? GenericEmptyEnumerator>.Instance : GetEnumerator(); + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs index 7537e2d4b80f90..668550bddf66b5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -129,6 +130,8 @@ public HashSet(int capacity, IEqualityComparer? comparer) : this(comparer) } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected HashSet(SerializationInfo info, StreamingContext context) { // We can't do anything with the keys and values until the entire graph has been @@ -368,6 +371,8 @@ IEnumerator IEnumerable.GetEnumerator() => #region ISerializable methods + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs index 47e0e94f307acf..9e3483d40b4159 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/KeyNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Collections.Generic @@ -27,6 +28,8 @@ public KeyNotFoundException(string? message, Exception? innerException) HResult = HResults.COR_E_KEYNOTFOUND; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected KeyNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/NonRandomizedStringEqualityComparer.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/NonRandomizedStringEqualityComparer.cs index 25846a6b2abb2c..de01ba5bdc5ad9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/NonRandomizedStringEqualityComparer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/NonRandomizedStringEqualityComparer.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; @@ -31,6 +32,8 @@ private NonRandomizedStringEqualityComparer(IEqualityComparer underlyin } // This is used by the serialization engine. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NonRandomizedStringEqualityComparer(SerializationInfo information, StreamingContext context) : this(EqualityComparer.Default) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs index b0c8757c3065a2..dfc019167c7d80 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs @@ -11,6 +11,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; using System.Threading; @@ -361,6 +362,8 @@ public Hashtable(IDictionary d, float loadFactor, IEqualityComparer? equalityCom Add(e.Key, e.Value); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected Hashtable(SerializationInfo info, StreamingContext context) { // We can't do anything with the keys and values until the entire graph has been deserialized @@ -1019,6 +1022,8 @@ public static Hashtable Synchronized(Hashtable table) return new SyncHashtable(table); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); @@ -1252,11 +1257,7 @@ internal SyncHashtable(Hashtable table) : base(false) _table = table; } - internal SyncHashtable(SerializationInfo info, StreamingContext context) : base(info, context) - { - throw new PlatformNotSupportedException(); - } - + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/ComponentModel/Win32Exception.cs b/src/libraries/System.Private.CoreLib/src/System/ComponentModel/Win32Exception.cs index dfc7955362fc01..a6239139beef8d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ComponentModel/Win32Exception.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ComponentModel/Win32Exception.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -13,7 +14,7 @@ namespace System.ComponentModel /// [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public class Win32Exception : ExternalException, ISerializable + public class Win32Exception : ExternalException { private const int E_FAIL = unchecked((int)0x80004005); @@ -56,11 +57,15 @@ public Win32Exception(string? message, Exception? innerException) : base(message NativeErrorCode = Marshal.GetLastPInvokeError(); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected Win32Exception(SerializationInfo info, StreamingContext context) : base(info, context) { NativeErrorCode = info.GetInt32(nameof(NativeErrorCode)); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Context.cs b/src/libraries/System.Private.CoreLib/src/System/Context.cs index e9aeef1838bae3..49f0cf41878eda 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Context.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Context.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -27,6 +28,8 @@ public ContextMarshalException(string? message, Exception? inner) : base(message HResult = HResults.COR_E_CONTEXTMARSHAL; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ContextMarshalException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/DBNull.cs b/src/libraries/System.Private.CoreLib/src/System/DBNull.cs index 41d56a6ce12282..efed247d28c7c8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DBNull.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DBNull.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -12,16 +13,15 @@ private DBNull() { } - private DBNull(SerializationInfo info, StreamingContext context) - { - throw new NotSupportedException(SR.NotSupported_DBNullSerial); - } - public static readonly DBNull Value = new DBNull(); + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { +#pragma warning disable SYSLIB0050 // UnitySerializationHolder is obsolete UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.NullUnity); +#pragma warning restore SYSLIB0050 } public override string ToString() diff --git a/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs b/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs index b2860db70ea096..9325e30e67a50e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DataMisalignedException.cs @@ -8,6 +8,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -34,6 +35,8 @@ public DataMisalignedException(string? message, Exception? innerException) HResult = HResults.COR_E_DATAMISALIGNED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] private DataMisalignedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Delegate.cs b/src/libraries/System.Private.CoreLib/src/System/Delegate.cs index 4d233631223d2d..be5b8157debbff 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Delegate.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Delegate.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; @@ -61,6 +62,8 @@ public abstract partial class Delegate : ICloneable, ISerializable return DynamicInvokeImpl(args); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) => throw new PlatformNotSupportedException(); public MethodInfo Method => GetMethodImpl(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractException.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractException.cs index 52883c91f2ee99..8925fb287823d1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Diagnostics.Contracts @@ -34,6 +35,7 @@ public ContractException(ContractFailureKind kind, string? failure, string? user _condition = condition; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private ContractException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -42,7 +44,8 @@ private ContractException(SerializationInfo info, StreamingContext context) _condition = info.GetString("Condition"); } - + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs index 8127d1d7db183d..29a2a53c927466 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Diagnostics.Tracing @@ -32,6 +33,8 @@ public EventSourceException(string? message, Exception? innerException) : base(m /// /// Initializes a new instance of the EventSourceException class with serialized data. /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected EventSourceException(SerializationInfo info, StreamingContext context) : base(info, context) { } internal EventSourceException(Exception? innerException) : diff --git a/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs b/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs index 1adfeeb463630a..7db76dc9f2d350 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DivideByZeroException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public DivideByZeroException(string? message, Exception? innerException) HResult = HResults.COR_E_DIVIDEBYZERO; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DivideByZeroException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs index 6b0a364c022007..3da70e3f7be0ae 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DllNotFoundException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -37,6 +38,8 @@ public DllNotFoundException(string? message, Exception? inner) HResult = HResults.COR_E_DLLNOTFOUND; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DllNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs b/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs index 2a3c27f0b32c43..24c86492ec822e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DuplicateWaitObjectException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -46,6 +47,8 @@ public DuplicateWaitObjectException(string? message, Exception? innerException) HResult = HResults.COR_E_DUPLICATEWAITOBJECT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DuplicateWaitObjectException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs index 8aaa97b9a9de13..d6677ed353edf7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/EntryPointNotFoundException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public EntryPointNotFoundException(string? message, Exception? inner) HResult = HResults.COR_E_ENTRYPOINTNOTFOUND; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected EntryPointNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Exception.cs b/src/libraries/System.Private.CoreLib/src/System/Exception.cs index f8271606e92b49..f7d5139e98a939 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Exception.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Exception.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -38,6 +39,8 @@ public Exception(string? message, Exception? innerException) _innerException = innerException; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected Exception(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); @@ -95,6 +98,8 @@ public virtual string? Source set => _source = value; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); diff --git a/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs index b8db7bd340a063..2fbdd9d53e0336 100644 --- a/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/FieldAccessException.cs @@ -8,6 +8,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -34,6 +35,8 @@ public FieldAccessException(string? message, Exception? inner) HResult = HResults.COR_E_FIELDACCESS; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected FieldAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/FormatException.cs b/src/libraries/System.Private.CoreLib/src/System/FormatException.cs index 3681fed74b6b0e..2eee0bca9ce988 100644 --- a/src/libraries/System.Private.CoreLib/src/System/FormatException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/FormatException.cs @@ -10,6 +10,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public FormatException(string? message, Exception? innerException) HResult = HResults.COR_E_FORMAT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected FormatException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs index bc274c3c907907..41f714b2cd1f96 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Globalization @@ -56,6 +57,8 @@ public CultureNotFoundException(string? paramName, int invalidCultureId, string? _invalidCultureId = invalidCultureId; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CultureNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -63,6 +66,8 @@ protected CultureNotFoundException(SerializationInfo info, StreamingContext cont _invalidCultureName = (string?)info.GetValue("InvalidCultureName", typeof(string)); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs index 1d53a086ea7161..dade7b3a68a64c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -33,6 +34,8 @@ public DirectoryNotFoundException(string? message, Exception? innerException) HResult = HResults.COR_E_DIRECTORYNOTFOUND; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected DirectoryNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs index c1f5c18ab18d9b..7bd422ba220c19 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/EndOfStreamException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -27,6 +28,8 @@ public EndOfStreamException(string? message, Exception? innerException) HResult = HResults.COR_E_ENDOFSTREAM; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected EndOfStreamException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileLoadException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileLoadException.cs index a7ca60e90c1b3f..816b90577eee85 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileLoadException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileLoadException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -67,6 +68,8 @@ public override string ToString() return s; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected FileLoadException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -74,6 +77,8 @@ protected FileLoadException(SerializationInfo info, StreamingContext context) FusionLog = info.GetString("FileLoad_FusionLog"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileNotFoundException.cs index 094a81877b6046..569dc1850b9ff2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; @@ -89,6 +90,8 @@ public override string ToString() return s; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected FileNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -96,6 +99,8 @@ protected FileNotFoundException(SerializationInfo info, StreamingContext context FusionLog = info.GetString("FileNotFound_FusionLog"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs index da70b06ed50393..6c4242dfa4cf23 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Runtime.Serialization; @@ -20,6 +21,8 @@ public abstract partial class FileSystemInfo : MarshalByRefObject, ISerializable private string? _linkTarget; private bool _linkTargetIsValid; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected FileSystemInfo(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); @@ -31,6 +34,8 @@ internal void Invalidate() InvalidateCore(); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/IOException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/IOException.cs index e3bcac9aafef19..0cbaac41038f11 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/IOException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/IOException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -33,6 +34,8 @@ public IOException(string? message, Exception? innerException) HResult = HResults.COR_E_IO; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected IOException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs index bd193133ef3392..2907219cc1e859 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/InvalidDataException.cs @@ -36,6 +36,7 @@ public InvalidDataException(string? message, Exception? innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private InvalidDataException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs b/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs index 51269a482ba28d..e5b66894f95bf6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/PathTooLongException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.IO @@ -27,6 +28,8 @@ public PathTooLongException(string? message, Exception? innerException) HResult = HResults.COR_E_PATHTOOLONG; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected PathTooLongException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs b/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs index 19ec2ee6819c45..2a900f8d24be1b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IndexOutOfRangeException.cs @@ -36,6 +36,7 @@ public IndexOutOfRangeException(string? message, Exception? innerException) HResult = HResults.COR_E_INDEXOUTOFRANGE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private IndexOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs b/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs index 125238128fd179..57479d9279ad6f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InsufficientExecutionStackException.cs @@ -27,6 +27,7 @@ public InsufficientExecutionStackException(string? message, Exception? innerExce HResult = HResults.COR_E_INSUFFICIENTEXECUTIONSTACK; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private InsufficientExecutionStackException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs b/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs index 1bac8b52bda970..e6681690a642ee 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InsufficientMemoryException.cs @@ -40,6 +40,7 @@ public InsufficientMemoryException(string? message, Exception? innerException) HResult = HResults.COR_E_INSUFFICIENTMEMORY; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private InsufficientMemoryException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs index 39492818d0890c..867c7bb97cc1bd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidCastException.cs @@ -7,6 +7,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -39,6 +40,8 @@ public InvalidCastException(string? message, int errorCode) HResult = errorCode; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs index 1bd63539ac5198..8ac60234798dea 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidOperationException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -37,6 +38,8 @@ public InvalidOperationException(string? message, Exception? innerException) HResult = HResults.COR_E_INVALIDOPERATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs index 67bef8a2d0c4d0..b4cdf72787ce94 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidProgramException.cs @@ -36,6 +36,7 @@ public InvalidProgramException(string? message, Exception? inner) HResult = HResults.COR_E_INVALIDPROGRAM; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private InvalidProgramException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/InvalidTimeZoneException.cs b/src/libraries/System.Private.CoreLib/src/System/InvalidTimeZoneException.cs index 3d98454aedf832..6ad67475a41d0d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/InvalidTimeZoneException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/InvalidTimeZoneException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -23,6 +24,8 @@ public InvalidTimeZoneException(string? message, Exception? innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs index d080911af1ee99..3863bc505e8b01 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MemberAccessException.cs @@ -7,6 +7,7 @@ // access, due to it being removed, private or something similar. //////////////////////////////////////////////////////////////////////////////// +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -42,6 +43,8 @@ public MemberAccessException(string? message, Exception? inner) HResult = HResults.COR_E_MEMBERACCESS; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MemberAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs index a42370e95aaab0..ff7f21820a55ee 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MethodAccessException.cs @@ -8,6 +8,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -34,6 +35,8 @@ public MethodAccessException(string? message, Exception? inner) HResult = HResults.COR_E_METHODACCESS; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MethodAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs b/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs index 11aad6da3cb2d1..2c388e8d7fbae0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MissingFieldException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -34,6 +35,8 @@ public MissingFieldException(string? className, string? fieldName) HResult = HResults.COR_E_MISSINGFIELD; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MissingFieldException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs b/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs index f0ef486d86e8b8..0ae639e0a31398 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MissingMemberException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -34,6 +35,8 @@ public MissingMemberException(string? className, string? memberName) HResult = HResults.COR_E_MISSINGMEMBER; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MissingMemberException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -42,6 +45,8 @@ protected MissingMemberException(SerializationInfo info, StreamingContext contex Signature = (byte[]?)info.GetValue("MMSignature", typeof(byte[])); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs b/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs index e8363f67a3d918..e16db06b7ecf08 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MissingMethodException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -43,6 +44,8 @@ public MissingMethodException(string? className, string? methodName) HResult = HResults.COR_E_MISSINGMETHOD; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MissingMethodException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs b/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs index c252ed8fb6114a..0826497e1dd0d9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MulticastNotSupportedException.cs @@ -32,6 +32,7 @@ public MulticastNotSupportedException(string? message, Exception? inner) HResult = HResults.COR_E_MULTICASTNOTSUPPORTED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private MulticastNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/NonSerializedAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/NonSerializedAttribute.cs index e521b6c7367862..c23e505d4e4a3c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NonSerializedAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NonSerializedAttribute.cs @@ -1,9 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; + namespace System { [AttributeUsage(AttributeTargets.Field, Inherited = false)] + [EditorBrowsable(EditorBrowsableState.Never)] public sealed class NonSerializedAttribute : Attribute { public NonSerializedAttribute() diff --git a/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs b/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs index 658acf29efbaf8..021e3cf3a2c3e2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NotFiniteNumberException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -51,11 +52,15 @@ public NotFiniteNumberException(string? message, double offendingNumber, Excepti HResult = HResults.COR_E_NOTFINITENUMBER; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context) { _offendingNumber = info.GetDouble("OffendingNumber"); // Do not rename (binary serialization) } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs b/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs index e3186470803538..5afbddf0cacd83 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NotImplementedException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -35,6 +36,8 @@ public NotImplementedException(string? message, Exception? inner) HResult = HResults.E_NOTIMPL; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NotImplementedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs b/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs index 2ad334efd0575d..b5946a1611e356 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NotSupportedException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public NotSupportedException(string? message, Exception? innerException) HResult = HResults.COR_E_NOTSUPPORTED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs b/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs index 63fa7e7369f08b..b54b391f2a2d44 100644 --- a/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/NullReferenceException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public NullReferenceException(string? message, Exception? innerException) HResult = HResults.E_POINTER; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected NullReferenceException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs b/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs index c0d5803d79f4e7..5066ae5ea43795 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ObjectDisposedException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Diagnostics; @@ -40,6 +41,8 @@ public ObjectDisposedException(string? message, Exception? innerException) HResult = HResults.COR_E_OBJECTDISPOSED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ObjectDisposedException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -72,6 +75,8 @@ public static void ThrowIf([DoesNotReturnIf(true)] bool condition, Type type) } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index 30d5455249d4ce..8d6f33448325f8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -65,6 +66,8 @@ internal OperatingSystem(PlatformID platform, Version version, string? servicePa _servicePack = servicePack; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs b/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs index 66537488945b1c..e0e0c72754aedc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs @@ -10,6 +10,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; using System.Threading; @@ -65,6 +66,8 @@ public OperationCanceledException(string? message, Exception? innerException, Ca CancellationToken = token; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected OperationCanceledException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs b/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs index a361f1402d8337..4094711a82f8e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OutOfMemoryException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -35,6 +36,8 @@ public OutOfMemoryException(string? message, Exception? innerException) HResult = HResults.COR_E_OUTOFMEMORY; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected OutOfMemoryException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs b/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs index 9bcaf83fff9fcc..8d30c3b75c299a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OverflowException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public OverflowException(string? message, Exception? innerException) HResult = HResults.COR_E_OVERFLOW; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected OverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs b/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs index 70f0b98d0c3758..474e0736f638ee 100644 --- a/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/PlatformNotSupportedException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public PlatformNotSupportedException(string? message, Exception? inner) HResult = HResults.COR_E_PLATFORMNOTSUPPORTED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected PlatformNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/RankException.cs b/src/libraries/System.Private.CoreLib/src/System/RankException.cs index a65ba6a469bbba..4bfe6529ee32e3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/RankException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/RankException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -37,6 +38,8 @@ public RankException(string? message, Exception? innerException) HResult = HResults.COR_E_RANK; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected RankException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs index 024ba7ac99fed6..e86467d58a2330 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/AmbiguousMatchException.cs @@ -27,6 +27,7 @@ public AmbiguousMatchException(string? message, Exception? inner) HResult = HResults.COR_E_AMBIGUOUSMATCH; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private AmbiguousMatchException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs index 00095ffb7f48bd..ea22b60e5544e7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs @@ -4,6 +4,7 @@ using System.IO; using System.Globalization; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration.Assemblies; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -164,6 +165,8 @@ public virtual IEnumerable ExportedTypes [RequiresAssemblyFiles(ThrowingMessageInRAF)] public virtual FileStream[] GetFiles(bool getResourceModules) { throw NotImplemented.ByDesign; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw NotImplemented.ByDesign; } public override string ToString() diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs index 479c6199feceb2..791f6f22d9f9f7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Configuration.Assemblies; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -278,6 +279,8 @@ public override string ToString() return s; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs index 794ab45c2f054e..f381af37df05cc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeFormatException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Reflection @@ -25,6 +26,8 @@ public CustomAttributeFormatException(string? message, Exception? inner) HResult = HResults.COR_E_CUSTOMATTRIBUTEFORMAT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAttributes.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAttributes.cs index f4296883de19c9..1af46410e02e26 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAttributes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldAttributes.cs @@ -22,6 +22,7 @@ public enum FieldAttributes Static = 0x0010, // Defined on type, else per instance. InitOnly = 0x0020, // Field may only be initialized, not written to after init. Literal = 0x0040, // Value is compile time constant. + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] NotSerialized = 0x0080, // Field does not have to be serialized when type is remoted. SpecialName = 0x0200, // field is special. Name describes how. diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldInfo.cs index a544be89c423ed..374c0ba5aeeb13 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/FieldInfo.cs @@ -18,6 +18,7 @@ protected FieldInfo() { } public bool IsInitOnly => (Attributes & FieldAttributes.InitOnly) != 0; public bool IsLiteral => (Attributes & FieldAttributes.Literal) != 0; + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public bool IsNotSerialized => (Attributes & FieldAttributes.NotSerialized) != 0; public bool IsPinvokeImpl => (Attributes & FieldAttributes.PinvokeImpl) != 0; public bool IsSpecialName => (Attributes & FieldAttributes.SpecialName) != 0; diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs index fc373de5990835..14a84fe6baade9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/InvalidFilterCriteriaException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Reflection @@ -25,6 +26,8 @@ public InvalidFilterCriteriaException(string? message, Exception? inner) HResult = HResults.COR_E_INVALIDFILTERCRITERIA; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidFilterCriteriaException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Module.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Module.cs index 30f47a9e21a8d7..8234c96676d6f9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Module.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Module.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -137,6 +138,8 @@ public virtual Type[] FindTypes(TypeFilter? filter, object? filterCriteria) [RequiresUnreferencedCode("Trimming changes metadata tokens")] public virtual Type ResolveType(int metadataToken, Type[]? genericTypeArguments, Type[]? genericMethodArguments) { throw NotImplemented.ByDesign; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw NotImplemented.ByDesign; } public override bool Equals(object? o) => base.Equals(o); diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs index 5a92ca202fc878..6c93d8b7d01dc7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs @@ -2,11 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Reflection { - public class ParameterInfo : ICustomAttributeProvider, IObjectReference + public class ParameterInfo : ICustomAttributeProvider +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete +#pragma warning disable SA1001 // CommasMustBeSpacedCorrectly + , IObjectReference +#pragma warning restore SA1001 +#pragma warning restore SYSLIB0050 { protected ParameterInfo() { } @@ -49,6 +55,8 @@ public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) public virtual int MetadataToken => MetadataToken_ParamDef; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public object GetRealObject(StreamingContext context) { // Once all the serializable fields have come in we can set up the real diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/ReflectionTypeLoadException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/ReflectionTypeLoadException.cs index 61b658c47df407..975b3993017e50 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/ReflectionTypeLoadException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/ReflectionTypeLoadException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Text; @@ -9,7 +10,7 @@ namespace System.Reflection { [Serializable] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public sealed class ReflectionTypeLoadException : SystemException, ISerializable + public sealed class ReflectionTypeLoadException : SystemException { public ReflectionTypeLoadException(Type?[]? classes, Exception?[]? exceptions) : this(classes, exceptions, null) @@ -24,6 +25,7 @@ public ReflectionTypeLoadException(Type?[]? classes, Exception?[]? exceptions, s HResult = HResults.COR_E_REFLECTIONTYPELOAD; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private ReflectionTypeLoadException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -31,6 +33,8 @@ private ReflectionTypeLoadException(SerializationInfo info, StreamingContext con LoaderExceptions = (Exception?[]?)info.GetValue("Exceptions", typeof(Exception[])) ?? Array.Empty(); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureType.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureType.cs index e1dedc841bd5bd..2d85c4ea0a5ef1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureType.cs @@ -195,6 +195,7 @@ public sealed override Type MakeArrayType(int rank) public sealed override bool IsSecurityCritical => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override bool IsSecuritySafeCritical => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override bool IsSecurityTransparent => throw new NotSupportedException(SR.NotSupported_SignatureType); + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public sealed override bool IsSerializable => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override bool IsSubclassOf(Type c) => throw new NotSupportedException(SR.NotSupported_SignatureType); protected sealed override bool IsValueTypeImpl() => throw new NotSupportedException(SR.NotSupported_SignatureType); diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs index 7ceaaebab1fb07..23c420df8eaa6e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.IO; using System.Runtime.Serialization; @@ -15,6 +16,8 @@ public StrongNameKeyPair(FileStream keyPairFile) => public StrongNameKeyPair(byte[] keyPairArray) => throw new PlatformNotSupportedException(SR.PlatformNotSupported_StrongNameSigning); + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected StrongNameKeyPair(SerializationInfo info, StreamingContext context) => throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetException.cs index a1d65febb3b83b..9efa8c9a1bc159 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Reflection @@ -25,6 +26,8 @@ public TargetException(string? message, Exception? inner) HResult = HResults.COR_E_TARGET; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TargetException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs index 83a32c0f123753..82b8a2b0ba1116 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetInvocationException.cs @@ -21,6 +21,7 @@ public TargetInvocationException(string? message, Exception? inner) HResult = HResults.COR_E_TARGETINVOCATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private TargetInvocationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs index 531bf4927b5622..de84822e6c92a9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/TargetParameterCountException.cs @@ -27,6 +27,7 @@ public TargetParameterCountException(string? message, Exception? inner) HResult = HResults.COR_E_TARGETPARAMCOUNT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private TargetParameterCountException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/TypeAttributes.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/TypeAttributes.cs index 894c4553155ca0..245cba7b13bf8e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/TypeAttributes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/TypeAttributes.cs @@ -37,6 +37,7 @@ public enum TypeAttributes // Implementation attributes. Import = 0x00001000, // Class / interface is imported + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] Serializable = 0x00002000, // The class is Serializable. WindowsRuntime = 0x00004000, // Type is a Windows Runtime type. diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs index b99dd7b3e26421..cfce9985321dd2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingManifestResourceException.cs @@ -29,6 +29,7 @@ public MissingManifestResourceException(string? message, Exception? inner) HResult = System.HResults.COR_E_MISSINGMANIFESTRESOURCE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] protected MissingManifestResourceException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs index 9634667e1193dc..de7724b91dcead 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/MissingSatelliteAssemblyException.cs @@ -14,6 +14,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Resources @@ -49,6 +50,8 @@ public MissingSatelliteAssemblyException(string? message, Exception? inner) HResult = System.HResults.COR_E_MISSINGSATELLITEASSEMBLY; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MissingSatelliteAssemblyException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs index 015ce9a317d9ef..692a26884d4875 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/AmbiguousImplementationException.cs @@ -27,6 +27,7 @@ public AmbiguousImplementationException(string? message, Exception? innerExcepti HResult = HResults.COR_E_AMBIGUOUSIMPLEMENTATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private AmbiguousImplementationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs index 74d207ba27b31e..e1c5af0e34daea 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.CompilerServices @@ -23,12 +24,15 @@ public RuntimeWrappedException(object thrownObject) _wrappedException = thrownObject; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private RuntimeWrappedException(SerializationInfo info, StreamingContext context) : base(info, context) { _wrappedException = info.GetValue("WrappedException", typeof(object))!; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs index f8106f171a60b9..b9a358eb538ecf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SwitchExpressionException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.CompilerServices @@ -27,6 +28,7 @@ public SwitchExpressionException(object? unmatchedValue) : this() UnmatchedValue = unmatchedValue; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private SwitchExpressionException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -40,6 +42,8 @@ public SwitchExpressionException(string? message, Exception? innerException) public object? UnmatchedValue { get; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs index 5fddcf97372948..f4dd72a3136175 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Globalization; using System.Text; @@ -40,6 +41,8 @@ public COMException(string? message, int errorCode) HResult = errorCode; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected COMException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs index 13b85e99139348..9032dbd17dc021 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Globalization; using System.Runtime.Serialization; @@ -46,6 +47,8 @@ public ExternalException(string? message, int errorCode) HResult = errorCode; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ExternalException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs index ef909472dbbd65..45614c4f6f27dd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.InteropServices @@ -32,6 +33,8 @@ public InvalidComObjectException(string? message, Exception? inner) HResult = HResults.COR_E_INVALIDCOMOBJECT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidComObjectException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs index c8937ae454719a..83b87e253ec09e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.InteropServices @@ -31,6 +32,8 @@ public InvalidOleVariantTypeException(string? message, Exception? inner) HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidOleVariantTypeException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs index 470b8498c5a1b7..8defddf208a10d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.InteropServices @@ -36,6 +37,8 @@ public MarshalDirectiveException(string? message, Exception? inner) HResult = HResults.COR_E_MARSHALDIRECTIVE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected MarshalDirectiveException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs index 5374fa82ac4b36..7b3596354d1a0a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.InteropServices @@ -29,6 +30,8 @@ public SEHException(string? message, Exception? inner) HResult = HResults.E_FAIL; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SEHException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs index 480d6b6b78b35b..f61cd68137f512 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.InteropServices @@ -31,6 +32,8 @@ public SafeArrayRankMismatchException(string? message, Exception? inner) HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SafeArrayRankMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs index 809ce090d1f1d2..6f27786022ee59 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Runtime.InteropServices @@ -31,6 +32,8 @@ public SafeArrayTypeMismatchException(string? message, Exception? inner) HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SafeArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IFormatterConverter.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IFormatterConverter.cs index f590627592f6dc..57230621e6bdc6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IFormatterConverter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IFormatterConverter.cs @@ -4,6 +4,7 @@ namespace System.Runtime.Serialization { [CLSCompliant(false)] + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface IFormatterConverter { object Convert(object value, Type type); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IObjectReference.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IObjectReference.cs index b6b6b6a8a80316..5674aece183cb6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IObjectReference.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/IObjectReference.cs @@ -3,6 +3,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface IObjectReference { object GetRealObject(StreamingContext context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISafeSerializationData.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISafeSerializationData.cs index 581a74fa38842b..96d952859b0f21 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISafeSerializationData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISafeSerializationData.cs @@ -3,204 +3,12 @@ namespace System.Runtime.Serialization { - // - // #SafeSerialization - // - // Types which are serializable via the ISerializable interface have a problem when it comes to allowing - // transparent subtypes which can allow themselves to serialize since the GetObjectData method is - // SecurityCritical. - // - // For instance, System.Exception implements ISerializable, however it is also desirable to have - // transparent exceptions with their own fields that need to be serialized. (For instance, in transparent - // assemblies such as the DLR and F#, or even in partial trust application code). Since overriding - // GetObjectData requires that the overriding method be security critical, this won't work directly. - // - // SafeSerializationManager solves this problem by allowing any partial trust code to contribute - // individual chunks of serializable data to be included in the serialized version of the derived class. - // These chunks are then deserialized back out of the serialized type and notified that they should - // populate the fields of the deserialized object when serialization is complete. This allows partial - // trust or transparent code to participate in serialization of an ISerializable type without having to - // override GetObjectData or implement the ISerializable constructor. - // - // On the serialization side, SafeSerializationManager has an event SerializeObjectState which it will - // fire in response to serialization in order to gather the units of serializable data that should be - // stored with the rest of the object during serialization. Methods which respond to these events - // create serializable objects which implement the ISafeSerializationData interface and add them to the - // collection of other serialized data by calling AddSerializedState on the SafeSerializationEventArgs - // passed into the event. - // - // By using an event rather than a virtual method on the base ISerializable object, we allow multiple - // potentially untrusted subclasses to participate in serialization, without each one having to ensure - // that it calls up to the base type in order for the whole system to work. (For instance Exception : - // TrustedException : UntrustedException, in this scenario UntrustedException would be able to override - // the virtual method an prevent TrustedException from ever seeing the method call, either accidentally - // or maliciously). - // - // Further, by only allowing additions of new chunks of serialization state rather than exposing the - // whole underlying list, we avoid exposing potentially sensitive serialized state to any of the - // potentially untrusted subclasses. - // - // At deserialization time, SafeSerializationManager performs the reverse operation. It deserializes the - // chunks of serialized state, and then notifies them that the object they belong to is deserialized by - // calling their CompleteSerialization method. In repsonse to this call, the state objects populate the - // fields of the object being deserialized with the state that they held. - // - // From a security perspective, the chunks of serialized state can only contain data that the specific - // subclass itself had access to read (otherwise it wouldn't be able to populate the type with that - // data), as opposed to having access to far more data in the SerializationInfo that GetObjectData uses. - // Similarly, at deserialization time, the serialized state can only modify fields that the type itself - // has access to (again, as opposed to the full SerializationInfo which could be modified). - // - // Individual types which wish to participate in safe serialization do so by containing an instance of a - // SafeSerializationManager and exposing its serialization event. During GetObjectData, the - // SafeSerializationManager is serialized just like any other field of the containing type. However, at - // the end of serialization it is called back one last time to CompleteSerialization. - // - // In CompleteSerialization, if the SafeSerializationManager detects that it has extra chunks of - // data to handle, it substitutes the root type being serialized (formerly the real type hosting the - // SafeSerializationManager) with itself. This allows it to gain more control over the deserialization - // process. It also saves away an extra bit of state in the serialization info indicating the real type - // of object that should be recreated during deserialization. - // - // At this point the serialized state looks like this: - // Data: - // realSerializedData1 - // ... - // realSerializedDataN - // safeSerializationData -> this is the serialization data member of the parent type - // _serializedState -> list of saved serialized states from subclasses responding to the safe - // serialization event - // RealTypeSerializationName -> type which is using safe serialization - // Type: - // SafeSerializationManager - // - // That is, the serialized data claims to be of type SafeSerializationManager, however contains only the - // data from the real object being serialized along with one bit of safe serialization metadata. - // - // At deserialization time, since the serialized data claims to be of type SafeSerializationManager, the - // root object being created is an instance of the SafeSerializationManager class. However, it detects - // that this isn't a real SafeSerializationManager (by looking for the real type field in the metadata), - // and simply saves away the SerializationInfo and the real type being deserialized. - // - // Since SafeSerializationManager implements IObjectReference, the next step of deserialization is the - // GetRealObject callback. This callback is the one responsible for getting the - // SafeSerializationManager out of the way and instead creating an instance of the actual type which was - // serialized. - // - // It does this by first creating an instance of the real type being deserialzed (saved away in the - // deserialzation constructor), but not running any of its constructors. Instead, it walks the - // inheritance hierarchy (moving toward the most derived type) looking for the last full trust type to - // implement the standard ISerializable constructor before any type does not implement the constructor. - // It is this last type's deserialization constructor which is then invoked, passing in the saved - // SerializationInfo. Once the constructors are run, we return this object as the real deserialized - // object. - // - // The reason that we do this walk is so that ISerializable types can protect themselves from malicious - // input during deserialization by making their deserialization constructors unavailable to partial - // trust code. By not requiring every type have a copy of this constructor, partial trust code can - // participate in safe serialization and not be required to have access to the parent's constructor. - // - // It should be noted however, that this heuristic means that if a full trust type does derive from - // a transparent or partial trust type using this safe serialization mechanism, that full trust type - // will not have its constructor called. Further, the protection of not invoking partial trust - // deserialization constructors only comes into play if SafeSerializationManager is in control of - // deserialization, which means there must be at least one (even empty) safe serialization event - // handler registered. - // - // Another interesting note is that at this point there are now two SafeSerializationManagers alive for - // this deserialization. The first object is the one which is controlling the deserialization and was - // created as the root object of the deserialization. The second one is the object which contains the - // serialized data chunks and is a data member of the real object being deserialized. For this reason, - // the data objects cannot be notified that the deserialization is complete during GetRealObject since - // the ISafeSerializationData objects are not members of the active SafeSerializationManager instance. - // - // The next step is the OnDeserialized callback, which comes to SafeSerializableObject since it was - // pretending to be the root object of the deserialization. It responds to this callback by calling - // any existing OnDeserialized callback on the real type that was deserialized. - // - // The real type needs to call its data member SafeSerializationData object's CompleteDeserialization - // method in response to the OnDeserialized call. This CompleteDeserialization call will then iterate - // through the ISafeSerializationData objects calling each of their CompleteDeserialization methods so - // that they can plug the nearly-complete object with their saved data. - // - // The reason for having a new ISafeSerializationData interface which is basically identical to - // IDeserializationCallback is that IDeserializationCallback will be called on the stored data chunks - // by the serialization code when they are deserialized, and that's not a desirable behavior. - // Essentially, we need to change the meaning of the object parameter to mean "parent object which - // participated in safe serialization", rather than "this object". - // - // Implementing safe serialization on an ISerialiable type is relatively straight forward. (For an - // example, see System.Exception): - // - // 1. Include a data member of type SafeSerializationManager: - // - // private SafeSerializationManager _safeSerializationManager; - // - // 2. Add a protected SerializeObjectState event, which passes through to the SafeSerializationManager: - // - // protected event EventHandler? SerializeObjectState - // { - // add { _safeSerializationManager.SerializeObjectState += value; } - // remove { _safeSerializationManager.SerializeObjectState -= value; } - // } - // - // 3. Serialize the safe serialization object in GetObjectData, and call its CompleteSerialization method: - // - // { - // info.AddValue("_safeSerializationManager", _safeSerializationManager, typeof(SafeSerializationManager)); - // _safeSerializationManager.CompleteSerialization(this, info, context); - // } - // - // 4. Add an OnDeserialized handler if one doesn't already exist, and call CompleteDeserialization in it: - // - // [OnDeserialized] - // private void OnDeserialized(StreamingContext context) - // { - // _safeSerializationManager.CompleteDeserialization(this); - // } - // - // On the client side, using safe serialization is also pretty easy. For example: - // - // [Serializable] - // public class TransparentException : Exception - // { - // [Serializable] - // private struct TransparentExceptionState : ISafeSerializationData - // { - // public string _extraData; - // - // void ISafeSerializationData.CompleteDeserialization(object obj) - // { - // TransparentException exception = obj as TransparentException; - // exception._state = this; - // } - // } - // - // [NonSerialized] - // private TransparentExceptionState _state = new TransparentExceptionState(); - // - // public TransparentException() - // { - // SerializeObjectState += delegate(object exception, SafeSerializationEventArgs eventArgs) - // { - // eventArgs.AddSerializedState(_state); - // }; - // } - // - // public string ExtraData - // { - // get { return _state._extraData; } - // set { _state._extraData = value; } - // } - // } - // + // This type was intended to support Code Access Security (CAS) scenarios in .NET Framework. + // Since CAS is no longer supported in .NET 5+, this interface has no further use. - // Interface to be supported by objects which are stored in safe serialization stores + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface ISafeSerializationData { - // CompleteDeserialization is called when the object to which the extra serialized data was attached - // has completed its deserialization, and now needs to be populated with the extra data stored in - // this object. void CompleteDeserialization(object deserialized); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISerializable.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISerializable.cs index 02f75df88162b9..ab60306e080443 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISerializable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/ISerializable.cs @@ -5,6 +5,7 @@ namespace System.Runtime.Serialization { public interface ISerializable { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] void GetObjectData(SerializationInfo info, StreamingContext context); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SafeSerializationEventArgs.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SafeSerializationEventArgs.cs index 431709a013ce54..8928bb50499c51 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SafeSerializationEventArgs.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SafeSerializationEventArgs.cs @@ -4,6 +4,7 @@ namespace System.Runtime.Serialization { // This type exists for public surface compatibility only. + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public sealed class SafeSerializationEventArgs : EventArgs { private SafeSerializationEventArgs() { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs index 688bd7ea08ea39..8b0ec24d125717 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationException.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; + namespace System.Runtime.Serialization { [Serializable] @@ -29,6 +31,8 @@ public SerializationException(string? message, Exception? innerException) HResult = HResults.COR_E_SERIALIZATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SerializationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.cs index a0699e47cbb282..1be37a3474115d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Diagnostics; +#pragma warning disable SYSLIB0050 // The SerializationInfo type is part of the obsolete legacy serialization framework + namespace System.Runtime.Serialization { /// The structure for holding all of the data needed for object serialization and deserialization. @@ -24,6 +26,7 @@ public sealed partial class SerializationInfo private Type _rootType; [CLSCompliant(false)] + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public SerializationInfo(Type type, IFormatterConverter converter) { ArgumentNullException.ThrowIfNull(type); @@ -43,6 +46,7 @@ public SerializationInfo(Type type, IFormatterConverter converter) } [CLSCompliant(false)] + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public SerializationInfo(Type type, IFormatterConverter converter, bool requireSameTokenInPartialTrust) : this(type, converter) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/StreamingContext.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/StreamingContext.cs index 1b3b86c0b9a646..81c9f675bd1e93 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/StreamingContext.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/StreamingContext.cs @@ -4,18 +4,23 @@ using System.Diagnostics.CodeAnalysis; #pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals +#pragma warning disable SYSLIB0050 // The StreamingContext type is part of the obsolete legacy serialization framework namespace System.Runtime.Serialization { public readonly struct StreamingContext { private readonly object? _additionalContext; + + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private readonly StreamingContextStates _state; + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public StreamingContext(StreamingContextStates state) : this(state, null) { } + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public StreamingContext(StreamingContextStates state, object? additional) { _state = state; @@ -34,12 +39,14 @@ public override bool Equals([NotNullWhen(true)] object? obj) public override int GetHashCode() => (int)_state; + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public StreamingContextStates State => _state; public object? Context => _additionalContext; } [Flags] + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public enum StreamingContextStates { CrossProcess = 0x01, diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs b/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs index 03abeccc82ac1c..e9669d4aae2a15 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/CryptographicException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; @@ -36,6 +37,8 @@ public CryptographicException([StringSyntax(StringSyntaxAttribute.CompositeForma { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CryptographicException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs b/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs index fcf3a7d796a570..42d95825ad6e92 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/SecurityException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Reflection; using System.Runtime.Serialization; @@ -50,6 +51,8 @@ public SecurityException(string? message, Type? type, string? state) PermissionState = state; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SecurityException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -63,6 +66,8 @@ protected SecurityException(SerializationInfo info, StreamingContext context) public override string ToString() => base.ToString(); + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs b/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs index 2bffac3ac5bd93..604d29e2bad3de 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/VerificationException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Security @@ -27,6 +28,8 @@ public VerificationException(string? message, Exception? innerException) HResult = HResults.COR_E_VERIFICATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected VerificationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/SerializableAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/SerializableAttribute.cs index 670a9142fda303..edca62a808b897 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SerializableAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SerializableAttribute.cs @@ -1,9 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; + namespace System { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)] + [EditorBrowsable(EditorBrowsableState.Never)] public sealed class SerializableAttribute : Attribute { public SerializableAttribute() { } diff --git a/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs b/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs index ce34e3f7e6b32e..3c75a77aa4ed09 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StackOverflowException.cs @@ -36,6 +36,7 @@ public StackOverflowException(string? message, Exception? innerException) HResult = HResults.COR_E_STACKOVERFLOW; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private StackOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/SystemException.cs b/src/libraries/System.Private.CoreLib/src/System/SystemException.cs index 0e219ccbd8f1e0..bc27ed3f05d541 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SystemException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SystemException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -27,6 +28,8 @@ public SystemException(string? message, Exception? innerException) HResult = HResults.COR_E_SYSTEM; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs index e3eb90b5393cb5..06470463438371 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs @@ -100,6 +100,7 @@ public DecoderFallbackException(string? message, byte[]? bytesUnknown, int index _index = index; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private DecoderFallbackException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderExceptionFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderExceptionFallback.cs index b314e6a19a4de9..a2295863caa006 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderExceptionFallback.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderExceptionFallback.cs @@ -120,6 +120,7 @@ internal EncoderFallbackException( _index = index; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private EncoderFallbackException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs index 7145be9695c5e3..940feebc2fee09 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs @@ -1106,7 +1106,7 @@ internal void ThrowCharsOverflow(DecoderNLS? decoder, bool nothingDecoded) decoder!.ClearMustFlush(); } - internal sealed class DefaultEncoder : Encoder, IObjectReference + internal sealed class DefaultEncoder : Encoder { private readonly Encoding _encoding; @@ -1115,9 +1115,6 @@ public DefaultEncoder(Encoding encoding) _encoding = encoding; } - public object GetRealObject(StreamingContext context) => - throw new PlatformNotSupportedException(); - // Returns the number of bytes the next call to GetBytes will // produce if presented with the given range of characters and the given // value of the flush parameter. The returned value takes into @@ -1161,7 +1158,7 @@ public override unsafe int GetBytes(char* chars, int charCount, _encoding.GetBytes(chars, charCount, bytes, byteCount); } - internal sealed class DefaultDecoder : Decoder, IObjectReference + internal sealed class DefaultDecoder : Decoder { private readonly Encoding _encoding; @@ -1170,9 +1167,6 @@ public DefaultDecoder(Encoding encoding) _encoding = encoding; } - public object GetRealObject(StreamingContext context) => - throw new PlatformNotSupportedException(); - // Returns the number of characters the next call to GetChars will // produce if presented with the given range of bytes. The returned value // takes into account the state in which the decoder was left following the diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs index 50e6641a043ef9..de8353322f442b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -51,6 +52,8 @@ public AbandonedMutexException(string? message, Exception? inner, int location, SetupException(location, handle); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected AbandonedMutexException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/CompressedStack.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/CompressedStack.cs index a56996a80aead8..3ba3c58b11034b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/CompressedStack.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/CompressedStack.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -11,6 +12,8 @@ private CompressedStack() { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs index a08bf91a530aa5..ea47926d3dc4b9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @@ -10,6 +10,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -47,6 +48,8 @@ private ExecutionContext( m_isFlowSuppressed = isFlowSuppressed; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/LockRecursionException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/LockRecursionException.cs index a57e8303ce28c0..eae6c61949b78a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/LockRecursionException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/LockRecursionException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -23,6 +24,8 @@ public LockRecursionException(string? message, Exception? innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected LockRecursionException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs index b1df072d464065..e57b02d28e3142 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreFullException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -21,6 +22,8 @@ public SemaphoreFullException(string? message, Exception? innerException) : base { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SemaphoreFullException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs index 9f53457fe6a0fb..d118ddd5c59762 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SynchronizationLockException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -37,6 +38,8 @@ public SynchronizationLockException(string? message, Exception? innerException) HResult = HResults.COR_E_SYNCHRONIZATIONLOCK; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected SynchronizationLockException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs index 1cc01ab6ef0014..c7fc558ea93f81 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCanceledException.cs @@ -9,6 +9,7 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading.Tasks @@ -79,6 +80,8 @@ public TaskCanceledException(Task? task) : /// /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TaskCanceledException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs index f8364706ad5f0d..5e3ebd6f9f36ed 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskSchedulerException.cs @@ -9,6 +9,7 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading.Tasks @@ -67,6 +68,8 @@ public TaskSchedulerException(string? message, Exception? innerException) : base /// the serialized object data about the exception being thrown. /// The that /// contains contextual information about the source or destination. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TaskSchedulerException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadAbortException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadAbortException.cs index d86ecc400640b8..f1cc648fc4a9d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadAbortException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadAbortException.cs @@ -28,6 +28,7 @@ internal ThreadAbortException() public object? ExceptionState => null; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private ThreadAbortException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs index 6c04711737a605..b6d9d7fcd8422d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadInterruptedException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -35,6 +36,8 @@ public ThreadInterruptedException(string? message, Exception? innerException) HResult = HResults.COR_E_THREADINTERRUPTED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ThreadInterruptedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStartException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStartException.cs index 80d0eb64e5c357..915495526101bf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStartException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStartException.cs @@ -21,6 +21,7 @@ internal ThreadStartException(Exception reason) HResult = HResults.COR_E_THREADSTART; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private ThreadStartException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs index b8ece7ce7859c0..a4622f30eed777 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadStateException.cs @@ -11,6 +11,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -37,6 +38,8 @@ public ThreadStateException(string? message, Exception? innerException) HResult = HResults.COR_E_THREADSTATE; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ThreadStateException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs index eb75a7733b8b15..51e81d9ce2092e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandleCannotBeOpenedException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading @@ -24,6 +25,8 @@ public WaitHandleCannotBeOpenedException(string? message, Exception? innerExcept HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WaitHandleCannotBeOpenedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneNotFoundException.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneNotFoundException.cs index 23b48ad8f479dc..ee12022332dcff 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneNotFoundException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneNotFoundException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -23,6 +24,8 @@ public TimeZoneNotFoundException(string? message, Exception? innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs b/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs index 21070493e3305c..6531c86a8815f7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeoutException.cs @@ -10,6 +10,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -36,6 +37,8 @@ public TimeoutException(string? message, Exception? innerException) HResult = HResults.COR_E_TIMEOUT; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs b/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs index f97d79c4f5f4f1..0e435d60718a63 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs @@ -10,6 +10,7 @@ namespace System // This file collects the longer methods of Type to make the main Type class more readable. public abstract partial class Type : MemberInfo, IReflect { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public virtual bool IsSerializable { get @@ -472,8 +473,10 @@ private static bool FilterAttributeImpl(MemberInfo m, object filterCriteria) return false; if (((criteria & FieldAttributes.Literal) != 0) && (attr & FieldAttributes.Literal) == 0) return false; +#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete if (((criteria & FieldAttributes.NotSerialized) != 0) && (attr & FieldAttributes.NotSerialized) == 0) return false; +#pragma warning restore SYSLIB0050 if (((criteria & FieldAttributes.PinvokeImpl) != 0) && (attr & FieldAttributes.PinvokeImpl) == 0) return false; return true; diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs index 3020228d363898..16b6aa7c89410b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeAccessException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -29,6 +30,8 @@ public TypeAccessException(string? message, Exception? inner) HResult = HResults.COR_E_TYPEACCESS; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TypeAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs index 7f0ac685ac9a5b..7e71dad29fb400 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeInitializationException.cs @@ -13,6 +13,7 @@ ** =============================================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -51,12 +52,15 @@ internal TypeInitializationException(string? fullTypeName, string? message, Exce HResult = HResults.COR_E_TYPEINITIALIZATION; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private TypeInitializationException(SerializationInfo info, StreamingContext context) : base(info, context) { _typeName = info.GetString("TypeName"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeLoadException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeLoadException.cs index e1a5bedc8daadd..9ac7ff2efc1f9f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeLoadException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeLoadException.cs @@ -1,13 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public partial class TypeLoadException : SystemException, ISerializable + public partial class TypeLoadException : SystemException { public TypeLoadException() : base(SR.Arg_TypeLoadException) @@ -38,6 +39,8 @@ public override string Message public string TypeName => _className ?? string.Empty; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TypeLoadException(SerializationInfo info, StreamingContext context) : base(info, context) { _className = info.GetString("TypeLoadClassName"); @@ -46,6 +49,8 @@ protected TypeLoadException(SerializationInfo info, StreamingContext context) : _resourceId = info.GetInt32("TypeLoadResourceID"); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs b/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs index ab9dd72f118045..31ef328977f32c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypeUnloadedException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -27,6 +28,8 @@ public TypeUnloadedException(string? message, Exception? innerException) HResult = HResults.COR_E_TYPEUNLOADED; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TypeUnloadedException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs b/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs index 7b2013246fea04..b57da7c36c30bd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UnauthorizedAccessException.cs @@ -12,6 +12,7 @@ ** ===========================================================*/ +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -40,6 +41,8 @@ public UnauthorizedAccessException(string? message, Exception? inner) HResult = HResults.COR_E_UNAUTHORIZEDACCESS; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected UnauthorizedAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/UnitySerializationHolder.cs b/src/libraries/System.Private.CoreLib/src/System/UnitySerializationHolder.cs index eedcebf37a7086..746834a648434c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UnitySerializationHolder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UnitySerializationHolder.cs @@ -10,6 +10,7 @@ namespace System /// This only exists for compatibility with .NET Framework. /// [Serializable] + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] // Needs to be public to support binary serialization compatibility public sealed class UnitySerializationHolder : ISerializable, IObjectReference { diff --git a/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs b/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs index 36cb48135dd89e..5bc19e32b6e9a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs +++ b/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -63,6 +64,8 @@ public bool TryGetTarget([MaybeNullWhen(false), NotNullWhen(true)] out T target) return o != null; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); diff --git a/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs b/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs index 81c33fd07445e3..5f4079183edfa8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs +++ b/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -51,6 +52,8 @@ public WeakReference(object? target, bool trackResurrection) Create(target, trackResurrection); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected WeakReference(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); @@ -61,6 +64,8 @@ protected WeakReference(SerializationInfo info, StreamingContext context) Create(target, trackResurrection); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj b/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj index e5751e43206791..c0ca93e494c5cb 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj +++ b/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj @@ -57,7 +57,6 @@ - diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs index c85fd6c23a6b84..aae72d1f3e1177 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs @@ -328,8 +328,10 @@ internal static bool IsNonAttributedTypeValidForSerialization( } } +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete if (type.IsSerializable) return false; +#pragma warning restore SYSLIB0050 if (Globals.TypeOfISerializable.IsAssignableFrom(type)) return false; @@ -635,8 +637,10 @@ internal ClassDataContractCriticalHelper([DynamicallyAccessedMembers(DataContrac { if (HasDataContract) throw new InvalidDataContractException(SR.Format(SR.ISerializableCannotHaveDataContract, DataContract.GetClrTypeFullName(type))); +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete if (baseType != null && !(baseType.IsSerializable && Globals.TypeOfISerializable.IsAssignableFrom(baseType))) baseType = null; +#pragma warning restore SYSLIB0050 } IsValueType = type.IsValueType; if (baseType != null && baseType != Globals.TypeOfObject && baseType != Globals.TypeOfValueType && baseType != Globals.TypeOfUri) @@ -919,7 +923,9 @@ private void ImportDataMembers() { FieldInfo? field = member as FieldInfo; +#pragma warning disable SYSLIB0050 // Field.IsNotSerialized is obsolete if (field != null && !field.IsNotSerialized) +#pragma warning restore SYSLIB0050 { DataMember memberContract = new DataMember(member); @@ -1044,7 +1050,9 @@ private void SetIsNonAttributedType( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces)] Type type) { +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete _isNonAttributedType = !type.IsSerializable && !_hasDataContract && IsNonAttributedTypeValidForSerialization(type); +#pragma warning restore SYSLIB0050 } private static bool IsMethodOverriding(MethodInfo method) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs index cd600ee2a0a5d3..a9b1042a26d118 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs @@ -913,10 +913,12 @@ private static CreateGenericDictionaryEnumeratorDelegate BuildCreateGenericDicti { return this; } +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete if (type.IsSerializable || type.IsDefined(Globals.TypeOfDataContractAttribute, false)) { return new ClassDataContract(type); } +#pragma warning restore SYSLIB0050 return null; } @@ -1023,7 +1025,9 @@ private static bool IsCollectionOrTryCreate(Type type, bool tryCreate, out DataC && baseType != Globals.TypeOfValueType && baseType != Globals.TypeOfUri) ? IsCollection(baseType) : false; // Avoid creating an invalid collection contract for Serializable types since we can create a ClassDataContract instead +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete bool createContractWithException = isBaseTypeCollection && !type.IsSerializable; +#pragma warning restore SYSLIB0050 if (type.IsDefined(Globals.TypeOfDataContractAttribute, false)) { @@ -1105,11 +1109,13 @@ private static bool IsCollectionOrTryCreate(Type type, bool tryCreate, out DataC // All collection types could be considered read-only collections except collection types that are marked [Serializable]. // Collection types marked [Serializable] cannot be read-only collections for backward compatibility reasons. // DataContract types and POCO types cannot be collection types, so they don't need to be factored in +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete if (type.IsSerializable) { return HandleIfInvalidCollection(type, tryCreate, hasCollectionDataContract, createContractWithException, SR.CollectionTypeDoesNotHaveDefaultCtor, null, ref dataContract); } +#pragma warning restore SYSLIB0050 else { isReadOnlyContract = true; @@ -1167,11 +1173,13 @@ private static bool IsCollectionOrTryCreate(Type type, bool tryCreate, out DataC // All collection types could be considered read-only collections except collection types that are marked [Serializable]. // Collection types marked [Serializable] cannot be read-only collections for backward compatibility reasons. // DataContract types and POCO types cannot be collection types, so they don't need to be factored in. +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete if (type.IsSerializable || skipIfReadOnlyContract) { return HandleIfInvalidCollection(type, tryCreate, hasCollectionDataContract, createContractWithException && !skipIfReadOnlyContract, SR.CollectionTypeDoesNotHaveAddMethod, DataContract.GetClrTypeFullName(itemType), ref dataContract); } +#pragma warning restore SYSLIB0050 else { isReadOnlyContract = true; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs index 3cf45d25769912..01a3a96eee7b78 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs @@ -480,10 +480,12 @@ private static DataContract CreateDataContract(Type type) if (!CollectionDataContract.TryCreate(type, out dataContract)) { +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete if (!type.IsSerializable && !type.IsDefined(Globals.TypeOfDataContractAttribute, false) && !ClassDataContract.IsNonAttributedTypeValidForSerialization(type)) { ThrowInvalidDataContractException(SR.Format(SR.TypeNotSerializable, type), type); } +#pragma warning restore SYSLIB0050 dataContract = new ClassDataContract(type); if (type != originalType) { @@ -1141,7 +1143,10 @@ internal static bool IsTypeSerializable(Type type) [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] private static bool IsTypeSerializable(Type type, HashSet? previousCollectionTypes) { - if (type.IsSerializable || + if ( +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete + type.IsSerializable || +#pragma warning restore SYSLIB0050 type.IsEnum || type.IsDefined(Globals.TypeOfDataContractAttribute, false) || type.IsInterface || diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs index 55f7c22c566328..58176b6dc52ccd 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSet.cs @@ -409,7 +409,10 @@ private static bool IsTypeReferenceable(Type type) { try { - return (type.IsSerializable || + return ( +#pragma warning disable SYSLIB0050 // Type.IsSerializable is obsolete + type.IsSerializable || +#pragma warning restore SYSLIB0050 type.IsDefined(Globals.TypeOfDataContractAttribute, false) || (Globals.TypeOfIXmlSerializable.IsAssignableFrom(type) && !type.IsGenericTypeDefinition) || CollectionDataContract.IsCollection(type, out _) || diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/EnumDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/EnumDataContract.cs index 3923fd0ecd9351..e8e6c3a6df94dd 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/EnumDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/EnumDataContract.cs @@ -253,6 +253,7 @@ private void ImportDataMembers() } else { +#pragma warning disable SYSLIB0050 // FieldInfo.IsNotSerialized is obsolete if (!field.IsNotSerialized) { DataMember memberContract = new DataMember(field) { Name = field.Name }; @@ -260,6 +261,7 @@ private void ImportDataMembers() ClassDataContract.CheckAndAddMember(tempMembers, memberContract, memberValuesTable); enumMemberValid = true; } +#pragma warning restore SYSLIB0050 } if (enumMemberValid) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs index 7d7c9786f77e0e..7c1c65e2d97967 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs @@ -107,9 +107,11 @@ internal static partial class Globals internal static Type TypeOfIDeserializationCallback => s_typeOfIDeserializationCallback ??= typeof(IDeserializationCallback); +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete private static Type? s_typeOfIObjectReference; internal static Type TypeOfIObjectReference => s_typeOfIObjectReference ??= typeof(IObjectReference); +#pragma warning restore SYSLIB0050 private static Type? s_typeOfXmlFormatClassWriterDelegate; internal static Type TypeOfXmlFormatClassWriterDelegate => diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerReadContextComplexJson.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerReadContextComplexJson.cs index f49faae9c17d01..188c016fa81da0 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerReadContextComplexJson.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerReadContextComplexJson.cs @@ -19,7 +19,9 @@ internal sealed class XmlObjectSerializerReadContextComplexJson : XmlObjectSeria private readonly bool _useSimpleDictionaryFormat; internal XmlObjectSerializerReadContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract) +#pragma warning disable SYSLIB0050 // StreamingContext ctor is obsolete : base(serializer, serializer.MaxItemsInObjectGraph, new StreamingContext(StreamingContextStates.All), serializer.IgnoreExtensionDataObject) +#pragma warning restore SYSLIB0050 { this.rootTypeDataContract = rootTypeDataContract; this.serializerKnownTypeList = serializer.knownTypeList; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerWriteContextComplexJson.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerWriteContextComplexJson.cs index f877c36e33d0b4..4f4b011193157f 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerWriteContextComplexJson.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerWriteContextComplexJson.cs @@ -25,7 +25,9 @@ internal static XmlObjectSerializerWriteContextComplexJson CreateContext(DataCon } internal XmlObjectSerializerWriteContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract) +#pragma warning disable SYSLIB0050 // StreamingContext ctor is obsolete : base(serializer, serializer.MaxItemsInObjectGraph, new StreamingContext(StreamingContextStates.All), serializer.IgnoreExtensionDataObject) +#pragma warning restore SYSLIB0050 { _emitXsiType = serializer.EmitTypeInformation; this.rootTypeDataContract = rootTypeDataContract; @@ -329,6 +331,7 @@ internal static void VerifyObjectCompatibilityWithInterface(DataContract contrac } } +#pragma warning disable SYSLIB0050 // The legacy serialization infrastructure (including ISerializable & friends) is obsolete [RequiresDynamicCode(DataContract.SerializerAOTWarning)] [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] internal void WriteJsonISerializable(XmlWriterDelegator xmlWriter, ISerializable obj) @@ -345,6 +348,7 @@ internal void WriteJsonISerializable(XmlWriterDelegator xmlWriter, ISerializable base.WriteSerializationInfo(xmlWriter, objType, serInfo); } } +#pragma warning restore SYSLIB0050 [return: NotNullIfNotNull(nameof(oldItemContract))] [RequiresDynamicCode(DataContract.SerializerAOTWarning)] diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs index 62e5f8bb3dbb52..f457a078c8c282 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs @@ -50,10 +50,12 @@ public object ReflectionReadClass(XmlReaderDelegator xmlReader, XmlObjectSeriali ReflectionReadMembers(xmlReader, context, memberNames, memberNamespaces, classContract, ref obj); } +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete if (obj is IObjectReference objectReference) { obj = context.GetRealObject(objectReference, context.GetObjectId()); } +#pragma warning restore SYSLIB0050 obj = ResolveAdapterObject(obj); InvokeDeserializationCallback(obj); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/SurrogateDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/SurrogateDataContract.cs deleted file mode 100644 index 98080f371d0a8b..00000000000000 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/SurrogateDataContract.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Security; - -namespace System.Runtime.Serialization.DataContracts -{ - internal sealed class SurrogateDataContract : DataContract - { - private readonly SurrogateDataContractCriticalHelper _helper; - - [RequiresDynamicCode(DataContract.SerializerAOTWarning)] - [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] - internal SurrogateDataContract(Type type, ISerializationSurrogate serializationSurrogate) - : base(new SurrogateDataContractCriticalHelper(type, serializationSurrogate)) - { - _helper = (base.Helper as SurrogateDataContractCriticalHelper)!; - } - - internal ISerializationSurrogate SerializationSurrogate => _helper.SerializationSurrogate; - - [RequiresDynamicCode(DataContract.SerializerAOTWarning)] - [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] - internal override void WriteXmlValue(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext? context) - { - Debug.Assert(context != null); - - SerializationInfo serInfo = new SerializationInfo(UnderlyingType, XmlObjectSerializer.FormatterConverter, !context.UnsafeTypeForwardingEnabled); - SerializationSurrogateGetObjectData(obj, serInfo, context.GetStreamingContext()); - context.WriteSerializationInfo(xmlWriter, UnderlyingType, serInfo); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private object? SerializationSurrogateSetObjectData(object obj, SerializationInfo serInfo, StreamingContext context) - { - return SerializationSurrogate.SetObjectData(obj, serInfo, context, null); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - internal static object? GetRealObject(IObjectReference obj, StreamingContext context) - { - return obj.GetRealObject(context); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static object GetUninitializedObject( - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] - Type objType) - { - return RuntimeHelpers.GetUninitializedObject(objType); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private void SerializationSurrogateGetObjectData(object obj, SerializationInfo serInfo, StreamingContext context) - { - SerializationSurrogate.GetObjectData(obj, serInfo, context); - } - - [RequiresDynamicCode(DataContract.SerializerAOTWarning)] - [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] - internal override object? ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext? context) - { - Debug.Assert(context != null); - - xmlReader.Read(); - Type objType = UnderlyingType; - object obj = objType.IsArray ? Array.CreateInstance(objType.GetElementType()!, 0) : GetUninitializedObject(objType); - context.AddNewObject(obj); - string objectId = context.GetObjectId(); - SerializationInfo serInfo = context.ReadSerializationInfo(xmlReader, objType); - object? newObj = SerializationSurrogateSetObjectData(obj, serInfo, context.GetStreamingContext()) ?? obj; - if (newObj is IDeserializationCallback) - ((IDeserializationCallback)newObj).OnDeserialization(null); - if (newObj is IObjectReference) - newObj = GetRealObject((IObjectReference)newObj, context.GetStreamingContext()); - context.ReplaceDeserializedObject(objectId, obj, newObj); - xmlReader.ReadEndElement(); - return newObj; - } - - private sealed class SurrogateDataContractCriticalHelper : DataContract.DataContractCriticalHelper - { - private readonly ISerializationSurrogate serializationSurrogate; - - [RequiresDynamicCode(DataContract.SerializerAOTWarning)] - [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] - internal SurrogateDataContractCriticalHelper( - [DynamicallyAccessedMembers(ClassDataContract.DataContractPreserveMemberTypes)] - Type type, - ISerializationSurrogate serializationSurrogate) - : base(type) - { - this.serializationSurrogate = serializationSurrogate; - string name, ns; - DataContract.GetDefaultXmlName(DataContract.GetClrTypeFullName(type), out name, out ns); - SetDataContractName(CreateQualifiedName(name, ns)); - } - - internal ISerializationSurrogate SerializationSurrogate => serializationSurrogate; - } - } -} diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializer.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializer.cs index db26bf0bd5fd88..778191ff35e67e 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializer.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializer.cs @@ -470,7 +470,9 @@ internal static string GetTypeInfoError(string errorMessage, Type? type, Excepti return null; } +#pragma warning disable SYSLIB0050 // IFormatterConverter is obsolete private static IFormatterConverter? s_formatterConverter; internal static IFormatterConverter FormatterConverter => s_formatterConverter ??= new FormatterConverter(); +#pragma warning restore SYSLIB0050 } } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerContext.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerContext.cs index ee2df1d054f298..93c2c91e74d62e 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerContext.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerContext.cs @@ -48,7 +48,9 @@ internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItems internal XmlObjectSerializerContext(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver? dataContractResolver) : this(serializer, serializer.MaxItemsInObjectGraph, +#pragma warning disable SYSLIB0050 // StreamingContext ctor is obsolete new StreamingContext(StreamingContextStates.All), +#pragma warning restore SYSLIB0050 serializer.IgnoreExtensionDataObject, dataContractResolver ) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs index 130c45d2b55aea..c8ff3273077f86 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs @@ -402,9 +402,10 @@ private object GetExistingObjectOrExtensionData(string id) return retObj; } +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete public object GetRealObject(IObjectReference obj, string id) { - object? realObj = SurrogateDataContract.GetRealObject(obj, this.GetStreamingContext()); + object? realObj = obj.GetRealObject(this.GetStreamingContext()); // If GetRealObject returns null, it indicates that the object could not resolve itself because // it is missing information. This may occur in a case where multiple IObjectReference instances // depend on each other. BinaryFormatter supports this by fixing up the references later. These @@ -416,6 +417,7 @@ public object GetRealObject(IObjectReference obj, string id) ReplaceDeserializedObject(id, obj, realObj); return realObj; } +#pragma warning restore SYSLIB0050 [RequiresDynamicCode(DataContract.SerializerAOTWarning)] [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] @@ -540,7 +542,9 @@ internal void CheckEndOfArray(XmlReaderDelegator xmlReader, int arraySize, XmlDi [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public SerializationInfo ReadSerializationInfo(XmlReaderDelegator xmlReader, Type type) { +#pragma warning disable SYSLIB0050 // SerializationInfo ctor is obsolete var serInfo = new SerializationInfo(type, XmlObjectSerializer.FormatterConverter); +#pragma warning restore SYSLIB0050 XmlNodeType nodeType; while ((nodeType = xmlReader.MoveToContent()) != XmlNodeType.EndElement) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs index c0909735e7f04a..150209bfba79b4 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs @@ -505,7 +505,9 @@ private static void WriteIXmlSerializable(XmlWriterDelegator xmlWriter, object o [MethodImpl(MethodImplOptions.NoInlining)] internal static void GetObjectData(ISerializable obj, SerializationInfo serInfo, StreamingContext context) { +#pragma warning disable SYSLIB0050 // ISerializable.GetObjectData is obsolete obj.GetObjectData(serInfo, context); +#pragma warning restore SYSLIB0050 } [RequiresDynamicCode(DataContract.SerializerAOTWarning)] @@ -513,7 +515,9 @@ internal static void GetObjectData(ISerializable obj, SerializationInfo serInfo, public void WriteISerializable(XmlWriterDelegator xmlWriter, ISerializable obj) { Type objType = obj.GetType(); +#pragma warning disable SYSLIB0050 // SerializationInfo ctor is obsolete var serInfo = new SerializationInfo(objType, XmlObjectSerializer.FormatterConverter /*!UnsafeTypeForwardingEnabled is always false*/); +#pragma warning restore SYSLIB0050 GetObjectData(obj, serInfo, GetStreamingContext()); // (!UnsafeTypeForwardingEnabled) is always false diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index 3c29cd3ba5052b..2203e42b544566 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -3,6 +3,7 @@ using System.Buffers; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -450,6 +451,8 @@ public Uri(Uri baseUri, string? relativeUri) // // ISerializable constructor // + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected Uri(SerializationInfo serializationInfo, StreamingContext streamingContext) { string? uriString = serializationInfo.GetString("AbsoluteUri"); // Do not rename (binary serialization) diff --git a/src/libraries/System.Private.Uri/src/System/UriFormatException.cs b/src/libraries/System.Private.Uri/src/System/UriFormatException.cs index 5eab840edfcc4f..76b88bb4c1207d 100644 --- a/src/libraries/System.Private.Uri/src/System/UriFormatException.cs +++ b/src/libraries/System.Private.Uri/src/System/UriFormatException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System @@ -24,10 +25,13 @@ public UriFormatException(string? textString, Exception? e) : base(textString, e { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected UriFormatException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { base.GetObjectData(serializationInfo, streamingContext); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs index e9ba54d399b3ac..a94063d84e2608 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/XmlSchemaInferenceException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.IO; using System.Resources; using System.Runtime.Serialization; @@ -15,10 +16,14 @@ namespace System.Xml.Schema [System.Runtime.CompilerServices.TypeForwardedFrom("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class XmlSchemaInferenceException : XmlSchemaException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XmlSchemaInferenceException(SerializationInfo info, StreamingContext context) : base(info, context) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs index 4e90c684de605a..a6e1e567fd48a3 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.IO; using System.Text; using System.Resources; @@ -27,6 +28,8 @@ public class XmlSchemaException : SystemException // message == null for V2 or higher exceptions; the exception message is stored on the base class (Exception._message) private readonly string? _message; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XmlSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) { _res = (string?)info.GetValue("res", typeof(string)); @@ -57,6 +60,8 @@ protected XmlSchemaException(SerializationInfo info, StreamingContext context) : } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs index a3742ab827e123..b542720a2f6d46 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidationException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.IO; using System.Text; using System.Resources; @@ -16,10 +17,14 @@ public class XmlSchemaValidationException : XmlSchemaException { private object? _sourceNodeObject; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XmlSchemaValidationException(SerializationInfo info, StreamingContext context) : base(info, context) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs index bca6862c4d6b84..420e0150a87fed 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Resources; using System.Runtime.Serialization; using System.Diagnostics; @@ -22,6 +23,8 @@ public class XPathException : SystemException // message == null for created V2 exceptions; the exception message is stored in Exception._message private readonly string? _message; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XPathException(SerializationInfo info, StreamingContext context) : base(info, context) { _res = (string)info.GetValue("res", typeof(string))!; @@ -49,6 +52,8 @@ protected XPathException(SerializationInfo info, StreamingContext context) : bas } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XmlException.cs b/src/libraries/System.Private.Xml/src/System/Xml/XmlException.cs index a728ab2a164529..8cadf7feff813e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XmlException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XmlException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Resources; using System.Text; using System.Diagnostics; @@ -30,6 +31,8 @@ public class XmlException : SystemException // message == null for V2 or higher exceptions; the exception message is stored on the base class (Exception._message) private readonly string? _message; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XmlException(SerializationInfo info, StreamingContext context) : base(info, context) { _res = (string)info.GetValue("res", typeof(string))!; @@ -65,6 +68,8 @@ protected XmlException(SerializationInfo info, StreamingContext context) : base( } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathCompileException.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathCompileException.cs index c4d4e030964ba5..36aa9e793e1cb4 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathCompileException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathCompileException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Text; @@ -25,6 +26,7 @@ internal XPathCompileException(string resId, params string[] args) : base(resId, args) { } // queryString will be set later + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] internal XPathCompileException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -33,6 +35,8 @@ internal XPathCompileException(SerializationInfo info, StreamingContext context) endChar = (int)info.GetValue("EndChar", typeof(int))!; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XslException.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XslException.cs index d2d6bdb62db3dd..64f22b58357bdd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XslException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XslException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Resources; @@ -16,6 +17,8 @@ public XslTransformException(Exception? inner, string res, params string?[]? arg : base(CreateMessage(res, args), inner) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public XslTransformException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -110,6 +113,7 @@ internal XslLoadException(Exception? inner, ISourceLineInfo? lineInfo) SetSourceLineInfo(lineInfo); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] internal XslLoadException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -161,6 +165,8 @@ internal void SetSourceLineInfo(ISourceLineInfo? lineInfo) _lineInfo = lineInfo; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs index e328918d7c9d71..dd4647c9df7f53 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Resources; @@ -23,6 +24,8 @@ public class XsltException : SystemException // message == null for created V2 exceptions; the exception message is stored in Exception._message private readonly string? _message; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XsltException(SerializationInfo info, StreamingContext context) : base(info, context) { _res = (string)info.GetValue("res", typeof(string))!; @@ -53,6 +56,8 @@ protected XsltException(SerializationInfo info, StreamingContext context) : base } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); @@ -149,10 +154,14 @@ private static string CreateMessage(string res, string?[]? args, string? sourceU [System.Runtime.CompilerServices.TypeForwardedFrom("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class XsltCompileException : XsltException { + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected XsltCompileException(SerializationInfo info, StreamingContext context) : base(info, context) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs index d77592743ef5c7..bd7ef3ff90eaeb 100644 --- a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs +++ b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs @@ -109,6 +109,9 @@ public override bool IsSecurityTransparent get { return _typeInfo.IsSecurityTransparent; } } +#if NET8_0_OR_GREATER + [Obsolete("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] +#endif public override bool IsSerializable { get { return _typeInfo.IsSerializable; } diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs index 4a615aec89750b..17093fb7e92161 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs @@ -16,6 +16,10 @@ public readonly partial struct AssemblyReference } public partial class ImageFormatLimitationException : System.Exception { +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ImageFormatLimitationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } diff --git a/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj b/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj index 04cbedc65b3c70..6d42a53f7c5a7c 100644 --- a/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj +++ b/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj @@ -249,6 +249,7 @@ The System.Reflection.Metadata library is built-in as part of the shared framewo + diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs index 4885861a0a9b3b..ed6b2ab3e8eab8 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Reflection.Metadata.Ecma335; using System.Runtime.Serialization; @@ -9,6 +10,10 @@ namespace System.Reflection.Metadata [Serializable] public partial class ImageFormatLimitationException : Exception { +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ImageFormatLimitationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs index 568fb5e4d18789..9e0e4320a021c9 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; @@ -197,6 +198,10 @@ public sealed override AssemblyName[] GetReferencedAssemblies() } // Serialization +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public sealed override void GetObjectData(SerializationInfo info, StreamingContext context) => throw new NotSupportedException(); // Satellite assemblies diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs index c932b87e373dd3..bd19faaac6256d 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -71,6 +72,10 @@ public sealed override string Name public abstract override MethodInfo[] GetMethods(BindingFlags bindingFlags); protected abstract override MethodInfo? GetMethodImpl(string name, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers); +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public sealed override void GetObjectData(SerializationInfo info, StreamingContext context) => throw new NotSupportedException(); public abstract override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs index 78beb8e60f8110..41de20bdda87b8 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs @@ -66,7 +66,9 @@ internal sealed override IEnumerable ComputeDirectlyImplementedInterface CoreType.IReadOnlyListT, }; +#pragma warning disable SYSLIB0050 // TypeAttributes.Serialized flag is obsolete protected sealed override TypeAttributes ComputeAttributeFlags() => TypeAttributes.AutoLayout | TypeAttributes.AnsiClass | TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Serializable; +#pragma warning restore SYSLIB0050 internal sealed override IEnumerable GetConstructorsCore(NameFilter? filter) { diff --git a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs index 716001ef46c416..9cd5c532093efe 100644 --- a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs +++ b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs @@ -11,7 +11,11 @@ namespace System.Resources.Extensions public partial class DeserializingResourceReader { private bool _assumeBinaryFormatter; + +// Issue https://github.com/dotnet/runtime/issues/39292 tracks finding an alternative to BinaryFormatter +#pragma warning disable SYSLIB0011 private BinaryFormatter? _formatter; +#pragma warning restore SYSLIB0011 private bool ValidateReaderType(string readerType) { diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index 6e091f27cc3e70..78a92c9dbdadb4 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -345,6 +345,8 @@ public DataMisalignedException(string? message, System.Exception? innerException public partial class DllNotFoundException : System.TypeLoadException { public DllNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DllNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DllNotFoundException(string? message) { } public DllNotFoundException(string? message, System.Exception? inner) { } @@ -510,6 +512,8 @@ public static void Combine(object rcw, System.Guid iid, int dispid, System.Deleg public partial class COMException : System.Runtime.InteropServices.ExternalException { public COMException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected COMException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public COMException(string? message) { } public COMException(string? message, System.Exception? inner) { } @@ -748,6 +752,8 @@ public InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType in public partial class InvalidComObjectException : System.SystemException { public InvalidComObjectException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidComObjectException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidComObjectException(string? message) { } public InvalidComObjectException(string? message, System.Exception? inner) { } @@ -755,6 +761,8 @@ public InvalidComObjectException(string? message, System.Exception? inner) { } public partial class InvalidOleVariantTypeException : System.SystemException { public InvalidOleVariantTypeException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidOleVariantTypeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidOleVariantTypeException(string? message) { } public InvalidOleVariantTypeException(string? message, System.Exception? inner) { } @@ -1054,6 +1062,8 @@ public MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType unmanaged public partial class MarshalDirectiveException : System.SystemException { public MarshalDirectiveException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MarshalDirectiveException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MarshalDirectiveException(string? message) { } public MarshalDirectiveException(string? message, System.Exception? inner) { } @@ -1393,6 +1403,8 @@ public ProgIdAttribute(string progId) { } public partial class SafeArrayRankMismatchException : System.SystemException { public SafeArrayRankMismatchException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SafeArrayRankMismatchException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SafeArrayRankMismatchException(string? message) { } public SafeArrayRankMismatchException(string? message, System.Exception? inner) { } @@ -1400,6 +1412,8 @@ public SafeArrayRankMismatchException(string? message, System.Exception? inner) public partial class SafeArrayTypeMismatchException : System.SystemException { public SafeArrayTypeMismatchException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SafeArrayTypeMismatchException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SafeArrayTypeMismatchException(string? message) { } public SafeArrayTypeMismatchException(string? message, System.Exception? inner) { } @@ -1407,6 +1421,8 @@ public SafeArrayTypeMismatchException(string? message, System.Exception? inner) public partial class SEHException : System.Runtime.InteropServices.ExternalException { public SEHException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SEHException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SEHException(string? message) { } public SEHException(string? message, System.Exception? inner) { } diff --git a/src/libraries/System.Runtime.Serialization.Formatters/Directory.Build.props b/src/libraries/System.Runtime.Serialization.Formatters/Directory.Build.props index 63f02a0f817ef2..96cb8776f64218 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/Directory.Build.props +++ b/src/libraries/System.Runtime.Serialization.Formatters/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + + $(NoWarn);SYSLIB0011;SYSLIB0050;SYSLIB0051 \ No newline at end of file diff --git a/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.cs b/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.cs index d1ebf7e6bd2257..b65239f8e0eb48 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.cs @@ -6,6 +6,7 @@ namespace System.Runtime.Serialization { + [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.CLSCompliantAttribute(false)] public abstract partial class Formatter : System.Runtime.Serialization.IFormatter { @@ -15,13 +16,11 @@ protected Formatter() { } public abstract System.Runtime.Serialization.SerializationBinder? Binder { get; set; } public abstract System.Runtime.Serialization.StreamingContext Context { get; set; } public abstract System.Runtime.Serialization.ISurrogateSelector? SurrogateSelector { get; set; } - [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] public abstract object Deserialize(System.IO.Stream serializationStream); protected virtual object? GetNext(out long objID) { throw null; } protected virtual long Schedule(object? obj) { throw null; } - [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] public abstract void Serialize(System.IO.Stream serializationStream, object graph); protected abstract void WriteArray(object obj, string name, System.Type memberType); @@ -48,6 +47,7 @@ protected virtual void WriteMember(string memberName, object? data) { } protected abstract void WriteUInt64(ulong val, string name); protected abstract void WriteValueType(object obj, string name, System.Type memberType); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial class FormatterConverter : System.Runtime.Serialization.IFormatterConverter { public FormatterConverter() { } @@ -73,6 +73,7 @@ public FormatterConverter() { } [System.CLSCompliantAttribute(false)] public ulong ToUInt64(object value) { throw null; } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static partial class FormatterServices { public static void CheckTypeSecurity(System.Type t, System.Runtime.Serialization.Formatters.TypeFilterLevel securityLevel) { } @@ -86,36 +87,39 @@ public static void CheckTypeSecurity(System.Type t, System.Runtime.Serialization public static object GetUninitializedObject([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type type) { throw null; } public static object PopulateObjectMembers(object obj, System.Reflection.MemberInfo[] members, object?[] data) { throw null; } } + [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface IFormatter { System.Runtime.Serialization.SerializationBinder? Binder { get; set; } System.Runtime.Serialization.StreamingContext Context { get; set; } System.Runtime.Serialization.ISurrogateSelector? SurrogateSelector { get; set; } - [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] object Deserialize(System.IO.Stream serializationStream); - [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] void Serialize(System.IO.Stream serializationStream, object graph); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface ISerializationSurrogate { void GetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context); object SetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.ISurrogateSelector? selector); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface ISurrogateSelector { void ChainSelector(System.Runtime.Serialization.ISurrogateSelector selector); System.Runtime.Serialization.ISurrogateSelector? GetNextSelector(); System.Runtime.Serialization.ISerializationSurrogate? GetSurrogate(System.Type type, System.Runtime.Serialization.StreamingContext context, out System.Runtime.Serialization.ISurrogateSelector selector); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial class ObjectIDGenerator { public ObjectIDGenerator() { } public virtual long GetId(object obj, out bool firstTime) { throw null; } public virtual long HasId(object obj, out bool firstTime) { throw null; } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial class ObjectManager { public ObjectManager(System.Runtime.Serialization.ISurrogateSelector? selector, System.Runtime.Serialization.StreamingContext context) { } @@ -144,6 +148,7 @@ protected SerializationBinder() { } public virtual void BindToName(System.Type serializedType, out string? assemblyName, out string? typeName) { throw null; } public abstract System.Type? BindToType(string assemblyName, string typeName); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public sealed partial class SerializationObjectManager { public SerializationObjectManager(System.Runtime.Serialization.StreamingContext context) { } @@ -151,6 +156,7 @@ public void RaiseOnSerializedEvent() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("SerializationObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")] public void RegisterObject(object obj) { } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial class SurrogateSelector : System.Runtime.Serialization.ISurrogateSelector { public SurrogateSelector() { } @@ -163,22 +169,26 @@ public virtual void RemoveSurrogate(System.Type type, System.Runtime.Serializati } namespace System.Runtime.Serialization.Formatters { + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public enum FormatterAssemblyStyle { Simple = 0, Full = 1, } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public enum FormatterTypeStyle { TypesWhenNeeded = 0, TypesAlways = 1, XsdString = 2, } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface IFieldInfo { string[]? FieldNames { get; set; } System.Type[]? FieldTypes { get; set; } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public enum TypeFilterLevel { Low = 2, @@ -187,6 +197,7 @@ public enum TypeFilterLevel } namespace System.Runtime.Serialization.Formatters.Binary { + [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public sealed partial class BinaryFormatter : System.Runtime.Serialization.IFormatter { public BinaryFormatter() { } @@ -197,11 +208,9 @@ public BinaryFormatter(System.Runtime.Serialization.ISurrogateSelector? selector public System.Runtime.Serialization.Formatters.TypeFilterLevel FilterLevel { get { throw null; } set { } } public System.Runtime.Serialization.ISurrogateSelector? SurrogateSelector { get { throw null; } set { } } public System.Runtime.Serialization.Formatters.FormatterTypeStyle TypeFormat { get { throw null; } set { } } - [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] public object Deserialize(System.IO.Stream serializationStream) { throw null; } - [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] public void Serialize(System.IO.Stream serializationStream, object graph) { } } diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatter.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatter.cs index 7d14ebcb67647a..4cce178d2a4231 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatter.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatter.cs @@ -9,6 +9,7 @@ namespace System.Runtime.Serialization { [CLSCompliant(false)] + [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public abstract class Formatter : IFormatter { protected ObjectIDGenerator m_idGenerator; @@ -20,7 +21,6 @@ protected Formatter() m_idGenerator = new ObjectIDGenerator(); } - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresDynamicCode(IFormatter.RequiresDynamicCodeMessage)] [RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)] public abstract object Deserialize(Stream serializationStream); @@ -62,7 +62,6 @@ protected virtual long Schedule(object? obj) return id; } - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)] public abstract void Serialize(Stream serializationStream, object graph); diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterConverter.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterConverter.cs index 34f84d14034bcf..8da5135e616d77 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterConverter.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterConverter.cs @@ -5,6 +5,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public class FormatterConverter : IFormatterConverter { public object Convert(object value, Type type) diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterServices.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterServices.cs index b1692273bf11cf..e3b3a6df8ff53e 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterServices.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterServices.cs @@ -12,6 +12,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static class FormatterServices { private static readonly ConcurrentDictionary s_memberInfoTable = new ConcurrentDictionary(); diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.Core.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.Core.cs index 51c3aa9aaee1d8..d3d9aefe515d7e 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.Core.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.Core.cs @@ -8,7 +8,6 @@ namespace System.Runtime.Serialization.Formatters.Binary { public sealed partial class BinaryFormatter : IFormatter { - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresDynamicCode(IFormatter.RequiresDynamicCodeMessage)] [RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)] public object Deserialize(Stream serializationStream) @@ -58,7 +57,6 @@ public object Deserialize(Stream serializationStream) } } - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)] public void Serialize(Stream serializationStream, object graph) { diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.PlatformNotSupported.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.PlatformNotSupported.cs index b212e94ea577a2..cf124a5c6de1ca 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.PlatformNotSupported.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.PlatformNotSupported.cs @@ -8,13 +8,11 @@ namespace System.Runtime.Serialization.Formatters.Binary { public sealed partial class BinaryFormatter : IFormatter { - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresDynamicCode(IFormatter.RequiresDynamicCodeMessage)] [RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)] public object Deserialize(Stream serializationStream) => throw new PlatformNotSupportedException(SR.BinaryFormatter_SerializationNotSupportedOnThisPlatform); - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)] public void Serialize(Stream serializationStream, object graph) => throw new PlatformNotSupportedException(SR.BinaryFormatter_SerializationNotSupportedOnThisPlatform); diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.cs index 59d2d519f42f5c..11b9fb735dfdde 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatter.cs @@ -5,6 +5,7 @@ namespace System.Runtime.Serialization.Formatters.Binary { + [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public sealed partial class BinaryFormatter : IFormatter { private static readonly ConcurrentDictionary s_typeNameCache = new ConcurrentDictionary(); diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/CommonEnums.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/CommonEnums.cs index a45f69096d9cc8..51fdeff6d3f1fc 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/CommonEnums.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/CommonEnums.cs @@ -3,6 +3,7 @@ namespace System.Runtime.Serialization.Formatters { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public enum FormatterTypeStyle { TypesWhenNeeded = 0, // Types are outputted only for Arrays of Objects, Object Members of type Object, and ISerializable non-primitive value types @@ -10,12 +11,14 @@ public enum FormatterTypeStyle XsdString = 0x2 // Strings are outputed as xsd rather then SOAP-ENC strings. No string ID's are transmitted } + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public enum FormatterAssemblyStyle { Simple = 0, Full = 1, } + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public enum TypeFilterLevel { Low = 0x2, diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/IFieldInfo.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/IFieldInfo.cs index 890b5e3bc47bf3..3d4d1ed22d0258 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/IFieldInfo.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/IFieldInfo.cs @@ -3,6 +3,7 @@ namespace System.Runtime.Serialization.Formatters { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface IFieldInfo { string[]? FieldNames { get; set; } diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/IFormatter.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/IFormatter.cs index 0928b3982c26b8..ef64d8b22ae1cc 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/IFormatter.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/IFormatter.cs @@ -6,16 +6,15 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface IFormatter { internal const string RequiresDynamicCodeMessage = "BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered."; internal const string RequiresUnreferencedCodeMessage = "BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered."; - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresDynamicCode(RequiresDynamicCodeMessage)] [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] object Deserialize(Stream serializationStream); - [Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] void Serialize(Stream serializationStream, object graph); ISurrogateSelector? SurrogateSelector { get; set; } diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISerializationSurrogate.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISerializationSurrogate.cs index ff9f16c28b2456..76aa414dbf1259 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISerializationSurrogate.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISerializationSurrogate.cs @@ -3,6 +3,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface ISerializationSurrogate { void GetObjectData(object obj, SerializationInfo info, StreamingContext context); diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISurrogateSelector.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISurrogateSelector.cs index 16e77fd567cb28..8aa06ff3f48ac0 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISurrogateSelector.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ISurrogateSelector.cs @@ -3,6 +3,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public interface ISurrogateSelector { void ChainSelector(ISurrogateSelector selector); diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectIDGenerator.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectIDGenerator.cs index 78d20856994b00..0d019f72cc80be 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectIDGenerator.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectIDGenerator.cs @@ -6,6 +6,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public class ObjectIDGenerator { private const int NumBins = 4; diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs index 53d1ab836b567c..89b91be09a3cbc 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs @@ -7,6 +7,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public class ObjectManager { private const int DefaultInitialSize = 16; diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SerializationObjectManager.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SerializationObjectManager.cs index 9c0b1299f093fd..204e0f2573b99e 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SerializationObjectManager.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SerializationObjectManager.cs @@ -6,6 +6,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public sealed class SerializationObjectManager { private const string SerializationObjectManagerUnreferencedCodeMessage = "SerializationObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered."; diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SurrogateSelector.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SurrogateSelector.cs index e8f87df23e6c96..8ba256b8406933 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SurrogateSelector.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SurrogateSelector.cs @@ -6,6 +6,7 @@ namespace System.Runtime.Serialization { + [Obsolete(Obsoletions.LegacyFormatterMessage, DiagnosticId = Obsoletions.LegacyFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public class SurrogateSelector : ISurrogateSelector { internal readonly SurrogateHashtable _surrogates = new SurrogateHashtable(32); diff --git a/src/libraries/System.Runtime.Serialization.Primitives/ref/System.Runtime.Serialization.Primitives.cs b/src/libraries/System.Runtime.Serialization.Primitives/ref/System.Runtime.Serialization.Primitives.cs index 63f1abbba95ae9..0ae13fef85681f 100644 --- a/src/libraries/System.Runtime.Serialization.Primitives/ref/System.Runtime.Serialization.Primitives.cs +++ b/src/libraries/System.Runtime.Serialization.Primitives/ref/System.Runtime.Serialization.Primitives.cs @@ -66,6 +66,8 @@ public IgnoreDataMemberAttribute() { } public partial class InvalidDataContractException : System.Exception { public InvalidDataContractException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidDataContractException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidDataContractException(string? message) { } public InvalidDataContractException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.Runtime.Serialization.Primitives/src/System.Runtime.Serialization.Primitives.csproj b/src/libraries/System.Runtime.Serialization.Primitives/src/System.Runtime.Serialization.Primitives.csproj index bd7267ae26b97c..e013ff5194a485 100644 --- a/src/libraries/System.Runtime.Serialization.Primitives/src/System.Runtime.Serialization.Primitives.csproj +++ b/src/libraries/System.Runtime.Serialization.Primitives/src/System.Runtime.Serialization.Primitives.csproj @@ -15,6 +15,7 @@ + diff --git a/src/libraries/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.cs b/src/libraries/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.cs index 9d821d781d5db4..0c5bff994f156d 100644 --- a/src/libraries/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.cs +++ b/src/libraries/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/InvalidDataContractException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Runtime.CompilerServices; namespace System.Runtime.Serialization @@ -25,6 +26,8 @@ public InvalidDataContractException(string? message, Exception? innerException) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected InvalidDataContractException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs index 316800e18fe336..a62636e16d9879 100644 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs +++ b/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs @@ -4145,6 +4145,9 @@ public MyArgumentException(string message, string paramName) : base(message) _paramName = paramName; } +#if NET8_0_OR_GREATER + [Obsolete("Exception..ctor(SerializationInfo, StreamingContext) is obsolete.", DiagnosticId = "SYSLIB0051")] +#endif protected MyArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) { _paramName = info.GetString("ParamName"); } @@ -4161,6 +4164,9 @@ internal set } } +#if NET8_0_OR_GREATER + [Obsolete("Exception.GetObjectData is obsolete.", DiagnosticId = "SYSLIB0051")] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 86305a208d9bea..853ee0518aa4a8 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -46,6 +46,8 @@ namespace System public partial class AccessViolationException : System.SystemException { public AccessViolationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected AccessViolationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public AccessViolationException(string? message) { } public AccessViolationException(string? message, System.Exception? innerException) { } @@ -94,6 +96,8 @@ public partial class AggregateException : System.Exception public AggregateException() { } public AggregateException(System.Collections.Generic.IEnumerable innerExceptions) { } public AggregateException(params System.Exception[] innerExceptions) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected AggregateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public AggregateException(string? message) { } public AggregateException(string? message, System.Collections.Generic.IEnumerable innerExceptions) { } @@ -103,6 +107,8 @@ public AggregateException(string? message, params System.Exception[] innerExcept public override string Message { get { throw null; } } public System.AggregateException Flatten() { throw null; } public override System.Exception GetBaseException() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void Handle(System.Func predicate) { } public override string ToString() { throw null; } @@ -226,6 +232,8 @@ internal AppDomainSetup() { } public partial class AppDomainUnloadedException : System.SystemException { public AppDomainUnloadedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected AppDomainUnloadedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public AppDomainUnloadedException(string? message) { } public AppDomainUnloadedException(string? message, System.Exception? innerException) { } @@ -233,6 +241,8 @@ public AppDomainUnloadedException(string? message, System.Exception? innerExcept public partial class ApplicationException : System.Exception { public ApplicationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ApplicationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ApplicationException(string? message) { } public ApplicationException(string? message, System.Exception? innerException) { } @@ -269,6 +279,8 @@ public void End() { } public partial class ArgumentException : System.SystemException { public ArgumentException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ArgumentException(string? message) { } public ArgumentException(string? message, System.Exception? innerException) { } @@ -276,12 +288,16 @@ public ArgumentException(string? message, string? paramName) { } public ArgumentException(string? message, string? paramName, System.Exception? innerException) { } public override string Message { get { throw null; } } public virtual string? ParamName { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static void ThrowIfNullOrEmpty([System.Diagnostics.CodeAnalysis.NotNullAttribute] string? argument, [System.Runtime.CompilerServices.CallerArgumentExpression("argument")] string? paramName = null) { throw null; } } public partial class ArgumentNullException : System.ArgumentException { public ArgumentNullException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ArgumentNullException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ArgumentNullException(string? paramName) { } public ArgumentNullException(string? message, System.Exception? innerException) { } @@ -293,6 +309,8 @@ public ArgumentNullException(string? paramName, string? message) { } public partial class ArgumentOutOfRangeException : System.ArgumentException { public ArgumentOutOfRangeException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ArgumentOutOfRangeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ArgumentOutOfRangeException(string? paramName) { } public ArgumentOutOfRangeException(string? message, System.Exception? innerException) { } @@ -300,6 +318,8 @@ public ArgumentOutOfRangeException(string? paramName, object? actualValue, strin public ArgumentOutOfRangeException(string? paramName, string? message) { } public virtual object? ActualValue { get { throw null; } } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static void ThrowIfEqual(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpression(nameof(value))] string? paramName = null) where T : System.IEquatable? { throw null; } public static void ThrowIfGreaterThan(T value, T other, [System.Runtime.CompilerServices.CallerArgumentExpressionAttribute(nameof(value))] string? paramName = null) where T : System.IComparable { throw null; } @@ -314,6 +334,8 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf public partial class ArithmeticException : System.SystemException { public ArithmeticException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ArithmeticException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ArithmeticException(string? message) { } public ArithmeticException(string? message, System.Exception? innerException) { } @@ -495,6 +517,8 @@ void System.Collections.IEnumerator.Reset() { } public partial class ArrayTypeMismatchException : System.SystemException { public ArrayTypeMismatchException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ArrayTypeMismatchException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ArrayTypeMismatchException(string? message) { } public ArrayTypeMismatchException(string? message, System.Exception? innerException) { } @@ -579,6 +603,8 @@ public AttributeUsageAttribute(System.AttributeTargets validOn) { } public partial class BadImageFormatException : System.SystemException { public BadImageFormatException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected BadImageFormatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public BadImageFormatException(string? message) { } public BadImageFormatException(string? message, System.Exception? inner) { } @@ -587,6 +613,8 @@ public BadImageFormatException(string? message, string? fileName, System.Excepti public string? FileName { get { throw null; } } public string? FusionLog { get { throw null; } } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } @@ -861,6 +889,8 @@ public static void SetByte(System.Array array, int index, byte value) { } public partial class CannotUnloadAppDomainException : System.SystemException { public CannotUnloadAppDomainException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CannotUnloadAppDomainException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CannotUnloadAppDomainException(string? message) { } public CannotUnloadAppDomainException(string? message, System.Exception? innerException) { } @@ -1061,6 +1091,8 @@ protected ContextBoundObject() { } public partial class ContextMarshalException : System.SystemException { public ContextMarshalException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ContextMarshalException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ContextMarshalException(string? message) { } public ContextMarshalException(string? message, System.Exception? inner) { } @@ -1868,6 +1900,8 @@ public sealed partial class DBNull : System.IConvertible, System.Runtime.Seriali { internal DBNull() { } public static readonly System.DBNull Value; + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.TypeCode GetTypeCode() { throw null; } bool System.IConvertible.ToBoolean(System.IFormatProvider? provider) { throw null; } @@ -2122,6 +2156,8 @@ protected Delegate([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAt public override int GetHashCode() { throw null; } public virtual System.Delegate[] GetInvocationList() { throw null; } protected virtual System.Reflection.MethodInfo GetMethodImpl() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static bool operator ==(System.Delegate? d1, System.Delegate? d2) { throw null; } public static bool operator !=(System.Delegate? d1, System.Delegate? d2) { throw null; } @@ -2132,6 +2168,8 @@ public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo public partial class DivideByZeroException : System.ArithmeticException { public DivideByZeroException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DivideByZeroException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DivideByZeroException(string? message) { } public DivideByZeroException(string? message, System.Exception? innerException) { } @@ -2330,6 +2368,8 @@ public DivideByZeroException(string? message, System.Exception? innerException) public partial class DuplicateWaitObjectException : System.ArgumentException { public DuplicateWaitObjectException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DuplicateWaitObjectException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DuplicateWaitObjectException(string? parameterName) { } public DuplicateWaitObjectException(string? message, System.Exception? innerException) { } @@ -2338,6 +2378,8 @@ public DuplicateWaitObjectException(string? parameterName, string? message) { } public partial class EntryPointNotFoundException : System.TypeLoadException { public EntryPointNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected EntryPointNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public EntryPointNotFoundException(string? message) { } public EntryPointNotFoundException(string? message, System.Exception? inner) { } @@ -2532,6 +2574,8 @@ public EventArgs() { } public partial class Exception : System.Runtime.Serialization.ISerializable { public Exception() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected Exception(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public Exception(string? message) { } public Exception(string? message, System.Exception? innerException) { } @@ -2546,6 +2590,8 @@ public Exception(string? message, System.Exception? innerException) { } [System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] protected event System.EventHandler? SerializeObjectState { add { } remove { } } public virtual System.Exception GetBaseException() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public new System.Type GetType() { throw null; } public override string ToString() { throw null; } @@ -2560,6 +2606,8 @@ public ExecutionEngineException(string? message, System.Exception? innerExceptio public partial class FieldAccessException : System.MemberAccessException { public FieldAccessException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FieldAccessException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public FieldAccessException(string? message) { } public FieldAccessException(string? message, System.Exception? inner) { } @@ -2572,6 +2620,8 @@ public FlagsAttribute() { } public partial class FormatException : System.SystemException { public FormatException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FormatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public FormatException(string? message) { } public FormatException(string? message, System.Exception? innerException) { } @@ -3812,6 +3862,8 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public partial class InvalidCastException : System.SystemException { public InvalidCastException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidCastException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidCastException(string? message) { } public InvalidCastException(string? message, System.Exception? innerException) { } @@ -3820,6 +3872,8 @@ public InvalidCastException(string? message, int errorCode) { } public partial class InvalidOperationException : System.SystemException { public InvalidOperationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidOperationException(string? message) { } public InvalidOperationException(string? message, System.Exception? innerException) { } @@ -3833,6 +3887,8 @@ public InvalidProgramException(string? message, System.Exception? inner) { } public partial class InvalidTimeZoneException : System.Exception { public InvalidTimeZoneException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidTimeZoneException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidTimeZoneException(string? message) { } public InvalidTimeZoneException(string? message, System.Exception? innerException) { } @@ -4118,6 +4174,8 @@ public static partial class MathF public partial class MemberAccessException : System.SystemException { public MemberAccessException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MemberAccessException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MemberAccessException(string? message) { } public MemberAccessException(string? message, System.Exception? inner) { } @@ -4151,6 +4209,8 @@ public void CopyTo(System.Memory destination) { } public partial class MethodAccessException : System.MemberAccessException { public MethodAccessException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MethodAccessException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MethodAccessException(string? message) { } public MethodAccessException(string? message, System.Exception? inner) { } @@ -4163,31 +4223,39 @@ public enum MidpointRounding ToNegativeInfinity = 3, ToPositiveInfinity = 4, } - public partial class MissingFieldException : System.MissingMemberException, System.Runtime.Serialization.ISerializable + public partial class MissingFieldException : System.MissingMemberException { public MissingFieldException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MissingFieldException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MissingFieldException(string? message) { } public MissingFieldException(string? message, System.Exception? inner) { } public MissingFieldException(string? className, string? fieldName) { } public override string Message { get { throw null; } } } - public partial class MissingMemberException : System.MemberAccessException, System.Runtime.Serialization.ISerializable + public partial class MissingMemberException : System.MemberAccessException { protected string? ClassName; protected string? MemberName; protected byte[]? Signature; public MissingMemberException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MissingMemberException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MissingMemberException(string? message) { } public MissingMemberException(string? message, System.Exception? inner) { } public MissingMemberException(string? className, string? memberName) { } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class MissingMethodException : System.MissingMemberException { public MissingMethodException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MissingMethodException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MissingMethodException(string? message) { } public MissingMethodException(string? message, System.Exception? inner) { } @@ -4239,6 +4307,8 @@ public abstract partial class MulticastDelegate : System.Delegate public sealed override int GetHashCode() { throw null; } public sealed override System.Delegate[] GetInvocationList() { throw null; } protected override System.Reflection.MethodInfo GetMethodImpl() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static bool operator ==(System.MulticastDelegate? d1, System.MulticastDelegate? d2) { throw null; } public static bool operator !=(System.MulticastDelegate? d1, System.MulticastDelegate? d2) { throw null; } @@ -4251,6 +4321,7 @@ public MulticastNotSupportedException(string? message) { } public MulticastNotSupportedException(string? message, System.Exception? inner) { } } [System.AttributeUsageAttribute(System.AttributeTargets.Field, Inherited=false)] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public sealed partial class NonSerializedAttribute : System.Attribute { public NonSerializedAttribute() { } @@ -4259,17 +4330,23 @@ public partial class NotFiniteNumberException : System.ArithmeticException { public NotFiniteNumberException() { } public NotFiniteNumberException(double offendingNumber) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NotFiniteNumberException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public NotFiniteNumberException(string? message) { } public NotFiniteNumberException(string? message, double offendingNumber) { } public NotFiniteNumberException(string? message, double offendingNumber, System.Exception? innerException) { } public NotFiniteNumberException(string? message, System.Exception? innerException) { } public double OffendingNumber { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class NotImplementedException : System.SystemException { public NotImplementedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NotImplementedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public NotImplementedException(string? message) { } public NotImplementedException(string? message, System.Exception? inner) { } @@ -4277,6 +4354,8 @@ public NotImplementedException(string? message, System.Exception? inner) { } public partial class NotSupportedException : System.SystemException { public NotSupportedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NotSupportedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public NotSupportedException(string? message) { } public NotSupportedException(string? message, System.Exception? innerException) { } @@ -4306,6 +4385,8 @@ public partial struct Nullable where T : struct public partial class NullReferenceException : System.SystemException { public NullReferenceException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected NullReferenceException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public NullReferenceException(string? message) { } public NullReferenceException(string? message, System.Exception? innerException) { } @@ -4324,12 +4405,16 @@ public Object() { } } public partial class ObjectDisposedException : System.InvalidOperationException { + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ObjectDisposedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ObjectDisposedException(string? objectName) { } public ObjectDisposedException(string? message, System.Exception? innerException) { } public ObjectDisposedException(string? objectName, string? message) { } public override string Message { get { throw null; } } public string ObjectName { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static void ThrowIf([System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute(true)] bool condition, object instance) => throw null; public static void ThrowIf([System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute(true)] bool condition, System.Type type) => throw null; @@ -4353,6 +4438,8 @@ public OperatingSystem(System.PlatformID platform, System.Version version) { } public System.Version Version { get { throw null; } } public string VersionString { get { throw null; } } public object Clone() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } @@ -4382,6 +4469,8 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public partial class OperationCanceledException : System.SystemException { public OperationCanceledException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected OperationCanceledException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public OperationCanceledException(string? message) { } public OperationCanceledException(string? message, System.Exception? innerException) { } @@ -4393,6 +4482,8 @@ public OperationCanceledException(System.Threading.CancellationToken token) { } public partial class OutOfMemoryException : System.SystemException { public OutOfMemoryException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected OutOfMemoryException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public OutOfMemoryException(string? message) { } public OutOfMemoryException(string? message, System.Exception? innerException) { } @@ -4400,6 +4491,8 @@ public OutOfMemoryException(string? message, System.Exception? innerException) { public partial class OverflowException : System.ArithmeticException { public OverflowException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected OverflowException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public OverflowException(string? message) { } public OverflowException(string? message, System.Exception? innerException) { } @@ -4428,6 +4521,8 @@ public enum PlatformID public partial class PlatformNotSupportedException : System.NotSupportedException { public PlatformNotSupportedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected PlatformNotSupportedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public PlatformNotSupportedException(string? message) { } public PlatformNotSupportedException(string? message, System.Exception? inner) { } @@ -4481,6 +4576,8 @@ public void Shuffle(T[] values) { } public partial class RankException : System.SystemException { public RankException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected RankException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RankException(string? message) { } public RankException(string? message, System.Exception? innerException) { } @@ -4571,6 +4668,8 @@ public partial struct RuntimeFieldHandle : System.IEquatable : System.Runtime.Serialization.ISerializable where T : class? @@ -7108,6 +7235,8 @@ public sealed partial class WeakReference : System.Runtime.Serialization.ISer public WeakReference(T target) { } public WeakReference(T target, bool trackResurrection) { } ~WeakReference() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void SetTarget(T target) { } public bool TryGetTarget([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false), System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out T target) { throw null; } @@ -7321,6 +7450,8 @@ public sealed partial class Comparer : System.Collections.IComparer, System.Runt public static readonly System.Collections.Comparer DefaultInvariant; public Comparer(System.Globalization.CultureInfo culture) { } public int Compare(object? a, object? b) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial struct DictionaryEntry @@ -7355,6 +7486,8 @@ public Hashtable(int capacity, float loadFactor) { } public Hashtable(int capacity, float loadFactor, System.Collections.IEqualityComparer? equalityComparer) { } [System.ObsoleteAttribute("This constructor has been deprecated. Use Hashtable(int, float, IEqualityComparer) instead.")] public Hashtable(int capacity, float loadFactor, System.Collections.IHashCodeProvider? hcp, System.Collections.IComparer? comparer) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected Hashtable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.ObsoleteAttribute("Hashtable.comparer has been deprecated. Use the KeyComparer properties instead.")] protected System.Collections.IComparer? comparer { get { throw null; } set { } } @@ -7378,6 +7511,8 @@ public virtual void Clear() { } public virtual void CopyTo(System.Array array, int arrayIndex) { } public virtual System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; } protected virtual int GetHash(object key) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected virtual bool KeyEquals(object? item, object key) { throw null; } public virtual void OnDeserialization(object? sender) { } @@ -7558,6 +7693,8 @@ public partial interface ISet : System.Collections.Generic.ICollection, Sy public partial class KeyNotFoundException : System.SystemException { public KeyNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected KeyNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public KeyNotFoundException(string? message) { } public KeyNotFoundException(string? message, System.Exception? innerException) { } @@ -8452,6 +8589,8 @@ public void ClearCachedData() { } public partial class CultureNotFoundException : System.ArgumentException { public CultureNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CultureNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CultureNotFoundException(string? message) { } public CultureNotFoundException(string? message, System.Exception? innerException) { } @@ -8463,6 +8602,8 @@ public CultureNotFoundException(string? paramName, string? invalidCultureName, s public virtual int? InvalidCultureId { get { throw null; } } public virtual string? InvalidCultureName { get { throw null; } } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } [System.FlagsAttribute] @@ -9328,6 +9469,8 @@ public void MoveTo(string destDirName) { } public partial class DirectoryNotFoundException : System.IO.IOException { public DirectoryNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected DirectoryNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public DirectoryNotFoundException(string? message) { } public DirectoryNotFoundException(string? message, System.Exception? innerException) { } @@ -9335,6 +9478,8 @@ public DirectoryNotFoundException(string? message, System.Exception? innerExcept public partial class EndOfStreamException : System.IO.IOException { public EndOfStreamException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected EndOfStreamException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public EndOfStreamException(string? message) { } public EndOfStreamException(string? message, System.Exception? innerException) { } @@ -9512,6 +9657,8 @@ public void MoveTo(string destFileName, bool overwrite) { } public partial class FileLoadException : System.IO.IOException { public FileLoadException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FileLoadException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public FileLoadException(string? message) { } public FileLoadException(string? message, System.Exception? inner) { } @@ -9520,6 +9667,8 @@ public FileLoadException(string? message, string? fileName, System.Exception? in public string? FileName { get { throw null; } } public string? FusionLog { get { throw null; } } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } @@ -9535,6 +9684,8 @@ public enum FileMode public partial class FileNotFoundException : System.IO.IOException { public FileNotFoundException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FileNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public FileNotFoundException(string? message) { } public FileNotFoundException(string? message, System.Exception? innerException) { } @@ -9543,6 +9694,8 @@ public FileNotFoundException(string? message, string? fileName, System.Exception public string? FileName { get { throw null; } } public string? FusionLog { get { throw null; } } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } @@ -9651,6 +9804,8 @@ public abstract partial class FileSystemInfo : System.MarshalByRefObject, System protected string FullPath; protected string OriginalPath; protected FileSystemInfo() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected FileSystemInfo(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.IO.FileAttributes Attributes { get { throw null; } set { } } public System.DateTime CreationTime { get { throw null; } set { } } @@ -9667,6 +9822,8 @@ protected FileSystemInfo(System.Runtime.Serialization.SerializationInfo info, Sy public System.IO.UnixFileMode UnixFileMode { get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] set { } } public void CreateAsSymbolicLink(string pathToTarget) { } public abstract void Delete(); + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void Refresh() { } public System.IO.FileSystemInfo? ResolveLinkTarget(bool returnFinalTarget) { throw null; } @@ -9686,6 +9843,8 @@ public InvalidDataException(string? message, System.Exception? innerException) { public partial class IOException : System.SystemException { public IOException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected IOException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public IOException(string? message) { } public IOException(string? message, System.Exception? innerException) { } @@ -9802,6 +9961,8 @@ public static partial class Path public partial class PathTooLongException : System.IO.IOException { public PathTooLongException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected PathTooLongException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public PathTooLongException(string? message) { } public PathTooLongException(string? message, System.Exception? innerException) { } @@ -10711,6 +10872,8 @@ public virtual event System.Reflection.ModuleResolveEventHandler? ModuleResolve public virtual System.Reflection.Module[] GetModules(bool getResourceModules) { throw null; } public virtual System.Reflection.AssemblyName GetName() { throw null; } public virtual System.Reflection.AssemblyName GetName(bool copiedName) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Assembly references might be removed")] public virtual System.Reflection.AssemblyName[] GetReferencedAssemblies() { throw null; } @@ -10885,6 +11048,8 @@ public AssemblyName(string assemblyName) { } public System.Configuration.Assemblies.AssemblyVersionCompatibility VersionCompatibility { get { throw null; } set { } } public object Clone() { throw null; } public static System.Reflection.AssemblyName GetAssemblyName(string assemblyFile) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public byte[]? GetPublicKey() { throw null; } public byte[]? GetPublicKeyToken() { throw null; } @@ -11053,6 +11218,8 @@ public static partial class CustomAttributeExtensions public partial class CustomAttributeFormatException : System.FormatException { public CustomAttributeFormatException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CustomAttributeFormatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CustomAttributeFormatException(string? message) { } public CustomAttributeFormatException(string? message, System.Exception? inner) { } @@ -11163,6 +11330,7 @@ public enum FieldAttributes Static = 16, InitOnly = 32, Literal = 64, + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] NotSerialized = 128, HasFieldRVA = 256, SpecialName = 512, @@ -11184,6 +11352,7 @@ protected FieldInfo() { } public bool IsFamilyOrAssembly { get { throw null; } } public bool IsInitOnly { get { throw null; } } public bool IsLiteral { get { throw null; } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public bool IsNotSerialized { get { throw null; } } public bool IsPinvokeImpl { get { throw null; } } public bool IsPrivate { get { throw null; } } @@ -11251,6 +11420,8 @@ public static partial class IntrospectionExtensions public partial class InvalidFilterCriteriaException : System.ApplicationException { public InvalidFilterCriteriaException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected InvalidFilterCriteriaException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public InvalidFilterCriteriaException(string? message) { } public InvalidFilterCriteriaException(string? message, System.Exception? inner) { } @@ -11507,6 +11678,8 @@ protected Module() { } public System.Reflection.MethodInfo[] GetMethods() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Methods might be removed")] public virtual System.Reflection.MethodInfo[] GetMethods(System.Reflection.BindingFlags bindingFlags) { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public virtual void GetPEKind(out System.Reflection.PortableExecutableKinds peKind, out System.Reflection.ImageFileMachine machine) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types might be removed")] @@ -11598,7 +11771,10 @@ public enum ParameterAttributes Reserved4 = 32768, ReservedMask = 61440, } - public partial class ParameterInfo : System.Reflection.ICustomAttributeProvider, System.Runtime.Serialization.IObjectReference + public partial class ParameterInfo : System.Reflection.ICustomAttributeProvider +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete + , System.Runtime.Serialization.IObjectReference +#pragma warning restore SYSLIB0050 { protected System.Reflection.ParameterAttributes AttrsImpl; protected System.Type? ClassImpl; @@ -11627,6 +11803,8 @@ protected ParameterInfo() { } public virtual System.Collections.Generic.IList GetCustomAttributesData() { throw null; } public virtual System.Type GetModifiedParameterType() { throw null; } public virtual System.Type[] GetOptionalCustomModifiers() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public object GetRealObject(System.Runtime.Serialization.StreamingContext context) { throw null; } public virtual System.Type[] GetRequiredCustomModifiers() { throw null; } public virtual bool IsDefined(System.Type attributeType, bool inherit) { throw null; } @@ -11721,13 +11899,15 @@ protected ReflectionContext() { } public abstract System.Reflection.Assembly MapAssembly(System.Reflection.Assembly assembly); public abstract System.Reflection.TypeInfo MapType(System.Reflection.TypeInfo type); } - public sealed partial class ReflectionTypeLoadException : System.SystemException, System.Runtime.Serialization.ISerializable + public sealed partial class ReflectionTypeLoadException : System.SystemException { public ReflectionTypeLoadException(System.Type?[]? classes, System.Exception?[]? exceptions) { } public ReflectionTypeLoadException(System.Type?[]? classes, System.Exception?[]? exceptions, string? message) { } public System.Exception?[] LoaderExceptions { get { throw null; } } public override string Message { get { throw null; } } public System.Type?[] Types { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } @@ -11763,6 +11943,8 @@ public partial class StrongNameKeyPair : System.Runtime.Serialization.IDeseriali { public StrongNameKeyPair(byte[] keyPairArray) { } public StrongNameKeyPair(System.IO.FileStream keyPairFile) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected StrongNameKeyPair(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public StrongNameKeyPair(string keyPairContainer) { } public byte[] PublicKey { get { throw null; } } @@ -11772,6 +11954,8 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public partial class TargetException : System.ApplicationException { public TargetException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TargetException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TargetException(string? message) { } public TargetException(string? message, System.Exception? inner) { } @@ -11812,6 +11996,7 @@ public enum TypeAttributes SpecialName = 1024, RTSpecialName = 2048, Import = 4096, + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] Serializable = 8192, WindowsRuntime = 16384, UnicodeClass = 65536, @@ -11947,6 +12132,7 @@ public partial interface IResourceReader : System.Collections.IEnumerable, Syste public partial class MissingManifestResourceException : System.SystemException { public MissingManifestResourceException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] protected MissingManifestResourceException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MissingManifestResourceException(string? message) { } public MissingManifestResourceException(string? message, System.Exception? inner) { } @@ -11954,6 +12140,8 @@ public MissingManifestResourceException(string? message, System.Exception? inner public partial class MissingSatelliteAssemblyException : System.SystemException { public MissingSatelliteAssemblyException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected MissingSatelliteAssemblyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public MissingSatelliteAssemblyException(string? message) { } public MissingSatelliteAssemblyException(string? message, System.Exception? inner) { } @@ -12708,6 +12896,8 @@ public sealed partial class RuntimeWrappedException : System.Exception { public RuntimeWrappedException(object thrownObject) { } public object WrappedException { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Module | System.AttributeTargets.Property | System.AttributeTargets.Struct, Inherited=false)] @@ -12754,6 +12944,8 @@ public SwitchExpressionException(string? message) { } public SwitchExpressionException(string? message, System.Exception? innerException) { } public override string Message { get { throw null; } } public object? UnmatchedValue { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public readonly partial struct TaskAwaiter : System.Runtime.CompilerServices.ICriticalNotifyCompletion, System.Runtime.CompilerServices.INotifyCompletion @@ -13004,6 +13196,8 @@ public void SetHandleAsInvalid() { } public partial class ExternalException : System.SystemException { public ExternalException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ExternalException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ExternalException(string? message) { } public ExternalException(string? message, System.Exception? inner) { } @@ -13313,6 +13507,7 @@ public partial interface IDeserializationCallback void OnDeserialization(object? sender); } [System.CLSCompliantAttribute(false)] + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface IFormatterConverter { object Convert(object value, System.Type type); @@ -13333,16 +13528,19 @@ public partial interface IFormatterConverter uint ToUInt32(object value); ulong ToUInt64(object value); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface IObjectReference { object GetRealObject(System.Runtime.Serialization.StreamingContext context); } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial interface ISafeSerializationData { void CompleteDeserialization(object deserialized); } public partial interface ISerializable { + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context); } [System.AttributeUsageAttribute(System.AttributeTargets.Method, Inherited=false)] @@ -13371,6 +13569,7 @@ public sealed partial class OptionalFieldAttribute : System.Attribute public OptionalFieldAttribute() { } public int VersionAdded { get { throw null; } set { } } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public sealed partial class SafeSerializationEventArgs : System.EventArgs { internal SafeSerializationEventArgs() { } @@ -13388,6 +13587,8 @@ public readonly partial struct SerializationEntry public partial class SerializationException : System.SystemException { public SerializationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SerializationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SerializationException(string? message) { } public SerializationException(string? message, System.Exception? innerException) { } @@ -13395,8 +13596,10 @@ public SerializationException(string? message, System.Exception? innerException) public sealed partial class SerializationInfo { [System.CLSCompliantAttribute(false)] + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public SerializationInfo(System.Type type, System.Runtime.Serialization.IFormatterConverter converter) { } [System.CLSCompliantAttribute(false)] + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public SerializationInfo(System.Type type, System.Runtime.Serialization.IFormatterConverter converter, bool requireSameTokenInPartialTrust) { } public string AssemblyName { get { throw null; } set { } } public string FullTypeName { get { throw null; } set { } } @@ -13462,14 +13665,18 @@ public readonly partial struct StreamingContext { private readonly object _dummy; private readonly int _dummyPrimitive; + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public StreamingContext(System.Runtime.Serialization.StreamingContextStates state) { throw null; } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public StreamingContext(System.Runtime.Serialization.StreamingContextStates state, object? additional) { throw null; } public object? Context { get { throw null; } } + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public System.Runtime.Serialization.StreamingContextStates State { get { throw null; } } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } } [System.FlagsAttribute] + [System.ObsoleteAttribute("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public enum StreamingContextStates { CrossProcess = 1, @@ -13721,6 +13928,8 @@ public void AddChild(System.Security.SecurityElement child) { } public partial class SecurityException : System.SystemException { public SecurityException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SecurityException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SecurityException(string? message) { } public SecurityException(string? message, System.Exception? inner) { } @@ -13736,6 +13945,8 @@ public SecurityException(string? message, System.Type? type, string? state) { } public object? PermitOnlySetInstance { get { throw null; } set { } } public string? RefusedSet { get { throw null; } set { } } public string? Url { get { throw null; } set { } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } @@ -13781,6 +13992,8 @@ public UnverifiableCodeAttribute() { } public partial class VerificationException : System.SystemException { public VerificationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected VerificationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public VerificationException(string? message) { } public VerificationException(string? message, System.Exception? innerException) { } @@ -13792,6 +14005,8 @@ public partial class CryptographicException : System.SystemException { public CryptographicException() { } public CryptographicException(int hr) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CryptographicException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CryptographicException(string? message) { } public CryptographicException(string? message, System.Exception? inner) { } @@ -14739,6 +14954,8 @@ public static partial class TaskAsyncEnumerableExtensions public partial class TaskCanceledException : System.OperationCanceledException { public TaskCanceledException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TaskCanceledException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TaskCanceledException(string? message) { } public TaskCanceledException(string? message, System.Exception? innerException) { } @@ -14965,6 +15182,8 @@ public partial class TaskSchedulerException : System.Exception { public TaskSchedulerException() { } public TaskSchedulerException(System.Exception? innerException) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TaskSchedulerException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TaskSchedulerException(string? message) { } public TaskSchedulerException(string? message, System.Exception? innerException) { } @@ -15205,6 +15424,8 @@ public partial class Uri : System.Runtime.Serialization.ISerializable public static readonly string UriSchemeTelnet; public static readonly string UriSchemeWs; public static readonly string UriSchemeWss; + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected Uri(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public Uri([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("Uri")] string uriString) { } [System.ObsoleteAttribute("This constructor has been deprecated; the dontEscape parameter is always false. Use Uri(string) instead.")] @@ -15351,6 +15572,8 @@ public enum UriFormat public partial class UriFormatException : System.FormatException, System.Runtime.Serialization.ISerializable { public UriFormatException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected UriFormatException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public UriFormatException(string? textString) { } public UriFormatException(string? textString, System.Exception? e) { } diff --git a/src/libraries/System.Security.AccessControl/ref/System.Security.AccessControl.cs b/src/libraries/System.Security.AccessControl/ref/System.Security.AccessControl.cs index 54edec6fe4570a..bd0e0ecbe1bf8c 100644 --- a/src/libraries/System.Security.AccessControl/ref/System.Security.AccessControl.cs +++ b/src/libraries/System.Security.AccessControl/ref/System.Security.AccessControl.cs @@ -444,6 +444,8 @@ public PrivilegeNotHeldException() { } public PrivilegeNotHeldException(string? privilege) { } public PrivilegeNotHeldException(string? privilege, System.Exception? inner) { } public string? PrivilegeName { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } [System.FlagsAttribute] diff --git a/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj b/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj index 35fabc2416c000..90b30c498da536 100644 --- a/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj +++ b/src/libraries/System.Security.AccessControl/src/System.Security.AccessControl.csproj @@ -24,6 +24,8 @@ + diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs index dab91343bdd7bc..b501fc7a3c7e97 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using System.Globalization; using System.Runtime.Serialization; @@ -9,7 +10,7 @@ namespace System.Security.AccessControl { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public sealed class PrivilegeNotHeldException : UnauthorizedAccessException, ISerializable + public sealed class PrivilegeNotHeldException : UnauthorizedAccessException { private readonly string? _privilegeName; @@ -30,11 +31,14 @@ public PrivilegeNotHeldException(string? privilege, Exception? inner) _privilegeName = privilege; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] private PrivilegeNotHeldException(SerializationInfo info, StreamingContext context) : base(info, context) { _privilegeName = info.GetString(nameof(PrivilegeName)); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Security.Claims/ref/System.Security.Claims.cs b/src/libraries/System.Security.Claims/ref/System.Security.Claims.cs index 60066df503fc99..4bc8d68fd834a5 100644 --- a/src/libraries/System.Security.Claims/ref/System.Security.Claims.cs +++ b/src/libraries/System.Security.Claims/ref/System.Security.Claims.cs @@ -41,7 +41,11 @@ public ClaimsIdentity(System.Collections.Generic.IEnumerable? claims, string? authenticationType) { } public ClaimsIdentity(System.Collections.Generic.IEnumerable? claims, string? authenticationType, string? nameType, string? roleType) { } public ClaimsIdentity(System.IO.BinaryReader reader) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ClaimsIdentity(System.Runtime.Serialization.SerializationInfo info) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ClaimsIdentity(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected ClaimsIdentity(System.Security.Claims.ClaimsIdentity other) { } public ClaimsIdentity(System.Security.Principal.IIdentity? identity) { } @@ -80,6 +84,8 @@ public partial class ClaimsPrincipal : System.Security.Principal.IPrincipal public ClaimsPrincipal() { } public ClaimsPrincipal(System.Collections.Generic.IEnumerable identities) { } public ClaimsPrincipal(System.IO.BinaryReader reader) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ClaimsPrincipal(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ClaimsPrincipal(System.Security.Principal.IIdentity identity) { } public ClaimsPrincipal(System.Security.Principal.IPrincipal principal) { } diff --git a/src/libraries/System.Security.Claims/src/System.Security.Claims.csproj b/src/libraries/System.Security.Claims/src/System.Security.Claims.csproj index 33c7635be6086b..f7f1be10a3687d 100644 --- a/src/libraries/System.Security.Claims/src/System.Security.Claims.csproj +++ b/src/libraries/System.Security.Claims/src/System.Security.Claims.csproj @@ -10,6 +10,7 @@ + diff --git a/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs b/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs index 282c8fe08250ca..9733ca86ff10b9 100644 --- a/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs +++ b/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Runtime.Serialization; using System.Security.Principal; @@ -229,6 +230,8 @@ protected ClaimsIdentity(ClaimsIdentity other) SafeAddClaims(other._instanceClaims); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ClaimsIdentity(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); @@ -242,6 +245,8 @@ protected ClaimsIdentity(SerializationInfo info, StreamingContext context) /// The to read from. /// /// Thrown is the is null. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ClaimsIdentity(SerializationInfo info) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs b/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs index f13d91a6b2e27a..a423bfa4ce4712 100644 --- a/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs +++ b/src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsPrincipal.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Runtime.Serialization; using System.Security.Principal; @@ -44,6 +45,8 @@ private enum SerializationMask }; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected ClaimsPrincipal(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System.Security.Cryptography.Xml.csproj b/src/libraries/System.Security.Cryptography.Xml/src/System.Security.Cryptography.Xml.csproj index bb9788b511908b..4e3b5e4f5201dc 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System.Security.Cryptography.Xml.csproj +++ b/src/libraries/System.Security.Cryptography.Xml/src/System.Security.Cryptography.Xml.csproj @@ -133,6 +133,8 @@ System.Security.Cryptography.Xml.XmlLicenseTransform + diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs index 907a494e7cd2f7..773341fe2f5c75 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Xml; @@ -19,6 +20,10 @@ public class CryptoSignedXmlRecursionException : XmlException public CryptoSignedXmlRecursionException() : base() { } public CryptoSignedXmlRecursionException(string message) : base(message) { } public CryptoSignedXmlRecursionException(string message, Exception inner) : base(message, inner) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected CryptoSignedXmlRecursionException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } diff --git a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs index 8b9691bf9e6dd4..5ca913712c4f85 100644 --- a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs +++ b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs @@ -542,6 +542,8 @@ public static void ZeroMemory(System.Span buffer) { } public partial class CryptographicUnexpectedOperationException : System.Security.Cryptography.CryptographicException { public CryptographicUnexpectedOperationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected CryptographicUnexpectedOperationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public CryptographicUnexpectedOperationException(string? message) { } public CryptographicUnexpectedOperationException(string? message, System.Exception? inner) { } @@ -2749,6 +2751,8 @@ public X509Certificate(byte[] rawData, string? password) { } public X509Certificate(byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public X509Certificate(System.IntPtr handle) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public X509Certificate(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public X509Certificate(System.Security.Cryptography.X509Certificates.X509Certificate cert) { } @@ -2846,6 +2850,8 @@ public X509Certificate2(System.IntPtr handle) { } public X509Certificate2(System.ReadOnlySpan rawData) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public X509Certificate2(System.ReadOnlySpan rawData, System.ReadOnlySpan password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected X509Certificate2(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public X509Certificate2(System.Security.Cryptography.X509Certificates.X509Certificate certificate) { } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs index 8c442b922e03a3..508b39fbcf6034 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicUnexpectedOperationException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Globalization; using System.Runtime.Serialization; @@ -30,6 +31,8 @@ public CryptographicUnexpectedOperationException(string format, string? insert) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected CryptographicUnexpectedOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs index 59a82d473dc575..30640e705e6b6e 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs @@ -3,6 +3,7 @@ using Internal.Cryptography; using Microsoft.Win32.SafeHandles; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -208,6 +209,8 @@ public X509Certificate(X509Certificate cert) } #pragma warning disable SYSLIB0026 + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public X509Certificate(SerializationInfo info, StreamingContext context) : this() #pragma warning restore SYSLIB0026 { diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs index b2855084370f44..650bea6130be9d 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics; using System.Formats.Asn1; using System.IO; @@ -168,6 +169,8 @@ public X509Certificate2(X509Certificate certificate) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected X509Certificate2(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs index 9f6048c4b3e091..512d130416ea6a 100644 --- a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs +++ b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs @@ -676,6 +676,10 @@ public static void RevertPermitOnly() { } public partial class HostProtectionException : System.SystemException { public HostProtectionException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected HostProtectionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public HostProtectionException(string message) { } public HostProtectionException(string message, System.Exception e) { } @@ -2057,6 +2061,10 @@ public Hash(System.Reflection.Assembly assembly) { } public static System.Security.Policy.Hash CreateSHA1(byte[] sha1) { throw null; } public static System.Security.Policy.Hash CreateSHA256(byte[] sha256) { throw null; } public byte[] GenerateHash(System.Security.Cryptography.HashAlgorithm hashAlg) { throw null; } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } } @@ -2123,6 +2131,10 @@ public PermissionRequestEvidence(System.Security.PermissionSet request, System.S public partial class PolicyException : System.SystemException { public PolicyException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected PolicyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public PolicyException(string message) { } public PolicyException(string message, System.Exception exception) { } diff --git a/src/libraries/System.Security.Permissions/src/System/ApplicationIdentity.cs b/src/libraries/System.Security.Permissions/src/System/ApplicationIdentity.cs index ab86933db6c310..56d7de00ed6eff 100644 --- a/src/libraries/System.Security.Permissions/src/System/ApplicationIdentity.cs +++ b/src/libraries/System.Security.Permissions/src/System/ApplicationIdentity.cs @@ -10,11 +10,6 @@ public sealed class ApplicationIdentity : ISerializable { private ApplicationIdentity() { } public ApplicationIdentity(string applicationIdentityFullName) { } - 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; } diff --git a/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs b/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs index fe7cd369cf470d..b93a00a2a8e59b 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Security.Permissions; using System.Text; @@ -47,6 +48,10 @@ public HostProtectionException(string message, HostProtectionResource protectedR DemandedResources = demandedResources; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected HostProtectionException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -80,6 +85,10 @@ public override string ToString() return sb.ToString(); } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs b/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs index d6df6bd611c49e..2db87c89e08dbd 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Security.Cryptography; using System.Runtime.Serialization; @@ -16,6 +17,10 @@ public Hash(System.Reflection.Assembly assembly) { } 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; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs b/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs index 4aa294e642d004..0c80cbc66509b9 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Security.Policy @@ -10,6 +11,10 @@ namespace System.Security.Policy public partial class PolicyException : System.SystemException { public PolicyException() { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected PolicyException(SerializationInfo info, StreamingContext context) : base(info, context) { } public PolicyException(string message) : base(message) { } public PolicyException(string message, Exception exception) : base(message, exception) { } diff --git a/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs b/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs index fc92711a1ab58f..b942716638c78f 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs @@ -14,6 +14,9 @@ public XmlSyntaxException(int lineNumber) { } public XmlSyntaxException(int lineNumber, string message) { } public XmlSyntaxException(string message) { } public XmlSyntaxException(string message, Exception inner) { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private XmlSyntaxException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } diff --git a/src/libraries/System.Security.Principal.Windows/ref/System.Security.Principal.Windows.cs b/src/libraries/System.Security.Principal.Windows/ref/System.Security.Principal.Windows.cs index 36dfeefbb7e156..a2b06618c09730 100644 --- a/src/libraries/System.Security.Principal.Windows/ref/System.Security.Principal.Windows.cs +++ b/src/libraries/System.Security.Principal.Windows/ref/System.Security.Principal.Windows.cs @@ -23,6 +23,8 @@ public IdentityNotMappedException() { } public IdentityNotMappedException(string? message) { } public IdentityNotMappedException(string? message, System.Exception? inner) { } public System.Security.Principal.IdentityReferenceCollection UnmappedIdentities { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } } public abstract partial class IdentityReference @@ -236,6 +238,8 @@ public WindowsIdentity(System.IntPtr userToken) { } public WindowsIdentity(System.IntPtr userToken, string type) { } public WindowsIdentity(System.IntPtr userToken, string type, System.Security.Principal.WindowsAccountType acctType) { } public WindowsIdentity(System.IntPtr userToken, string type, System.Security.Principal.WindowsAccountType acctType, bool isAuthenticated) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public WindowsIdentity(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected WindowsIdentity(System.Security.Principal.WindowsIdentity identity) { } public WindowsIdentity(string sUserPrincipalName) { } diff --git a/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj b/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj index a67d4af63ebe44..9bc4bee276e996 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj +++ b/src/libraries/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj @@ -24,6 +24,8 @@ + + Link="Common\Interop\Windows\WinMm\Interop.waveOutRestart.cs" /> + diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.cs b/src/libraries/System.Text.Json/ref/System.Text.Json.cs index 3002b59dcff3b0..0e02787a776f2b 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.cs +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.cs @@ -142,6 +142,10 @@ public void Reset() { } public partial class JsonException : System.Exception { public JsonException() { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected JsonException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public JsonException(string? message) { } public JsonException(string? message, System.Exception? innerException) { } @@ -151,6 +155,10 @@ public JsonException(string? message, string? path, long? lineNumber, long? byte public long? LineNumber { get { throw null; } } public override string Message { get { throw null; } } public string? Path { get { throw null; } } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class JsonNamingPolicy diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs b/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs index 75b23332f4a86a..d3301362fcc1a8 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Text.Json @@ -84,6 +85,10 @@ public JsonException() : base() { } /// /// Thrown when is . /// +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected JsonException(SerializationInfo info, StreamingContext context) : base(info, context) { LineNumber = (long?)info.GetValue("LineNumber", typeof(long?)); @@ -102,6 +107,10 @@ protected JsonException(SerializationInfo info, StreamingContext context) : base /// /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs index 3c42977d383c1c..a50c91c9452913 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs @@ -13,6 +13,9 @@ public JsonReaderException(string message, long lineNumber, long bytePositionInL { } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] +#endif private JsonReaderException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Text.RegularExpressions/gen/System.Text.RegularExpressions.Generator.csproj b/src/libraries/System.Text.RegularExpressions/gen/System.Text.RegularExpressions.Generator.csproj index 20c35068fbc757..8899c55f958798 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/System.Text.RegularExpressions.Generator.csproj +++ b/src/libraries/System.Text.RegularExpressions/gen/System.Text.RegularExpressions.Generator.csproj @@ -27,6 +27,7 @@ + diff --git a/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs b/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs index 29cd116d641b26..4cda09dc0a02c6 100644 --- a/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs +++ b/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs @@ -142,6 +142,8 @@ public partial class Regex : System.Runtime.Serialization.ISerializable protected internal string? pattern; protected internal System.Text.RegularExpressions.RegexOptions roptions; protected Regex() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected Regex(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { } @@ -264,6 +266,8 @@ public GeneratedRegexAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(Sys public partial class RegexMatchTimeoutException : System.TimeoutException, System.Runtime.Serialization.ISerializable { public RegexMatchTimeoutException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected RegexMatchTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RegexMatchTimeoutException(string message) { } public RegexMatchTimeoutException(string message, System.Exception inner) { } @@ -328,6 +332,8 @@ public sealed partial class RegexParseException : System.ArgumentException private RegexParseException() { } public System.Text.RegularExpressions.RegexParseError Error { get { throw null; } } public int Offset { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class RegexRunner diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs index 6516af531e2a6f..d41516f57bde6c 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; +using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -169,6 +170,8 @@ protected internal static void ValidateMatchTimeout(TimeSpan matchTimeout) } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected Regex(SerializationInfo info, StreamingContext context) => throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs index 1dcd7efab3605c..aac7f3420da9ab 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Text.RegularExpressions @@ -50,6 +51,8 @@ public RegexMatchTimeoutException(string message) : base(message) { } /// The exception that is the cause of the current exception, or a null. public RegexMatchTimeoutException(string message, Exception inner) : base(message, inner) { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected RegexMatchTimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -58,6 +61,7 @@ protected RegexMatchTimeoutException(SerializationInfo info, StreamingContext co MatchTimeout = new TimeSpan(info.GetInt64("timeoutTicks")); } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs index 38808caac811fe..fad385a183aaca 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Text.RegularExpressions @@ -23,18 +24,18 @@ sealed class RegexParseException : ArgumentException /// Gets the zero-based character offset in the regular expression pattern where the parse error occurs. public int Offset { get; } + // No need for a serialization ctor: we swap the active type during serialization. + internal RegexParseException(RegexParseError error, int offset, string message) : base(message) { Error = error; Offset = offset; } - private RegexParseException(SerializationInfo info, StreamingContext context) - { - // It means someone modified the payload. - throw new NotImplementedException(); - } - +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/libraries/System.Text.RegularExpressions/tests/UnitTests/System.Text.RegularExpressions.Unit.Tests.csproj b/src/libraries/System.Text.RegularExpressions/tests/UnitTests/System.Text.RegularExpressions.Unit.Tests.csproj index 25c3668059d99b..a3d8e3a172dc7a 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/UnitTests/System.Text.RegularExpressions.Unit.Tests.csproj +++ b/src/libraries/System.Text.RegularExpressions/tests/UnitTests/System.Text.RegularExpressions.Unit.Tests.csproj @@ -22,6 +22,7 @@ + diff --git a/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netcoreapp.cs b/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netcoreapp.cs index c090e57d0ded47..617aff6b1bfec0 100644 --- a/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netcoreapp.cs +++ b/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netcoreapp.cs @@ -8,6 +8,10 @@ namespace System.Threading.Channels { public partial class ChannelClosedException : System.InvalidOperationException { +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected ChannelClosedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class ChannelReader diff --git a/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj b/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj index 4fa5540d270690..64804032bc9e45 100644 --- a/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj +++ b/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj @@ -45,6 +45,8 @@ System.Threading.Channel<T> Link="Common\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs" /> + diff --git a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs index 8c439e2f420fb4..f3e3c31338c698 100644 --- a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs +++ b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; namespace System.Threading.Channels @@ -12,6 +13,10 @@ public partial class ChannelClosedException : InvalidOperationException /// Initializes a new instance of the class with serialized data. /// The object that holds the serialized object data. /// The contextual information about the source or destination. +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected ChannelClosedException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs index d764627ce63651..6e90254a45f550 100644 --- a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs +++ b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs @@ -26,6 +26,8 @@ internal CompressedStack() { } public static System.Threading.CompressedStack Capture() { throw null; } public System.Threading.CompressedStack CreateCopy() { throw null; } public static System.Threading.CompressedStack GetCompressedStack() { throw null; } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static void Run(System.Threading.CompressedStack compressedStack, System.Threading.ContextCallback callback, object? state) { } } @@ -161,6 +163,8 @@ public ThreadExceptionEventArgs(System.Exception t) { } public partial class ThreadInterruptedException : System.SystemException { public ThreadInterruptedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ThreadInterruptedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ThreadInterruptedException(string? message) { } public ThreadInterruptedException(string? message, System.Exception? innerException) { } @@ -195,6 +199,8 @@ public enum ThreadState public partial class ThreadStateException : System.SystemException { public ThreadStateException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected ThreadStateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public ThreadStateException(string? message) { } public ThreadStateException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.Threading/ref/System.Threading.cs b/src/libraries/System.Threading/ref/System.Threading.cs index 2963a3ad970c4b..d837e35ad99890 100644 --- a/src/libraries/System.Threading/ref/System.Threading.cs +++ b/src/libraries/System.Threading/ref/System.Threading.cs @@ -39,6 +39,8 @@ public partial class BarrierPostPhaseException : System.Exception { public BarrierPostPhaseException() { } public BarrierPostPhaseException(System.Exception? innerException) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected BarrierPostPhaseException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public BarrierPostPhaseException(string? message) { } public BarrierPostPhaseException(string? message, System.Exception? innerException) { } @@ -130,6 +132,8 @@ public partial class AbandonedMutexException : System.SystemException { public AbandonedMutexException() { } public AbandonedMutexException(int location, System.Threading.WaitHandle? handle) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected AbandonedMutexException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public AbandonedMutexException(string? message) { } public AbandonedMutexException(string? message, System.Exception? inner) { } @@ -194,6 +198,8 @@ internal ExecutionContext() { } public static System.Threading.ExecutionContext? Capture() { throw null; } public System.Threading.ExecutionContext CreateCopy() { throw null; } public void Dispose() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public static bool IsFlowSuppressed() { throw null; } public static void Restore(System.Threading.ExecutionContext executionContext) { } @@ -280,6 +286,8 @@ public static partial class LazyInitializer public partial class LockRecursionException : System.Exception { public LockRecursionException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected LockRecursionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public LockRecursionException(string? message) { } public LockRecursionException(string? message, System.Exception? innerException) { } @@ -398,6 +406,8 @@ public Semaphore(int initialCount, int maximumCount, string? name) { } public partial class SemaphoreFullException : System.SystemException { public SemaphoreFullException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SemaphoreFullException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SemaphoreFullException(string? message) { } public SemaphoreFullException(string? message, System.Exception? innerException) { } @@ -478,6 +488,8 @@ protected void SetWaitNotificationRequired() { } public partial class SynchronizationLockException : System.SystemException { public SynchronizationLockException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected SynchronizationLockException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public SynchronizationLockException(string? message) { } public SynchronizationLockException(string? message, System.Exception? innerException) { } @@ -542,6 +554,8 @@ public static void Write([System.Diagnostics.CodeAnalysis.NotNullIfNotNullAtt public partial class WaitHandleCannotBeOpenedException : System.ApplicationException { public WaitHandleCannotBeOpenedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected WaitHandleCannotBeOpenedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public WaitHandleCannotBeOpenedException(string? message) { } public WaitHandleCannotBeOpenedException(string? message, System.Exception? innerException) { } diff --git a/src/libraries/System.Threading/src/System.Threading.csproj b/src/libraries/System.Threading/src/System.Threading.csproj index 929c5cbcca9dcb..1996fdb878272e 100644 --- a/src/libraries/System.Threading/src/System.Threading.csproj +++ b/src/libraries/System.Threading/src/System.Threading.csproj @@ -15,6 +15,8 @@ + diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs index 496d3c5e6fdafe..e5633da1ee19aa 100644 --- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs +++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs @@ -10,6 +10,7 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; using System.Runtime.Versioning; @@ -65,6 +66,8 @@ public BarrierPostPhaseException(string? message, Exception? innerException) /// /// The object that holds the serialized object data. /// The contextual information about the source or destination. + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected BarrierPostPhaseException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs b/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs index 49a092ceed5332..3248f45eb505e7 100644 --- a/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs +++ b/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs @@ -1134,6 +1134,7 @@ public ReaderWriterLockApplicationException(int errorHResult, string message) HResult = errorHResult; } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public ReaderWriterLockApplicationException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs b/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs index 99e82f525ee689..f3efc656f3c148 100644 --- a/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs +++ b/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs @@ -144,6 +144,8 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public partial class TransactionAbortedException : System.Transactions.TransactionException { public TransactionAbortedException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TransactionAbortedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TransactionAbortedException(string? message) { } public TransactionAbortedException(string? message, System.Exception? innerException) { } @@ -157,6 +159,8 @@ public TransactionEventArgs() { } public partial class TransactionException : System.SystemException { public TransactionException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TransactionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TransactionException(string? message) { } public TransactionException(string? message, System.Exception? innerException) { } @@ -164,6 +168,8 @@ public TransactionException(string? message, System.Exception? innerException) { public partial class TransactionInDoubtException : System.Transactions.TransactionException { public TransactionInDoubtException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TransactionInDoubtException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TransactionInDoubtException(string? message) { } public TransactionInDoubtException(string? message, System.Exception? innerException) { } @@ -201,6 +207,8 @@ public static void RecoveryComplete(System.Guid resourceManagerIdentifier) { } public partial class TransactionManagerCommunicationException : System.Transactions.TransactionException { public TransactionManagerCommunicationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected TransactionManagerCommunicationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public TransactionManagerCommunicationException(string? message) { } public TransactionManagerCommunicationException(string? message, System.Exception? innerException) { } @@ -219,6 +227,8 @@ public partial struct TransactionOptions : System.IEquatable + diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/NonWindowsUnsupported.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/NonWindowsUnsupported.cs index 4a540c6d0cb6d2..272fa78221d31b 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/NonWindowsUnsupported.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/NonWindowsUnsupported.cs @@ -58,7 +58,7 @@ internal static Exception NotSupported() /// clones have the same capabilities as the original transaction, except for the ability to commit /// the transaction. /// - internal class OletxTransaction : ISerializable, IObjectReference + internal class OletxTransaction : ISerializable { internal OletxTransaction() { @@ -108,9 +108,6 @@ internal IPromotedEnlistment EnlistVolatile( internal static byte[] GetExportCookie(byte[] whereaboutsCopy) => throw NotSupported(); - public object GetRealObject(StreamingContext context) - => throw NotSupported(); - internal static byte[] GetTransmitterPropagationToken() => throw NotSupported(); diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransaction.cs index c85ebe16bea71a..b778978da8df4d 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransaction.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransaction.cs @@ -22,7 +22,12 @@ namespace System.Transactions.Oletx /// the transaction. /// [Serializable] - internal class OletxTransaction : ISerializable, IObjectReference + internal class OletxTransaction : ISerializable +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete +#pragma warning disable SA1001 // CommasMustBeSpacedCorrectly + , IObjectReference +#pragma warning restore SA1001 +#pragma warning restore SYSLIB0050 { // We have a strong reference on realOletxTransaction which does the real work internal RealOletxTransaction RealOletxTransaction; @@ -135,6 +140,7 @@ protected OletxTransaction(SerializationInfo? serializationInfo, StreamingContex RealOletxTransaction = null!; } +#pragma warning disable SYSLIB0050 // IObjectReference is obsolete public object GetRealObject(StreamingContext context) { TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; @@ -181,6 +187,7 @@ public object GetRealObject(StreamingContext context) return returnValue; } +#pragma warning restore SYSLIB0050 /// /// Implementation of IDisposable.Dispose. Releases managed, and unmanaged resources diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs index 1e5b49146b1963..cb850655b69b04 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Runtime.Serialization; using System.Transactions.Configuration; @@ -88,6 +89,8 @@ public TransactionException(string? message, Exception? innerException) : base(m /// /// /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TransactionException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -211,6 +214,8 @@ internal TransactionAbortedException(Exception? innerException, Guid distributed /// /// /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TransactionAbortedException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -272,6 +277,8 @@ public TransactionInDoubtException(string? message, Exception? innerException) : /// /// /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TransactionInDoubtException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -332,6 +339,8 @@ public TransactionManagerCommunicationException( /// /// /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TransactionManagerCommunicationException(SerializationInfo info, StreamingContext context) : base(info, context) { } @@ -370,6 +379,8 @@ public TransactionPromotionException(string? message, Exception? innerException) /// /// /// + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] protected TransactionPromotionException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs b/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs index c1f732f2baad40..b3c5b73533c532 100644 --- a/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs +++ b/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs @@ -11,6 +11,10 @@ public partial class SoundPlayer : System.ComponentModel.Component, System.Runti { public SoundPlayer() { } public SoundPlayer(System.IO.Stream? stream) { } +#if NET8_0_OR_GREATER + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] +#endif protected SoundPlayer(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context) { } public SoundPlayer(string soundLocation) { } public bool IsLoadCompleted { get { throw null; } } diff --git a/src/libraries/System.Windows.Extensions/src/System.Windows.Extensions.csproj b/src/libraries/System.Windows.Extensions/src/System.Windows.Extensions.csproj index c2c574b9edda6d..d976d96e14caac 100644 --- a/src/libraries/System.Windows.Extensions/src/System.Windows.Extensions.csproj +++ b/src/libraries/System.Windows.Extensions/src/System.Windows.Extensions.csproj @@ -83,6 +83,8 @@ System.Security.Cryptography.X509Certificates.X509SelectionFlag + diff --git a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs index 3d5b536895c1e1..6e39549fd0d604 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs @@ -61,6 +61,10 @@ public SoundPlayer(Stream? stream) : this() _stream = stream; } +#if NET8_0_OR_GREATER + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] +#endif protected SoundPlayer(SerializationInfo serializationInfo, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs b/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs index 126e319d3d446d..ebf8dab5103b92 100644 --- a/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs +++ b/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs @@ -471,6 +471,8 @@ public override void WriteTo(System.Xml.XmlWriter w) { } public partial class XmlException : System.SystemException { public XmlException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XmlException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XmlException(string? message) { } public XmlException(string? message, System.Exception? innerException) { } @@ -479,6 +481,8 @@ public XmlException(string? message, System.Exception? innerException, int lineN public int LinePosition { get { throw null; } } public override string Message { get { throw null; } } public string? SourceUri { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class XmlImplementation @@ -1869,6 +1873,8 @@ public XmlSchemaEnumerationFacet() { } public partial class XmlSchemaException : System.SystemException { public XmlSchemaException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XmlSchemaException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XmlSchemaException(string? message) { } public XmlSchemaException(string? message, System.Exception? innerException) { } @@ -1878,6 +1884,8 @@ public XmlSchemaException(string? message, System.Exception? innerException, int public override string Message { get { throw null; } } public System.Xml.Schema.XmlSchemaObject? SourceSchemaObject { get { throw null; } } public string? SourceUri { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class XmlSchemaExternal : System.Xml.Schema.XmlSchemaObject @@ -1982,10 +1990,14 @@ public enum InferenceOption public partial class XmlSchemaInferenceException : System.Xml.Schema.XmlSchemaException { public XmlSchemaInferenceException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XmlSchemaInferenceException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XmlSchemaInferenceException(string message) { } public XmlSchemaInferenceException(string message, System.Exception? innerException) { } public XmlSchemaInferenceException(string message, System.Exception? innerException, int lineNumber, int linePosition) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public partial class XmlSchemaInfo : System.Xml.Schema.IXmlSchemaInfo @@ -2322,11 +2334,15 @@ public enum XmlSchemaUse public partial class XmlSchemaValidationException : System.Xml.Schema.XmlSchemaException { public XmlSchemaValidationException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XmlSchemaValidationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XmlSchemaValidationException(string? message) { } public XmlSchemaValidationException(string? message, System.Exception? innerException) { } public XmlSchemaValidationException(string? message, System.Exception? innerException, int lineNumber, int linePosition) { } public object? SourceObject { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } protected internal void SetSourceObject(object? sourceObject) { } } @@ -2841,9 +2857,13 @@ public partial class XsltCompileException : System.Xml.Xsl.XsltException { public XsltCompileException() { } public XsltCompileException(System.Exception inner, string sourceUri, int lineNumber, int linePosition) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XsltCompileException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XsltCompileException(string message) { } public XsltCompileException(string message, System.Exception innerException) { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class XsltContext : System.Xml.XmlNamespaceManager @@ -2859,6 +2879,8 @@ protected XsltContext(System.Xml.NameTable table) : base (default(System.Xml.Xml public partial class XsltException : System.SystemException { public XsltException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XsltException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XsltException(string message) { } public XsltException(string message, System.Exception? innerException) { } @@ -2866,6 +2888,8 @@ public XsltException(string message, System.Exception? innerException) { } public virtual int LinePosition { get { throw null; } } public override string Message { get { throw null; } } public virtual string? SourceUri { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class XsltMessageEncounteredEventArgs : System.EventArgs diff --git a/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs b/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs index e36e9430e28e15..d858ccd867811c 100644 --- a/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs +++ b/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs @@ -19,10 +19,14 @@ public XPathDocument(System.Xml.XmlReader reader, System.Xml.XmlSpace space) { } public partial class XPathException : System.SystemException { public XPathException() { } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected XPathException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public XPathException(string? message) { } public XPathException(string? message, System.Exception? innerException) { } public override string Message { get { throw null; } } + [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } diff --git a/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.cs index a801b8772ca440..d9f04d3059e51a 100644 --- a/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.Serialization; @@ -24,6 +25,8 @@ protected MulticastDelegate([DynamicallyAccessedMembers(DynamicallyAccessedMembe { } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { throw new SerializationException(SR.Serialization_DelegatesNotSupported); diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs index 9067621f5f69fd..add2c153f66f1f 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs @@ -88,9 +88,11 @@ private static bool IsUserCattrProvider(object obj) int count = 0; TypeAttributes Attributes = type.Attributes; +#pragma warning disable SYSLIB0050 // TypeAttributes.Serializable is obsolete /* IsSerializable returns true for delegates/enums as well */ if ((Attributes & TypeAttributes.Serializable) != 0) count++; +#pragma warning restore SYSLIB0050 if ((Attributes & TypeAttributes.Import) != 0) count++; @@ -99,8 +101,10 @@ private static bool IsUserCattrProvider(object obj) object[] attrs = new object[count]; count = 0; +#pragma warning disable SYSLIB0050 // TypeAttributes.Serializable is obsolete if ((Attributes & TypeAttributes.Serializable) != 0) attrs[count++] = new SerializableAttribute(); +#pragma warning restore SYSLIB0050 if ((Attributes & TypeAttributes.Import) != 0) attrs[count++] = new ComImportAttribute(); @@ -528,9 +532,11 @@ internal static IList GetCustomAttributesDataBase(ICustomAt int count = 0; TypeAttributes Attributes = type.Attributes; +#pragma warning disable SYSLIB0050 // TypeAttributes.Serializable is obsolete /* IsSerializable returns true for delegates/enums as well */ if ((Attributes & TypeAttributes.Serializable) != 0) count++; +#pragma warning restore SYSLIB0050 if ((Attributes & TypeAttributes.Import) != 0) count++; @@ -539,8 +545,10 @@ internal static IList GetCustomAttributesDataBase(ICustomAt CustomAttributeData[] attrsData = new CustomAttributeData[count]; count = 0; +#pragma warning disable SYSLIB0050 // TypeAttributes.Serializable is obsolete if ((Attributes & TypeAttributes.Serializable) != 0) attrsData[count++] = new RuntimeCustomAttributeData((typeof(SerializableAttribute)).GetConstructor(Type.EmptyTypes)!); +#pragma warning restore SYSLIB0050 if ((Attributes & TypeAttributes.Import) != 0) attrsData[count++] = new RuntimeCustomAttributeData((typeof(ComImportAttribute)).GetConstructor(Type.EmptyTypes)!); diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeFieldBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeFieldBuilder.Mono.cs index fcd8d18f8e96b5..db8d805de1646b 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeFieldBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeFieldBuilder.Mono.cs @@ -188,11 +188,13 @@ protected override void SetCustomAttributeCore(CustomAttributeBuilder customBuil offset |= ((int)data[5]) << 24; return; } +#pragma warning disable SYSLIB0050 // FieldAttributes.NotSerialized is obsolete else if (attrname == "System.NonSerializedAttribute") { attrs |= FieldAttributes.NotSerialized; return; } +#pragma warning restore SYSLIB0050 else if (attrname == "System.Runtime.CompilerServices.SpecialNameAttribute") { attrs |= FieldAttributes.SpecialName; diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.Mono.cs index 18bc362c0e6e7e..98670c99f16313 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.Mono.cs @@ -1499,11 +1499,13 @@ protected override void SetCustomAttributeCore(CustomAttributeBuilder customBuil attrs |= TypeAttributes.SpecialName; return; } +#pragma warning disable SYSLIB0050 // TypeAttributes.Serializable is obsolete else if (attrname == "System.SerializableAttribute") { attrs |= TypeAttributes.Serializable; return; } +#pragma warning restore SYSLIB0050 else if (attrname == "System.Runtime.InteropServices.ComImportAttribute") { attrs |= TypeAttributes.Import; diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/FieldInfo.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/FieldInfo.Mono.cs index 7da1a2e9465702..94e81cc4c1f69f 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/FieldInfo.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/FieldInfo.Mono.cs @@ -40,8 +40,10 @@ internal virtual int GetFieldOffset() { int count = 0; +#pragma warning disable SYSLIB0050 // FieldInfo.IsNotSerialized is obsolete if (IsNotSerialized) count++; +#pragma warning restore SYSLIB0050 if (DeclaringType!.IsExplicitLayout) count++; @@ -55,8 +57,10 @@ internal virtual int GetFieldOffset() object[] attrs = new object[count]; count = 0; +#pragma warning disable SYSLIB0050 // FieldInfo.IsNotSerialized is obsolete if (IsNotSerialized) attrs[count++] = new NonSerializedAttribute(); +#pragma warning restore SYSLIB0050 if (DeclaringType.IsExplicitLayout) attrs[count++] = new FieldOffsetAttribute(GetFieldOffset()); if (marshalAs != null) @@ -69,8 +73,10 @@ internal virtual int GetFieldOffset() { int count = 0; +#pragma warning disable SYSLIB0050 // FieldInfo.IsNotSerialized is obsolete if (IsNotSerialized) count++; +#pragma warning restore SYSLIB0050 if (DeclaringType!.IsExplicitLayout) count++; @@ -84,8 +90,10 @@ internal virtual int GetFieldOffset() CustomAttributeData[] attrsData = new CustomAttributeData[count]; count = 0; +#pragma warning disable SYSLIB0050 // FieldInfo.IsNotSerialized is obsolete if (IsNotSerialized) attrsData[count++] = new RuntimeCustomAttributeData((typeof(NonSerializedAttribute)).GetConstructor(Type.EmptyTypes)!); +#pragma warning restore SYSLIB0050 if (DeclaringType.IsExplicitLayout) { var ctorArgs = new CustomAttributeTypedArgument[] { new CustomAttributeTypedArgument(typeof(int), GetFieldOffset()) }; diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs index 9b2c1d7bd2e7ab..b28bcb0cf7d916 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs @@ -1,13 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System { - [Serializable] public struct RuntimeFieldHandle : IEquatable, ISerializable { private readonly IntPtr value; @@ -17,11 +17,8 @@ internal RuntimeFieldHandle(IntPtr v) value = v; } - private RuntimeFieldHandle(SerializationInfo info, StreamingContext context) - { - throw new PlatformNotSupportedException(); - } - + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs index 4280686a3c4f67..ad6341620d35f8 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; using System.Reflection; using System.Runtime.Serialization; using System.Runtime.CompilerServices; @@ -8,7 +9,6 @@ namespace System { - [Serializable] public struct RuntimeMethodHandle : IEquatable, ISerializable { private readonly IntPtr value; @@ -18,13 +18,10 @@ internal RuntimeMethodHandle(IntPtr v) value = v; } - private RuntimeMethodHandle(SerializationInfo info, StreamingContext context) - { - throw new PlatformNotSupportedException(); - } - public IntPtr Value => value; + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs index 3e69be66ea9694..6754ba616073aa 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs @@ -31,6 +31,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.Serialization; @@ -39,7 +40,6 @@ namespace System { - [Serializable] public struct RuntimeTypeHandle : IEquatable, ISerializable { private readonly IntPtr value; @@ -54,11 +54,6 @@ internal RuntimeTypeHandle(RuntimeType type) { } - private RuntimeTypeHandle(SerializationInfo info, StreamingContext context) - { - throw new PlatformNotSupportedException(); - } - public IntPtr Value { get @@ -67,6 +62,8 @@ public IntPtr Value } } + [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException();