@@ -41,7 +41,10 @@ module Impl =
4141 System.Collections.ObjectModel.ReadOnlyCollection<_>( Seq.toArray arr) :> IList<_>
4242 let makeXmlDoc ( XmlDoc x ) = makeReadOnlyCollection ( x)
4343
44- let rescopeEntity viewedCcu ( entity : Entity ) =
44+ let rescopeEntity optViewedCcu ( entity : Entity ) =
45+ match optViewedCcu with
46+ | None -> mkLocalEntityRef entity
47+ | Some viewedCcu ->
4548 match tryRescopeEntity viewedCcu entity with
4649 | None -> mkLocalEntityRef entity
4750 | Some eref -> eref
@@ -1115,9 +1118,37 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
11151118 | P m ->
11161119 let minfo = m.GetterMethod
11171120 FSharpMemberOrFunctionOrValue( cenv, M minfo, Item.MethodGroup ( minfo.DisplayName,[ minfo]))
1118- | E _
1119- | M _
1120- | V _ -> invalidOp " the value or member doesn't have an associated getter method"
1121+ | E _ | M _ | V _ -> invalidOp " the value or member doesn't have an associated getter method"
1122+
1123+ member __.EventAddMethod =
1124+ checkIsResolved()
1125+ match d with
1126+ | E e ->
1127+ let minfo = e.GetAddMethod()
1128+ FSharpMemberOrFunctionOrValue( cenv, M minfo, Item.MethodGroup ( minfo.DisplayName,[ minfo]))
1129+ | P _ | M _ | V _ -> invalidOp " the value or member doesn't have an associated add method"
1130+
1131+ member __.EventRemoveMethod =
1132+ checkIsResolved()
1133+ match d with
1134+ | E e ->
1135+ let minfo = e.GetRemoveMethod()
1136+ FSharpMemberOrFunctionOrValue( cenv, M minfo, Item.MethodGroup ( minfo.DisplayName,[ minfo]))
1137+ | P _ | M _ | V _ -> invalidOp " the value or member doesn't have an associated remove method"
1138+
1139+ member __.EventDelegateType =
1140+ checkIsResolved()
1141+ match d with
1142+ | E e -> FSharpType( cenv, e.GetDelegateType( cenv.amap, range0))
1143+ | P _ | M _ | V _ -> invalidOp " the value or member doesn't have an associated event delegate type"
1144+
1145+ member __.EventIsStandard =
1146+ checkIsResolved()
1147+ match d with
1148+ | E e ->
1149+ let dty = e.GetDelegateType( cenv.amap, range0)
1150+ TryDestStandardDelegateTyp cenv.infoReader range0 AccessibleFromSomewhere dty |> isSome
1151+ | P _ | M _ | V _ -> invalidOp " the value or member is not an event"
11211152
11221153 member __.HasSetterMethod =
11231154 if isUnresolved() then false
@@ -1446,9 +1477,15 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
14461477 | E e ->
14471478 // INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
14481479 let retInfo : ArgReprInfo = { Name= None; Attribs= [] }
1449- let rty = PropTypOfEventInfo cenv.infoReader range0 AccessibleFromSomewhere e
1450- let _ , rty , _cxs = PrettyTypes.PrettifyTypes1 cenv.g rty
1480+ let rty =
1481+ try PropTypOfEventInfo cenv.infoReader range0 AccessibleFromSomewhere e
1482+ with _ ->
1483+ // For non-standard events, just use the delegate type as the ReturnParameter type
1484+ e.GetDelegateType( cenv.amap, range0)
1485+
1486+ let _ , rty , _cxs = PrettyTypes.PrettifyTypes1 cenv.g rty
14511487 FSharpParameter( cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg= false , isOutArg= false , isOptionalArg= false )
1488+
14521489 | P p ->
14531490 // INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
14541491 let retInfo : ArgReprInfo = { Name= None; Attribs= [] }
@@ -1813,9 +1850,13 @@ and FSharpParameter(cenv, typ:TType, topArgInfo:ArgReprInfo, mOpt, isParamArrayA
18131850 override x.ToString () =
18141851 " parameter " + ( match x.Name with None -> " <unnamed" | Some s -> s)
18151852
1816- and FSharpAssemblySignature internal ( cenv , topAttribs : TypeChecker.TopAttribs option , mtyp : ModuleOrNamespaceType ) =
1853+ and FSharpAssemblySignature private ( cenv , topAttribs : TypeChecker.TopAttribs option , optViewedCcu : CcuThunk option, mtyp : ModuleOrNamespaceType ) =
18171854
1818- new ( g , thisCcu , tcImports , topAttribs , mtyp ) = FSharpAssemblySignature( cenv( g, thisCcu, tcImports), topAttribs, mtyp)
1855+ // Assembly signature for a referenced/linked assembly
1856+ new ( cenv , ccu : CcuThunk ) = FSharpAssemblySignature(( if ccu.IsUnresolvedReference then cenv else ( new cenv( cenv.g, ccu, cenv.tcImports))), None, Some ccu, ccu.Contents.ModuleOrNamespaceType)
1857+
1858+ // Assembly signature for an assembly produced via type-checking.
1859+ new ( g , thisCcu , tcImports , topAttribs , mtyp ) = FSharpAssemblySignature( cenv( g, thisCcu, tcImports), topAttribs, None, mtyp)
18191860
18201861 member __.Entities =
18211862
@@ -1824,7 +1865,8 @@ and FSharpAssemblySignature internal (cenv, topAttribs: TypeChecker.TopAttribs o
18241865 if entity.IsNamespace then
18251866 yield ! loop entity.ModuleOrNamespaceType
18261867 else
1827- yield FSharpEntity( cenv, mkLocalEntityRef entity) |]
1868+ let entityRef = rescopeEntity optViewedCcu entity
1869+ yield FSharpEntity( cenv, entityRef) |]
18281870
18291871 loop mtyp |> makeReadOnlyCollection
18301872
@@ -1839,15 +1881,15 @@ and FSharpAssemblySignature internal (cenv, topAttribs: TypeChecker.TopAttribs o
18391881
18401882and FSharpAssembly internal ( cenv , ccu : CcuThunk ) =
18411883
1842- new ( g , thisCcu , tcImports , ccu ) = FSharpAssembly( cenv( g, thisCcu , tcImports), ccu)
1884+ new ( g , tcImports , ccu ) = FSharpAssembly( cenv( g, ccu , tcImports), ccu)
18431885
18441886 member __.RawCcuThunk = ccu
18451887 member __.QualifiedName = match ccu.QualifiedName with None -> " " | Some s -> s
18461888 member __.CodeLocation = ccu.SourceCodeDirectory
18471889 member __.FileName = ccu.FileName
18481890 member __.SimpleName = ccu.AssemblyName
18491891 member __.IsProviderGenerated = ccu.IsProviderGenerated
1850- member __.Contents = FSharpAssemblySignature(( if ccu.IsUnresolvedReference then cenv else ( new cenv ( cenv.g , ccu, cenv.tcImports ))), None , ccu.Contents.ModuleOrNamespaceType )
1892+ member __.Contents = FSharpAssemblySignature( cenv, ccu)
18511893
18521894 override x.ToString () = x.QualifiedName
18531895
0 commit comments