Skip to content

Simplify consumption of C# centric object builders #877

@wallymathieu

Description

@wallymathieu

Simplify consumption of C# centric object builders

I propose we add support in some form to allow the construction of objects in line with how API:s are defined for use in C#

One alternative that might go with the grain of current usage of computation expression builders would be the possibility of a computation expression wrapper that allows for constructing mutable objects in a similar fashion to how they are constructed in C# syntactic sugar for object and collection initializers. Similar functionality exists within VB.net, but in a manner more appropriate for that style of programming.

The existing way of approaching this problem in F# is to do something similar as:

let v = ConfigurationBuilder(UseExplicitWhatnot = true)
v.Sublevel.BasementMapping <- mapping
v.ListOfFloors.Add floor1
...

that's fine for small usages of C# API:s, but can be a bit annoying when trying to consume larger chunks.

Pros and Cons

The advantages of making this adjustment to F# are to make it more compatible with C# intended API:s

The disadvantages of making this adjustment to F# are that it could complicate the F# compiler.

Extra information

Estimated cost (XS, S, M, L, XL, XXL):

I'm unsure about the cost since this is sort of a rough suggestion

Related suggestions: (put links to related suggestions here)

Affidavit (please submit!)

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this

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