@@ -380,79 +380,81 @@ protected override string GetMethodDeclaration (MethodDefinition method)
380380 return null ;
381381 }
382382
383- protected override StringBuilder AppendMethodName ( StringBuilder buf , MethodDefinition method )
383+ protected override StringBuilder AppendMethodName ( StringBuilder buf , MethodDefinition method )
384384 {
385- if ( DocUtils . IsExplicitlyImplemented ( method ) )
385+ var methodName = method . Name ;
386+ if ( DocUtils . IsExplicitlyImplemented ( method ) )
386387 {
387388 TypeReference iface ;
388389 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 ;
393393 }
394394
395- if ( method . Name . StartsWith ( "op_" , StringComparison . Ordinal ) )
395+ if ( methodName . StartsWith ( "op_" , StringComparison . Ordinal ) )
396396 {
397397 // this is an operator
398- switch ( method . Name )
398+ switch ( methodName )
399399 {
400400 case "op_Implicit" :
401401 case "op_Explicit" :
402402 buf . Length -- ; // remove the last space, which assumes a member name is coming
403403 return buf ;
404404 case "op_Addition" :
405405 case "op_UnaryPlus" :
406- return buf . Append ( "operator +" ) ;
406+ return buf . Append ( "operator +" ) ;
407407 case "op_Subtraction" :
408408 case "op_UnaryNegation" :
409- return buf . Append ( "operator -" ) ;
409+ return buf . Append ( "operator -" ) ;
410410 case "op_Division" :
411- return buf . Append ( "operator /" ) ;
411+ return buf . Append ( "operator /" ) ;
412412 case "op_Multiply" :
413- return buf . Append ( "operator *" ) ;
413+ return buf . Append ( "operator *" ) ;
414414 case "op_Modulus" :
415- return buf . Append ( "operator %" ) ;
415+ return buf . Append ( "operator %" ) ;
416416 case "op_BitwiseAnd" :
417- return buf . Append ( "operator &" ) ;
417+ return buf . Append ( "operator &" ) ;
418418 case "op_BitwiseOr" :
419- return buf . Append ( "operator |" ) ;
419+ return buf . Append ( "operator |" ) ;
420420 case "op_ExclusiveOr" :
421- return buf . Append ( "operator ^" ) ;
421+ return buf . Append ( "operator ^" ) ;
422422 case "op_LeftShift" :
423- return buf . Append ( "operator <<" ) ;
423+ return buf . Append ( "operator <<" ) ;
424424 case "op_RightShift" :
425- return buf . Append ( "operator >>" ) ;
425+ return buf . Append ( "operator >>" ) ;
426426 case "op_LogicalNot" :
427- return buf . Append ( "operator !" ) ;
427+ return buf . Append ( "operator !" ) ;
428428 case "op_OnesComplement" :
429- return buf . Append ( "operator ~" ) ;
429+ return buf . Append ( "operator ~" ) ;
430430 case "op_Decrement" :
431- return buf . Append ( "operator --" ) ;
431+ return buf . Append ( "operator --" ) ;
432432 case "op_Increment" :
433- return buf . Append ( "operator ++" ) ;
433+ return buf . Append ( "operator ++" ) ;
434434 case "op_True" :
435- return buf . Append ( "operator true" ) ;
435+ return buf . Append ( "operator true" ) ;
436436 case "op_False" :
437- return buf . Append ( "operator false" ) ;
437+ return buf . Append ( "operator false" ) ;
438438 case "op_Equality" :
439- return buf . Append ( "operator ==" ) ;
439+ return buf . Append ( "operator ==" ) ;
440440 case "op_Inequality" :
441- return buf . Append ( "operator !=" ) ;
441+ return buf . Append ( "operator !=" ) ;
442442 case "op_LessThan" :
443- return buf . Append ( "operator <" ) ;
443+ return buf . Append ( "operator <" ) ;
444444 case "op_LessThanOrEqual" :
445- return buf . Append ( "operator <=" ) ;
445+ return buf . Append ( "operator <=" ) ;
446446 case "op_GreaterThan" :
447- return buf . Append ( "operator >" ) ;
447+ return buf . Append ( "operator >" ) ;
448448 case "op_GreaterThanOrEqual" :
449- return buf . Append ( "operator >=" ) ;
449+ return buf . Append ( "operator >=" ) ;
450450 default :
451- return base . AppendMethodName ( buf , method ) ;
451+ return buf . Append ( methodName ) ;
452452 }
453453 }
454454 else
455- return base . AppendMethodName ( buf , method ) ;
455+ {
456+ return buf . Append ( methodName ) ;
457+ }
456458 }
457459
458460 protected override string GetTypeNullableSymbol ( TypeReference type , bool ? isNullableType )
@@ -519,14 +521,16 @@ protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefin
519521 if ( method . IsStatic ) modifiers += " static" ;
520522 if ( method . IsVirtual && ! method . IsAbstract )
521523 {
522- if ( ( method . Attributes & MethodAttributes . NewSlot ) != 0 ) modifiers += " virtual" ;
524+ if ( ( method . Attributes & MethodAttributes . NewSlot ) != 0 || method . IsStatic ) modifiers += " virtual" ;
523525 else modifiers += " override" ;
524526 }
525527 TypeDefinition declType = ( TypeDefinition ) method . DeclaringType ;
526- if ( method . IsAbstract && ! declType . IsInterface ) modifiers += " abstract" ;
528+ if ( method . IsAbstract && ( ! declType . IsInterface || method . IsStatic ) ) modifiers += " abstract" ;
527529 if ( method . IsFinal ) modifiers += " sealed" ;
528530 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 ) )
530534 {
531535 modifiers += buf . Length == 0 ? "readonly" : " readonly" ;
532536 }
@@ -541,7 +545,7 @@ protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefin
541545 break ;
542546 }
543547
544- return buf . Append ( modifiers ) ;
548+ return buf . Append ( buf . Length == 0 ? modifiers . TrimStart ( ) : modifiers ) ;
545549 }
546550
547551 protected override StringBuilder AppendRefTypeName ( StringBuilder buf , ByReferenceType type , IAttributeParserContext context )
@@ -608,6 +612,15 @@ protected override StringBuilder AppendParameter(StringBuilder buf, ParameterDef
608612 TypeReference parameterType = parameter . ParameterType ;
609613 var refType = new BitArray ( 3 ) ;
610614
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+
611624 if ( parameterType is RequiredModifierType requiredModifierType )
612625 {
613626 switch ( requiredModifierType . ModifierType . FullName )
@@ -691,23 +704,8 @@ protected override string GetPropertyDeclaration (PropertyDefinition property)
691704 if ( method == null )
692705 method = property . GetMethod ;
693706
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 ( ' ' ) ;
711709
712710 var context = AttributeParserContext . Create ( property ) ;
713711 var isNullableType = context . IsNullable ( ) ;
0 commit comments