Fast Dynamic Property Access in C# using Reflection.Emit
I just read an extremely interesting article on CodeProject called: Fast Dynamic Property Access with C# by James Nies. Wow, I am really impressed both by the idea to use Emit in this genius way and by the coding style. Very nice work.
So, I had to sit down and port it to .NET 2.0 and use Generics. Actually, what I found out – it is way simpler, than what he did.
How fortunate for me, since this was the very first time I even looked at Emit.
Please remember: This is a quick port. It won’t work, if you don’t know exactly the return type, especially if it is a ValueType.
Here are links to download the stuff:
GenericPropertyAccessor as Zip
Or as txts:
IGenericPropertyAccessor.cs
GenericPropertyAccessor.cs
And finally the updated test app:
SampleApp.cs
This is not the complete solution you need in order to build the SampleApp. Please go to Codeproject and download the source code, then add my files.

I noticed that you too elaborated on the effort of James Nies
That makes two of us. I just thought you might be interested in the enhancement that I had published earlier cf.
http://www.codeproject.com/csharp/Fast_Dynamic_Properties.asp?msg=1505107#xx1505107xx
which also happens to contain most if not all the performance enhancements proposed in other replies on CodeProject…
That is, apart from exploiting generics of course. I didn’t get so lucky to be using .NET 2.0 at the time.
Feel free to peruse the download available from http://sehe.xs4all.nl/FastDynamicMemberAccessor.zip in anywhich way you seem fit and I’d be interested to see a generic version of it if you had one
Cheers
Comment on June 9, 2006 @ 23:22:42
Hi Seth,
thanks for your heads up! I will look into it as soon as I will be able to do so. I am always willing to learn something new.
Have a good one!
Tobi
Comment on June 10, 2006 @ 01:38:02