Skip to content

Comments

WIP Fix MediaContent-related API not being generated#1356

Open
marius-bughiu wants to merge 1 commit intodotnet:mainfrom
marius-bughiu:fix/mediacontent-api
Open

WIP Fix MediaContent-related API not being generated#1356
marius-bughiu wants to merge 1 commit intodotnet:mainfrom
marius-bughiu:fix/mediacontent-api

Conversation

@marius-bughiu
Copy link

WIP (do not merge)
This is mostly generated with Claude and I need to test it first.
Fixes: #973
Needed for: marius-bughiu/Plugin.AdMob#78

Problem

The IMediaContent interface was not being generated because it contained obfuscated methods (zza(), zzb()) that referenced internal types (com.google.android.gms.internal.ads.zzbfs). This caused the binding generator to skip the entire interface.

As a result, the MediaContent property on NativeAd, MediaView, and related classes was unavailable to .NET developers.

Solution

Added <remove-node> rules to the Metadata.xml transform files to exclude the problematic obfuscated methods from the MediaContent interface:

<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zza']" />
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zzb']" />

New API Surface

Android.Gms.Ads.IMediaContent interface with:

  • AspectRatio
  • CurrentTime
  • Duration
  • HasVideoContent
  • MainImage
  • VideoController

MediaContent property now available on:

  • NativeAd
  • MediaView
  • INativeCustomFormatAd

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts binding metadata for Google Play Services Ads so MediaContent / IMediaContent is generated again (by removing problematic obfuscated members), restoring expected managed API surface for native ads.

Changes:

  • Add remove-node rules for com.google.android.gms.ads.MediaContent.zza/zzb in Ads and Ads.Lite Metadata transforms.
  • Update play-services-ads-lite PublicAPI baseline to include Android.Gms.Ads.IMediaContent and related native-ad APIs.
  • PublicAPI baseline updates also appear in unrelated packages (kotlinx-* and ads-identifier).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
source/com.google.android.gms/play-services-ads/Transforms/Metadata.xml Adds targeted removals for MediaContent.zza/zzb (but duplicates an existing broad zz* method removal rule).
source/com.google.android.gms/play-services-ads-lite/Transforms/Metadata.xml Adds targeted removals for MediaContent.zza/zzb to prevent interface generation from being blocked.
source/com.google.android.gms/play-services-ads-lite/PublicAPI/PublicAPI.Unshipped.txt Records newly generated IMediaContent and native-ad related API surface in the public API baseline.
source/org.jetbrains.kotlinx/kotlinx-serialization-core-jvm/PublicAPI/PublicAPI.Unshipped.txt Adds new KotlinX.Serialization API entries (not described by the PR).
source/org.jetbrains.kotlinx/atomicfu-jvm/PublicAPI/PublicAPI.Unshipped.txt Adds new AtomicFU API entries (not described by the PR).
source/com.google.android.gms/play-services-ads-identifier/PublicAPI/PublicAPI.Unshipped.txt Swaps obfuscated method signatures in the public API baseline (not described by the PR).

Comment on lines +10 to +11
Google.Ads.Identifier.AdvertisingIdClient.Zza(bool p0) -> void
Google.Ads.Identifier.AdvertisingIdClient.Zzc() -> void
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes the public API baseline for play-services-ads-identifier by swapping the Zza/Zzc signatures. This isn’t mentioned in the PR description and seems unrelated to the MediaContent binding fix; please confirm it’s intentional (and backed by updated bindings) or revert/split it to avoid accidental API churn.

Copilot uses AI. Check for mistakes.
Comment on lines +114 to +118
<!-- MediaContent API bindings -->
<!-- Remove obfuscated methods from MediaContent interface that reference internal types -->
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zza']" />
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zzb']" />

Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this Metadata.xml you already have a global <remove-node path="/api/*/*/method[contains(@name, 'zz')]" /> rule (line 40) which should remove MediaContent.zza/zzb as well. These new remove-node entries are redundant and may confuse future maintainers about which rule is actually required; consider removing the duplicate rules or narrowing/removing the global rule and keeping only the targeted removals.

Suggested change
<!-- MediaContent API bindings -->
<!-- Remove obfuscated methods from MediaContent interface that reference internal types -->
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zza']" />
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zzb']" />

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marius-bughiu this is kind of what I thought as well, do the new <remove-node/> entries added here, not actually do anything?

Comment on lines 228 to 232
KotlinX.Serialization.MissingFieldException.MissingFieldException(System.Collections.Generic.IList<string!>! missingFields, string? message, Java.Lang.Throwable? cause) -> void
KotlinX.Serialization.MissingFieldException.MissingFieldException(string! missingField, string! serialName) -> void
KotlinX.Serialization.MissingFieldException.MissingFields.get -> System.Collections.Generic.IList<string!>!
KotlinX.Serialization.MissingFieldException.SerialName.get -> string?
KotlinX.Serialization.Modules.ISerializersModuleCollector
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These PublicAPI baseline additions for KotlinX.Serialization (e.g., MissingFieldException.SerialName / new PolymorphicModuleBuilder API) are not mentioned in the PR description and appear unrelated to the MediaContent binding fix. If these are not intentional version/API updates, please revert them or move them into a separate PR to keep review/release notes scoped.

Copilot uses AI. Check for mistakes.
Comment on lines 239 to 244
KotlinX.Serialization.Modules.PolymorphicModuleBuilder
KotlinX.Serialization.Modules.PolymorphicModuleBuilder.Default(Kotlin.Jvm.Functions.IFunction1! defaultSerializerProvider) -> void
KotlinX.Serialization.Modules.PolymorphicModuleBuilder.DefaultDeserializer(Kotlin.Jvm.Functions.IFunction1! defaultDeserializerProvider) -> void
KotlinX.Serialization.Modules.PolymorphicModuleBuilder.Subclass(Kotlin.Reflect.IKClass! subclass, KotlinX.Serialization.IKSerializer! serializer) -> void
KotlinX.Serialization.Modules.PolymorphicModuleBuilder.SubclassesOfSealed(KotlinX.Serialization.IKSerializer! serializer) -> void
KotlinX.Serialization.Modules.PolymorphicModuleBuilderKt
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new SubclassesOfSealed(...) API entry in KotlinX.Serialization is not described by the PR and seems unrelated to the MediaContent binding work. If it is unintended (e.g., from regenerating PublicAPI files), please revert or split it into a dedicated PR for that package.

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +81
KotlinX.AtomicFU.Locks.SynchronousMutex
KotlinX.AtomicFU.Locks.SynchronousMutex.Lock() -> void
KotlinX.AtomicFU.Locks.SynchronousMutex.SynchronousMutex() -> void
KotlinX.AtomicFU.Locks.SynchronousMutex.TryLock() -> bool
KotlinX.AtomicFU.Locks.SynchronousMutex.TryLock(long timeout) -> bool
KotlinX.AtomicFU.Locks.SynchronousMutex.Unlock() -> void
KotlinX.AtomicFU.Locks.SynchronousMutexKt
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These KotlinX.AtomicFU PublicAPI baseline additions (new SynchronousMutex types/members) are not mentioned in the PR description and appear unrelated to the MediaContent binding fix. If they are not intentional API updates for atomicfu-jvm, please revert or move them to a separate PR.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeCustomFormatAd and related types missing from Ads/Ads.Lite

2 participants