Skip to content

Duplicate Java Callable Wrapper names are allowed when they shouldn't be. #2266

@jonpryor

Description

@jonpryor

Steps to Reproduce

  1. Create a solution consisting of three projects: App.csproj, Lib1.csproj, Lib2.csproj, in which App.csproj references both Lib1.csproj and Lib2.csproj.

  2. Add the following file to both Lib1.csproj and Lib2.csproj:

    using System;
    using Android.Runtime;
    
    namespace Lib1
    {
      [Register("examplelib.EmptyClass")]
      public class EmptyClass : Java.Lang.Object
      {
      }
    }
  3. Create an .apk: msbuild /t:SignAndroidPackage App.csproj

Expected Behavior

It should error out, as we have two assemblies which will each generate an example lib.EmptyClass Java type.

Actual Behavior

Warnings:

warning : Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Lib1.EmptyClass, Lib1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Lib1.EmptyClass, Lib2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
warning : References to the type 'Lib1.EmptyClass' will refer to 'Lib1.EmptyClass, Lib1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Discussion:

The warning is correct, in that it should be emitted. However, because we emit that warning, we don't check for duplicate Java Callable Wrapper names. The problem is here:

https://github.com/xamarin/xamarin-android/blob/5c80b4b260981cf16d74cdcbc8dfc4215c01ec83/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs#L188

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions