- Notifications
You must be signed in to change notification settings - Fork564
[release/9.0.1xx] introduce$(_AndroidIsAssignableFromCheck) escape hatch#10473
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
… hatchContext:https://github.com/jonathanpeppers/IntuneReproNet9Context:35f41dcContext:9a27140.NET 9 introduced a Java "instanceof" check for multiple reasons: if (!JniEnvironment.Types.IsAssignableFrom (handleClass, typeClass)) { return null; }The problem with this check, is that it fails in combination with thepackage: <PackageReference Include="Microsoft.Intune.Maui.Essentials.android" Version="11.0.0-develop" />`LayoutInflater.From (Context)` returns `null` due to: Handle 0x7f346ad02d is of type 'com/android/internal/policy/PhoneLayoutInflater' which is not assignable to'com/microsoft/intune/mam/client/view/MAMLayoutInflater'To solve this:* Introduce `-p:_AndroidIsAssignableFromCheck=false` to disable the check, defaulting to `true` for .NET 9+.* Add a test that calls `LayoutInflater.From (Context)` and verify it returns non-null.* Add a test entry in `Remaps.xml` to remap `com.microsoft.intune.mam.client.view.MAMLayoutInflater` to a test Java class `net.dot.android.test.MyLayoutInflater` that extends `android.view.LayoutInflater`.I introduced a new test run configuration "IsAssignableFrom"to leverage the new property `-p:_AndroidIsAssignableFromCheck=false`.After this is merged, I'll need to manually port this to main for .NET10. Various files have moved around there; we can use `RuntimeFeature.cs`, etc.
| <RuntimeHostConfigurationOptionInclude="Microsoft.Android.Runtime.RuntimeFeature.IsAssignableFromCheck" | ||
| Condition="'$(_AndroidIsAssignableFromCheck)' != ''" | ||
| Value="$(_AndroidIsAssignableFromCheck)" | ||
| Trim="true" | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This needs to set even in Debug mode.
| <_AndroidRemapMembersInclude="Remaps.xml" /> | ||
| <_AndroidRemapMembersInclude="IsAssignableFromRemaps.xml"Condition=" '$(_AndroidIsAssignableFromCheck)' == 'false'" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
IsAssignableFromRemaps.xml is in its own file, because we have a couple tests that need to use thereal Android LayoutInflater.
We run only theIntune category under-p:_AndroidIsAssignableFromCheck=false.
jonathanpeppers commentedSep 10, 2025
jonathanpeppers commentedSep 11, 2025
This looks green, there are just a couple networking-related failures we can ignore: |
f395493 intorelease/9.0.1xxUh oh!
There was an error while loading.Please reload this page.
Forward port of:#10473Context:https://github.com/jonathanpeppers/IntuneReproNet9Context:35f41dcContext:9a27140.NET 9 introduced a Java "instanceof" check for multiple reasons: if (!JniEnvironment.Types.IsAssignableFrom (handleClass, typeClass)) { return null; }The problem with this check, is that it fails in combination with thepackage: <PackageReference Include="Microsoft.Intune.Maui.Essentials.android" Version="11.0.0-develop" />`LayoutInflater.From (Context)` returns `null` due to: Handle 0x7f346ad02d is of type 'com/android/internal/policy/PhoneLayoutInflater' which is not assignable to'com/microsoft/intune/mam/client/view/MAMLayoutInflater'To solve this:* Introduce `-p:_AndroidIsAssignableFromCheck=false` to disable the check, defaulting to `true` for .NET 9+.* Add a test that calls `LayoutInflater.From (Context)` and verify it returns non-null.* Add a test entry in `IsAssignableFromRemaps.xml` to remap `com.microsoft.intune.mam.client.view.MAMLayoutInflater` to a test Java class `net.dot.android.test.MyLayoutInflater` that extends `android.view.LayoutInflater`.I introduced a new test run configuration "IsAssignableFrom"to leverage the new property `-p:_AndroidIsAssignableFromCheck=false`,and only run the `Intune` category.
…tch (#10475)Forward port of:#10473Context:https://github.com/jonathanpeppers/IntuneReproNet9Context:35f41dcContext:9a27140.NET 9 introduced a Java "instanceof" check for multiple reasons: if (!JniEnvironment.Types.IsAssignableFrom (handleClass, typeClass)) { return null; }The problem with this check, is that it fails in combination with the package: <PackageReference Include="Microsoft.Intune.Maui.Essentials.android" Version="11.0.0-develop" />`LayoutInflater.From (Context)` returns `null` due to: Handle 0x7f346ad02d is of type 'com/android/internal/policy/PhoneLayoutInflater' which is not assignable to 'com/microsoft/intune/mam/client/view/MAMLayoutInflater'To solve this:* Introduce `-p:_AndroidIsAssignableFromCheck=false` to disable the check, defaulting to `true` for .NET 9+.* Add a test that calls `LayoutInflater.From (Context)` and verify it returns non-null.* Add a test entry in `IsAssignableFromRemaps.xml` to remap `com.microsoft.intune.mam.client.view.MAMLayoutInflater` to a test Java class `net.dot.android.test.MyLayoutInflater` that extends `android.view.LayoutInflater`.I introduced a new test run configuration "IsAssignableFrom" to leverage the new property `-p:_AndroidIsAssignableFromCheck=false`, and only run the `Intune` category.

Uh oh!
There was an error while loading.Please reload this page.
Context:https://github.com/jonathanpeppers/IntuneReproNet9
Context:35f41dc
Context:9a27140
.NET 9 introduced a Java "instanceof" check for multiple reasons:
The problem with this check, is that it fails in combination with the package:
LayoutInflater.From (Context)returnsnulldue to:To solve this:
Introduce
-p:_AndroidIsAssignableFromCheck=falseto disable the check, defaulting totruefor .NET 9+.Add a test that calls
LayoutInflater.From (Context)and verify it returns non-null.Add a test entry in
Remaps.xmlto remapcom.microsoft.intune.mam.client.view.MAMLayoutInflaterto a test Java classnet.dot.android.test.MyLayoutInflaterthat extendsandroid.view.LayoutInflater.I introduced a new test run configuration "IsAssignableFrom" to leverage the new property
-p:_AndroidIsAssignableFromCheck=false.After this is merged, I'll need to manually port this to main for .NET 10. Various files have moved around there; we can use
RuntimeFeature.cs, etc.