Bug 54388 - InternalsVisibleTo is case sensitive
Summary: InternalsVisibleTo is case sensitive
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Katelyn Gadd
URL:
Depends on:
Blocks:
 
Reported: 2017-04-02 13:16 UTC by softlion
Modified: 2017-09-06 15:08 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description softlion 2017-04-02 13:16:39 UTC
The assembly name set as InternalsVisibleTo parameter is case insensitive.

[assembly: InternalsVisibleTo("MyControlForms.Ios")]

If the assembly name is set to MyControlForms.iOS, the compiler compiles fine (it authorize the use of any internal property), but accessing any internal property crashes at runtime with

	Unhandled Exception:
	System.FieldAccessException: Field `MyControlForms:MyInternalProperty' is inaccessible from method `MyControlForms.iOS.MyControlRenderer...

It should not crash, or the compiler should fail to compile.
Comment 1 Katelyn Gadd 2017-04-03 21:34:23 UTC
In Xamarin Studio 6.2.1 build 3, if the case of the assembly name does not match, I get a build failure saying that the member is inaccessible due to its protection level. If I correct the case of the assembly name the test application builds.

Can you provide a more specific example of some code (or ideally a pair of projects) where this failure occurs? I can't reproduce it.
Comment 2 Marek Safar 2017-04-03 22:20:28 UTC
Katelyn, I think that's the bug. The runtime loader treats the InternalsVisibleTo value as case sensitive which probably shouldn't (requires checking on .net)
Comment 3 Katelyn Gadd 2017-04-03 22:21:27 UTC
So the intended behavior is not "It should not crash, or the compiler should fail to compile." but "it should work"? I'll see how this works on Windows.
Comment 4 softlion 2017-04-04 04:50:58 UTC
I'm on vs2015 windows not xs.
Don't know what the c# spec directs here.
Comment 5 Katelyn Gadd 2017-04-04 20:42:26 UTC
OK, I can confirm that in VS2015 on windows, the case of the argument to InternalsVisibleTo is ignored. It still fails as expected if the name is entirely incorrect. I assume this is done to make sure things still work if win32 case insensitivity causes the assembly name to get messed up.

So to match this behavior, I think the mono runtime would need to change, in addition to the mono compiler.
Comment 6 Katelyn Gadd 2017-04-06 18:02:33 UTC
@softlion What version of Xamarin.iOS are you using?
Comment 7 softlion 2017-04-06 18:03:28 UTC
I was using the beta version which is the stable version since a couple of days.
Comment 8 Katelyn Gadd 2017-04-06 18:05:01 UTC
OK, 15.1? Thanks. I'll chase this down.

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.


Create a new report for Bug 54388 on Developer Community or GitHub if you have new information to add and do not yet see a matching report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments


Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Related Links: