Skip to content

Commit fe08ab0

Browse files
CopilotT-Gro
andcommitted
Fix CLIEvent IsEvent property and XmlDocSig prefix
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
1 parent 0cb12fd commit fe08ab0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Compiler/Symbols/Symbols.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
18901890
member _.IsEvent =
18911891
match d with
18921892
| E _ -> true
1893+
| P p when p.IsFSharpEventProperty -> true // CLIEvent properties should be considered events
18931894
| _ -> false
18941895

18951896
member _.EventForFSharpProperty =
@@ -2072,6 +2073,9 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
20722073
| P p ->
20732074
let range = defaultArg sym.DeclarationLocationOpt range0
20742075
match GetXmlDocSigOfProp cenv.infoReader range p with
2076+
| Some (_, docsig) when p.IsFSharpEventProperty && docsig.StartsWith("P:") ->
2077+
// For CLIEvent properties, use E: prefix instead of P:
2078+
"E:" + docsig.Substring(2)
20752079
| Some (_, docsig) -> docsig
20762080
| _ -> ""
20772081
| M m | C m ->

tests/FSharp.Compiler.Service.Tests/Symbols.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,26 @@ type T() =
13111311
)
13121312

13131313
Assert.False hasPropertySymbols
1314+
1315+
[<Fact>]
1316+
let ``CLIEvent is recognized as event`` () =
1317+
let _, checkResults = getParseAndCheckResults """
1318+
type T() =
1319+
[<CLIEvent>]
1320+
member this.Event = Event<int>().Publish
1321+
"""
1322+
let symbolUse =
1323+
checkResults.GetSymbolUsesAtLocation(4, 21, " member this.Event = Event<int>().Publish", [ "Event" ])
1324+
|> List.head
1325+
1326+
match symbolUse.Symbol with
1327+
| :? FSharpMemberOrFunctionOrValue as mfv ->
1328+
// CLIEvent properties should be recognized as events
1329+
Assert.True mfv.IsEvent
1330+
// Their XmlDocSig should use E: prefix
1331+
Assert.StartsWith("E:", mfv.XmlDocSig)
1332+
| _ ->
1333+
Assert.True(false, "Expected FSharpMemberOrFunctionOrValue")
13141334

13151335
module Delegates =
13161336
[<Fact>]

0 commit comments

Comments
 (0)