Skip to content

Conversation

@mattleibow
Copy link
Member

This pull request adds support for two new ML Kit GenAI libraries (genai-common and genai-prompt) to the project, including their configuration, API surface, and metadata transforms. The changes introduce the necessary NuGet package entries, public API definitions, and enum mappings to enable usage of Google's GenAI features in Xamarin. The most important changes are grouped below:

Configuration and Package Integration:

  • Added new entries for Xamarin.Google.MLKit.GenAI.Common and Xamarin.Google.MLKit.GenAI.Prompt to config.json, specifying their group IDs, artifact IDs, versions, NuGet IDs, and types.

Public API Exposure:

  • Introduced PublicAPI.Unshipped.txt files for both genai-common and genai-prompt, declaring all new types, methods, properties, and enums exposed by the GenAI libraries. This includes classes like AudioSource, BaseOptions, GenAiException, IGenerativeModel, GenerateContentRequest, and many more. [1] [2]
  • Enabled nullable reference types in the PublicAPI.Shipped.txt for both GenAI libraries to improve null safety and code clarity.

Enum and Metadata Mapping:

  • Added EnumFields.xml to map the GenAiErrorCode enum between CLR and JNI names/values for proper interop.
  • Added EnumMethods.xml to map methods that use the GenAiErrorCode enum in GenAiException.
  • Added Metadata.xml to remove unused internal classes and resolve naming conflicts for the GenAI exception error code interface.

@moljac
Copy link
Contributor

moljac commented Nov 4, 2025

@mattleibow

========================================
verify-namespace-file
========================================
New Namespaces
--------------
Google.MLKit.GenAI.Common
Google.MLKit.GenAI.Common.Audio
Google.MLKit.GenAI.Prompt
Google.MLKit.GenAI.Prompt.Java

An error occurred when executing task 'verify-namespace-file'.

----------------------------------------
TearDown
----------------------------------------
     #TimingDataStopwatch,  20251104-052209.05,                   verify-namespace-file,         00:00:20.3795553
          #TimingDataCake,  20251104-052209.05,                   verify-namespace-file,         00:00:20.3787197
Error: Namespaces were added or removed.
please run:
    dotnet cake utilities.cake -t=generate-namespace-file

@mattleibow
Copy link
Member Author

@copilot please do what @moljac said and run

dotnet cake utilities.cake -t=generate-namespace-file

Copy link
Contributor

Copilot AI commented Nov 4, 2025

@mattleibow I've opened a new pull request, #1313, to work on those changes. Once the pull request is ready, I'll request review from you.

@moljac
Copy link
Contributor

moljac commented Nov 4, 2025

@mattleibow What powers do I need to become LLM Whisperer?

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@mattleibow
Copy link
Member Author

Not sure, i thiunk copilot is having issues because it did nothing.

@moljac
Copy link
Contributor

moljac commented Nov 4, 2025

Not sure, i thiunk copilot is having issues because it did nothing.

Mental health?

Removed 'Google.MLKit.GenAI.Common.Internal' from the list.
@mattleibow mattleibow requested review from Copilot and jonathanpeppers and removed request for Copilot November 5, 2025 02:05
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

This PR adds .NET bindings for two new Google ML Kit GenAI packages: com.google.mlkit:genai-common and com.google.mlkit:genai-prompt. These enable on-device generative AI capabilities in .NET for Android applications.

Key changes:

  • Added bindings for ML Kit GenAI Common (v1.0.0-beta2) and GenAI Prompt (v1.0.0-alpha1) libraries
  • Configured enum mappings for error codes and finish reasons
  • Applied metadata transforms to handle Kotlin-specific constructs and naming conventions
  • Registered new namespaces for the bindings

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config.json Added two new artifact entries for genai-common and genai-prompt packages
source/com.google.mlkit/genai-common/Transforms/Metadata.xml Metadata transforms to remove Kotlin helpers, rename types, and clean up generated API
source/com.google.mlkit/genai-common/Transforms/EnumMethods.xml Maps GenAIException methods to use GenAIErrorCode enum type
source/com.google.mlkit/genai-common/Transforms/EnumFields.xml Defines GenAIErrorCode enum values from Java interface constants
source/com.google.mlkit/genai-common/PublicAPI/PublicAPI.Unshipped.txt Public API surface for genai-common package
source/com.google.mlkit/genai-common/PublicAPI/PublicAPI.Shipped.txt Placeholder for shipped API (empty)
source/com.google.mlkit/genai-prompt/Transforms/Metadata.xml Metadata transforms for prompt API including companion object handling
source/com.google.mlkit/genai-prompt/Transforms/EnumMethods.xml Maps Candidate.getFinishReason to use CandidateFinishReason enum
source/com.google.mlkit/genai-prompt/Transforms/EnumFields.xml Defines CandidateFinishReason enum values
source/com.google.mlkit/genai-prompt/PublicAPI/PublicAPI.Unshipped.txt Public API surface for genai-prompt package
source/com.google.mlkit/genai-prompt/PublicAPI/PublicAPI.Shipped.txt Placeholder for shipped API (empty)
published-namespaces.txt Added four new namespace entries for the GenAI bindings

mattleibow and others added 2 commits November 5, 2025 16:13
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.

4 participants