diff --git a/src/TestFramework/TestFramework/Constants.cs b/src/TestFramework/TestFramework/Constants.cs new file mode 100644 index 0000000000..6973e5008c --- /dev/null +++ b/src/TestFramework/TestFramework/Constants.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestTools.UnitTesting; + +/// +/// Constants used throughout. +/// +internal static class Constants +{ + internal const string PublicTypeObsoleteMessage = "We will remove or hide this type starting with v4. If you are using this type, reach out to our team on https://github.com/microsoft/testfx."; +} diff --git a/src/TestFramework/TestFramework/Exceptions/InternalTestFailureException.cs b/src/TestFramework/TestFramework/Exceptions/InternalTestFailureException.cs index 718eb05d9f..4a668b3a09 100644 --- a/src/TestFramework/TestFramework/Exceptions/InternalTestFailureException.cs +++ b/src/TestFramework/TestFramework/Exceptions/InternalTestFailureException.cs @@ -10,6 +10,13 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting; /// This class is only added to preserve source compatibility with the V1 framework. /// For all practical purposes either use AssertFailedException/AssertInconclusiveException. /// +#if RELEASE +#if NET6_0_OR_GREATER +[Obsolete(Constants.PublicTypeObsoleteMessage, DiagnosticId = "MSTESTOBS")] +#else +[Obsolete(Constants.PublicTypeObsoleteMessage)] +#endif +#endif [Serializable] public class InternalTestFailureException : UnitTestAssertException { diff --git a/src/TestFramework/TestFramework/GenericParameterHelper.cs b/src/TestFramework/TestFramework/GenericParameterHelper.cs index a689fed725..22e8c71095 100644 --- a/src/TestFramework/TestFramework/GenericParameterHelper.cs +++ b/src/TestFramework/TestFramework/GenericParameterHelper.cs @@ -15,7 +15,13 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting; // This next suppression could mask a problem, since Equals and CompareTo may not agree! [SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes", Justification = "Compat reasons.")] [SuppressMessage("Design", "CA1010:Generic interface should also be implemented", Justification = "Part of the public API")] - +#if RELEASE +#if NET6_0_OR_GREATER +[Obsolete(Constants.PublicTypeObsoleteMessage, DiagnosticId = "MSTESTOBS")] +#else +[Obsolete(Constants.PublicTypeObsoleteMessage)] +#endif +#endif // GenericParameterHelper in full CLR version also implements ICloneable, but we don't have ICloneable in core CLR public class GenericParameterHelper : IComparable, IEnumerable {