1919using System ;
2020using System . Collections . Generic ;
2121using System . Linq ;
22- using System . Reflection ;
2322
2423using ICSharpCode . Decompiler . TypeSystem ;
2524using ICSharpCode . Decompiler . TypeSystem . Implementation ;
@@ -71,90 +70,74 @@ public void TestGetInnerClassInGenericClass2()
7170 }
7271
7372 [ Test ]
74- public void TestToTypeReferenceInnerClass ( )
73+ public void TestFindTypeReflectionNameInnerClass ( )
7574 {
7675 Assert . That ( compilation . FindType ( typeof ( Environment . SpecialFolder ) ) . ReflectionName , Is . EqualTo ( "System.Environment+SpecialFolder" ) ) ;
7776 }
7877
7978 [ Test ]
80- public void TestToTypeReferenceUnboundGenericClass ( )
79+ public void TestFindTypeReflectionNameUnboundGenericClass ( )
8180 {
8281 Assert . That ( compilation . FindType ( typeof ( Action < > ) ) . ReflectionName , Is . EqualTo ( "System.Action`1" ) ) ;
8382 Assert . That ( compilation . FindType ( typeof ( Action < , > ) ) . ReflectionName , Is . EqualTo ( "System.Action`2" ) ) ;
8483 }
8584
8685 [ Test ]
87- public void TestToTypeReferenceBoundGenericClass ( )
86+ public void TestFindTypeReflectionNameBoundGenericClass ( )
8887 {
8988 Assert . That ( compilation . FindType ( typeof ( Action < string > ) ) . ReflectionName , Is . EqualTo ( "System.Action`1[[System.String]]" ) ) ;
9089 Assert . That ( compilation . FindType ( typeof ( Action < int , short > ) ) . ReflectionName , Is . EqualTo ( "System.Action`2[[System.Int32],[System.Int16]]" ) ) ;
9190 }
9291
9392
9493 [ Test ]
95- public void TestToTypeReferenceNullableType ( )
94+ public void TestFindTypeReflectionNameNullableType ( )
9695 {
9796 Assert . That ( compilation . FindType ( typeof ( int ? ) ) . ReflectionName , Is . EqualTo ( "System.Nullable`1[[System.Int32]]" ) ) ;
9897 }
9998
10099 [ Test ]
101- public void TestToTypeReferenceInnerClassInUnboundGenericType ( )
100+ public void TestFindTypeReflectionNameInnerClassInUnboundGenericType ( )
102101 {
103102 Assert . That ( compilation . FindType ( typeof ( Dictionary < , > . ValueCollection ) ) . ReflectionName , Is . EqualTo ( "System.Collections.Generic.Dictionary`2+ValueCollection" ) ) ;
104103 }
105104
106105 [ Test ]
107- public void TestToTypeReferenceInnerClassInBoundGenericType ( )
106+ public void TestFindTypeReflectionNameInnerClassInBoundGenericType ( )
108107 {
109108 Assert . That ( compilation . FindType ( typeof ( Dictionary < string , int > . KeyCollection ) ) . ReflectionName , Is . EqualTo ( "System.Collections.Generic.Dictionary`2+KeyCollection[[System.String],[System.Int32]]" ) ) ;
110109 }
111110
112111 [ Test ]
113- public void TestToTypeReferenceArrayType ( )
112+ public void TestFindTypeReflectionNameArrayType ( )
114113 {
115114 Assert . That ( compilation . FindType ( typeof ( int [ ] ) ) . ReflectionName , Is . EqualTo ( typeof ( int [ ] ) . FullName ) ) ;
116115 }
117116
118117 [ Test ]
119- public void TestToTypeReferenceMultidimensionalArrayType ( )
118+ public void TestFindTypeReflectionNameMultidimensionalArrayType ( )
120119 {
121120 Assert . That ( compilation . FindType ( typeof ( int [ , ] ) ) . ReflectionName , Is . EqualTo ( typeof ( int [ , ] ) . FullName ) ) ;
122121 }
123122
124123 [ Test ]
125- public void TestToTypeReferenceJaggedMultidimensionalArrayType ( )
124+ public void TestFindTypeReflectionNameJaggedMultidimensionalArrayType ( )
126125 {
127126 Assert . That ( compilation . FindType ( typeof ( int [ , ] [ , , ] ) ) . ReflectionName , Is . EqualTo ( typeof ( int [ , ] [ , , ] ) . FullName ) ) ;
128127 }
129128
130129 [ Test ]
131- public void TestToTypeReferencePointerType ( )
130+ public void TestFindTypeReflectionNamePointerType ( )
132131 {
133132 Assert . That ( compilation . FindType ( typeof ( int * ) ) . ReflectionName , Is . EqualTo ( typeof ( int * ) . FullName ) ) ;
134133 }
135134
136135 [ Test ]
137- public void TestToTypeReferenceByReferenceType ( )
136+ public void TestFindTypeReflectionNameByReferenceType ( )
138137 {
139138 Assert . That ( compilation . FindType ( typeof ( int ) . MakeByRefType ( ) ) . ReflectionName , Is . EqualTo ( typeof ( int ) . MakeByRefType ( ) . FullName ) ) ;
140139 }
141140
142- [ Test ]
143- public void TestToTypeReferenceGenericType ( )
144- {
145- MethodInfo convertAllInfo = typeof ( List < > ) . GetMethod ( "ConvertAll" ) ;
146- ITypeReference parameterType = convertAllInfo . GetParameters ( ) [ 0 ] . ParameterType . ToTypeReference ( ) ; // Converter[[`0],[``0]]
147- // cannot resolve generic types without knowing the parent entity:
148- IType resolvedWithoutEntity = parameterType . Resolve ( new SimpleTypeResolveContext ( compilation ) ) ;
149- Assert . That ( resolvedWithoutEntity . ReflectionName , Is . EqualTo ( "System.Converter`2[[`0],[``0]]" ) ) ;
150- Assert . That ( ( ( ITypeParameter ) ( ( ParameterizedType ) resolvedWithoutEntity ) . GetTypeArgument ( 0 ) ) . Owner , Is . Null ) ;
151- // now try with parent entity:
152- IMethod convertAll = compilation . FindType ( typeof ( List < > ) ) . GetMethods ( m => m . Name == "ConvertAll" ) . Single ( ) ;
153- IType resolvedWithEntity = parameterType . Resolve ( new SimpleTypeResolveContext ( convertAll ) ) ;
154- Assert . That ( resolvedWithEntity . ReflectionName , Is . EqualTo ( "System.Converter`2[[`0],[``0]]" ) ) ;
155- Assert . That ( ( ( ITypeParameter ) ( ( ParameterizedType ) resolvedWithEntity ) . GetTypeArgument ( 0 ) ) . Owner , Is . SameAs ( convertAll . DeclaringTypeDefinition ) ) ;
156- }
157-
158141 [ Test ]
159142 public void ParseReflectionName ( )
160143 {
@@ -204,21 +187,21 @@ public void ParseInvalidReflectionName1()
204187 public void ParseInvalidReflectionName2 ( )
205188 {
206189 var context = new SimpleTypeResolveContext ( compilation . MainModule ) ;
207- Assert . Throws < ReflectionNameParseException > ( ( ) => ReflectionHelper . ParseReflectionName ( "`" , context ) ) ;
190+ Assert . That ( ReflectionHelper . ParseReflectionName ( "`" , context ) . ReflectionName , Is . EqualTo ( "`" ) ) ;
208191 }
209192
210193 [ Test ]
211194 public void ParseInvalidReflectionName3 ( )
212195 {
213196 var context = new SimpleTypeResolveContext ( compilation . MainModule ) ;
214- Assert . Throws < ReflectionNameParseException > ( ( ) => ReflectionHelper . ParseReflectionName ( "``" , context ) ) ;
197+ Assert . That ( ReflectionHelper . ParseReflectionName ( "``" , context ) . ReflectionName , Is . EqualTo ( "``" ) ) ;
215198 }
216199
217200 [ Test ]
218201 public void ParseInvalidReflectionName4 ( )
219202 {
220203 var context = new SimpleTypeResolveContext ( compilation . MainModule ) ;
221- Assert . Throws < ReflectionNameParseException > ( ( ) => ReflectionHelper . ParseReflectionName ( "System.Action`A" , context ) ) ;
204+ Assert . That ( ReflectionHelper . ParseReflectionName ( "System.Action`A" , context ) . ReflectionName , Is . EqualTo ( "System.Action`A" ) ) ;
222205 }
223206
224207 [ Test ]
@@ -232,7 +215,7 @@ public void ParseInvalidReflectionName5()
232215 public void ParseInvalidReflectionName5b ( )
233216 {
234217 var context = new SimpleTypeResolveContext ( compilation . MainModule ) ;
235- Assert . Throws < ReflectionNameParseException > ( ( ) => ReflectionHelper . ParseReflectionName ( "System.Environment+`" , context ) ) ;
218+ Assert . That ( ReflectionHelper . ParseReflectionName ( "System.Environment+`" , context ) . ReflectionName , Is . EqualTo ( "System.Environment+`" ) ) ;
236219 }
237220
238221 [ Test ]
@@ -246,7 +229,7 @@ public void ParseInvalidReflectionName6()
246229 public void ParseInvalidReflectionName7 ( )
247230 {
248231 var context = new SimpleTypeResolveContext ( compilation . MainModule ) ;
249- Assert . Throws < ReflectionNameParseException > ( ( ) => ReflectionHelper . ParseReflectionName ( "System.Int32[`]" , context ) ) ;
232+ Assert . That ( ReflectionHelper . ParseReflectionName ( "System.Int32[`]" , context ) . ReflectionName , Is . EqualTo ( "System.Int32" ) ) ;
250233 }
251234
252235 [ Test ]
0 commit comments