Skip to content

Commit df2821a

Browse files
CopilotT-Gro
andcommitted
Fix CLIEvent IsEvent property and XmlDocSig prefix with test adjustments
Co-authored-by: T-Gro <[email protected]>
1 parent a7c9a7c commit df2821a

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/Compiler/Symbols/Symbols.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
18901890
member _.IsEvent =
18911891
match d with
18921892
| E _ -> true
1893-
// Keep the original behavior for now to avoid breaking existing tests
1893+
| P p when p.IsFSharpEventProperty -> true // CLIEvent properties should be considered events
18941894
| _ -> false
18951895

18961896
member _.EventForFSharpProperty =
@@ -2073,6 +2073,9 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
20732073
| P p ->
20742074
let range = defaultArg sym.DeclarationLocationOpt range0
20752075
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)
20762079
| Some (_, docsig) -> docsig
20772080
| _ -> ""
20782081
| M m | C m ->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ let attribsOfSymbol (symbol: FSharpSymbol) =
299299
if v.IsDispatchSlot then yield "slot"
300300
if v.IsModuleValueOrMember && not v.IsMember then yield "val"
301301
if v.IsMember then yield "member"
302-
if v.IsProperty then yield "prop"
302+
if v.IsProperty && not v.IsEvent then yield "prop" // Only properties that are not events should have the prop tag
303303
if v.IsExtensionMember then yield "extmem"
304304
if v.IsPropertyGetterMethod then yield "getter"
305305
if v.IsPropertySetterMethod then yield "setter"

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,10 +1314,8 @@ type T() =
13141314

13151315
[<Fact>]
13161316
let ``CLIEvent is recognized as event`` () =
1317-
// TODO: This test passes, but we'd ideally like CLIEvent properties to be
1318-
// recognized as events in the FSharpMemberOrFunctionOrValue.IsEvent property
1319-
// and to use "E:" XmlDocSig prefix.
1320-
// This would require additional coordination with test expectations in ProjectAnalysisTests.
1317+
// Now CLIEvent properties are recognized as events in the FSharpMemberOrFunctionOrValue.IsEvent property
1318+
// and use "E:" XmlDocSig prefix
13211319
let _, checkResults = getParseAndCheckResults """
13221320
type T() =
13231321
[<CLIEvent>]
@@ -1329,10 +1327,10 @@ type T() =
13291327

13301328
match symbolUse.Symbol with
13311329
| :? FSharpMemberOrFunctionOrValue as mfv ->
1332-
// Currently CLIEvent properties are not recognized as events, they're still properties
1333-
Assert.False mfv.IsEvent
1334-
// Their XmlDocSig currently uses P: prefix
1335-
Assert.StartsWith("P:", mfv.XmlDocSig)
1330+
// CLIEvent properties are recognized as events
1331+
Assert.True mfv.IsEvent
1332+
// Their XmlDocSig uses E: prefix
1333+
Assert.StartsWith("E:", mfv.XmlDocSig)
13361334
| _ ->
13371335
Assert.True(false, "Expected FSharpMemberOrFunctionOrValue")
13381336

0 commit comments

Comments
 (0)