Skip to content

F# interface-stub generator re-offers a property already implemented via explicit get/set accessors #206

Description

@MelbourneDeveloper

What

Given an interface member abstract member Value: int with get, set implemented as:

type BothAccessors() =
    let mutable current = 0
    interface IStore with
        member _.Value
            with get () = current
            and set value = current <- value

FSharpCodeActions.tryGenerateInterfaceStub still offers Value among the members to generate. Accepting the fix would emit a second Value beside the existing accessors, which does not compile.

This is the implementation being complete, not a partial one

Confirmed against the compiler — the with get () = ... and set v = ... form does fully satisfy abstract member Value: int with get, set. A standalone project containing exactly the type above plus member _.Reset() = ... builds with 0 errors. So the member really is implemented and should be excluded from the candidate set.

The genuinely-partial forms behave correctly: a getter-only or setter-only implementation leaves the other half outstanding, and offering Value again there is right.

Where

implementedMemberSignatures / the candidate scan in FSharpCodeActions.fs appears not to recognise a SynMemberDefn.GetSetMember carrying both accessors as satisfying both halves of the abstract property.

Tests

FSharpAccessorStubTests covers the three accessor shapes. The get/set case deliberately asserts only that the genuinely missing Reset is offered, rather than pinning the duplicate Value as expected behaviour — so it will not need weakening when this is fixed, only strengthening with Assert.DoesNotContain("Value", text).

Notes

Pre-existing, not a regression from #200. Found while closing that PR's F# coverage gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions