You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You want to implement DoSomething.Do () in C# and apply the [JavascriptInterface] attribute to it, hoping the @JavascriptInterface Java annotation will be added to your JCW method.
If Do () was an override to a Java class method this would work. However when we generate JCWs for implemented interface methods, we do not consider what the user has written. We (correctly) assume that the user has provided an implementation for every required interface method. That is, we generate a JCW method for every method we find on implemented interfaces.
Because we ignore what the user has written when generating the JCW method, we will not see that they have added an attribute to their method, and we will not add the requested Java annotation to the JCW method.
To fix this, we need to figure out which methods in the user's code implements an interface method so we can apply any attributes the user has added to the JCW method.
Note that the implementation for this is likely quite complex. We will have to build a map between the user's methods and the implemented interface methods so we can determine which user methods are interface implementations and which aren't. This also gets more complicated with things like generics, explicit interface implementations, and default interface methods.
The text was updated successfully, but these errors were encountered:
Context: dotnet/maui@0820530
Context: dotnet/android#7714
Imagine that you have the following Java interface and annotation:
You want to implement
DoSomething.Do ()
in C# and apply the[JavascriptInterface]
attribute to it, hoping the@JavascriptInterface
Java annotation will be added to your JCW method.If
Do ()
was anoverride
to a Javaclass
method this would work. However when we generate JCWs for implemented interface methods, we do not consider what the user has written. We (correctly) assume that the user has provided an implementation for every required interface method. That is, we generate a JCW method for every method we find on implemented interfaces.Because we ignore what the user has written when generating the JCW method, we will not see that they have added an attribute to their method, and we will not add the requested Java annotation to the JCW method.
To fix this, we need to figure out which methods in the user's code implements an interface method so we can apply any attributes the user has added to the JCW method.
Note that the implementation for this is likely quite complex. We will have to build a map between the user's methods and the implemented interface methods so we can determine which user methods are interface implementations and which aren't. This also gets more complicated with things like generics, explicit interface implementations, and default interface methods.
The text was updated successfully, but these errors were encountered: