tags:

views:

268

answers:

6

Hi, Is there any library (like open source projects etc) that makes it easier to use complex reflection like creating objects or classes on the fly, inspecting instances etc?

Thanks

+2  A: 

there is a LinFu library available which can do lot other interesting stuffs than reflection... try it

Ramesh Vel
A: 

The MS unit test assembly has PrivateObject and PrivateType which make access to private instance/type members pretty straight forward.

Brian Rasmussen
Although, using this outside testing is a horrible, horrible idea...
Matthew Scharley
It is just a wrapper for what you can do through reflection, so it is really nothing special, but I agree that you should not mess with private stuff in instances/types.
Brian Rasmussen
+2  A: 

In my opinion I don't think reflection could get any easier to use than it is now. Almost all of the core functionality is wrapped up within the Type class. Just take your time to learn about how it works and you won't need another unnecessary layer on top of it.

Specifically, you can do 'complex things' as creating unitialized objects like this:

// Instantiates an uninitialized object of the specified type.
var newObject = (MyObject)FormatterServices.GetUninitializedObject( elementType );
Trap
+1  A: 

There are some interesting ReflectionHelpers out there.

JP Alioto
A: 

Reflection is by definition hard. It's a level of indirection placed over the whole object structure. I'm not really sure how you can make it easier, without limiting its power.

C. Ross
+1  A: 

If reflection is hard, then it might be possible that you don't have a full understanding of the basics of .Net. You might want to try a tutorial like this.

TheCodeMonk