public void GetGenericNestedTypeOfBoundGenericClass() { // class A<X> { class B<Y> { } } DefaultUnresolvedTypeDefinition a = new DefaultUnresolvedTypeDefinition(string.Empty, "A"); a.TypeParameters.Add(new DefaultUnresolvedTypeParameter(EntityType.TypeDefinition, 0, "X")); DefaultUnresolvedTypeDefinition b = new DefaultUnresolvedTypeDefinition(a, "B"); b.TypeParameters.Add(a.TypeParameters[0]); b.TypeParameters.Add(new DefaultUnresolvedTypeParameter(EntityType.TypeDefinition, 1, "Y")); a.NestedTypes.Add(b); var compilation = TypeSystemHelper.CreateCompilation(a, b); ITypeDefinition resolvedA = compilation.MainAssembly.GetTypeDefinition(a.FullTypeName); ITypeDefinition resolvedB = compilation.MainAssembly.GetTypeDefinition(b.FullTypeName); // A<> gets self-parameterized, B<> stays unbound Assert.AreEqual("A`1+B`1[[`0],[]]", resolvedA.GetNestedTypes().Single().ReflectionName); ParameterizedType pt = new ParameterizedType(resolvedA, new [] { compilation.FindType(KnownTypeCode.String) }); Assert.AreEqual("A`1+B`1[[System.String],[]]", pt.GetNestedTypes().Single().ReflectionName); }
public void GetGenericNestedTypeOfBoundGenericClass() { // class A<X> { class B<Y> { } } DefaultTypeDefinition a = new DefaultTypeDefinition(mscorlib, string.Empty, "A"); a.TypeParameters.Add(new DefaultTypeParameter(EntityType.TypeDefinition, 0, "X")); DefaultTypeDefinition b = new DefaultTypeDefinition(a, "B"); b.TypeParameters.Add(a.TypeParameters[0]); b.TypeParameters.Add(new DefaultTypeParameter(EntityType.TypeDefinition, 1, "Y")); a.NestedTypes.Add(b); // A<> gets self-parameterized, B<> stays unbound Assert.AreEqual("A`1+B`1[[`0],[]]", a.GetNestedTypes(mscorlib).Single().ReflectionName); ParameterizedType pt = new ParameterizedType(a, new [] { KnownTypeReference.String.Resolve(mscorlib) }); Assert.AreEqual("A`1+B`1[[System.String],[]]", pt.GetNestedTypes(mscorlib).Single().ReflectionName); }
public void GetGenericNestedTypeOfBoundGenericClass() { // class A<X> { class B<Y> { } } DefaultUnresolvedTypeDefinition a = new DefaultUnresolvedTypeDefinition(string.Empty, "A"); a.TypeParameters.Add(new DefaultUnresolvedTypeParameter(SymbolKind.TypeDefinition, 0, "X")); DefaultUnresolvedTypeDefinition b = new DefaultUnresolvedTypeDefinition(a, "B"); b.TypeParameters.Add(a.TypeParameters[0]); b.TypeParameters.Add(new DefaultUnresolvedTypeParameter(SymbolKind.TypeDefinition, 1, "Y")); a.NestedTypes.Add(b); var compilation = TypeSystemHelper.CreateCompilation(a, b); ITypeDefinition resolvedA = compilation.MainAssembly.GetTypeDefinition(a.FullTypeName); ITypeDefinition resolvedB = compilation.MainAssembly.GetTypeDefinition(b.FullTypeName); // A<> gets self-parameterized, B<> stays unbound Assert.AreEqual("A`1+B`1[[`0],[]]", resolvedA.GetNestedTypes().Single().ReflectionName); ParameterizedType pt = new ParameterizedType(resolvedA, new [] { compilation.FindType(KnownTypeCode.String) }); Assert.AreEqual("A`1+B`1[[System.String],[]]", pt.GetNestedTypes().Single().ReflectionName); }