<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:06 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-528] Support deserializing immutable types</title>
                <link>https://jira.mongodb.org/browse/CSHARP-528</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I&apos;m trying to write a F# driver implementation that wraps what the C# driver does. Right now the main thing that I&apos;m getting stuck on is deserializing immutable record types. If I have this F# record:&lt;/p&gt;

&lt;p&gt;    type Person = &lt;/p&gt;
{
        Id : BsonObjectId
        Name : string
    }

&lt;p&gt;it compiles to &lt;span class=&quot;error&quot;&gt;&amp;#91;roughly&amp;#93;&lt;/span&gt; this C# code&lt;/p&gt;

&lt;p&gt;    public class Person&lt;br/&gt;
    {&lt;br/&gt;
      private readonly BsonObjectId id;&lt;br/&gt;
      private readonly string name;&lt;/p&gt;

&lt;p&gt;      public Person(BsonObjectId id, string name) &lt;/p&gt;
      {
        this.id = id;
        this.name = name;
      }

&lt;p&gt;      public BsonObjectId Id { get &lt;/p&gt;
{ return id; }
&lt;p&gt; }&lt;br/&gt;
      public string Name { get &lt;/p&gt;
{ return name; }
&lt;p&gt; }&lt;br/&gt;
    }&lt;/p&gt;

&lt;p&gt;I can configure the BsonClassMapSerializer to &lt;b&gt;serialize&lt;/b&gt; objects just fine, however when I try deserializing it skips all the properties of the record because they don&apos;t have setter methods.&lt;/p&gt;

&lt;p&gt;A big part of the problem is that BsonClassMapSerializer does 90% of what I need, but it&apos;s an internal class. Even if it were public, it&apos;s too much of a behemoth to be able to customize via subclassing. A better solution might be to add configuration to class maps. Perhaps an interface such as:&lt;/p&gt;

&lt;p&gt;    interface IMemberAccumulator &lt;/p&gt;
{
      object Initialize(Type nominalType);
      void AccumulateMember(object state, Type nominalType, MemberInfo memberInfo, object value);
      object GetFinalValue(object state, Type nominalType);
    }

&lt;p&gt;and a `BsonClassMap.SetMemberAccumulator(IMemberAccumulator)` would probably get me what I need. I&apos;m sure this sort of thing might even be useful for other languages, including C#.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/tkellogg/MongoDB.FSharp&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/tkellogg/MongoDB.FSharp&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="44235">CSHARP-528</key>
            <summary>Support deserializing immutable types</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="tkellogg">Tim Kellogg</reporter>
                        <labels>
                            <label>driver</label>
                            <label>immutable</label>
                    </labels>
                <created>Mon, 16 Jul 2012 00:01:53 +0000</created>
                <updated>Tue, 12 Feb 2013 23:30:26 +0000</updated>
                            <resolved>Tue, 12 Feb 2013 23:30:17 +0000</resolved>
                                    <version>1.5</version>
                                    <fixVersion>1.8</fixVersion>
                                    <component>Feature Request</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="264601" author="rstam" created="Tue, 12 Feb 2013 23:30:17 +0000"  >&lt;p&gt;Implemented by &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-476&quot; title=&quot;Support parameterized constructors on deserialization&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-476&quot;&gt;&lt;del&gt;CSHARP-476&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="143995" author="tkellogg" created="Tue, 17 Jul 2012 14:05:59 +0000"  >&lt;p&gt;yeah that&apos;s what I need. Probably a better implementation too.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="143092" author="craiggwilson" created="Mon, 16 Jul 2012 02:38:11 +0000"  >&lt;p&gt;Tim,&lt;br/&gt;
  Checkout the linked &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-476&quot; title=&quot;Support parameterized constructors on deserialization&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-476&quot;&gt;&lt;del&gt;CSHARP-476&lt;/del&gt;&lt;/a&gt;.  It seems like it would fix your issue as well;  essentially member deserialization could map to a constructor parameter.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="39461">CSHARP-476</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh7a7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>13979</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>