@@ -20,87 +20,88 @@ public static CsDeclaration Create(Type type)
20
20
if ( type . IsEnum )
21
21
{
22
22
return new CsEnum ( type )
23
- {
24
- Values = type . GetFields ( )
25
- . Where ( f => f . Name != "value__" )
26
- . Select ( y => new CsEnumValue
27
- {
28
- Name = y . Name ,
29
- Value =
30
- Convert
31
- . ToInt32 ( y . GetRawConstantValue ( ) )
32
- } )
33
- . ToArray ( )
34
- } ;
23
+ {
24
+ Values = type . GetFields ( )
25
+ . Where ( f => f . Name != "value__" )
26
+ . Select ( y => new CsEnumValue
27
+ {
28
+ Name = y . Name ,
29
+ Value =
30
+ Convert
31
+ . ToInt32 ( y . GetRawConstantValue ( ) )
32
+ } )
33
+ . ToArray ( )
34
+ } ;
35
35
}
36
36
37
37
if ( type . IsClass )
38
38
{
39
39
return new CsClass ( type )
40
- {
41
- TypeParameters = type . IsGenericType
42
- ? type . GetGenericTypeDefinition ( )
43
- . GetGenericArguments ( )
44
- . Select ( x => x . Name )
45
- . ToArray ( )
46
- : Array . Empty < string > ( ) ,
47
- Members = type . GetDefinition ( )
48
- . GetMembers ( BindingFlags . Public | BindingFlags . Instance |
49
- BindingFlags . DeclaredOnly | BindingFlags . Static )
50
- . Where ( m => ! typeof ( object )
51
- . GetMembers ( )
52
- . Select ( me => me . Name )
53
- . Contains ( m . Name ) )
54
- . Select ( Create )
55
- . Where ( x => x != null )
56
- . ToArray ( )
57
- } ;
40
+ {
41
+ TypeParameters = type . IsGenericType
42
+ ? type . GetGenericTypeDefinition ( )
43
+ . GetGenericArguments ( )
44
+ . Select ( x => x . Name )
45
+ . ToArray ( )
46
+ : Array . Empty < string > ( ) ,
47
+ Members = type . GetDefinition ( )
48
+ . GetMembers ( BindingFlags . Public | BindingFlags . Instance |
49
+ BindingFlags . DeclaredOnly |
50
+ BindingFlags . Static )
51
+ . Where ( m => ! typeof ( object )
52
+ . GetMembers ( )
53
+ . Select ( me => me . Name )
54
+ . Contains ( m . Name ) )
55
+ . Select ( Create )
56
+ . Where ( x => x != null )
57
+ . ToArray ( )
58
+ } ;
58
59
}
59
60
60
61
if ( type . IsInterface )
61
62
{
62
63
return new CsInterface ( type )
63
- {
64
- TypeParameters = type . IsGenericType
65
- ? type . GetGenericTypeDefinition ( )
66
- . GetGenericArguments ( )
67
- . Select ( x => x . Name )
68
- . ToArray ( )
69
- : Array . Empty < string > ( ) ,
70
- Members = type . GetDefinition ( )
71
- . GetMembers ( BindingFlags . Public | BindingFlags . Instance |
72
- BindingFlags . DeclaredOnly )
73
- . Where ( m => ! typeof ( object )
74
- . GetMembers ( )
75
- . Select ( me => me . Name )
76
- . Contains ( m . Name ) )
77
- . Select ( Create )
78
- . Where ( x => x != null )
79
- . ToArray ( )
80
- } ;
64
+ {
65
+ TypeParameters = type . IsGenericType
66
+ ? type . GetGenericTypeDefinition ( )
67
+ . GetGenericArguments ( )
68
+ . Select ( x => x . Name )
69
+ . ToArray ( )
70
+ : Array . Empty < string > ( ) ,
71
+ Members = type . GetDefinition ( )
72
+ . GetMembers ( BindingFlags . Public | BindingFlags . Instance |
73
+ BindingFlags . DeclaredOnly )
74
+ . Where ( m => ! typeof ( object )
75
+ . GetMembers ( )
76
+ . Select ( me => me . Name )
77
+ . Contains ( m . Name ) )
78
+ . Select ( Create )
79
+ . Where ( x => x != null )
80
+ . ToArray ( )
81
+ } ;
81
82
}
82
83
83
84
var isStruct = type . IsValueType && ! type . IsEnum && ! type . IsPrimitive ;
84
85
if ( isStruct )
85
86
{
86
87
return new CsStruct ( type )
87
- {
88
- TypeParameters = type . IsGenericType
89
- ? type . GetGenericTypeDefinition ( )
90
- . GetGenericArguments ( )
91
- . Select ( x => x . Name )
92
- . ToArray ( )
93
- : Array . Empty < string > ( ) ,
94
- Members = type . GetDefinition ( )
95
- . GetMembers ( )
96
- . Where ( m => ! typeof ( object )
97
- . GetMembers ( )
98
- . Select ( me => me . Name )
99
- . Contains ( m . Name ) )
100
- . Select ( Create )
101
- . Where ( x => x != null )
102
- . ToArray ( )
103
- } ;
88
+ {
89
+ TypeParameters = type . IsGenericType
90
+ ? type . GetGenericTypeDefinition ( )
91
+ . GetGenericArguments ( )
92
+ . Select ( x => x . Name )
93
+ . ToArray ( )
94
+ : Array . Empty < string > ( ) ,
95
+ Members = type . GetDefinition ( )
96
+ . GetMembers ( )
97
+ . Where ( m => ! typeof ( object )
98
+ . GetMembers ( )
99
+ . Select ( me => me . Name )
100
+ . Contains ( m . Name ) )
101
+ . Select ( Create )
102
+ . Where ( x => x != null )
103
+ . ToArray ( )
104
+ } ;
104
105
}
105
106
106
107
return null ;
@@ -149,24 +150,24 @@ private static CsTypeMember Create(FieldInfo fieldInfo)
149
150
}
150
151
151
152
return new CsField
152
- {
153
- Name = fieldInfo . Name ,
154
- IsStatic = fieldInfo . IsStatic ,
155
- IsInherited = fieldInfo . DeclaringType != fieldInfo . ReflectedType ,
156
- AccessModifier = GetAccessModifier ( fieldInfo . IsPrivate ,
157
- fieldInfo . IsFamily ,
158
- fieldInfo . IsPublic ,
159
- fieldInfo . IsAssembly ) ,
160
- Attributes = fieldInfo . CustomAttributes
161
- . Select ( x => new CsAttribute
162
- {
163
- Name = x . AttributeType . Name ,
164
- OriginalType = x . AttributeType
165
- } )
166
- . ToArray ( ) ,
167
- Type = new CsType ( fieldInfo . FieldType ) ,
168
- Value = GetLiteral ( fieldInfo . FieldType )
169
- } ;
153
+ {
154
+ Name = fieldInfo . Name ,
155
+ IsStatic = fieldInfo . IsStatic ,
156
+ IsInherited = fieldInfo . DeclaringType != fieldInfo . ReflectedType ,
157
+ AccessModifier = GetAccessModifier ( fieldInfo . IsPrivate ,
158
+ fieldInfo . IsFamily ,
159
+ fieldInfo . IsPublic ,
160
+ fieldInfo . IsAssembly ) ,
161
+ Attributes = fieldInfo . CustomAttributes
162
+ . Select ( x => new CsAttribute
163
+ {
164
+ Name = x . AttributeType . Name ,
165
+ OriginalType = x . AttributeType
166
+ } )
167
+ . ToArray ( ) ,
168
+ Type = new CsType ( fieldInfo . FieldType ) ,
169
+ Value = GetLiteral ( fieldInfo . FieldType )
170
+ } ;
170
171
}
171
172
172
173
private static CsMethod Create ( MethodInfo methodInfo )
@@ -175,27 +176,27 @@ private static CsMethod Create(MethodInfo methodInfo)
175
176
return null ;
176
177
177
178
return new CsMethod
178
- {
179
- Name = methodInfo . Name ,
180
- IsStatic = methodInfo . IsStatic ,
181
- IsInherited = methodInfo . DeclaringType != methodInfo . ReflectedType ,
182
- AccessModifier = GetAccessModifier ( methodInfo . IsPrivate ,
183
- methodInfo . IsFamily ,
184
- methodInfo . IsPublic ,
185
- methodInfo . IsAssembly ) ,
186
- Attributes = methodInfo . CustomAttributes
187
- . Select ( x => new CsAttribute
188
- {
189
- Name = x . AttributeType . Name ,
190
- OriginalType = x . AttributeType
191
- } )
192
- . ToArray ( ) ,
193
- ReturnType = new CsType ( methodInfo . ReturnType ) ,
194
- Parameters = methodInfo . GetParameters ( )
195
- . Select ( Create )
196
- . ToArray ( ) ,
197
- OriginalMethod = methodInfo
198
- } ;
179
+ {
180
+ Name = methodInfo . Name ,
181
+ IsStatic = methodInfo . IsStatic ,
182
+ IsInherited = methodInfo . DeclaringType != methodInfo . ReflectedType ,
183
+ AccessModifier = GetAccessModifier ( methodInfo . IsPrivate ,
184
+ methodInfo . IsFamily ,
185
+ methodInfo . IsPublic ,
186
+ methodInfo . IsAssembly ) ,
187
+ Attributes = methodInfo . CustomAttributes
188
+ . Select ( x => new CsAttribute
189
+ {
190
+ Name = x . AttributeType . Name ,
191
+ OriginalType = x . AttributeType
192
+ } )
193
+ . ToArray ( ) ,
194
+ ReturnType = new CsType ( methodInfo . ReturnType ) ,
195
+ Parameters = methodInfo . GetParameters ( )
196
+ . Select ( Create )
197
+ . ToArray ( ) ,
198
+ OriginalMethod = methodInfo
199
+ } ;
199
200
}
200
201
201
202
private static CsProperty Create ( PropertyInfo propertyInfo )
@@ -213,23 +214,23 @@ private static CsProperty Create(PropertyInfo propertyInfo)
213
214
}
214
215
215
216
return new CsProperty
216
- {
217
- Name = propertyInfo . Name ,
218
- IsStatic = getMethod . IsStatic ,
219
- IsInherited = propertyInfo . DeclaringType != propertyInfo . ReflectedType ,
220
- AccessModifier = GetAccessModifier ( getMethod . IsPrivate ,
221
- getMethod . IsFamily ,
222
- getMethod . IsPublic ,
223
- getMethod . IsAssembly ) ,
224
- Attributes = propertyInfo . CustomAttributes
225
- . Select ( x => new CsAttribute
226
- {
227
- Name = x . AttributeType . Name ,
228
- OriginalType = x . AttributeType
229
- } )
230
- . ToArray ( ) ,
231
- Type = new CsType ( propertyInfo . PropertyType )
232
- } ;
217
+ {
218
+ Name = propertyInfo . Name ,
219
+ IsStatic = getMethod . IsStatic ,
220
+ IsInherited = propertyInfo . DeclaringType != propertyInfo . ReflectedType ,
221
+ AccessModifier = GetAccessModifier ( getMethod . IsPrivate ,
222
+ getMethod . IsFamily ,
223
+ getMethod . IsPublic ,
224
+ getMethod . IsAssembly ) ,
225
+ Attributes = propertyInfo . CustomAttributes
226
+ . Select ( x => new CsAttribute
227
+ {
228
+ Name = x . AttributeType . Name ,
229
+ OriginalType = x . AttributeType
230
+ } )
231
+ . ToArray ( ) ,
232
+ Type = new CsType ( propertyInfo . PropertyType )
233
+ } ;
233
234
}
234
235
235
236
private static CsMethodParameter Create ( ParameterInfo x )
0 commit comments