Skip to content

Commit

Permalink
negate instance member invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Mar 25, 2024
1 parent 339e5d7 commit 18d87af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/FsAutoComplete/CodeFixes/NegateBooleanExpression.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ let fix (getParseResultsForFile: GetParseResultsForFile) : CodeFix =
Path = path
NeedsParensAfterNot = true }

// X.Y()
| SynExpr.App(funcExpr = SynExpr.LongIdent(longDotId = LastIdentFromSynLongIdent ident))

// X().Y()
| SynExpr.App(funcExpr = SynExpr.DotGet(longDotId = LastIdentFromSynLongIdent ident))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,24 @@ type X() =
let b = not (X().Y())"

testCaseAsync "negate instance member invocation"
<| CodeFix.check
server
"
open System.Collections.Generic
let foo () =
let dict = dict []
dict.TryAdd$0(\"foo\", \"bar\")
()"
Diagnostics.acceptAll
selectCodeFix
"
open System.Collections.Generic
let foo () =
let dict = dict []
(not (dict.TryAdd(\"foo\", \"bar\")))
()"

])

0 comments on commit 18d87af

Please sign in to comment.