Bug 6170 - Static methods from base classes aren't exported
Summary: Static methods from base classes aren't exported
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on: 1353
Blocks:
  Show dependency tree
 
Reported: 2012-07-18 06:25 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2013-03-14 19:31 UTC (History)
4 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Rolf Bjarne Kvinge [MSFT] 2012-07-18 06:25:56 UTC
This is currently required:

class Foo {
    [Export ("foo")]
    public static void Foo () {}
}

class Bar : Foo {
    [Export ("foo")]
    public new static void Foo () {}
}

See also: http://stackoverflow.com/questions/11529173/can-i-avoid-exporting-layerclass-in-views-derived-from-iphoneosgameview
Comment 1 Miguel de Icaza [MSFT] 2012-07-18 10:20:45 UTC
The above sample works, but in some cases the problem is that they require a value to be returned, and returning a value would change the default behavior.

For example, consider the static layerClass property on UIViews, the documentation states:

layerClass - Implement this method only if you want your view to use a different Core Animation layer for its backing store. For example, if you are using OpenGL ES to do your drawing, you would want to override this method and return the CAEAGLLayer class.

We could certainly research case-by-case problems.

Or is this a case that a custom implementation of the class (BaseGameView) overwrote that, but we failed to register that when the class is derived?

That is: if class "Foo" explicitly defines a static export, that we should register that in any Bar classes?
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-07-18 11:22:36 UTC
The problem is that in derived classes you need to Export again, otherwise you get a selector not found exception.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-03-13 08:16:36 UTC
This is now fixed with the new registrar.
Comment 4 Miguel de Icaza [MSFT] 2013-03-13 13:02:28 UTC
How does the fix work?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-03-13 19:49:15 UTC
In fact the base method is exported properly, the problem occurs when the trampoline tries to look up the managed method to invoke. The old code did not look in base types for exported methods when looking up the managed method, while the new code does.
Comment 6 jacobf 2013-03-14 11:37:10 UTC
Does the fix apply to [Outlet] as well?
Comment 7 Rolf Bjarne Kvinge [MSFT] 2013-03-14 19:31:34 UTC
Jacob: do you mean bug #1449?