@@ -155,7 +155,7 @@ public static string GetDeserializePrefix(this ITypeSymbol ts)
155
155
}
156
156
157
157
var assName = ts . ContainingAssembly . Name ;
158
- var curNamespace = $ "{ assName ! } ";
158
+ var curNamespace = $ "{ assName } ";
159
159
if ( ! string . IsNullOrEmpty ( curNamespace ) )
160
160
curNamespace = $ "{ curNamespace } _";
161
161
if ( ! char . IsLetter ( curNamespace [ 0 ] ) )
@@ -176,7 +176,7 @@ public static string GetSerializePrefix(this ITypeSymbol ts)
176
176
}
177
177
178
178
var assName = ts . ContainingAssembly . Name ;
179
- var curNamespace = $ "{ assName ! } ";
179
+ var curNamespace = $ "{ assName } ";
180
180
if ( ! string . IsNullOrEmpty ( curNamespace ) )
181
181
curNamespace = $ "{ curNamespace } _";
182
182
if ( ! char . IsLetter ( curNamespace [ 0 ] ) )
@@ -349,7 +349,7 @@ private static string GetFullTypeName(TypeDeclarationSyntax typeDeclaration, str
349
349
switch ( memberDeclaration )
350
350
{
351
351
case PropertyDeclarationSyntax propertyDeclaration :
352
- var propertySymbol = model . GetDeclaredSymbol ( propertyDeclaration ) as IPropertySymbol ;
352
+ var propertySymbol = model . GetDeclaredSymbol ( propertyDeclaration ) ;
353
353
return propertySymbol ? . Type ;
354
354
355
355
case FieldDeclarationSyntax fieldDeclaration :
@@ -358,7 +358,7 @@ private static string GetFullTypeName(TypeDeclarationSyntax typeDeclaration, str
358
358
return fieldSymbol ? . Type ;
359
359
360
360
case ParameterSyntax parameterSyntax :
361
- var parameterSymbol = model . GetDeclaredSymbol ( parameterSyntax ) as IParameterSymbol ;
361
+ var parameterSymbol = model . GetDeclaredSymbol ( parameterSyntax ) ;
362
362
return parameterSymbol ? . Type ;
363
363
}
364
364
@@ -402,78 +402,82 @@ public static List<CSharpSyntaxNode> GetNinoTypeMembers(this TypeDeclarationSynt
402
402
if ( parentNinoTypes != null )
403
403
ninoTypes . AddRange ( parentNinoTypes ) ;
404
404
//get all fields and properties with getter and setter
405
- var ret = ninoTypes . SelectMany ( static t => t . Members )
406
- . Where ( static m => m is FieldDeclarationSyntax or PropertyDeclarationSyntax { AccessorList : not null } )
407
- . Select ( static m => m as CSharpSyntaxNode )
408
- . Concat (
409
- //consider record (init only) properties
410
- //i.e. public record Record(int A, string B);, we want to get A and B
411
- ninoTypes . Where ( static t => t is RecordDeclarationSyntax )
412
- . Select ( static t => t as RecordDeclarationSyntax )
413
- . Where ( static r => r != null && r . ParameterList != null )
414
- //now extract the init only properties (A and B) from the record declaration
415
- . SelectMany ( static r => r ! . ParameterList ! . Parameters )
416
- . Where ( static p => p . Type != null )
417
- )
418
- . Where ( static m => m != null )
419
- . Where ( node =>
420
- {
421
- MemberDeclarationSyntax ? m = node as MemberDeclarationSyntax ;
422
- //has to be public
423
- if ( m != null )
405
+ var ret =
406
+ //consider record (init only) properties
407
+ //i.e. public record Record(int A, string B);, we want to get A and B
408
+ ninoTypes . Where ( static t => t is RecordDeclarationSyntax )
409
+ . Select ( static t => t as RecordDeclarationSyntax )
410
+ . Where ( static r => r != null && r . ParameterList != null )
411
+ //now extract the init only properties (A and B) from the record declaration
412
+ . SelectMany ( static r => r ! . ParameterList ! . Parameters )
413
+ . Where ( static p => p . Type != null )
414
+ . Concat (
415
+ ninoTypes
416
+ . SelectMany ( static t => t . Members )
417
+ . Where ( static m => m is FieldDeclarationSyntax or PropertyDeclarationSyntax
418
+ {
419
+ AccessorList : not null
420
+ } )
421
+ . Select ( static m => m as CSharpSyntaxNode )
422
+ . Where ( static m => m != null ) )
423
+ . Where ( node =>
424
424
{
425
- if ( ! m . Modifiers . Any ( static m => m . Text == "public" ) )
425
+ MemberDeclarationSyntax ? m = node as MemberDeclarationSyntax ;
426
+ //has to be public
427
+ if ( m != null )
426
428
{
427
- return false ;
429
+ if ( ! m . Modifiers . Any ( static m => m . Text == "public" ) )
430
+ {
431
+ return false ;
432
+ }
428
433
}
429
- }
430
434
431
- var attrList = m ? . AttributeLists ?? ( ( ParameterSyntax ) node ) . AttributeLists ;
435
+ var attrList = m ? . AttributeLists ?? ( ( ParameterSyntax ) node ) . AttributeLists ;
432
436
433
- //if has ninoignore attribute, ignore this member
434
- if ( attrList . SelectMany ( static al => al . Attributes )
435
- . Any ( static a => a . Name . ToString ( ) == "NinoIgnore" ) )
436
- {
437
- return false ;
438
- }
437
+ //if has ninoignore attribute, ignore this member
438
+ if ( attrList . SelectMany ( static al => al . Attributes )
439
+ . Any ( static a => a . Name . ToString ( ) == "NinoIgnore" ) )
440
+ {
441
+ return false ;
442
+ }
439
443
440
- var memberName = node . GetMemberName ( ) ;
441
- if ( memberName == null )
442
- {
443
- return false ;
444
- }
444
+ var memberName = node . GetMemberName ( ) ;
445
+ if ( memberName == null )
446
+ {
447
+ return false ;
448
+ }
445
449
446
- if ( autoCollect )
447
- {
448
- memberIndex [ memberName ] = memberIndex . Count ;
449
- return true ;
450
- }
450
+ if ( autoCollect )
451
+ {
452
+ memberIndex [ memberName ] = memberIndex . Count ;
453
+ return true ;
454
+ }
451
455
452
456
453
- //get nino member attribute's first argument on this member
454
- var arg = attrList . SelectMany ( static al => al . Attributes )
455
- . Where ( static a => a . Name . ToString ( ) == "NinoMember" )
456
- . Select ( static a => a . ArgumentList ? . Arguments . FirstOrDefault ( ) )
457
- . Select ( static a => a ? . Expression )
458
- . OfType < LiteralExpressionSyntax > ( )
459
- . FirstOrDefault ( ) ;
457
+ //get nino member attribute's first argument on this member
458
+ var arg = attrList . SelectMany ( static al => al . Attributes )
459
+ . Where ( static a => a . Name . ToString ( ) == "NinoMember" )
460
+ . Select ( static a => a . ArgumentList ? . Arguments . FirstOrDefault ( ) )
461
+ . Select ( static a => a ? . Expression )
462
+ . OfType < LiteralExpressionSyntax > ( )
463
+ . FirstOrDefault ( ) ;
460
464
461
- if ( arg == null )
462
- {
463
- return false ;
464
- }
465
+ if ( arg == null )
466
+ {
467
+ return false ;
468
+ }
465
469
466
- //get index value from NinoMemberAttribute
467
- var indexValue = arg . Token . Value as int ? ;
468
- if ( indexValue == null )
469
- {
470
- return false ;
471
- }
470
+ //get index value from NinoMemberAttribute
471
+ var indexValue = arg . Token . Value as int ? ;
472
+ if ( indexValue == null )
473
+ {
474
+ return false ;
475
+ }
472
476
473
- memberIndex [ memberName ] = indexValue . Value ;
474
- return true ;
475
- } )
476
- . ToList ( ) ;
477
+ memberIndex [ memberName ] = indexValue . Value ;
478
+ return true ;
479
+ } )
480
+ . ToList ( ) ;
477
481
478
482
//sort by name
479
483
ret . Sort ( ( a , b ) =>
0 commit comments