@@ -390,29 +390,83 @@ c.Abc
390
390
391
391
testToolTipSquashing source 7 5 " c.Abc" [ " c" ; " Abc" ] FSharpTokenTag.Identifier
392
392
393
- [<Fact>]
394
- let ``Auto property should display a single tool tip`` () =
395
- let source = """
396
- namespace Foo
397
-
398
- /// Some comment on class
399
- type Bar() =
400
- /// Some comment on class member
401
- member val Foo = "bla" with get, set
402
- """
393
+ let getCheckResults source options =
403
394
let fileName , options =
404
395
mkTestFileAndOptions
405
396
source
406
- Array.empty
397
+ options
407
398
let _ , checkResults = parseAndCheckFile fileName source options
408
- let ( ToolTipText ( items )) = checkResults.GetToolTip( 7 , 18 , " member val Foo = \" bla\" with get, set" , [ " Foo" ], FSharpTokenTag.Identifier)
409
- Assert.True ( items.Length = 1 )
399
+ checkResults
400
+
401
+ let assertAndGetSingleToolTipText ( ToolTipText ( items )) =
402
+ Assert.Equal( 1 , items.Length)
410
403
match items.[ 0 ] with
411
404
| ToolTipElement.Group [ { MainDescription = description } ] ->
412
405
let toolTipText =
413
406
description
414
407
|> Array.map ( fun taggedText -> taggedText.Text)
415
408
|> String.concat " "
416
-
417
- Assert.Equal( " property Bar.Foo: string with get, set" , toolTipText)
409
+ toolTipText
418
410
| _ -> failwith $" Expected group, got {items.[0]}"
411
+
412
+ let normalize ( s : string ) = s.Replace( " \r\n " , " \n " ) .Replace( " \n\n " , " \n " )
413
+
414
+ [<Fact>]
415
+ let ``Auto property should display a single tool tip`` () =
416
+ let source = """
417
+ namespace Foo
418
+
419
+ /// Some comment on class
420
+ type Bar() =
421
+ /// Some comment on class member
422
+ member val Foo = "bla" with get, set
423
+ """
424
+ let checkResults = getCheckResults source Array.empty
425
+ checkResults.GetToolTip( 7 , 18 , " member val Foo = \" bla\" with get, set" , [ " Foo" ], FSharpTokenTag.Identifier)
426
+ |> assertAndGetSingleToolTipText
427
+ |> Assert.shouldBeEquivalentTo " property Bar.Foo: string with get, set"
428
+
429
+ [<FactForNETCOREAPP>]
430
+ let ``Should display nullable Csharp code analysis annotations on method argument`` () =
431
+
432
+ let source = """ module Foo
433
+ let exists() = System.IO.Path.Exists(null:string)
434
+ """
435
+ let checkResults = getCheckResults source [| " --checknulls+" ; " --langversion:preview" |]
436
+ checkResults.GetToolTip( 2 , 36 , " let exists() = System.IO.Path.Exists(null:string)" , [ " Exists" ], FSharpTokenTag.Identifier)
437
+ |> assertAndGetSingleToolTipText
438
+ |> Assert.shouldBeEquivalentTo " System.IO.Path.Exists([<NotNullWhenAttribute (true)>] path: string | null) : bool"
439
+
440
+
441
+ [<FactForNETCOREAPP>]
442
+ let ``Should display nullable Csharp code analysis annotations on method return type`` () =
443
+
444
+ let source = """ module Foo
445
+ let getPath() = System.IO.Path.GetFileName(null:string)
446
+ """
447
+ let checkResults = getCheckResults source [| " --checknulls+" ; " --langversion:preview" |]
448
+ checkResults.GetToolTip( 2 , 42 , " let getPath() = System.IO.Path.GetFileName(null:string)" , [ " GetFileName" ], FSharpTokenTag.Identifier)
449
+ |> assertAndGetSingleToolTipText
450
+ |> Assert.shouldBeEquivalentTo ( """ [<return:NotNullIfNotNullAttribute ("path")>]
451
+ System.IO.Path.GetFileName(path: string | null) : string | null""" |> normalize)
452
+
453
+ [<FactForNETCOREAPP>]
454
+ let ``Should display nullable Csharp code analysis annotations on TryParse pattern`` () =
455
+ let source = """ module Foo
456
+ let success,version = System.Version.TryParse(null)
457
+ """
458
+ let checkResults = getCheckResults source [| " --checknulls+" ; " --langversion:preview" |]
459
+ checkResults.GetToolTip( 2 , 45 , " let success,version = System.Version.TryParse(null)" , [ " TryParse" ], FSharpTokenTag.Identifier)
460
+ |> assertAndGetSingleToolTipText
461
+ |> Assert.shouldBeEquivalentTo ( """ System.Version.TryParse([<NotNullWhenAttribute (true)>] input: string | null, [<NotNullWhenAttribute (true)>] result: byref<System.Version | null>) : bool""" )
462
+
463
+ [<FactForNETCOREAPP>]
464
+ let ``Display with nullable annotations can be squashed`` () =
465
+ let source = """ module Foo
466
+ let success,version = System.Version.TryParse(null)
467
+ """
468
+ let checkResults = getCheckResults source [| " --checknulls+" ; " --langversion:preview" |]
469
+ checkResults.GetToolTip( 2 , 45 , " let success,version = System.Version.TryParse(null)" , [ " TryParse" ], FSharpTokenTag.Identifier, width= 100 )
470
+ |> assertAndGetSingleToolTipText
471
+ |> Assert.shouldBeEquivalentTo ( """ System.Version.TryParse([<NotNullWhenAttribute (true)>] input: string | null,
472
+ [<NotNullWhenAttribute (true)>] result: byref<System.Version | null>) : bool""" |> normalize)
0 commit comments