Skip to content

Commit

Permalink
offer "generate xml documentation" to properties with explicit getter…
Browse files Browse the repository at this point in the history
…/setter (#1126)
  • Loading branch information
dawedawe authored Jul 1, 2023
1 parent 0e4a2e3 commit 95fa929
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,18 @@ type Commands
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)
Expand Down
63 changes: 63 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
/// <summary></summary>
/// <returns></returns>
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 = ""
/// <summary></summary>
/// <returns></returns>
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 = ""
/// <summary></summary>
/// <param name="x"></param>
/// <returns></returns>
member _.Name
with set (x: string) = someField <- x
"""

testCaseAsync "not applicable for explicit getter"

<| CodeFix.checkNotApplicable
Expand Down

0 comments on commit 95fa929

Please sign in to comment.