JetBrains/resharper-fsharp

Calling a method get_ break the syntax highlights and tooltips on hover

MangelMaxime opened this issue · 4 comments

Hello,

I found a strange bug in my project when calling a method get_.

Demo:

rider_bug_get_

As you can see in the demo, the syntax highlight stop working after get_ is called same goes for the tooltips. Sometimes it seems like syntax and tooltip still works for but I guess that's because some information are still in the cache.

To check if it was a bug in the FCS I checked with Ionide v5.2.0 (latest ATM) and it working fine with it.

Reproduction code:

type Test =
    abstract get : unit -> unit
    abstract get_ : unit -> unit
    abstract Get : unit -> unit
    abstract Get_ : unit -> unit
    abstract ARandomMethodName_ : unit -> unit
    
let t = unbox<Test> null

// 1. Uncomment this line 
t.get_()
// ---
t.get()    
t.Get()    
t.Get_()
t.get()
t.Get()    
t.Get_()
// ---
// 2. Try to write one of the previous line and see how neither the syntax highlight doesn't work or neither the tooltips
t.get()
    
// From my test the problem seems to happen only with get_ not Get_ or XXXXX_ methods
// 3. To confirm you can try by replacing t.get_() with t.ARandomMethodName_()

If context is needed:

I know it not a common name for a method/functions in F# but this is because I creating a binding for Express and I am adding _ to some method to say this methods returns unit on opposition with the same method name without _ which returns a value. That's mostly for syntax sugar and avoid having |> ignore everywhere.

@MangelMaxime Thanks for the report! The highlighting disappears due to exception in FCS:

com.jetbrains.rdclient.util.BackendException: Invalid internal property name: 'get_'

--- EXCEPTION #1/2 [Exception]
Message = “Invalid internal property name: 'get_'”
ExceptionPath = Root.InnerException
ClassName = System.Exception
HResult = COR_E_EXCEPTION=80131500
Source = FSharp.Core
StackTraceString = “
  at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1433.Invoke(String message) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1433
     at FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue.get_IsPropertyGetterMethod()
     at JetBrains.ReSharper.Plugins.FSharp.Psi.Features.Daemon.FSharpSymbolHighlightingUtil.GetMfvHighlightingAttributeId(FSharpMemberOrFunctionOrValue mfv) in C:\BuildAgent\work\175d07bfda058979\ReSharper.FSharp\src\FSharp.Psi\src\Features\Daemon\FSharpSymbolHighlightingUtil.cs:line 64

I'll look into what a proper fix on both our and FCS sides should be.

This has been fixed.
@MangelMaxime Thanks again!

@auduchinok Thank you for the fix :)