Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotating F# records with Bond attributes only works when adding the CLIMutable attribute #85

Open
ant0nsc opened this issue Sep 10, 2015 · 9 comments
Assignees

Comments

@ant0nsc
Copy link

ant0nsc commented Sep 10, 2015

Serializing/deserializing this record fails:

    [< Bond.Schema >]
    type PlainRecord = 
    {
        [< Bond.Id(0us) >] 
        DoubleImmutable     : float
    }

whereas this one works:

    [< Bond.Schema >]
    [< CLIMutable >]
    type MutableRecord = 
    {
        [< Bond.Id(0us) >] 
        DoubleMutable : float
    }
@jack-pappas
Copy link

I think this is by design? The [<CLIMutable>] attribute causes the F# compiler to generate slightly different code for the record (compared to what it'd generate without the attribute); with the attribute, the compiler generates get, set auto-properties for the record fields so they can be set via reflection -- the F# compiler just enforces that you can't call the setters from F# code (so the record remains "immutable" as far as F# code is concerned).

[<CLIMutable>] was introduced to allow F# records to be used with serializers (e.g., Bond) or ORMs, so I don't think this is a Bond-specific issue.

@ant0nsc
Copy link
Author

ant0nsc commented Jan 17, 2017

Yes, I'm aware of why that attribute exists. This issue here is more of a reminder to me and @chwarr. A solution to the problem is in code review.

@ncthbrt
Copy link

ncthbrt commented Jul 13, 2017

Any update on this @ant0nsc ?

@chwarr
Copy link
Member

chwarr commented Jul 14, 2017

@ant0nsc is waiting for me to implement F# codegen as part of first-class F# support. This work has been delayed because I need to work on some internal-to-Microsoft systems that use/build Bond. No ETA for when I'll be able to pick F# back up.

@ncthbrt
Copy link

ncthbrt commented Jul 14, 2017 via email

@brettrowberry
Copy link

Interested in this!

@chwarr
Copy link
Member

chwarr commented Nov 13, 2020

As of September 2020 and for the foreseeable future, no new languages will be added to Bond by Microsoft.

@brettrowberry
Copy link

Thanks @chwarr, should we be moving to protobuf?

@chwarr
Copy link
Member

chwarr commented Nov 14, 2020

@brettrowberry, I've answered in issue #312, "F# code generation from IDL".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants