From cc258f72bb95c5afdd36e104c1c8cf0b7ad279e6 Mon Sep 17 00:00:00 2001 From: dawe Date: Sat, 1 Jul 2023 15:41:04 +0200 Subject: [PATCH] offer "generate xml documentation" to properties with explicit getter/setter --- src/FsAutoComplete.Core/Commands.fs | 12 ++++ .../CodeFixTests/Tests.fs | 63 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/FsAutoComplete.Core/Commands.fs b/src/FsAutoComplete.Core/Commands.fs index ca6f93544..4a60686e9 100644 --- a/src/FsAutoComplete.Core/Commands.fs +++ b/src/FsAutoComplete.Core/Commands.fs @@ -2091,6 +2091,18 @@ type Commands(checker: FSharpCompilerServiceChecker, state: State, hasAnalyzers: rangeContainsPos ident.idRange pos && xmlDoc.IsEmpty -> Some() + | SynMemberDefn.GetSetMember( + memberDefnForGet = Some(SynBinding( + xmlDoc = xmlDoc; headPat = SynPat.LongIdent(longDotId = longDotId)))) when + rangeContainsPos longDotId.Range pos && xmlDoc.IsEmpty + -> + Some() + | SynMemberDefn.GetSetMember( + memberDefnForSet = Some(SynBinding( + xmlDoc = xmlDoc; headPat = SynPat.LongIdent(longDotId = longDotId)))) when + rangeContainsPos longDotId.Range pos && xmlDoc.IsEmpty + -> + Some() | _ -> None) | _ -> None) | _ -> None) diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs index 5f6ba2e5f..216017423 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs @@ -1618,6 +1618,69 @@ let private generateXmlDocumentationTests state = Diagnostics.acceptAll selectCodeFix + testCaseAsync "documentation on property with explicit getter and setter" + <| CodeFix.check + server + """ + type MyClass() = + let mutable someField = "" + member _.$0Name + with get () = "foo" + and set (x: string) = someField <- x + """ + Diagnostics.acceptAll + selectCodeFix + """ + type MyClass() = + let mutable someField = "" + /// + /// + member _.Name + with get () = "foo" + and set (x: string) = someField <- x + """ + + testCaseAsync "documentation on property with explicit getter" + <| CodeFix.check + server + """ + type MyClass() = + let mutable someField = "" + member _.$0Name + with get () = "foo" + """ + Diagnostics.acceptAll + selectCodeFix + """ + type MyClass() = + let mutable someField = "" + /// + /// + member _.Name + with get () = "foo" + """ + + testCaseAsync "documentation on property with explicit setter" + <| CodeFix.check + server + """ + type MyClass() = + let mutable someField = "" + member _.$0Name + with set (x: string) = someField <- x + """ + Diagnostics.acceptAll + selectCodeFix + """ + type MyClass() = + let mutable someField = "" + /// + /// + /// + member _.Name + with set (x: string) = someField <- x + """ + testCaseAsync "not applicable for explicit getter" <| CodeFix.checkNotApplicable