Bug 32815

Summary: PropertyInfo.Module throws System.NotImplementedException
Product: [Mono] Class Libraries Reporter: Artur Grzegorzewicz <artur.grzegorzewicz>
Component: mscorlibAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: masafa, mono-bugs+mono
Priority: ---    
Version: master   
Target Milestone: Untriaged   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Artur Grzegorzewicz 2015-08-06 03:59:23 UTC
While testing FluentNhibernate on Linux I've noticed that it throws System.NotImplementedException at  at System.Reflection.MemberInfo.get_Module (). It is working fine on .NET though.

The root cause of this is the implementation of their MemberEqualityComparer:

https://github.com/jagregory/fluent-nhibernate/commit/989ff8d686d76763f25b120f67b49c3aa7e04185

I was able to reproduce it using minimal test case (see code below):

using System;
using System.Reflection;

class Program
{
        class Test
        {
                public int TestProperty { get; set; }
        }

        static void Main(string[] args)
        {
                var i1 = typeof(Test).GetProperty("TestProperty");
                var i2 = typeof(Test).GetProperty("TestProperty");

                Console.WriteLine(Compare(i1, i2));
        }

        static public bool Compare(MemberInfo x, MemberInfo y)
        {
                return x.MetadataToken.Equals(y.MetadataToken) && x.Module.Equals(y.Module);
        }
}

Mono JIT compiler version 4.3.0 (Nightly 4.3.0.723/8f7b98b Tue Aug  4 09:31:21 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
  at System.Reflection.MemberInfo.get_Module () <0x7ff47ffb3e10 + 0x00095> in <filename unknown>:0
  at Program.Compare (System.Reflection.MemberInfo x, System.Reflection.MemberInfo y) <0x4102da60 + 0x00057> in <filename unknown>:0
  at Program.Main (System.String[] args) <0x4102cd40 + 0x00073> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: The method or operation is not implemented.
  at System.Reflection.MemberInfo.get_Module () <0x7ff47ffb3e10 + 0x00095> in <filename unknown>:0
  at Program.Compare (System.Reflection.MemberInfo x, System.Reflection.MemberInfo y) <0x4102da60 + 0x00057> in <filename unknown>:0
  at Program.Main (System.String[] args) <0x4102cd40 + 0x00073> in <filename unknown>:0
Comment 1 Marek Safar 2015-08-10 07:05:50 UTC
Fixed in master and Mono 4.2