Skip to content

Commit

Permalink
guard against explicit getters/setters in Commands.GenerateXmlDocumen…
Browse files Browse the repository at this point in the history
…tation (#1124)

* guard against explicit getters/setters in Commands.GenerateXmlDocumentation

* Pin YoloDev.Expecto.TestSdk to 0.13.3 in ExpectoTests.fsproj
  • Loading branch information
dawedawe authored Jun 28, 2023
1 parent 3b20177 commit c784751
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1989,10 +1989,14 @@ type Commands(checker: FSharpCompilerServiceChecker, state: State, hasAnalyzers:
{ new SyntaxVisitorBase<_>() with
member _.VisitBinding(_, defaultTraverse, synBinding) =
match synBinding with
| SynBinding(xmlDoc = xmlDoc) as s when
| SynBinding(xmlDoc = xmlDoc; valData = valData) as s when
rangeContainsPos s.RangeOfBindingWithoutRhs pos && xmlDoc.IsEmpty
->
Some()
match valData with
| SynValData(memberFlags = Some({ MemberKind = SynMemberKind.PropertyGet }))
| SynValData(memberFlags = Some({ MemberKind = SynMemberKind.PropertySet }))
| SynValData(memberFlags = Some({ MemberKind = SynMemberKind.PropertyGetSet })) -> None
| _ -> Some()
| _ -> defaultTraverse synBinding

member _.VisitComponentInfo(_, synComponentInfo) =
Expand Down
37 changes: 37 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,43 @@ let private generateXmlDocumentationTests state =
member val Name = "" with get, set
"""

testCaseAsync "not applicable for explicit getter and setter"
<| CodeFix.checkNotApplicable
server
"""
type MyClass() =
let mutable someField = ""
member _.Name
with $0get () = "foo"
and set (x: string) = someField <- x
"""
Diagnostics.acceptAll
selectCodeFix

testCaseAsync "not applicable for explicit getter"

<| CodeFix.checkNotApplicable
server
"""
type MyClass() =
member _.Name
with $0get () = "foo"
"""
Diagnostics.acceptAll
selectCodeFix

testCaseAsync "not applicable for explicit setter"
<| CodeFix.checkNotApplicable
server
"""
type MyClass() =
let mutable someField = ""
member _.Name
with s$0et (x: string) = someField <- x
"""
Diagnostics.acceptAll
selectCodeFix

testCaseAsync "documentation for named module"
<| CodeFix.check
server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="Expecto" Version="9.*" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.*" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.13.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
<PackageReference Update="FSharp.Core" Version="4.*" />
</ItemGroup>
Expand Down

0 comments on commit c784751

Please sign in to comment.