Say, for example, I've got this simple class:

public class MyClass
{
  public String MyProperty { get; set; }
}

The way to get the PropertyInfo for MyProperty would be:

typeof(MyClass).GetProperty("MyProperty");

This sucks!

Why? Easy: it will break as soon as I change the Name of the Property, it needs a lot of dedicated tests to find every location where a property is used like this, refactoring and usage trees are unable to find these kinds of access.

Ain't there any way to properly access a property? Something, that is validated on compile time?
I'd love a command like this:

propertyof(MyClass.MyProperty);
Edit
Report