Rather odd question ...

I know this isn't a code help forum or anything. But I'm pretty certain
ReSharper uses reflection ..'VERY' extensively, and I need an expert on
reflection. so the worse I could get is a 'no'. So I might as well try to
ask.

How did you overcome the problem of non-default constructors and constructor
parameters without default values available?

I'm trying to write a library that takes an assembly, loads it, and allows
you to iterate through each class in the library and loads it into a
property grid, but I'm running into an issue with the fact that many classes
do not have a default (parameterless) constructor. I solved this by just
getting all the constructors and taking the one with the most parameters,
but this leads to the problem of trying to package them with reflection, I
do not have default values for many of the parameters in the constructors.
Any suggestions?


1 comment
Comment actions Permalink

I'm not quite sure I understand you correctly but it looks like you are trying to create a tool which is able to instantiate classes, inspect their properties and maybe set them new values. I think that classes that do not have default (parameterless) constructor are just not intended for such use. I cannot see any way how you can fetch 'default' values for a constructor. There can be no such default values for some of constructors. You should at least know some additional information about classes being instantiated.

--
Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com "Develop with pleasure!"


I know this isn't a code help forum or anything. But I'm pretty
certain ReSharper uses reflection ..'VERY' extensively, and I need an
expert on reflection. so the worse I could get is a 'no'. So I might
as well try to ask.

How did you overcome the problem of non-default constructors and
constructor parameters without default values available?

I'm trying to write a library that takes an assembly, loads it, and
allows you to iterate through each class in the library and loads it
into a property grid, but I'm running into an issue with the fact that
many classes do not have a default (parameterless) constructor. I
solved this by just getting all the constructors and taking the one
with the most parameters, but this leads to the problem of trying to
package them with reflection, I do not have default values for many of
the parameters in the constructors. Any suggestions?


0

Please sign in to leave a comment.