Skip to content

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

Closed

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

Activity

  1. added this to the d16-0 milestone on Oct 8, 2018
  2. jonathanpeppers commented on Oct 8, 2018

    @jonathanpeppers
    Member

    I started working on this as an "easy win" during triage today, but @brendanzagaeski should probably finish this up: master...jonathanpeppers:dupe-jcws

    As part of: #2258 (comment)

  3. ghost locked as resolved and limited conversation to collaborators on Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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