@@ -380,79 +380,81 @@ protected override string GetMethodDeclaration (MethodDefinition method)
380
380
return null ;
381
381
}
382
382
383
- protected override StringBuilder AppendMethodName ( StringBuilder buf , MethodDefinition method )
383
+ protected override StringBuilder AppendMethodName ( StringBuilder buf , MethodDefinition method )
384
384
{
385
- if ( DocUtils . IsExplicitlyImplemented ( method ) )
385
+ var methodName = method . Name ;
386
+ if ( DocUtils . IsExplicitlyImplemented ( method ) )
386
387
{
387
388
TypeReference iface ;
388
389
MethodReference ifaceMethod ;
389
- DocUtils . GetInfoForExplicitlyImplementedMethod ( method , out iface , out ifaceMethod ) ;
390
- return buf . Append ( new CSharpMemberFormatter ( this . TypeMap ) . GetName ( iface ) )
391
- . Append ( '.' )
392
- . Append ( ifaceMethod . Name ) ;
390
+ DocUtils . GetInfoForExplicitlyImplementedMethod ( method , out iface , out ifaceMethod ) ;
391
+ buf . Append ( new CSharpMemberFormatter ( this . TypeMap ) . GetName ( iface ) ) . Append ( '.' ) ;
392
+ methodName = ifaceMethod . Name ;
393
393
}
394
394
395
- if ( method . Name . StartsWith ( "op_" , StringComparison . Ordinal ) )
395
+ if ( methodName . StartsWith ( "op_" , StringComparison . Ordinal ) )
396
396
{
397
397
// this is an operator
398
- switch ( method . Name )
398
+ switch ( methodName )
399
399
{
400
400
case "op_Implicit" :
401
401
case "op_Explicit" :
402
402
buf . Length -- ; // remove the last space, which assumes a member name is coming
403
403
return buf ;
404
404
case "op_Addition" :
405
405
case "op_UnaryPlus" :
406
- return buf . Append ( "operator +" ) ;
406
+ return buf . Append ( "operator +" ) ;
407
407
case "op_Subtraction" :
408
408
case "op_UnaryNegation" :
409
- return buf . Append ( "operator -" ) ;
409
+ return buf . Append ( "operator -" ) ;
410
410
case "op_Division" :
411
- return buf . Append ( "operator /" ) ;
411
+ return buf . Append ( "operator /" ) ;
412
412
case "op_Multiply" :
413
- return buf . Append ( "operator *" ) ;
413
+ return buf . Append ( "operator *" ) ;
414
414
case "op_Modulus" :
415
- return buf . Append ( "operator %" ) ;
415
+ return buf . Append ( "operator %" ) ;
416
416
case "op_BitwiseAnd" :
417
- return buf . Append ( "operator &" ) ;
417
+ return buf . Append ( "operator &" ) ;
418
418
case "op_BitwiseOr" :
419
- return buf . Append ( "operator |" ) ;
419
+ return buf . Append ( "operator |" ) ;
420
420
case "op_ExclusiveOr" :
421
- return buf . Append ( "operator ^" ) ;
421
+ return buf . Append ( "operator ^" ) ;
422
422
case "op_LeftShift" :
423
- return buf . Append ( "operator <<" ) ;
423
+ return buf . Append ( "operator <<" ) ;
424
424
case "op_RightShift" :
425
- return buf . Append ( "operator >>" ) ;
425
+ return buf . Append ( "operator >>" ) ;
426
426
case "op_LogicalNot" :
427
- return buf . Append ( "operator !" ) ;
427
+ return buf . Append ( "operator !" ) ;
428
428
case "op_OnesComplement" :
429
- return buf . Append ( "operator ~" ) ;
429
+ return buf . Append ( "operator ~" ) ;
430
430
case "op_Decrement" :
431
- return buf . Append ( "operator --" ) ;
431
+ return buf . Append ( "operator --" ) ;
432
432
case "op_Increment" :
433
- return buf . Append ( "operator ++" ) ;
433
+ return buf . Append ( "operator ++" ) ;
434
434
case "op_True" :
435
- return buf . Append ( "operator true" ) ;
435
+ return buf . Append ( "operator true" ) ;
436
436
case "op_False" :
437
- return buf . Append ( "operator false" ) ;
437
+ return buf . Append ( "operator false" ) ;
438
438
case "op_Equality" :
439
- return buf . Append ( "operator ==" ) ;
439
+ return buf . Append ( "operator ==" ) ;
440
440
case "op_Inequality" :
441
- return buf . Append ( "operator !=" ) ;
441
+ return buf . Append ( "operator !=" ) ;
442
442
case "op_LessThan" :
443
- return buf . Append ( "operator <" ) ;
443
+ return buf . Append ( "operator <" ) ;
444
444
case "op_LessThanOrEqual" :
445
- return buf . Append ( "operator <=" ) ;
445
+ return buf . Append ( "operator <=" ) ;
446
446
case "op_GreaterThan" :
447
- return buf . Append ( "operator >" ) ;
447
+ return buf . Append ( "operator >" ) ;
448
448
case "op_GreaterThanOrEqual" :
449
- return buf . Append ( "operator >=" ) ;
449
+ return buf . Append ( "operator >=" ) ;
450
450
default :
451
- return base . AppendMethodName ( buf , method ) ;
451
+ return buf . Append ( methodName ) ;
452
452
}
453
453
}
454
454
else
455
- return base . AppendMethodName ( buf , method ) ;
455
+ {
456
+ return buf . Append ( methodName ) ;
457
+ }
456
458
}
457
459
458
460
protected override string GetTypeNullableSymbol ( TypeReference type , bool ? isNullableType )
@@ -519,14 +521,16 @@ protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefin
519
521
if ( method . IsStatic ) modifiers += " static" ;
520
522
if ( method . IsVirtual && ! method . IsAbstract )
521
523
{
522
- if ( ( method . Attributes & MethodAttributes . NewSlot ) != 0 ) modifiers += " virtual" ;
524
+ if ( ( method . Attributes & MethodAttributes . NewSlot ) != 0 || method . IsStatic ) modifiers += " virtual" ;
523
525
else modifiers += " override" ;
524
526
}
525
527
TypeDefinition declType = ( TypeDefinition ) method . DeclaringType ;
526
- if ( method . IsAbstract && ! declType . IsInterface ) modifiers += " abstract" ;
528
+ if ( method . IsAbstract && ( ! declType . IsInterface || method . IsStatic ) ) modifiers += " abstract" ;
527
529
if ( method . IsFinal ) modifiers += " sealed" ;
528
530
if ( modifiers == " virtual sealed" ) modifiers = "" ;
529
- if ( declType . IsValueType && DocUtils . HasCustomAttribute ( method , Consts . IsReadOnlyAttribute ) )
531
+ if ( declType . IsValueType
532
+ && ! ( method . IsSpecialName && method . Name . StartsWith ( "get_" ) ) // Property without set method is by defualt readonly.
533
+ && DocUtils . HasCustomAttribute ( method , Consts . IsReadOnlyAttribute ) )
530
534
{
531
535
modifiers += buf . Length == 0 ? "readonly" : " readonly" ;
532
536
}
@@ -541,7 +545,7 @@ protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefin
541
545
break ;
542
546
}
543
547
544
- return buf . Append ( modifiers ) ;
548
+ return buf . Append ( buf . Length == 0 ? modifiers . TrimStart ( ) : modifiers ) ;
545
549
}
546
550
547
551
protected override StringBuilder AppendRefTypeName ( StringBuilder buf , ByReferenceType type , IAttributeParserContext context )
@@ -608,6 +612,15 @@ protected override StringBuilder AppendParameter(StringBuilder buf, ParameterDef
608
612
TypeReference parameterType = parameter . ParameterType ;
609
613
var refType = new BitArray ( 3 ) ;
610
614
615
+ if ( parameter . HasCustomAttributes )
616
+ {
617
+ var isScoped = parameter . CustomAttributes . Any (
618
+ ca => ca . AttributeType . FullName == Consts . ScopedRefAttribute
619
+ || ca . AttributeType . FullName == Consts . LifetimeAnnotationAttribute ) ; // Workaround as complier in ci pipeline has delay for update.
620
+ if ( isScoped )
621
+ buf . AppendFormat ( "scoped " ) ;
622
+ }
623
+
611
624
if ( parameterType is RequiredModifierType requiredModifierType )
612
625
{
613
626
switch ( requiredModifierType . ModifierType . FullName )
@@ -691,23 +704,8 @@ protected override string GetPropertyDeclaration (PropertyDefinition property)
691
704
if ( method == null )
692
705
method = property . GetMethod ;
693
706
694
- string modifiers = String . Empty ;
695
- if ( method . IsStatic ) modifiers += " static" ;
696
- if ( method . IsVirtual && ! method . IsAbstract )
697
- {
698
- if ( ( method . Attributes & MethodAttributes . NewSlot ) != 0 )
699
- modifiers += " virtual" ;
700
- else
701
- modifiers += " override" ;
702
- }
703
- TypeDefinition declDef = ( TypeDefinition ) method . DeclaringType ;
704
- if ( method . IsAbstract && ! declDef . IsInterface )
705
- modifiers += " abstract" ;
706
- if ( method . IsFinal )
707
- modifiers += " sealed" ;
708
- if ( modifiers == " virtual sealed" )
709
- modifiers = "" ;
710
- buf . Append ( modifiers ) . Append ( ' ' ) ;
707
+ AppendModifiers ( buf , method ) ;
708
+ buf . Append ( ' ' ) ;
711
709
712
710
var context = AttributeParserContext . Create ( property ) ;
713
711
var isNullableType = context . IsNullable ( ) ;
0 commit comments