dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.93k stars 786 forks source link

Symbols API: property CompiledName is compiled name of accessor #4135

Open auduchinok opened 6 years ago

auduchinok commented 6 years ago
type T() =
    [<CompiledName("Bar")>]
    member x.Foo1 = 123

    member x.Foo2 with set (_) = ()

When getting CompiledName for a symbol representing the Foo1 property the result is get_Foo1 (i.e. name of an accessor without applying CompiledNameAttribute) while I think it should be Bar instead (to be consistent with the attribute). There're separate symbols for accessors (when available) and they have improper names too (e.g. get_Foo1, set_Foo1).

When getting CompiledName for Foo2 property the result is set_Foo2 and I expect it to be just Foo2.

dsyme commented 6 years ago

Agreed

realvictorprm commented 3 years ago

this is also the case with val declarations.

In my current case this is especially unfortunate because I wanted to do this but that doesn't work :|

type Foo =
   struct
      [<CompiledName("type")>]
      val mutable ``type``: int
   end
realvictorprm commented 3 years ago

Side note, this is at least the case for me looking at the IL output via sharplab.io

realvictorprm commented 3 years ago

Well, it appears that the reflection does return the correct name. However the actual IL name is not the same. Is this by design?

        // Fields
        .field public valuetype [System.Private.CoreLib]System.Int32 'type'
        .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompiledNameAttribute::.ctor(class [System.Private.CoreLib]System.String) = (
            01 00 04 74 79 70 65 00 00
        )