-
Notifications
You must be signed in to change notification settings - Fork 566
Description
[TrimmableTypeMap] Add integration tests for generator-consumed scanner fields
Part of #10789
Context
PR #10827 added integration tests that validate the new JavaPeerScanner (SRM-based) against the legacy Cecil-based scanner. These tests cover the fields that overlap between the two scanners: JavaName, BaseJavaName, ImplementedInterfaces, MarshalMethods, ActivationCtors, and type flags (IsInterface, IsAbstract, IsGenericDefinition, DoNotGenerateAcw).
However, PR #10808 introduced the Generator pipeline (ModelBuilder → TypeMapAssemblyEmitter) which consumes several JavaPeerInfo fields that are new concepts with no legacy equivalent. These fields cannot be validated via legacy-vs-new comparison and need standalone correctness tests.
Fields not covered by integration tests
| Field | Used by | Risk if wrong |
|---|---|---|
IsUnconditional |
ModelBuilder.IsUnconditionalEntry() — determines 2-arg (unconditional) vs 3-arg (trimmable) TypeMap attribute |
Wrong trimming behavior — types could be incorrectly trimmed or unnecessarily preserved |
InvokerTypeName |
ModelBuilder.BuildProxyType() — proxy generation for interfaces/abstract types |
Missing invoker = runtime MissingMethodException when activating interface wrappers |
CompatJniName |
AcwMapWriter — backward-compatible ACW name for acw-map.txt |
Broken debugging, profiling, or tooling that relies on acw-map.txt |
MarshalMethods.ManagedMethodName |
Future UCO wrapper generation | Low risk now, but incorrect values would cause wrong method dispatch |
Proposed tests
1. IsUnconditional_ComponentTypes
Scan UserTypesFixture.dll:
- Types with
[Activity],[Service],[BroadcastReceiver],[ContentProvider]→IsUnconditional = true - Plain Java peer types without component attributes →
IsUnconditional = false - Types referenced by
[Application(BackupAgent=typeof(X))]→ forced unconditional via cross-reference
2. IsUnconditional_MonoAndroid
Scan Mono.Android.dll:
- All MCW binding types have
DoNotGenerateAcw=trueand should not be marked unconditional - Sanity check: count of unconditional types = 0
3. InvokerTypeName_InterfacesAndAbstractTypes
Scan Mono.Android.dll:
- Every type with
IsInterface = trueshould have a non-nullInvokerTypeName - The referenced invoker type should actually exist in the scanned assemblies
- Validate resolution via
[Register]connector (primary) and{TypeName}Invokerconvention (fallback)
4. InvokerTypeName_UserTypes
Scan UserTypesFixture.dll:
- Concrete user types →
InvokerTypeName = null - User-defined interfaces (if present) → invoker resolved correctly
5. CompatJniName_UserTypes
Scan UserTypesFixture.dll:
- Verify
CompatJniNameuses lowercased raw namespace format - E.g.,
MyApp.Namespace.MyType→myapp.namespace/MyType
6. ManagedMethodName_MarshalMethods
Scan Mono.Android.dll:
- Every
MarshalMethodInfohas non-null, non-emptyManagedMethodName - Spot-check known types (e.g.,
Android.App.ActivityhasOnCreatemethod)
Notes
- These tests should live in
tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/ - Unlike the existing comparison tests, these are standalone correctness tests — they validate the new scanner's output against known expectations, not against the legacy scanner
- The
UserTypesFixturemay need additional types (e.g., user-defined interfaces,[Application]withBackupAgent) to exercise all paths