From d64c11eabf313cbd52c2f83f89d5a63ad91ddca2 Mon Sep 17 00:00:00 2001 From: Sychev Vadim Date: Sun, 21 Mar 2021 11:06:25 +0300 Subject: [PATCH] Add a CustomConstantAttribute test (#49748) (#49767) There is a test the custom constant attribute assigns the default value to Type.Missing parameter. --- .../System.Runtime/tests/System/DelegateTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libraries/System.Runtime/tests/System/DelegateTests.cs b/src/libraries/System.Runtime/tests/System/DelegateTests.cs index cadeabb5dc692..269b5f7b218af 100644 --- a/src/libraries/System.Runtime/tests/System/DelegateTests.cs +++ b/src/libraries/System.Runtime/tests/System/DelegateTests.cs @@ -102,6 +102,22 @@ public static void DynamicInvoke() emptyDelegate.DynamicInvoke(null); } + private class SomeCustomConstantAttribute : CustomConstantAttribute + { + public static object Do(object o) => o; + + public override object Value => "SomeValue"; + } + + private delegate object ObjectDelegateWithSomeCustomConstantAttribute([SomeCustomConstant] object o); + + [Fact] + [SkipOnMono("https://github.com/dotnet/runtime/issues/49806")] + public static void DynamicInvoke_MissingTypeForCustomConstantAttribute_Succeeds() + { + Assert.Equal("SomeValue", (string)(new ObjectDelegateWithSomeCustomConstantAttribute(SomeCustomConstantAttribute.Do).DynamicInvoke(Type.Missing))); + } + [Fact] public static void DynamicInvoke_MissingTypeForDefaultParameter_Succeeds() {