Bug 1702 - Register attributes can be hidden by user class
Summary: Register attributes can be hidden by user class
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Version: 2.8
Hardware: PC Mac OS
: Low enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
: 7199 ()
Depends on:
Reported: 2011-10-26 14:31 UTC by Mikayla Hutchinson [MSFT]
Modified: 2017-07-19 23:52 UTC (History)
4 users (show)

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

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.

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.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mikayla Hutchinson [MSFT] 2011-10-26 14:31:17 UTC
The templates and designer files that MD generates have [Register("foo")] attributes applied. Since they're not fully qualified, they can be silently hidden by a user class in the same namespace and the resulting errors are hard to track down. The same likely applies to Outlet and Export attributes.

It would seem a shame to fully qualify them all since that would make all the templates and generated code ugly. Maybe it would be possible for the Xcode integration to inspect all attributes on the NSObject-derived classes and warn if a RegisterAttribute has been hidden by another class.
Comment 1 Mikayla Hutchinson [MSFT] 2011-10-26 14:33:13 UTC
Alternatively this might be something that a Gendarme analysis could look for.
Comment 2 steven.orth 2012-09-20 19:13:44 UTC
Our dev team has encountered this problem within our own codebase. We had to classes named "Foo" in two different namespaces. We encountered an InvalidCastException at runtime in the managed/unmanaged transition code because the wrong type was selected.
Comment 3 Jeffrey Stedfast 2012-10-15 18:23:28 UTC
*** Bug 7199 has been marked as a duplicate of this bug. ***
Comment 4 Dominic N [MSFT] 2017-07-19 23:52:26 UTC
If there is any additional information you'd like to contribute, please comment on this report. This enhancement request has been noted and will now be closed.

Thank you everyone for the feedback.