Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Remove test that sets static readonly field after type initialization #33413

Merged
Changes from all commits
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
15 changes: 0 additions & 15 deletions src/System.Linq.Expressions/tests/MemberInit/BindTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,6 @@ public void StaticField(bool useInterpreter)
Assert.Equal("ABC", PropertyAndFields.StaticStringField);
}

[Theory, ClassData(typeof(CompilationTypes))]
public void StaticReadonlyField(bool useInterpreter)
{
MemberInfo member = typeof(PropertyAndFields).GetMember(nameof(PropertyAndFields.StaticReadonlyStringField))[0];
Expression<Func<PropertyAndFields>> assignToReadonly = Expression.Lambda<Func<PropertyAndFields>>(
Expression.MemberInit(
Expression.New(typeof(PropertyAndFields)),
Expression.Bind(member, Expression.Constant("ABC" + useInterpreter))
)
);
Func<PropertyAndFields> func = assignToReadonly.Compile(useInterpreter);
func();
Assert.Equal("ABC" + useInterpreter, PropertyAndFields.StaticReadonlyStringField);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume both the false and true variants of this test fail now (by design) with your change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, no ... the compiled version will still "succeed."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are number of other discrepancies between interpreted and compiled expressions if the expression is invalid. This is just one more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should be made consistent if there isn't a very good reason otherwise. I'll hopefully get back into contributing later this year, and I'd be interested in doing it then, but I'm by no means grabbing it if anyone else is interested.


[Theory, ClassData(typeof(CompilationTypes))]
public void StaticProperty(bool useInterpreter)
{
Expand Down