Skip to content

Commit

Permalink
Add a CustomConstantAttribute test (#49748) (#49767)
Browse files Browse the repository at this point in the history
There is a test the custom constant attribute assigns the default value to Type.Missing parameter.
  • Loading branch information
SkiFoD authored Mar 21, 2021
1 parent 3961d91 commit d64c11e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libraries/System.Runtime/tests/System/DelegateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit d64c11e

Please sign in to comment.