Skip to content

Commit fa4dcfc

Browse files
authored
Don't add property symbol for CLIEvent member. (#16658)
* Don't add property symbol for CLIEvent member. * Add release notes
1 parent ef6d5f2 commit fa4dcfc

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

docs/release-notes/.FSharp.Compiler.Service/8.0.300.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550))
66
* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588), [PR #16643](https://github.com/dotnet/fsharp/pull/16643))
77
* Keep parens for problematic exprs (`if`, `match`, etc.) in `$"{(…):N0}"`, `$"{(…),-3}"`, etc. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578))
8-
* Fix crash in DOTNET_SYSTEM_GLOBALIZATION_INVARIANT mode [#PR 16471](https://github.com/dotnet/fsharp/pull/16471))
9-
8+
* Fix crash in DOTNET_SYSTEM_GLOBALIZATION_INVARIANT mode ([PR #16471](https://github.com/dotnet/fsharp/pull/16471))
9+
* `[<CliEvent>]` member should not produce property symbol. ([Issue #16640](https://github.com/dotnet/fsharp/issues/16640), [PR #16658](https://github.com/dotnet/fsharp/pull/16658))
1010

1111
### Added
1212

src/Compiler/Checking/CheckDeclarations.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,11 +1140,11 @@ module MutRecBindingChecking =
11401140
for b1, b2 in List.pairwise defnAs do
11411141
match b1, b2 with
11421142
| TyconBindingPhase2A.Phase2AMember {
1143-
SyntacticBinding = NormalizedBinding(pat = SynPat.Named(ident = SynIdent(ident = getIdent)); valSynData = SynValData(memberFlags = Some mf))
1143+
SyntacticBinding = NormalizedBinding(pat = SynPat.Named(ident = SynIdent(ident = Get_OrSet_Ident & getIdent)); valSynData = SynValData(memberFlags = Some mf))
11441144
RecBindingInfo = RecursiveBindingInfo(vspec = vGet)
11451145
},
11461146
TyconBindingPhase2A.Phase2AMember {
1147-
SyntacticBinding = NormalizedBinding(pat = SynPat.Named(ident = SynIdent(ident = setIdent)))
1147+
SyntacticBinding = NormalizedBinding(pat = SynPat.Named(ident = SynIdent(ident = Get_OrSet_Ident & setIdent)))
11481148
RecBindingInfo = RecursiveBindingInfo(vspec = vSet)
11491149
} when Range.equals getIdent.idRange setIdent.idRange ->
11501150
match vGet.ApparentEnclosingEntity with

src/Compiler/SyntaxTree/SyntaxTreeOps.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,3 +1062,9 @@ let (|TypesForTypar|) (t: SynType) =
10621062
| _ -> continuation [ t ]
10631063

10641064
visit id t
1065+
1066+
[<return: Struct>]
1067+
let (|Get_OrSet_Ident|_|) (ident: Ident) =
1068+
if ident.idText.StartsWithOrdinal("get_") then ValueSome()
1069+
elif ident.idText.StartsWithOrdinal("set_") then ValueSome()
1070+
else ValueNone

src/Compiler/SyntaxTree/SyntaxTreeOps.fsi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,7 @@ val getTypeFromTuplePath: path: SynTupleTypeSegment list -> SynType list
355355
val (|MultiDimensionArrayType|_|): t: SynType -> (int * SynType * range) voption
356356

357357
val (|TypesForTypar|): t: SynType -> SynType list
358+
359+
/// Generated get_XYZ or set_XYZ ident text
360+
[<return: Struct>]
361+
val (|Get_OrSet_Ident|_|): Ident -> unit voption

tests/service/Symbols.fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,3 +1214,24 @@ type T() =
12141214
let i = 1
12151215
"""
12161216
assertHasSymbolUsages ["i"] checkResults
1217+
1218+
module Event =
1219+
[<Test>]
1220+
let ``CLIEvent member does not produce additional property symbol`` () =
1221+
let _, checkResults = getParseAndCheckResults """
1222+
type T() =
1223+
[<CLIEvent>]
1224+
member this.Event = Event<int>().Publish
1225+
"""
1226+
let allSymbols =
1227+
checkResults.GetSymbolUsesAtLocation(4, 21, " member this.Event = Event<int>().Publish", [ "Event" ])
1228+
1229+
let hasPropertySymbols =
1230+
allSymbols
1231+
|> List.exists (fun su ->
1232+
match su.Symbol with
1233+
| :? FSharpMemberOrFunctionOrValue as mfv -> mfv.IsProperty
1234+
| _ -> false
1235+
)
1236+
1237+
Assert.False hasPropertySymbols

0 commit comments

Comments
 (0)