[Mono-bugs] [Bug 473186] New: Incorrect generic parameter declaring type for recursively nested generic types.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Feb 6 03:55:53 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=473186


           Summary: Incorrect generic parameter declaring type for
                    recursively nested generic types.
    Classification: Mono
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: x86
               URL: http:///
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Cecil
        AssignedTo: jbevain at novell.com
        ReportedBy: jeff.brown at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Description of Problem:

The wrong generic parameters under certain conditions involving nested
inherited generic types.


Given the following type declaration:

(This code appears in a test of the Gallio Test Automation Platform reflection
layer.)

    public class ReflectionPolicySample
    {
        public class TortureTest<T>
        {
            public class NestedType
            {
                public class DirectlyRecursiveNestedType : NestedType
                {
                }

                public class MiddleType
                {
                    public class IndirectlyRecursiveNestedType : NestedType
                    {
                    }
                }
            }
        }
     }

Then:

TypeReference type = ... grab type reference of IndirectlyRecursiveNestedType
..
TypeReference baseType = type.BaseType;
GenericParameter genericParam = baseType.GenericParameters[0];
TypeReference ownerType = genericParam.Owner as TypeReference;

Actual Results:

ownerType.FullName ==
"MbUnit.TestResources.Reflection.ReflectionPolicySample/TortureTest`1/NestedType/DirectlyRecursiveNestedType"

Expected Results:

ownerType.FullName ==
"MbUnit.TestResources.Reflection.ReflectionPolicySample/TortureTest`1/NestedType/MiddleType/IndirectlyRecursiveNestedType"

How often does this happen? 

Always.

Additional Information:

Yes this is a very weird case but it causes problems because the wrong generic
type parameter is being returned here.  IndirectlyRecursiveNestedType is
completely unrelated to DirectlyRecursiveNestedType yet its generic parameter
type is being returned.

It's not clear to me whether the problem is related to the inheritance of a
declaring type within a nested type or if it's some bad / ambiguous lookup
metadata code in Cecil.

Hope this makes sense.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list