@@ -14,7 +14,7 @@ private enum FriendlyOverloadOf
1414        InterfaceMethod , 
1515    } 
1616
17-     private  IEnumerable < MethodDeclarationSyntax >  DeclareFriendlyOverloads ( MethodDefinition  methodDefinition ,  MethodDeclarationSyntax  externMethodDeclaration ,  NameSyntax  declaringTypeName ,  FriendlyOverloadOf  overloadOf ,  HashSet < string >  helperMethodsAdded ) 
17+     private  IEnumerable < MethodDeclarationSyntax >  DeclareFriendlyOverloads ( MethodDefinition  methodDefinition ,  MethodDeclarationSyntax  externMethodDeclaration ,  NameSyntax  declaringTypeName ,  FriendlyOverloadOf  overloadOf ,  HashSet < string >  helperMethodsAdded ,   bool   avoidWinmdRootAlias ) 
1818    { 
1919        if  ( ! this . options . FriendlyOverloads . Enabled ) 
2020        { 
@@ -59,7 +59,12 @@ private IEnumerable<MethodDeclarationSyntax> DeclareFriendlyOverloads(MethodDefi
5959            _ =>  throw  new  NotSupportedException ( overloadOf . ToString ( ) ) , 
6060        } ; 
6161
62-         MethodSignature < TypeHandleInfo >  originalSignature  =  methodDefinition . DecodeSignature ( SignatureHandleProvider . Instance ,  null ) ; 
62+         if  ( avoidWinmdRootAlias ) 
63+         { 
64+             parameterTypeSyntaxSettings  =  parameterTypeSyntaxSettings  with  {  AvoidWinmdRootAlias  =  true  } ; 
65+         } 
66+ 
67+         MethodSignature < TypeHandleInfo >  originalSignature  =  methodDefinition . DecodeSignature ( this . SignatureHandleProvider ,  null ) ; 
6368        CustomAttributeHandleCollection ?  returnTypeAttributes  =  null ; 
6469        var  parameters  =  externMethodDeclaration . ParameterList . Parameters . Select ( StripAttributes ) . ToList ( ) ; 
6570        var  lengthParamUsedBy  =  new  Dictionary < int ,  int > ( ) ; 
@@ -105,7 +110,7 @@ private IEnumerable<MethodDeclarationSyntax> DeclareFriendlyOverloads(MethodDefi
105110
106111            TypeHandleInfo  parameterTypeInfo  =  originalSignature . ParameterTypes [ param . SequenceNumber  -  1 ] ; 
107112            bool  isManagedParameterType  =  this . IsManagedType ( parameterTypeInfo ) ; 
108-             bool  mustRemainAsPointer  =  parameterTypeInfo  is  PointerTypeHandleInfo  {  ElementType :  HandleTypeHandleInfo  pointedElement  }  &&  this . IsStructWithFlexibleArray ( pointedElement ) ; 
113+             bool  mustRemainAsPointer  =  parameterTypeInfo  is  PointerTypeHandleInfo  {  ElementType :  HandleTypeHandleInfo  pointedElement  }  &&  pointedElement . Generator . IsStructWithFlexibleArray ( pointedElement ) ; 
109114
110115            IdentifierNameSyntax  origName  =  IdentifierName ( externParam . Identifier . ValueText ) ; 
111116
@@ -146,7 +151,7 @@ private IEnumerable<MethodDeclarationSyntax> DeclareFriendlyOverloads(MethodDefi
146151                bool  hasOut  =  externParam . Modifiers . Any ( SyntaxKind . OutKeyword ) ; 
147152                arguments [ param . SequenceNumber  -  1 ]  =  arguments [ param . SequenceNumber  -  1 ] . WithRefKindKeyword ( TokenWithSpace ( hasOut  ?  SyntaxKind . OutKeyword  :  SyntaxKind . RefKeyword ) ) ; 
148153            } 
149-             else  if  ( isOut  &&  ! isIn  &&  ! isReleaseMethod  &&  parameterTypeInfo  is  PointerTypeHandleInfo  {  ElementType :  HandleTypeHandleInfo  pointedElementInfo  }  &&  this . TryGetHandleReleaseMethod ( pointedElementInfo . Handle ,  paramAttributes ,  out  string ?  outReleaseMethod )  &&  ! this . Reader . StringComparer . Equals ( methodDefinition . Name ,  outReleaseMethod ) ) 
154+             else  if  ( isOut  &&  ! isIn  &&  ! isReleaseMethod  &&  parameterTypeInfo  is  PointerTypeHandleInfo  {  ElementType :  HandleTypeHandleInfo  pointedElementInfo  }  &&  pointedElementInfo . Generator . TryGetHandleReleaseMethod ( pointedElementInfo . Handle ,  paramAttributes ,  out  string ?  outReleaseMethod )  &&  ! this . Reader . StringComparer . Equals ( methodDefinition . Name ,  outReleaseMethod ) ) 
150155            { 
151156                if  ( this . RequestSafeHandle ( outReleaseMethod )  is  TypeSyntax  safeHandleType ) 
152157                { 
@@ -668,7 +673,7 @@ bool TryHandleCountParam(TypeSyntax elementType, bool nullableSource)
668673        } 
669674
670675        TypeSyntax ?  returnSafeHandleType  =  originalSignature . ReturnType  is  HandleTypeHandleInfo  returnTypeHandleInfo 
671-             &&  this . TryGetHandleReleaseMethod ( returnTypeHandleInfo . Handle ,  returnTypeAttributes ,  out  string ?  returnReleaseMethod ) 
676+             &&  returnTypeHandleInfo . Generator . TryGetHandleReleaseMethod ( returnTypeHandleInfo . Handle ,  returnTypeAttributes ,  out  string ?  returnReleaseMethod ) 
672677            ?  this . RequestSafeHandle ( returnReleaseMethod )  :  null ; 
673678        SyntaxToken  friendlyMethodName  =  externMethodDeclaration . Identifier ; 
674679
@@ -794,7 +799,7 @@ bool TryHandleCountParam(TypeSyntax elementType, bool nullableSource)
794799            // If we're using C# 13 or later, consider adding the overload resolution attribute if it would likely resolve ambiguities. 
795800            if  ( this . LanguageVersion  >=  ( LanguageVersion ) 1300  &&  parameters . Count  ==  externMethodDeclaration . ParameterList . Parameters . Count ) 
796801            { 
797-                 this . DeclareOverloadResolutionPriorityAttributeIfNecessary ( ) ; 
802+                 this . volatileCode . GenerationTransaction ( ( )   =>   this . DeclareOverloadResolutionPriorityAttributeIfNecessary ( ) ) ; 
798803                friendlyDeclaration  =  friendlyDeclaration . AddAttributeLists ( AttributeList ( ) . AddAttributes ( OverloadResolutionPriorityAttribute ( 1 ) ) ) ; 
799804            } 
800805
0 commit comments