Skip to content

[build] Drop unused protobuf-net references from Mono.AndroidTools#11592

Open
jonathanpeppers wants to merge 1 commit into
mainfrom
jonathanpeppers/drop-protobuf-from-mono-androidtools
Open

[build] Drop unused protobuf-net references from Mono.AndroidTools#11592
jonathanpeppers wants to merge 1 commit into
mainfrom
jonathanpeppers/drop-protobuf-from-mono-androidtools

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Summary

PR #11529 inlined Mono.AndroidTools from android-platform-support, which carried PackageReferences to protobuf-net 3.2.26 and protobuf-net.Core 3.2.26. The original consumer of these packages was the native tools/base/deploy/installer binary, which was removed in the same PR. None of the inlined managed code (Mono.AndroidTools, Xamarin.AndroidTools, Xamarin.Installer.*, Xamarin.Android.Build.Debugging.Tasks) actually uses the ProtoBuf namespace, [ProtoContract] / [ProtoMember] attributes, or Serializer.* calls — so the references are dead weight.

The actual bug

The unused references were also breaking class-parse's Kotlin metadata parsing on every PR build:

class-parse : warning : Unable to parse Kotlin metadata on 'Utf8("foo/UnsignedInstanceMethods")':
System.IO.FileNotFoundException: Could not load file or assembly
'protobuf-net.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67'.

…manifesting downstream as:

KotlinUnsignedTypesTests.cs(17,64): error CS1503: Argument 1: cannot convert from 'uint' to 'int'
KotlinUnsignedTypesTests.cs(20,35): error CS0266: Cannot implicitly convert type 'uint' to 'int'.
…

Mono.AndroidTools.csproj outputs to $(MicrosoftAndroidSdkOutDir), where it dropped a v3 protobuf-net.dll (a thin facade) that overwrote the v2 self-contained DLL shipped by Java.Interop's Xamarin.Android.Tools.Bytecode (pinned to protobuf-net 2.4.4). Because protobuf-net.Core.dll was never added to the SDK pack file lists in build-tools/installers/create-installers.targets or Microsoft.Android.Sdk.proj, class-parse failed at runtime and KotlinFixups.Fixup silently skipped Kotlin metadata. Bindings then regenerated unsigned types as their signed counterparts, breaking the hand-written KotlinUnsignedTypesTests.cs.

Fix

Drop the v3 references from src/Mono.AndroidTools/Mono.AndroidTools.csproj (both the PackageReferences and the dependent NuGetFilesToSign group), and the now-unused ProtobufNetVersion / ProtobufNetCoreVersion properties from Directory.Build.props. The v2 protobuf-net.dll from Java.Interop's class-parse becomes the only protobuf-net.dll in $(MicrosoftAndroidSdkOutDir) again, restoring Kotlin metadata parsing.

The existing entries that ship the v2 DLL into the SDK pack — _MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)protobuf-net.dll" in build-tools/installers/create-installers.targets and <ThirdParty Include="protobuf-net.dll" /> in build-tools/create-packs/SignList.xml, both added by #5529 — continue to do their job.

Verification

  • Audited src/Mono.AndroidTools and all transitive consumers: zero usage of using ProtoBuf, [Proto*] attributes, or Serializer.* calls.
  • dotnet restore src/Mono.AndroidTools/Mono.AndroidTools.csproj completes cleanly with no transitive protobuf-net resolution.
  • KotlinUnsignedTypesTests.cs should compile and pass once class-parse can again deserialize Kotlin metadata.

PR #11529 inlined `Mono.AndroidTools` from android-platform-support, which carried PackageReferences to `protobuf-net` 3.2.26 and `protobuf-net.Core` 3.2.26. The original consumer of these packages was the native `tools/base/deploy/installer` binary, which was removed in the same PR. None of the inlined managed code (`Mono.AndroidTools`, `Xamarin.AndroidTools`, `Xamarin.Installer.*`, `Xamarin.Android.Build.Debugging.Tasks`) actually uses the `ProtoBuf` namespace, `[ProtoContract]` / `[ProtoMember]` attributes, or `Serializer.*` calls — so the references are dead weight.

More importantly, they were actively breaking `class-parse`'s Kotlin metadata parsing. `Mono.AndroidTools.csproj` outputs to `MicrosoftAndroidSdkOutDir`, where it dropped a v3 `protobuf-net.dll` (a thin facade) that overwrote the v2 self-contained DLL shipped by Java.Interop's `Xamarin.Android.Tools.Bytecode`. Because `protobuf-net.Core.dll` is not packed into the SDK pack, `class-parse` failed at runtime with `FileNotFoundException: Could not load file or assembly 'protobuf-net.Core, Version=3.0.0.0...'`, and `KotlinFixups.Fixup` silently skipped Kotlin metadata. Bindings then regenerated unsigned types as their signed counterparts, breaking `KotlinUnsignedTypesTests.cs` with CS1503/CS0266 errors.

Drop the v3 references from `Mono.AndroidTools.csproj` and the now-unused `ProtobufNetVersion` / `ProtobufNetCoreVersion` properties from `Directory.Build.props`. The v2 `protobuf-net.dll` from Java.Interop's class-parse becomes the only one in `MicrosoftAndroidSdkOutDir`, restoring Kotlin metadata parsing. The existing `_MSBuildFiles Include=...protobuf-net.dll` and `SignList.xml` `ThirdParty` entry (added in #5529) continue to ship the v2 DLL into the SDK pack.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 20:08
Copy link
Copy Markdown
Contributor

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

Removes unused protobuf-net v3 package references from the inlined Mono.AndroidTools project to avoid polluting $(MicrosoftAndroidSdkOutDir) with an incompatible protobuf-net.dll, restoring class-parse runtime behavior (Kotlin metadata parsing) and preventing downstream binding/test failures.

Changes:

  • Dropped protobuf-net / protobuf-net.Core PackageReferences from src/Mono.AndroidTools/Mono.AndroidTools.csproj, along with the corresponding Release-only NuGetFilesToSign entries.
  • Removed the now-dead ProtobufNetVersion / ProtobufNetCoreVersion properties from Directory.Build.props.
  • Verified via repository search that no other MSBuild files still reference these removed properties or packages.

Reviewed changes

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

File Description
src/Mono.AndroidTools/Mono.AndroidTools.csproj Removes unused protobuf-net v3 package references and related signing inputs so the project no longer outputs the conflicting facade DLL into the SDK tools output directory.
Directory.Build.props Deletes unused protobuf-net version properties after removing the only consumer.

@jonathanpeppers
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants