@@ -41,7 +41,10 @@ module Impl =
41
41
System.Collections.ObjectModel.ReadOnlyCollection<_>( Seq.toArray arr) :> IList<_>
42
42
let makeXmlDoc ( XmlDoc x ) = makeReadOnlyCollection ( x)
43
43
44
- let rescopeEntity viewedCcu ( entity : Entity ) =
44
+ let rescopeEntity optViewedCcu ( entity : Entity ) =
45
+ match optViewedCcu with
46
+ | None -> mkLocalEntityRef entity
47
+ | Some viewedCcu ->
45
48
match tryRescopeEntity viewedCcu entity with
46
49
| None -> mkLocalEntityRef entity
47
50
| Some eref -> eref
@@ -1115,9 +1118,37 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
1115
1118
| P m ->
1116
1119
let minfo = m.GetterMethod
1117
1120
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"
1121
1152
1122
1153
member __.HasSetterMethod =
1123
1154
if isUnresolved() then false
@@ -1446,9 +1477,15 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
1446
1477
| E e ->
1447
1478
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
1448
1479
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
1451
1487
FSharpParameter( cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg= false , isOutArg= false , isOptionalArg= false )
1488
+
1452
1489
| P p ->
1453
1490
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
1454
1491
let retInfo : ArgReprInfo = { Name= None; Attribs= [] }
@@ -1813,9 +1850,13 @@ and FSharpParameter(cenv, typ:TType, topArgInfo:ArgReprInfo, mOpt, isParamArrayA
1813
1850
override x.ToString () =
1814
1851
" parameter " + ( match x.Name with None -> " <unnamed" | Some s -> s)
1815
1852
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 ) =
1817
1854
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)
1819
1860
1820
1861
member __.Entities =
1821
1862
@@ -1824,7 +1865,8 @@ and FSharpAssemblySignature internal (cenv, topAttribs: TypeChecker.TopAttribs o
1824
1865
if entity.IsNamespace then
1825
1866
yield ! loop entity.ModuleOrNamespaceType
1826
1867
else
1827
- yield FSharpEntity( cenv, mkLocalEntityRef entity) |]
1868
+ let entityRef = rescopeEntity optViewedCcu entity
1869
+ yield FSharpEntity( cenv, entityRef) |]
1828
1870
1829
1871
loop mtyp |> makeReadOnlyCollection
1830
1872
@@ -1839,15 +1881,15 @@ and FSharpAssemblySignature internal (cenv, topAttribs: TypeChecker.TopAttribs o
1839
1881
1840
1882
and FSharpAssembly internal ( cenv , ccu : CcuThunk ) =
1841
1883
1842
- new ( g , thisCcu , tcImports , ccu ) = FSharpAssembly( cenv( g, thisCcu , tcImports), ccu)
1884
+ new ( g , tcImports , ccu ) = FSharpAssembly( cenv( g, ccu , tcImports), ccu)
1843
1885
1844
1886
member __.RawCcuThunk = ccu
1845
1887
member __.QualifiedName = match ccu.QualifiedName with None -> " " | Some s -> s
1846
1888
member __.CodeLocation = ccu.SourceCodeDirectory
1847
1889
member __.FileName = ccu.FileName
1848
1890
member __.SimpleName = ccu.AssemblyName
1849
1891
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)
1851
1893
1852
1894
override x.ToString () = x.QualifiedName
1853
1895
0 commit comments