Skip to content

Conversation

@cartermp
Copy link
Contributor

Addresses the following additional cases in #10941

type C() =
    member _.M(x) = ()


let c = C()
c.M(sqrt)// <<- caret is after 't'!

Before this PR: tooltip for M
After this PR: tooltip for sqrt

    /// Tries to cast an object to a given type; throws with the given error message if it fails.
    let tryConvert<'T> (descriptor: string) (value: obj) : 'T =
        try
            Convert.ChangeType(value, typeof<'T>) :?> 'T
        with ex ->
            let msg = sprintf "Unable to convert '%s' with value %A" descriptor value
            raise (new Exception(msg, ex))

    // Tooltip does NOT show when the generic argument is present:
    let result= (box 123) |> tryConvert<string> // <<- caret is here

Before this PR: no tooltip
After this PR: tooltip for tryConvert

@cartermp cartermp marked this pull request as ready for review March 10, 2021 02:26
// This means that the adjusted position relative to the caret could be a ',' or a '(' or '<',
// which would mean we're already inside of a method call - not a function argument. So we bail if that's the case.
| Some ' ', None when adjustedColumnChar <> ',' && adjustedColumnChar <> '(' && adjustedColumnChar <> '<' ->
| Some ' ', _ when adjustedColumnChar <> ',' && adjustedColumnChar <> '(' && adjustedColumnChar <> '<' ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the most impactful change. It's what enables triggering function signature help when in a parenthesized context without any quirks.

@TIHan TIHan merged commit 2b7517d into dotnet:main Mar 10, 2021
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants