Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offer "generate xml documentation" to properties with explicit getter/setter #1126

Merged
merged 1 commit into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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