Skip to content

Auto-generated methods / fields for events and properties are not marked as such #4050

@realvictorprm

Description

@realvictorprm

During using Code Lens I noticed in some cases multiple annotations which was obviously a bug. Cause of such were auto-generated methods / fields by the compiler which we're all on the same line (because they are virtual but need some kind of placement). To fix this I tried filtering each FSharpMemberOfFunctionOrValue element out which func.IsCompilerGenerated was true. However I noticed that several methods were not flagged although they are compiler generated.

Example:

type Foo() =

    let foo = new Event<int>()

    member __.bar1 =
        foo.Publish

    [<CLIEvent>] 
    member __.bar2 =
        foo.Publish  

The compiler generates here getter and setter for both members but does not flag them as compiler generated. Also the generated methods are not flagged as event neither as getter or setter method for events (e.g. IsEventAddMethodor IsEventRemoveMethod) which I think is wrong too.

Repro Steps

  1. Create a new F# project
  2. Add the F# Compiler Service package to it
  3. Iterate over func declarations of the example code below (use the checker)
  4. Print out whether methods are compiler generated

Expected behavior

Methods which are compiler generated should have the flag IsCompilerGenerated set to true.
Moreover relevant flags like IsEventAddMethod should be set to true too for events.

Here a text file which contains the output for the remove method of bar2 from the example:
EventAutogeneratedBug.txt

Metadata

Metadata

Assignees

Labels

Area-LangService-CodeLensBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions