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
Update the CustomAttributeUpdates test to check attribute value
Check that we get the updated custom attribute string property value.
  • Loading branch information
lambdageek committed Jul 10, 2021
commit e2dc8fbc7acbbd70fe92ab25d675ea2b104e36d1
15 changes: 14 additions & 1 deletion src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,20 @@ public void CustomAttributeUpdates()
ApplyUpdateUtil.ApplyUpdate(assm);
ApplyUpdateUtil.ClearAllReflectionCaches();

Assert.True(true); // just check that the update loaded
// Just check the updated value on one method

Type attrType = typeof(System.Reflection.Metadata.ApplyUpdate.Test.MyAttribute);
Type ty = assm.GetType("System.Reflection.Metadata.ApplyUpdate.Test.ClassWithCustomAttributeUpdates");
Assert.NotNull(ty);
MethodInfo mi = ty.GetMethod(nameof(System.Reflection.Metadata.ApplyUpdate.Test.ClassWithCustomAttributeUpdates.Method1), BindingFlags.Public | BindingFlags.Static);
Assert.NotNull(mi);
var cattrs = Attribute.GetCustomAttributes(mi, attrType);
Assert.NotNull(cattrs);
Assert.Equal(1, cattrs.Length);
Assert.NotNull(cattrs[0]);
Assert.Equal(attrType, cattrs[0].GetType());
string p = (cattrs[0] as System.Reflection.Metadata.ApplyUpdate.Test.MyAttribute).StringValue;
Assert.Equal("rstuv", p);
});
}

Expand Down