Add a test for Expression.Property and its handling of property accessors#54279
Conversation
…sors This mostly a linker test as this effectively validates linker feature from dotnet/linker#1880. But having a clean trimming tests here is better validation for this specific case.
|
Tagging subscribers to this area: @cston Issue DetailsThis mostly a linker test as this effectively validates linker feature from dotnet/linker#1880. But having a clean trimming tests here is better validation for this specific case.
|
| { | ||
| var obj = new TestType(); | ||
| var param = Expression.Parameter(typeof(TestType)); | ||
| var prop = Expression.Property(param, typeof(TestType).GetMethod("get_TestProperty")); |
There was a problem hiding this comment.
Maybe it is overkill, but should we also have a test that has Roslyn creating the Expression? ex.
var obj = new TestType();
Expression<Func<TestType, bool>> expression = t => t.TestProperty;
var prop = ((MemberExpression)expression.Body);
((PropertyInfo)prop.Member).SetValue(obj, true);
if (obj._testPropertyValue != true)
return -1;
return 100;
eerhardt
left a comment
There was a problem hiding this comment.
Thanks for following up on this.
Note: we don't verify our trimming tests don't have ILLink warnings. But maybe we should have some subset of tests that verify no warnings? |
|
It would be nice to be able to validate that there were no warnings. I looking at that a little bit, but it's rather complicated... not a simple fix anywhere really. |
|
|
||
| result = LambdaCreation.Test(); | ||
|
|
||
| Type.GetType("foo"); |
There was a problem hiding this comment.
I was trying to turn on the warnings - and this is an easy way to get a warning... but I left it in.
|
Linker tests passed. Runtime libraries test failures are unrelated. |
This mostly a linker test as this effectively validates linker feature from dotnet/linker#1880.
But having a clean trimming tests here is better validation for this specific case.