From c78475191651687507e893a455335d18e29d52b4 Mon Sep 17 00:00:00 2001 From: dawe Date: Wed, 28 Jun 2023 11:39:38 +0200 Subject: [PATCH] guard against explicit getters/setters in Commands.GenerateXmlDocumentation (#1124) * guard against explicit getters/setters in Commands.GenerateXmlDocumentation * Pin YoloDev.Expecto.TestSdk to 0.13.3 in ExpectoTests.fsproj --- src/FsAutoComplete.Core/Commands.fs | 8 +++- .../CodeFixTests/Tests.fs | 37 +++++++++++++++++++ .../ExpectoTests/ExpectoTests.fsproj | 2 +- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/FsAutoComplete.Core/Commands.fs b/src/FsAutoComplete.Core/Commands.fs index aaf980315..ca6f93544 100644 --- a/src/FsAutoComplete.Core/Commands.fs +++ b/src/FsAutoComplete.Core/Commands.fs @@ -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) = diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs index 272c6d527..5f6ba2e5f 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs @@ -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 diff --git a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj index 647a91da2..f065837b8 100644 --- a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj +++ b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj @@ -13,7 +13,7 @@ - +