New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InternalsVisibleTo does not work with AssemblyBuilder #12454
Comments
I'd say this is a bug, but I don't know what the priority to fix it would be. I've reproduced the issue locally, but have not root caused it. |
I'm assigning milestones to things in area-TypeSystem in preparation for the 3.0 release. Since this behaves the same on desktop CLR, I'm placing this to the Future milestone. |
…egen limitation (I hope to revert this commit in the future) - JasperFx/marten#1655, dotnet/runtime#12454
…egen limitation (I hope to revert this commit in the future) - JasperFx/marten#1655, dotnet/runtime#12454
So, it turns out that I was incorrect in my initial triage of this bug. This test case has a bug. In particular, the |
It appears that the InternalsVisibleToAttribute does not work when the friend assembly is a dynamic assembly /
AssemblyBuilder
.Repro:
Invoking the method leads to
FieldAccessException: Attempt by method 'T.M()' to access field 'Program.x' failed
even though internals are visible to that assembly. It also doesn't work when both assemblies (i.e. the one declaring the attribute and the subject of the attribute) are dynamic assemblies. The two commented-out lines adds an IgnoresAccessChecksToAttribute to the dynamic assembly, which seems to work fine. It may be necessary to define that attribute as follows:Am I missing something? Is there a reason why InternalsVisibleTo can not be used with dynamic assemblies? Granted, it is a relatively unusual scenario, but I don't see why it shouldn't work. A possible alternative or additional solution I'd love to see would be to allow disabling access checks altogether when defining a dynamic assembly, just as is possible with
DynamicMethod
.The text was updated successfully, but these errors were encountered: