Skip to content

ArrayTypeMismatchException when using array of generic ICollection<T> or IList<T> #1120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MaasOne opened this issue Dec 16, 2017 · 1 comment

Comments

@MaasOne
Copy link

MaasOne commented Dec 16, 2017

Steps to Reproduce

  1. Use the following test interface and class
public interface IFoo
{
    int MyInt { get; }
}

public class Bar : IFoo
{
    public int MyInt => 0;
}
  1. Use the following test code for reproducing the exception
ICollection<IFoo> arr1 = new Bar[1] { new Bar() };
ICollection<IFoo> arr2 = new Bar[1] { new Bar() };

ICollection<IFoo>[] a2d = new ICollection<IFoo>[2] { arr1, arr2 }; //ArrayTypeMismatchException
  1. Try the same test code with IList<T>
IList<IFoo> arr1 = new Bar[1] { new Bar() };
IList<IFoo> arr2 = new Bar[1] { new Bar() };

IList<IFoo>[] a2d = new IList<IFoo>[2] { arr1, arr2 }; //ArrayTypeMismatchException

Expected Behavior

Expected no exception throwing.

Actual Behavior

Throws an ArrayTypeMismatchException at last line of test code at runtime when using ICollection<T> or IList<T>.
The following types are working properly as expected:
IEnumerable
IEnumerable<T>
ICollection
IList
Code is compiling successfully with all types.

Version Information

Visual Studio: 15.5.2
Mono: MonoAndroid70 / 4.0.30319 / 8.1.0.25
Android: 7.0
Kernel: 4.1.18-gdd36b34

Log File

at (wrapper stelemref) System.Object:virt_stelemref_interface (intptr,object)

@jonpryor
Copy link
Member

Moved to: mono/mono#6266

jonpryor pushed a commit that referenced this issue Oct 28, 2020
Fixes: xamarin/monodroid#1121
Fixes: xamarin/monodroid#1123

Changes: http://github.com/xamarin/monodroid/compare/767f647151936303c294d154d0d0a4da8b601464...04b0423ea298eda7263ba23e64df63c940ebddad

  * xamarin/monodroid@04b0423ea: Bump android-sdk-installer, androidtools, xamarin-android (#1128)
  * xamarin/monodroid@b0f824253: [tools/msbuild] Update RunActivity to use Async methods. (#1127)
  * xamarin/monodroid@ad6ea2a3c: [tools/msbuild] changes not deployed in some cases (#1125)
  * xamarin/monodroid@dfa0cba44: [tools/msbuild] Add check for 'ro.boot.disable_runas' (#1124)
  * xamarin/monodroid@3f2ca1173: [tools/msbuild] Add additional timing information for FastDeploy. (#1126)
  * xamarin/monodroid@d47db99c7: [tools/msbuild] fix _Run target for .NET 6 (#1118)
  * xamarin/monodroid@49a6dd572: Bump to xamarin/xamarin-android/master@e0999a43 (#1120)
@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants