Q:

Property-of aka infoof -- via Rosyln?

A few years ago Eric Lippert blogged about a hypothetical infoof operator that would allow you to get method/property information at compile time i stead of at runtime.  Basically saying that it's a nice pony, but no unicorn....
I read a bit about Rosyln's ability to rewrite your code at compile time, how difficult would it be to implement infoof using Roslyn?
EDIT: I thought this might be a way to get everything Eric said you they were thinking about, but I should have broken down the features a bit in case it wasn't.

Get a property name.
Get a property type.
Get property accessors.
Get a methods name.
Get everything he meant by infoof...

In a refactoring-safe way, that gets verified at compile time. For me personally, 1 covers about 90% of what I would actually use (the new caller info attribute for getting a callers name can actually cover about 60%, but of course if there was a way that worked both inside and outside of the method, that would be preferable).

A:

You can easily use Roslyn to rewrite one valid C# code into another valid C# code. But it's not meant for adding extensions to the language.
Roslyn does parse invalid code too (it has to, if you want to use it for IntelliSense on an incomplete line), but since it's invalid, there is no guarantee it will do it correctly (because it's not clear what exactly does “correctly” mean). Also, I think the structure that it will use for infoof won't be very convenient for you.
To summarize: this is not what Roslyn is meant to be used for and doing it is probably a bad idea. But I think it's not impossible to do this using Roslyn.

