From 3a0837e69d6de08e7c9bbe58e65ffa33aec7c00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Sat, 6 May 2023 07:01:42 +0200 Subject: [PATCH 1/3] Deprecate serialization ctor for .NET8 onward --- .../ManagedNameUtilities/InvalidManagedNameException.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs index 78b6d36363..1475555e29 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs @@ -11,5 +11,8 @@ public class InvalidManagedNameException : Exception, ISerializable { public InvalidManagedNameException(string? message) : base(message) { } +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif protected InvalidManagedNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } } From fff1a87ee94360d4b6f79de9acb1ea0b16bdea23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 9 May 2023 11:12:37 +0200 Subject: [PATCH 2/3] Add message to ObsoleteAttribute --- .../ManagedNameUtilities/InvalidManagedNameException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs index 1475555e29..72ecae9883 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs @@ -12,7 +12,7 @@ public class InvalidManagedNameException : Exception, ISerializable public InvalidManagedNameException(string? message) : base(message) { } #if NET8_0_OR_GREATER - [Obsolete(DiagnosticId = "SYSLIB0051")] + [Obsolete(DiagnosticId = "SYSLIB0051", "Serialization constructors are deprecated in .NET8+")] #endif protected InvalidManagedNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } } From 0fbf163084622c749ba38dddfabe46b5b5a660a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 9 May 2023 15:53:22 +0200 Subject: [PATCH 3/3] Fix correctly --- .../ManagedNameUtilities/InvalidManagedNameException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs index 72ecae9883..c0bdef2cbb 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs @@ -12,7 +12,7 @@ public class InvalidManagedNameException : Exception, ISerializable public InvalidManagedNameException(string? message) : base(message) { } #if NET8_0_OR_GREATER - [Obsolete(DiagnosticId = "SYSLIB0051", "Serialization constructors are deprecated in .NET8+")] + [Obsolete("Serialization constructors are deprecated in .NET8+", DiagnosticId = "SYSLIB0051")] #endif protected InvalidManagedNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } }