ionide / ionide/FsAutoComplete

Refactoring: Extract Interface from Type member declaration (refactoring)

Open
#1,227 2 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
F#
Stars
486
Forks
169
Avg merge
2d 8h
Merged PRs (30d)
5

Description

### Details

would be great to be able to easilly extract an abstact type (interface) from a type with a public member, and have it implement (interface with) that interface,

with just 1 context action.

Reason

* interfaces in F# look quite odd, due to type signatures differing from actual implementation signatures, this confuses quite many people getting started with F# i believe

```fsharp

// LIGHT BULB HERE ---> extract all public members to interface, also useful..
type TripFaqMapper( ... ) =

// LIGHT BULB HERE! --> here suggestion lights up, as this is a public member, possibly can be extracted to interface
member this.MapGroupTagAsync
(
id: int64,
groupCode: string,
tag: string,
appId: string,
locale,
currency,
cancellationToken: CancellationToken
) : TravixFaqResponse Task =

task {...} // implementation

// generates this, like in C# extract interface..

type TripFaqMapper( ... ) =

interface ITripFaqMapper with

member this.MapGroupTagAsync
(
id: int64,
groupCode: string,
tag: string,
appId: string,
locale,
currency,
cancellationToken: CancellationToken
) : TravixFaqResponse Task =

task {...} // implementation

type ITripFaqMapper =
abstract member MapGroupTagAsync:
id: int64 *
groupCode: string *
tag: string *
appId: string *
locale: Locale *
currency: Currency *
cancellationToken: CancellationToken ->
TravixFaqResponse Task

```

* interfaces are only part of OO world, but having a great time C# interoperability should be always important and useful

* helps .NET developers be less scared of F# to also know they can easilly make regular class types with interfaces and inject them in their DI containers of habit, like what is provided in HostBuilder and Aspnetcore by default.

### Checklist

- [X] I have looked through existing issues to make sure that this feature has not been requested before
- [X] I have provided a descriptive title for this issue
- [X] I am aware that even valid feature requests may be rejected if they do not align with the project's goals
- [X] I or my company would be willing to contribute this feature

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.