1

Resolved

SimpleIoc misleading error when class has private constructor

description

SimpleIoc does not check whether the selected constructor is private.
This issue lies in GetConstructorInfo, these lines should be modified:
            var preferredConstructorInfo
                = (from t in constructorInfos

if NETFX_CORE

                   let attribute = t.GetCustomAttribute(typeof (PreferredConstructorAttribute))

else

                   let attribute = Attribute.GetCustomAttribute(t, typeof(PreferredConstructorAttribute))

endif

                   where attribute != null
                   select t).FirstOrDefault();
If the constructor is private a IndexOutOfRangeException is raised, this is really misleading.

thank you laurent for your amazing toolkit, this is the swiss knife of all WPF/SL developers!

comments

lbugnion wrote Jun 24, 2012 at 9:49 AM

Good stuff, thanks. I already have V4 RTM assemblies built but I will fix that in the very next.

Thanks!
Laurent

HeDo88TH wrote Jun 24, 2012 at 7:54 PM

great, I'm looking forward to the V4!