diff --git a/src/Compiler/Service/FSharpParseFileResults.fs b/src/Compiler/Service/FSharpParseFileResults.fs
index 2cb1110b76a..3589c79f0d8 100644
--- a/src/Compiler/Service/FSharpParseFileResults.fs
+++ b/src/Compiler/Service/FSharpParseFileResults.fs
@@ -398,6 +398,35 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
SyntaxTraversal.Traverse(expressionPos, input, visitor)
+ member _.TryRangeOfReturnTypeHint(symbolUseStart: pos, ?skipLambdas) =
+ let skipLambdas = defaultArg skipLambdas true
+
+ SyntaxTraversal.Traverse(
+ symbolUseStart,
+ input,
+ { new SyntaxVisitorBase<_>() with
+ member _.VisitExpr(_path, _traverseSynExpr, defaultTraverse, expr) = defaultTraverse expr
+
+ override _.VisitBinding(_path, defaultTraverse, binding) =
+ match binding with
+ | SynBinding(expr = SynExpr.Lambda _) when skipLambdas -> defaultTraverse binding
+
+ // Skip manually type-annotated bindings
+ | SynBinding(returnInfo = Some (SynBindingReturnInfo(typeName = SynType.LongIdent _))) -> defaultTraverse binding
+
+ // Let binding
+ | SynBinding (trivia = { EqualsRange = Some equalsRange }; range = range) when range.Start = symbolUseStart ->
+ Some equalsRange.StartRange
+
+ // Member binding
+ | SynBinding (headPat = SynPat.LongIdent(longDotId = SynLongIdent(id = _ :: ident :: _))
+ trivia = { EqualsRange = Some equalsRange }) when ident.idRange.Start = symbolUseStart ->
+ Some equalsRange.StartRange
+
+ | _ -> defaultTraverse binding
+ }
+ )
+
member _.FindParameterLocations pos = ParameterLocations.Find(pos, input)
member _.IsPositionContainedInACurriedParameter pos =
diff --git a/src/Compiler/Service/FSharpParseFileResults.fsi b/src/Compiler/Service/FSharpParseFileResults.fsi
index e20de374d16..2d3918015c2 100644
--- a/src/Compiler/Service/FSharpParseFileResults.fsi
+++ b/src/Compiler/Service/FSharpParseFileResults.fsi
@@ -52,6 +52,10 @@ type public FSharpParseFileResults =
/// Gets the range of an expression being dereferenced. For `!expr`, gives the range of `expr`
member TryRangeOfExpressionBeingDereferencedContainingPos: expressionPos: pos -> range option
+ /// Gets the range of where a return type hint could be placed for a function binding. This will be right in front of the equals sign.
+ /// Returns None if type annotation is present.
+ member TryRangeOfReturnTypeHint: symbolUseStart: pos * ?skipLambdas: bool -> range option
+
/// Notable parse info for ParameterInfo at a given location
member FindParameterLocations: pos: pos -> ParameterLocations option
diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs
index 69ab4da96e1..2c799cdcbca 100644
--- a/src/Compiler/Symbols/Symbols.fs
+++ b/src/Compiler/Symbols/Symbols.fs
@@ -2331,24 +2331,20 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
|> LayoutRender.toArray
member x.GetReturnTypeLayout (displayContext: FSharpDisplayContext) =
- match x.IsMember, d with
- | true, _ ->
- None
- | false, _ ->
- checkIsResolved()
- match d with
- | E _
- | P _
- | C _ -> None
- | M m ->
- let retTy = m.GetFSharpReturnType(cenv.amap, range0, m.FormalMethodInst)
- NicePrint.layoutType (displayContext.Contents cenv.g) retTy
- |> LayoutRender.toArray
- |> Some
- | V v ->
- NicePrint.layoutOfValReturnType (displayContext.Contents cenv.g) v
- |> LayoutRender.toArray
- |> Some
+ checkIsResolved()
+ match d with
+ | E _
+ | P _
+ | C _ -> None
+ | M m ->
+ let retTy = m.GetFSharpReturnType(cenv.amap, range0, m.FormalMethodInst)
+ NicePrint.layoutType (displayContext.Contents cenv.g) retTy
+ |> LayoutRender.toArray
+ |> Some
+ | V v ->
+ NicePrint.layoutOfValReturnType (displayContext.Contents cenv.g) v
+ |> LayoutRender.toArray
+ |> Some
member x.GetWitnessPassingInfo() =
let witnessInfos =
diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl
index 86a216e066b..5cf10db4690 100644
--- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl
+++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl
@@ -2091,6 +2091,7 @@ FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FShar
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfNameOfNearestOuterBindingContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfRecordExpressionContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfRefCellDereferenceContainingPos(FSharp.Compiler.Text.Position)
+FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfReturnTypeHint(FSharp.Compiler.Text.Position, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean])
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfStringInterpolationContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ValidateBreakpointLocation(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]] GetAllArgumentsForFunctionApplicationAtPosition(FSharp.Compiler.Text.Position)
diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl
index 86a216e066b..5cf10db4690 100644
--- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl
+++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl
@@ -2091,6 +2091,7 @@ FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FShar
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfNameOfNearestOuterBindingContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfRecordExpressionContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfRefCellDereferenceContainingPos(FSharp.Compiler.Text.Position)
+FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfReturnTypeHint(FSharp.Compiler.Text.Position, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean])
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfStringInterpolationContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ValidateBreakpointLocation(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]] GetAllArgumentsForFunctionApplicationAtPosition(FSharp.Compiler.Text.Position)
diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
index e14959f62a6..6ba152f9233 100644
--- a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
+++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
@@ -137,6 +137,7 @@
+
diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx
index 505a8cf1629..53f3978cdb1 100644
--- a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx
+++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx
@@ -224,6 +224,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/Hints/HintService.fs b/vsintegration/src/FSharp.Editor/Hints/HintService.fs
index ee6b6ac6c1f..d83b182348d 100644
--- a/vsintegration/src/FSharp.Editor/Hints/HintService.fs
+++ b/vsintegration/src/FSharp.Editor/Hints/HintService.fs
@@ -17,6 +17,9 @@ module HintService =
Seq.filter (InlineTypeHints.isValidForHint parseResults symbol)
>> Seq.collect (InlineTypeHints.getHints symbol)
+ let inline private getReturnTypeHints parseResults symbol =
+ Seq.collect (InlineReturnTypeHints(parseResults, symbol).getHints)
+
let inline private getHintsForMemberOrFunctionOrValue (sourceText: SourceText) parseResults symbol : NativeHintResolver =
Seq.filter (InlineParameterNameHints.isMemberOrFunctionOrValueValidForHint symbol)
>> Seq.collect (InlineParameterNameHints.getHintsForMemberOrFunctionOrValue sourceText parseResults symbol)
@@ -35,6 +38,10 @@ module HintService =
match symbol with
| :? FSharpMemberOrFunctionOrValue as symbol -> getTypeHints parseResults symbol |> Some
| _ -> None
+ | HintKind.ReturnTypeHint ->
+ match symbol with
+ | :? FSharpMemberOrFunctionOrValue as symbol -> getReturnTypeHints parseResults symbol |> Some
+ | _ -> None
| HintKind.ParameterNameHint ->
match symbol with
| :? FSharpMemberOrFunctionOrValue as symbol ->
@@ -45,7 +52,7 @@ module HintService =
:: resolvers
|> resolve hintKinds
- in resolve hintKinds []
+ resolve hintKinds []
let private getHintsForSymbol (sourceText: SourceText) parseResults hintKinds (symbol: FSharpSymbol, symbolUses: FSharpSymbolUse seq) =
symbol
diff --git a/vsintegration/src/FSharp.Editor/Hints/Hints.fs b/vsintegration/src/FSharp.Editor/Hints/Hints.fs
index 428f1fa54ed..dcdb17e5eee 100644
--- a/vsintegration/src/FSharp.Editor/Hints/Hints.fs
+++ b/vsintegration/src/FSharp.Editor/Hints/Hints.fs
@@ -9,6 +9,7 @@ module Hints =
type HintKind =
| TypeHint
| ParameterNameHint
+ | ReturnTypeHint
// Relatively convenient for testing
type NativeHint =
@@ -22,3 +23,4 @@ module Hints =
match kind with
| TypeHint -> "type"
| ParameterNameHint -> "parameterName"
+ | ReturnTypeHint -> "returnType"
diff --git a/vsintegration/src/FSharp.Editor/Hints/InlineReturnTypeHints.fs b/vsintegration/src/FSharp.Editor/Hints/InlineReturnTypeHints.fs
new file mode 100644
index 00000000000..f9152c6e88e
--- /dev/null
+++ b/vsintegration/src/FSharp.Editor/Hints/InlineReturnTypeHints.fs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.VisualStudio.FSharp.Editor.Hints
+
+open Microsoft.VisualStudio.FSharp.Editor
+open FSharp.Compiler.CodeAnalysis
+open FSharp.Compiler.Symbols
+open FSharp.Compiler.Text
+open Hints
+
+type InlineReturnTypeHints(parseFileResults: FSharpParseFileResults, symbol: FSharpMemberOrFunctionOrValue) =
+
+ let getHintParts (symbolUse: FSharpSymbolUse) =
+ symbol.GetReturnTypeLayout symbolUse.DisplayContext
+ |> Option.map (fun typeInfo ->
+ [
+ TaggedText(TextTag.Text, ": ")
+ yield! typeInfo |> Array.toList
+ TaggedText(TextTag.Space, " ")
+ ])
+
+ let getHint symbolUse range =
+ getHintParts symbolUse
+ |> Option.map (fun parts ->
+ {
+ Kind = HintKind.ReturnTypeHint
+ Range = range
+ Parts = parts
+ })
+
+ member _.getHints(symbolUse: FSharpSymbolUse) =
+ [
+ if symbol.IsFunction then
+ yield!
+ parseFileResults.TryRangeOfReturnTypeHint symbolUse.Range.Start
+ |> Option.bind (getHint symbolUse)
+ |> Option.toList
+ ]
diff --git a/vsintegration/src/FSharp.Editor/Hints/OptionParser.fs b/vsintegration/src/FSharp.Editor/Hints/OptionParser.fs
index 181bc2b7c61..4b318490111 100644
--- a/vsintegration/src/FSharp.Editor/Hints/OptionParser.fs
+++ b/vsintegration/src/FSharp.Editor/Hints/OptionParser.fs
@@ -15,4 +15,7 @@ module OptionParser =
if options.IsInlineParameterNameHintsEnabled then
HintKind.ParameterNameHint
+
+ if options.IsInlineReturnTypeHintsEnabled then
+ HintKind.ReturnTypeHint
]
diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs
index e83dcbacaf7..0b51e1c7818 100644
--- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs
+++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs
@@ -137,6 +137,9 @@ type internal FSharpWorkspaceServiceFactory [
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
index f93b21f57af..96428fd3af5 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
index 433fe605418..a9f0793da07 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
index bd0c4c69881..e5a2fcf6e58 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
index ece82b76af6..516179e8057 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
index 688ad3123f0..925baddcb25 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
index a01fcb2e77f..35912d93aac 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
index 39618f26945..ee3dafd4a3c 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
index 940c53b43a5..96dba0bfd1f 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
index 0a5b668279e..56a1271598a 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
index eb8a524241d..486d2a886a6 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
index aa70f9bf92c..8d10219c3db 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
index 0002b466f32..4c4764fa3a4 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
@@ -34,6 +34,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
@@ -43,6 +44,7 @@ Outlining;
Show outlining and collapsible nodes for F# code;
Inline hints;
Display inline type hints (preview);
+Display return type hints (preview);
Display inline parameter name hints (preview);Beer;
Live Buffers;
Use live (unsaved) buffers for checking
diff --git a/vsintegration/src/FSharp.UIResources/AdvancedOptionsControl.xaml b/vsintegration/src/FSharp.UIResources/AdvancedOptionsControl.xaml
index ad43ae05717..78afe373f84 100644
--- a/vsintegration/src/FSharp.UIResources/AdvancedOptionsControl.xaml
+++ b/vsintegration/src/FSharp.UIResources/AdvancedOptionsControl.xaml
@@ -28,6 +28,8 @@
+
diff --git a/vsintegration/src/FSharp.UIResources/Strings.Designer.cs b/vsintegration/src/FSharp.UIResources/Strings.Designer.cs
index c4712eb66bd..1cafe38a4f0 100644
--- a/vsintegration/src/FSharp.UIResources/Strings.Designer.cs
+++ b/vsintegration/src/FSharp.UIResources/Strings.Designer.cs
@@ -402,6 +402,15 @@ public static string Show_Outlining {
}
}
+ ///
+ /// Looks up a localized string similar to Display return type hints (preview).
+ ///
+ public static string Show_Return_Type_Hints {
+ get {
+ return ResourceManager.GetString("Show_Return_Type_Hints", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Simplify names (remove unnecessary qualifiers).
///
diff --git a/vsintegration/src/FSharp.UIResources/Strings.resx b/vsintegration/src/FSharp.UIResources/Strings.resx
index 1140a72b7ed..8036c30d271 100644
--- a/vsintegration/src/FSharp.UIResources/Strings.resx
+++ b/vsintegration/src/FSharp.UIResources/Strings.resx
@@ -261,4 +261,7 @@
Format signature to the given width by adding line breaks conforming with F# syntax rules.
+
+ Display return type hints (preview)
+
\ No newline at end of file
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf
index 89780f6d6b6..2dfde6a2550 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf
@@ -107,6 +107,11 @@
Zobrazení tipů pro vložený typ (experimentální)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Zobrazit s_ymboly v neotevřených oborech názvů
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf
index 7451bd7fe2c..cdf2b9f5c09 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf
@@ -107,6 +107,11 @@
Hinweise für Inlinetypen anzeigen (experimentell)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
S_ymbole in nicht geöffneten Namespaces anzeigen
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf
index f2e1721854a..44ad67c73ba 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf
@@ -107,6 +107,11 @@
Mostrar sugerencias de tipo insertadas (experimental)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Mostrar sím_bolos en espacios de nombres sin abrir
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf
index e78bbcf8d1c..d3b296e2819 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf
@@ -107,6 +107,11 @@
Afficher les indicateurs de type inline (expérimental)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Afficher les sym_boles dans les espaces de noms non ouverts
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf
index 0f34e28dd06..d84dafc3a4e 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf
@@ -107,6 +107,11 @@
Visualizzare suggerimenti di tipo inline (sperimentale)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Mostra si_mboli in spazi dei nomi non aperti
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf
index 7e1eb91b4ea..562f2cdc5c2 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf
@@ -107,6 +107,11 @@
インライン型のヒントを表示する (試験段階)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
開かれていない名前空間の記号を表示する(_Y)
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf
index 67a4dacb312..1683801a804 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf
@@ -107,6 +107,11 @@
인라인 유형 힌트 표시(실험적)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
열려 있지 않은 네임스페이스에 기호 표시(_Y)
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf
index 7ca1c623135..e9675edcebb 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf
@@ -107,6 +107,11 @@
Wyświetl wskazówki typu wbudowanego (eksperymentalne)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Pokaż s_ymbole w nieotwartych przestrzeniach nazw
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf
index 5ded3335b0e..f73b5f2db4b 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf
@@ -107,6 +107,11 @@
Exibir as dicas de tipo embutido (experimental)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Mostrar s_ímbolos em namespaces não abertos
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf
index a7f235c094e..3a3446d4e37 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf
@@ -107,6 +107,11 @@
Отображать подсказки для встроенных типов (экспериментальная версия)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
По_казать символы в неоткрытых пространствах имен
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf
index 9ed15c7345b..7ec9e13dc70 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf
@@ -107,6 +107,11 @@
Satır içi tür ipuçlarını göster (deneysel)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
Açılmamış ad alanlarında s_embolleri göster
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf
index 88c45e47255..b86ac50201d 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf
@@ -107,6 +107,11 @@
显示内联类型提示(实验性)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
显示未打开的命名空间中的符号(_Y)
diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf
index a6a50c29ded..59099520d0e 100644
--- a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf
+++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf
@@ -107,6 +107,11 @@
顯示內嵌類型提示 (實驗性)
+
+ Display return type hints (preview)
+ Display return type hints (preview)
+
+
Show s_ymbols in unopened namespaces
顯示未開啟之命名空間中的符號(_Y)
diff --git a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj
index 889ede04813..9fe2d265ade 100644
--- a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj
+++ b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj
@@ -34,6 +34,7 @@
+
diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs
index 70f06bb0940..4717e0f9e65 100644
--- a/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs
+++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs
@@ -64,11 +64,16 @@ module HintTestFramework =
|> Async.RunSynchronously
let getTypeHints document =
- getHints document (Set.empty.Add(HintKind.TypeHint))
+ getHints document (set [ HintKind.TypeHint ])
+
+ let getReturnTypeHints document =
+ getHints document (set [ HintKind.ReturnTypeHint ])
let getParameterNameHints document =
- getHints document (Set.empty.Add(HintKind.ParameterNameHint))
+ getHints document (set [ HintKind.ParameterNameHint ])
let getAllHints document =
- let hintKinds = Set.empty.Add(HintKind.TypeHint).Add(HintKind.ParameterNameHint)
+ let hintKinds =
+ set [ HintKind.TypeHint; HintKind.ParameterNameHint; HintKind.ReturnTypeHint ]
+
getHints document hintKinds
diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineReturnTypeHintTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineReturnTypeHintTests.fs
new file mode 100644
index 00000000000..48f838f9e8a
--- /dev/null
+++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineReturnTypeHintTests.fs
@@ -0,0 +1,120 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+module FSharp.Editor.Tests.Hints.InlineReturnTypeHintTests
+
+open Xunit
+open HintTestFramework
+open FSharp.Test
+
+[]
+let ``Hints are shown for let-bound function return types`` () =
+ let code =
+ """
+let func () = 3
+let func2 x = x + 1
+let setConsoleOut = System.Console.SetOut
+"""
+
+ let document = getFsDocument code
+
+ let result = getReturnTypeHints document
+
+ let expected =
+ [
+ {
+ Content = ": int "
+ Location = (1, 13)
+ }
+ {
+ Content = ": int "
+ Location = (2, 13)
+ }
+ {
+ Content = ": unit "
+ Location = (3, 19)
+ }
+ ]
+
+ Assert.Equal(expected, result)
+
+[]
+let ``Hints are shown for method return types`` () =
+ let code =
+ """
+type Test() =
+ member this.Func() = 3
+"""
+
+ let document = getFsDocument code
+
+ let result = getReturnTypeHints document
+
+ let expected =
+ [
+ {
+ Content = ": int "
+ Location = (2, 24)
+ }
+ ]
+
+ Assert.Equal(expected, result)
+
+[]
+let ``Hints are shown for generic functions`` () =
+ let code = "let func _a = 5"
+
+ let document = getFsDocument code
+
+ let result = getReturnTypeHints document
+
+ let expected =
+ [
+ {
+ Content = ": int "
+ Location = (0, 13)
+ }
+ ]
+
+ Assert.Equal(expected, result)
+
+[]
+let ``Hints are shown for functions within expressions`` () =
+ let code =
+ """
+ let _ =
+ let func () = 2
+"""
+
+ let document = getFsDocument code
+
+ let result = getReturnTypeHints document
+
+ let expected =
+ [
+ {
+ Content = ": int "
+ Location = (2, 21)
+ }
+ ]
+
+ Assert.Equal(expected, result)
+
+[]
+let ``Hints are not shown for lambda bindings`` () =
+ let code = "let func = fun () -> 3"
+
+ let document = getFsDocument code
+
+ let result = getReturnTypeHints document
+
+ Assert.Empty result
+
+[]
+let ``Hints are not shown when there's type annotation`` () =
+ let code = "let func x : int = x"
+
+ let document = getFsDocument code
+
+ let result = getReturnTypeHints document
+
+ Assert.Empty result
diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/OverallHintExperienceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/OverallHintExperienceTests.fs
index 187cf1c89e9..c6c85d9decc 100644
--- a/vsintegration/tests/FSharp.Editor.Tests/Hints/OverallHintExperienceTests.fs
+++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/OverallHintExperienceTests.fs
@@ -26,7 +26,7 @@ let a = Square 1
let b = Rectangle (1, 2)
type C (blahFirst: int) =
- member _.Normal (what: string) = 1
+ member _.Normal (what: string) = 1
let a = C 1
let cc = a.Normal "hmm"
@@ -40,6 +40,10 @@ let cc = a.Normal "hmm"
Content = ": Song"
Location = (2, 18)
}
+ {
+ Content = ": string "
+ Location = (2, 19)
+ }
{
Content = "song = "
Location = (4, 23)
@@ -68,6 +72,10 @@ let cc = a.Normal "hmm"
Content = ": Shape"
Location = (11, 6)
}
+ {
+ Content = ": int "
+ Location = (14, 36)
+ }
{
Content = "blahFirst = "
Location = (16, 11)