File tree Expand file tree Collapse file tree 7 files changed +75
-3
lines changed Expand file tree Collapse file tree 7 files changed +75
-3
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) .NET Foundation and Contributors
3
+ // See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ using Mono . Cecil ;
7
+ using System . Linq ;
8
+ using System . Text ;
9
+
10
+ namespace nanoFramework . Tools . MetadataProcessor . Core . Extensions
11
+ {
12
+ internal static class MethodDefinitionExtensions
13
+ {
14
+ public static string FullName ( this MethodDefinition value )
15
+ {
16
+ if ( value . GenericParameters . Count == 0 )
17
+ {
18
+ return value . Name ;
19
+ }
20
+ else
21
+ {
22
+ StringBuilder name = new StringBuilder ( value . Name ) ;
23
+ name . Append ( "<" ) ;
24
+
25
+ foreach ( var p in value . GenericParameters )
26
+ {
27
+ name . Append ( p . Name ) ;
28
+ if ( ! p . Equals ( value . GenericParameters . Last ( ) ) )
29
+ {
30
+ name . Append ( "," ) ;
31
+ }
32
+ }
33
+
34
+ name . Append ( ">" ) ;
35
+
36
+ return name . ToString ( ) ;
37
+ }
38
+ }
39
+ }
40
+ }
Original file line number Diff line number Diff line change @@ -97,6 +97,11 @@ public static string TypeSignatureAsString(this TypeReference type)
97
97
return byrefSig . ToString ( ) ;
98
98
}
99
99
100
+ if ( type . IsGenericParameter )
101
+ {
102
+ return $ "!!{ type . Name } ";
103
+ }
104
+
100
105
return "" ;
101
106
}
102
107
@@ -165,6 +170,10 @@ public static string ToNativeTypeAsString(this TypeReference type)
165
170
return arraySig . ToString ( ) ;
166
171
}
167
172
173
+ if ( type . IsGenericParameter )
174
+ {
175
+ return "UNSUPPORTED" ;
176
+ }
168
177
return "" ;
169
178
}
170
179
@@ -234,6 +243,11 @@ public static string ToCLRTypeAsString(this TypeReference type)
234
243
return arraySig . ToString ( ) ;
235
244
}
236
245
246
+ if ( type . IsGenericParameter )
247
+ {
248
+ return "UNSUPPORTED" ;
249
+ }
250
+
237
251
return "" ;
238
252
}
239
253
Original file line number Diff line number Diff line change 70
70
<Compile Include =" Endianness\nanoBinaryWriter.cs" />
71
71
<Compile Include =" Extensions\ParameterDefintionExtensions.cs" />
72
72
<Compile Include =" Extensions\ByteArrayExtensions.cs" />
73
+ <Compile Include =" Extensions\MethodDefinitionExtensions.cs" />
73
74
<Compile Include =" Extensions\TypeReferenceExtensions.cs" />
74
75
<Compile Include =" Extensions\TypeDefinitionExtensions.cs" />
75
76
<Compile Include =" InanoTable.cs" />
Original file line number Diff line number Diff line change @@ -342,6 +342,12 @@ public void WriteDataType(
342
342
return ;
343
343
}
344
344
345
+ if ( typeDefinition . IsGenericParameter || typeDefinition . IsGenericInstance )
346
+ {
347
+ writer . WriteByte ( ( byte ) nanoCLR_DataType . DATATYPE_GENERIC ) ;
348
+ return ;
349
+ }
350
+
345
351
writer . WriteByte ( 0x00 ) ;
346
352
}
347
353
Original file line number Diff line number Diff line change @@ -183,8 +183,18 @@ internal static string GetnanoClrTypeName(TypeReference parameterType)
183
183
}
184
184
else
185
185
{
186
- // type is not primitive, get full qualified type name
187
- return parameterType . FullName . Replace ( "." , String . Empty ) ;
186
+ // type is not primitive
187
+
188
+ if ( parameterType . IsGenericParameter )
189
+ {
190
+ // check if it's generic
191
+ return "DATATYPE_GENERICTYPE" ;
192
+ }
193
+ else
194
+ {
195
+ // this is not a generic, get full qualified type name
196
+ return parameterType . FullName . Replace ( "." , String . Empty ) ;
197
+ }
188
198
}
189
199
}
190
200
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ public enum nanoCLR_DataType : byte
47
47
DATATYPE_LAST_PRIMITIVE = DATATYPE_STRING,
48
48
49
49
DATATYPE_OBJECT , // Shortcut for System.Object
50
+ DATATYPE_GENERIC = DATATYPE_OBJECT ,
50
51
DATATYPE_CLASS , // CLASS <class Token>
51
52
DATATYPE_VALUETYPE , // VALUETYPE <class Token>
52
53
DATATYPE_SZARRAY , // Shortcut for single dimension zero lower bound array SZARRAY <type>
Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ private void DumpTypeDefinitions(DumpAllTable dumpTable)
247
247
var methodDef = new MethodDef ( )
248
248
{
249
249
ReferenceId = m . MetadataToken . ToInt32 ( ) . ToString ( "x8" ) ,
250
- Name = m . Name ,
250
+ Name = m . FullName ( ) ,
251
251
RVA = m . RVA . ToString ( "x8" ) ,
252
252
Implementation = "00000000" ,
253
253
Signature = PrintSignatureForMethod ( m )
You can’t perform that action at this time.
0 commit comments