Why doesnt [Dependency] work with public properties?

Mar 12, 2013 at 7:11 PM
Well, migrating the code to use the container has been such a big endeavor, this is not even funny.

I wanted to ask why doesn't the DependencyAttribute work when applied to internal properties. This makes very little sense, because the whole injection pipeline works with internal classes and InjectionMethod's.

I can't use ctor injection in my current case because I'm actually injecting onto web pages. I went with the custom httpModule solution to call buildup on every page and it's controls, so I need to use property or method injection.

Since property injection is a bit simpler, I would really like to go with that. I can't though, because some of the types exposed by them are internal, and this gives me an error about inconsistent accessibility. These classes are in referenced assemblies which have the InternalsVisibleTo(<my_assembly>) in them.

I also cannot convert the pages to internal because the aspnet framework complains about it and cannot compile the pages (if I could that would be a somewhat good solution IMHO).

Why have you decided to exclude internal properties from the injection mechanism? Isn't it enough that the assembly that is configuring the container has access to the properties? Wouldn't it be possible to update the Unity framework to allow internal properties (provided the container configuration is in the same assembly or one with the InternalsVisibleToAttribute applied)?

Thanks in advance, and sorry for making multiple consecutive questions here. It's just that I'm having a hard time on some parts.