Instantiate public objects

37 views
Skip to first unread message

srudin

unread,
Apr 13, 2012, 11:28:20 AM4/13/12
to structuremap-users
I was using a customized 2.6.1 version and have now updated to the
2.6.3 NuGet package. The reason for using a customized version was
that I wanted to instantiate internal classes and not only public
classes - I have posted this request as well as the required code
changes a long time ago. I was quite disappointed to see that this
change has not been introduced into the 2.6.3 version so I would like
to ask if this was on purpose or if my request got lost somehow?

Jeremy D. Miller

unread,
Apr 13, 2012, 11:36:55 AM4/13/12
to structure...@googlegroups.com
If you really want to, you can always get around the issue by using this:  http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx

I don't see the pull request anywhere in GitHub, but regardless, my very long standing policy has been against using anything but public types and public constructors.  Mostly because of the performance issue, partly because of how much architectural work it would take to make that change, and my feeling that it adds no real value.  I'm not particularly a believer in paranoid scoping.

That being said, SM itself is extensible.  You could just use your own Instance subclass that can build internal classes thru reflection if you want.


 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: srudin <goo...@sandrorudin.net>
To: structuremap-users <structure...@googlegroups.com>
Sent: Fri, April 13, 2012 10:28:23 AM
Subject: [sm-users] Instantiate public objects
--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To post to this group, send email to structure...@googlegroups.com.
To unsubscribe from this group, send email to structuremap-users+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/structuremap-users?hl=en.

srudin

unread,
Apr 14, 2012, 6:56:05 AM4/14/12
to structuremap-users
Ok, I see. My point is that is that this distinction has nothing to do
with paranoia but simply with the fact that internal classes are
treated differently. Take FxCop for example - there are rules that are
validated differently whether the class is internal or public (like a
method/parameter/constant etc. never used on an internal class is
obsolete what cannot be said for a public class). This is just one
example of a number of similar points that make me believe that it
does make a difference whether you implement something internal or
public besides wanting to hide anything (which is useless because of
refelction anyway). So my opinion is still that it would make sense to
include internals in the SM functionality.

But I take your hint about the InternalsVisibleToAttribute. I will try
this out and probably this will already be enough to do the job as I
wish.

Kind regards
Sandro

On 13 Apr., 17:36, "Jeremy D. Miller" <jeremydmil...@yahoo.com> wrote:
> If you really want to, you can always get around the issue by using this:
>  http://msdn.microsoft.com/en-us/library/system.runtime.compilerservic...
>
> I don't see the pull request anywhere in GitHub, but regardless, my very long
> standing policy has been against using anything but public types and public
> constructors.  Mostly because of the performance issue, partly because of how
> much architectural work it would take to make that change, and my feeling that
> it adds no real value.  I'm not particularly a believer in paranoid scoping.
>
> That being said, SM itself is extensible.  You could just use your own Instance
> subclass that can build internal classes thru reflection if you want.
>
>  Jeremy D. Miller
> The Shade Tree Developer
> jeremydmil...@yahoo.com
>
> ________________________________
> From: srudin <goo...@sandrorudin.net>
> To: structuremap-users <structure...@googlegroups.com>
> Sent: Fri, April 13, 2012 10:28:23 AM
> Subject: [sm-users] Instantiate public objects
>
> I was using a customized 2.6.1 version and have now updated to the
> 2.6.3 NuGet package. The reason for using a customized version was
> that I wanted to instantiate internal classes and not only public
> classes - I have posted this request as well as the required code
> changes a long time ago. I was quite disappointed to see that this
> change has not been introduced into the 2.6.3 version so I would like
> to ask if this was on purpose or if my request got lost somehow?
>
> --
> You received this message because you are subscribed to the Google Groups
> "structuremap-users" group.
> To post to this group, send email to structure...@googlegroups.com.
> To unsubscribe from this group, send email to
> structuremap-us...@googlegroups.com.

srudin

unread,
Apr 16, 2012, 6:04:38 AM4/16/12
to structuremap-users
Hm, I tried with the following attribute:

[assembly:
InternalsVisibleTo("StructureMap,PublicKey=00240000048000009400000006020000002400005253413100040000010001008d9a2a76e43cd9b1b1944b1f3b489a046b33f0bcd755b25cc5d3ed7b18ded38240d6db7578cd986c72d3feb4f94a7ab26fcfa41e3e4f41cf2c029fba91159db05c44d63f0b2bfac24353a07f4a1230dd3d4240340adafa2275277fa083c75958062cd0e60016701db6af7ae718efdf1e802a840595b49c290964255b3c60c494",
AllInternalsVisible = true)]

Unfortunately the error does not disappear - am I missing something?
Reply all
Reply to author
Forward
0 new messages