Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
There should be 2 attributes on the 4th param
  • Loading branch information
lambdageek committed Oct 29, 2022
commit d0788312f1cb2c699ca54efd6a410926022374bc
22 changes: 17 additions & 5 deletions src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Xunit;

namespace System.Reflection.Metadata
Expand Down Expand Up @@ -684,11 +685,22 @@ public static void TestReflectionAddNewMethod()
parmPos++;
}

foreach (var ca in parms[4].GetCustomAttributes(false)) {
Console.WriteLine (" - parm[4] has {0}", ca);
}
Assert.Equal (1, parms[4].GetCustomAttributes(false).Length);
Assert.Equal (typeof (CallerMemberNameAttribute), parms[4].GetCustomAttributes(false)[0].GetType());
var parmAttrs = parms[4].GetCustomAttributes(false);
Assert.Equal (2, parmAttrs.Length);
bool foundCallerMemberName = false;
bool foundOptional = false;
foreach (var pa in parmAttrs) {
if (typeof (CallerMemberNameAttribute).Equals(pa.GetType()))
{
foundCallerMemberName = true;
}
if (typeof (OptionalAttribute).Equals(pa.GetType()))
{
foundOptional = true;
}
}
Assert.True(foundCallerMemberName);
Assert.True(foundOptional);

// TODO: check the default values of the last two params
});
Expand Down