@@ -573,62 +573,40 @@ let GetTyconRefForExtensionMembers minfo (deref: Entity) amap m g =
573573/// Get the info for all the .NET-style extension members listed as static members in the type.
574574let private GetCSharpStyleIndexedExtensionMembersForTyconRef ( amap : Import.ImportMap ) m ( tcrefOfStaticClass : TyconRef ) =
575575 let g = amap.g
576- let pri = NextExtensionMethodPriority()
577-
578- if g.langVersion.SupportsFeature( LanguageFeature.CSharpExtensionAttributeNotRequired) then
579- let csharpStyleExtensionMembers =
580- if IsTyconRefUsedForCSharpStyleExtensionMembers g m tcrefOfStaticClass || ( tcrefOfStaticClass.IsLocalRef && not tcrefOfStaticClass.IsTypeAbbrev) then
581- protectAssemblyExploration [] ( fun () ->
582- let ty = generalizedTyconRef g tcrefOfStaticClass
583- GetImmediateIntrinsicMethInfosOfType ( None, AccessorDomain.AccessibleFromSomeFSharpCode) g amap m ty
584- |> List.filter ( IsMethInfoPlainCSharpStyleExtensionMember g m true ))
585- else
586- []
587576
588- if not csharpStyleExtensionMembers.IsEmpty then
589- [ for minfo in csharpStyleExtensionMembers do
590- let ilExtMem = ILExtMem ( tcrefOfStaticClass, minfo, pri)
577+ let isApplicable =
578+ IsTyconRefUsedForCSharpStyleExtensionMembers g m tcrefOfStaticClass ||
591579
592- // The results are indexed by the TyconRef of the first 'this' argument, if any.
593- // So we need to go and crack the type of the 'this' argument.
594- //
595- // This is convoluted because we only need the ILTypeRef of the first argument, and we don't
596- // want to read any other metadata as it can trigger missing-assembly errors. It turns out ImportILTypeRef
597- // is less eager in reading metadata than GetParamTypes.
598- //
599- // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension
600- // methods for tuple occur in C# code)
601- let thisTyconRef = GetTyconRefForExtensionMembers minfo tcrefOfStaticClass.Deref amap m g
602- match thisTyconRef with
603- | None -> ()
604- | Some ( Some tcref) -> yield Choice1Of2( tcref, ilExtMem)
605- | Some None -> yield Choice2Of2 ilExtMem ]
606- else
607- []
608- else
609- if IsTyconRefUsedForCSharpStyleExtensionMembers g m tcrefOfStaticClass then
610- let ty = generalizedTyconRef g tcrefOfStaticClass
611- let minfos = GetImmediateIntrinsicMethInfosOfType ( None, AccessorDomain.AccessibleFromSomeFSharpCode) g amap m ty
612-
613- [ for minfo in minfos do
614- if IsMethInfoPlainCSharpStyleExtensionMember g m true minfo then
615- let ilExtMem = ILExtMem ( tcrefOfStaticClass, minfo, pri)
616- // The results are indexed by the TyconRef of the first 'this' argument, if any.
617- // So we need to go and crack the type of the 'this' argument.
618- //
619- // This is convoluted because we only need the ILTypeRef of the first argument, and we don't
620- // want to read any other metadata as it can trigger missing-assembly errors. It turns out ImportILTypeRef
621- // is less eager in reading metadata than GetParamTypes.
622- //
623- // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension
624- // methods for tuple occur in C# code)
625- let thisTyconRef = GetTyconRefForExtensionMembers minfo tcrefOfStaticClass.Deref amap m g
626- match thisTyconRef with
627- | None -> ()
628- | Some ( Some tcref) -> yield Choice1Of2( tcref, ilExtMem)
629- | Some None -> yield Choice2Of2 ilExtMem ]
630- else
631- []
580+ g.langVersion.SupportsFeature( LanguageFeature.CSharpExtensionAttributeNotRequired) &&
581+ tcrefOfStaticClass.IsLocalRef &&
582+ not tcrefOfStaticClass.IsTypeAbbrev
583+
584+ if not isApplicable then [] else
585+
586+ let ty = generalizedTyconRef g tcrefOfStaticClass
587+ let pri = NextExtensionMethodPriority()
588+
589+ let methods =
590+ protectAssemblyExploration []
591+ ( fun () -> GetImmediateIntrinsicMethInfosOfType ( None, AccessorDomain.AccessibleFromSomeFSharpCode) g amap m ty)
592+
593+ [ for minfo in methods do
594+ if IsMethInfoPlainCSharpStyleExtensionMember g m true minfo then
595+ let ilExtMem = ILExtMem ( tcrefOfStaticClass, minfo, pri)
596+ // The results are indexed by the TyconRef of the first 'this' argument, if any.
597+ // So we need to go and crack the type of the 'this' argument.
598+ //
599+ // This is convoluted because we only need the ILTypeRef of the first argument, and we don't
600+ // want to read any other metadata as it can trigger missing-assembly errors. It turns out ImportILTypeRef
601+ // is less eager in reading metadata than GetParamTypes.
602+ //
603+ // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension
604+ // methods for tuple occur in C# code)
605+ let thisTyconRef = GetTyconRefForExtensionMembers minfo tcrefOfStaticClass.Deref amap m g
606+ match thisTyconRef with
607+ | None -> ()
608+ | Some ( Some tcref) -> yield Choice1Of2( tcref, ilExtMem)
609+ | Some None -> yield Choice2Of2 ilExtMem ]
632610
633611/// Query the declared properties of a type (including inherited properties)
634612let IntrinsicPropInfosOfTypeInScope ( infoReader : InfoReader ) optFilter ad findFlag m ty =
0 commit comments