-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
BadImageFormatException when calling static virtual method in interface #82217
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
/cc @thaystg |
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger Issue DetailsDescriptionCalling static methods from an interface on another interface type implementing the first interface causes a BadImageFormatException (Method has no body) on Android. I have tried this on both an emulator and my actual Android phone, and I get the same result both ways. The exact same code works on Windows, but fails on Android. I wasn't sure if this was a runtime issue or a rosalyn issue so I just raised it here - sorry if this isn't the right place. Reproduction StepsHere is a simple MAUI app that reproduces the issue: On Android:
Expected behaviorThe method should be called, like it is on Windows Actual behaviorException: System.BadImageFormatException: Method has no body Regression?I don't think this is a regression, seeing as how the language feature is pretty new. Known WorkaroundsNo response Configuration
Other informationNo response
|
cc @BrzVlad as he worked on the static virtual interface support a bit. |
I have a fix for it here: https://github.com/dotnet/runtime/compare/main...thaystg:runtime:thays_fix_82217?expand=1 |
hi @thaystg - any update of this, are we still tracking this for 8.0 ? |
I'm not working on it. We can move it to net9. I hope @BrzVlad can take a look at my changes and give me some feedback? |
This issue seems to consist of a constrained call where the generic type is also an interface. This looks like a duplicate of #90139. I think this is fixed on main. |
There is still an issue in 9.0, I extracted the repro into a simpler console-based mono app:
Crash:
|
@steveisok is someone from your team that should work on it? |
I think this is a duplicate of #79331. Closing. |
Description
Calling static methods from an interface on another interface type implementing the first interface causes a BadImageFormatException (Method has no body) on Android. I have tried this on both an emulator and my actual Android phone, and I get the same result both ways. The exact same code works on Windows, but fails on Android. I wasn't sure if this was a runtime issue or a rosalyn issue so I just raised it here - sorry if this isn't the right place.
Reproduction Steps
Here is a simple MAUI app that reproduces the issue:
Repo link
edit by @akoeplinger See #82217 (comment) for a simpler repro
On Android:
Have an interface with a static virtual member, like this:
public interface IHaveStaticMethod { static abstract void Method(); }
Have another interface that implements the first interface, like this:
public interface IInterface : IHaveStaticMethod { static void IHaveStaticMethod.Method() { Console.WriteLine("Hello, world!"); } }
Call the static method, using a method like this:
private void CallMethod<T>() where T : IHaveStaticMethod => T.Method();
Expected behavior
The method should be called, like it is on Windows
Actual behavior
Exception: System.BadImageFormatException: Method has no body
Regression?
I don't think this is a regression, seeing as how the language feature is pretty new.
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: