From 68f013f3ecc2af921faf43b568c83bf935c086db Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 21 Dec 2024 09:45:10 +1100 Subject: [PATCH] use polyfill in TestFramework.ForTestingMSTest --- .../CallerArgumentExpressionAttribute.cs | 27 ------------- .../CodeAnalysisAttributes.cs | 26 ------------- .../DoesNotReturnIfAttribute.cs | 39 ------------------- .../TestFramework.ForTestingMSTest.csproj | 1 + 4 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 test/Utilities/TestFramework.ForTestingMSTest/CallerArgumentExpressionAttribute.cs delete mode 100644 test/Utilities/TestFramework.ForTestingMSTest/CodeAnalysisAttributes.cs delete mode 100644 test/Utilities/TestFramework.ForTestingMSTest/DoesNotReturnIfAttribute.cs diff --git a/test/Utilities/TestFramework.ForTestingMSTest/CallerArgumentExpressionAttribute.cs b/test/Utilities/TestFramework.ForTestingMSTest/CallerArgumentExpressionAttribute.cs deleted file mode 100644 index 2ca70c0553..0000000000 --- a/test/Utilities/TestFramework.ForTestingMSTest/CallerArgumentExpressionAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#if !NET5_0 && !NET6_0 -namespace System.Runtime.CompilerServices; - -/// -/// Allows capturing of the expressions passed to a method. -/// -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class CallerArgumentExpressionAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The name of the targeted parameter. - public CallerArgumentExpressionAttribute(string parameterName) => ParameterName = parameterName; - - /// - /// Gets the target parameter name of the CallerArgumentExpression. - /// - /// - /// The name of the targeted parameter of the CallerArgumentExpression. - /// - public string ParameterName { get; } -} -#endif diff --git a/test/Utilities/TestFramework.ForTestingMSTest/CodeAnalysisAttributes.cs b/test/Utilities/TestFramework.ForTestingMSTest/CodeAnalysisAttributes.cs deleted file mode 100644 index 42657395bd..0000000000 --- a/test/Utilities/TestFramework.ForTestingMSTest/CodeAnalysisAttributes.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#if !NETCOREAPP3_0_OR_GREATER -namespace System.Diagnostics.CodeAnalysis; - -/// Applied to a method that will never return under any circumstance. -[AttributeUsage(AttributeTargets.Method, Inherited = false)] -internal sealed class DoesNotReturnAttribute : Attribute; - -/// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class NotNullWhenAttribute : Attribute -{ - /// - /// Initializes a new instance of the class.Initializes the attribute with the specified return value condition. - /// - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - /// - public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; - - /// Gets a value indicating whether gets to return value condition. - public bool ReturnValue { get; } -} -#endif diff --git a/test/Utilities/TestFramework.ForTestingMSTest/DoesNotReturnIfAttribute.cs b/test/Utilities/TestFramework.ForTestingMSTest/DoesNotReturnIfAttribute.cs deleted file mode 100644 index bb519abe20..0000000000 --- a/test/Utilities/TestFramework.ForTestingMSTest/DoesNotReturnIfAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#if NETSTANDARD2_0 || NETFRAMEWORK - -#pragma warning disable SA1623 // Remove ridiculous stylecop documentation warning -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that the method will not return if the associated -/// parameter is passed the specified value. -/// -[ExcludeFromCodeCoverage] -[DebuggerNonUserCode] -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class DoesNotReturnIfAttribute : - Attribute -{ - /// - /// Gets the condition parameter value. - /// Code after the method is considered unreachable by diagnostics if the argument - /// to the associated parameter matches this value. - /// - public bool ParameterValue { get; } - - /// - /// Initializes a new instance of the - /// class with the specified parameter value. - /// - /// - /// The condition parameter value. - /// Code after the method is considered unreachable by diagnostics if the argument - /// to the associated parameter matches this value. - /// - public DoesNotReturnIfAttribute(bool parameterValue) => - ParameterValue = parameterValue; -} - -#endif diff --git a/test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj b/test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj index 02afe9633d..cb92c85954 100644 --- a/test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj +++ b/test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj @@ -10,6 +10,7 @@ +