<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:38 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-376] Use IBsonSerializationOptions in Deserialize/Serialize methods in the various Bson/Serialization/Serializers/*</title>
                <link>https://jira.mongodb.org/browse/CSHARP-376</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Possibly related to &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-284&quot; title=&quot;Add a way to provide serialization attributes to be applied to collection elements&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-284&quot;&gt;&lt;del&gt;CSHARP-284&lt;/del&gt;&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-308&quot; title=&quot;Support serialization options for Array and Dictionary values&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-308&quot;&gt;&lt;del&gt;CSHARP-308&lt;/del&gt;&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;I noticed in the various serializers in Bson/Serialization/Serializers/ that the Deserialize and Serialize methods were ignoring the given IBsonSerializationOptions.  Is this by design?&lt;/p&gt;

&lt;p&gt;I recently came across an issue by attempting to use the BsonRepresentationAttribute on a collection, e.g.:&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonRepresentation(BsonType.Int64, AllowOverflow = true)&amp;#93;&lt;/span&gt;&lt;br/&gt;
public List&amp;lt;UInt64&amp;gt; Ids &lt;/p&gt;
{ get; set; }

&lt;p&gt;Then I hit an OverflowException when calling ToJson on my object:&lt;/p&gt;

&lt;p&gt;System.OverflowException: Arithmetic operation resulted in an overflow.&lt;br/&gt;
   at MongoDB.Bson.Serialization.Options.RepresentationSerializationOptions.ToInt64(UInt64 value)&lt;br/&gt;
   at MongoDB.Bson.Serialization.Serializers.UInt64Serializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options)&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonClassMapSerializer.SerializeMember(BsonWriter bsonWriter, Object obj, BsonMemberMap memberMap)&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonClassMapSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options)&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options)&lt;br/&gt;
   at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType, IBsonSerializationOptions options, JsonWriterSettings settings)&lt;br/&gt;
   at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType, JsonWriterSettings settings)&lt;br/&gt;
   at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType)&lt;br/&gt;
   at MongoDB.Bson.BsonExtensionMethods.ToJson&lt;span class=&quot;error&quot;&gt;&amp;#91;TNominalType&amp;#93;&lt;/span&gt;(TNominalType obj)&lt;/p&gt;</description>
                <environment></environment>
        <key id="27698">CSHARP-376</key>
            <summary>Use IBsonSerializationOptions in Deserialize/Serialize methods in the various Bson/Serialization/Serializers/*</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="1" iconUrl="https://jira.mongodb.org/images/icons/priorities/blocker.svg">Blocker - P1</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="3">Duplicate</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="dmarien">Doug Marien</reporter>
                        <labels>
                            <label>driver</label>
                            <label>serialization</label>
                    </labels>
                <created>Wed, 4 Jan 2012 18:07:17 +0000</created>
                <updated>Thu, 20 Mar 2014 16:39:28 +0000</updated>
                            <resolved>Wed, 4 Jan 2012 18:28:58 +0000</resolved>
                                    <version>1.3.1</version>
                                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="77622" author="rstam" created="Wed, 4 Jan 2012 20:12:04 +0000"  >&lt;p&gt;It&apos;s not a C# restriction... I probably didn&apos;t say it very well!&lt;/p&gt;

&lt;p&gt;The custom attribute is being applied to the property named Ids. The C# driver assumes that this attribute is defining serialization options for the serializer for List&amp;lt;UInt64&amp;gt; (in other words, the serializer for the Ids property as a whole), not for the serializer for UInt64.&lt;/p&gt;

&lt;p&gt;What is needed is some way to provide options that are applied to the elements of the collection rather than to the collection itself.&lt;/p&gt;

&lt;p&gt;By the way, you don&apos;t get compile time errors because as far as C# is concerned any attribute can be applied to any property (subject to the AttributeUsage defined for it). And you don&apos;t get a runtime error because the serializer for List&amp;lt;UInt64&amp;gt; ignores any options provided because it doesn&apos;t use any.&lt;/p&gt;</comment>
                            <comment id="77616" author="dmarien" created="Wed, 4 Jan 2012 19:58:24 +0000"  >&lt;p&gt;I didn&apos;t realize C# had a restriction as to the usage of custom attributes?  Were you planning on using BsonRepresentationAttribute to apply to a List&amp;lt;&amp;gt; or other collection?  In that case does AllowOverflow or AllowTruncation make sense?  Or are you planning on creating a new attribute that is more explicit about being applied to the collection types?&lt;/p&gt;</comment>
                            <comment id="77571" author="rstam" created="Wed, 4 Jan 2012 18:28:20 +0000"  >&lt;p&gt;The way you have it written the attribute is being applied to the List, not to the elements of the list (which there isn&apos;t a way to do yet).&lt;/p&gt;

&lt;p&gt;This is related to &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-284&quot; title=&quot;Add a way to provide serialization attributes to be applied to collection elements&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-284&quot;&gt;&lt;del&gt;CSHARP-284&lt;/del&gt;&lt;/a&gt;, which is about having a way to specify serialization options for the elements themselves as opposed to the list as a whole.&lt;/p&gt;

&lt;p&gt;I&apos;m going to close this one and leave &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-284&quot; title=&quot;Add a way to provide serialization attributes to be applied to collection elements&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-284&quot;&gt;&lt;del&gt;CSHARP-284&lt;/del&gt;&lt;/a&gt; open.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="20142">CSHARP-284</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <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|hrh833:</customfieldvalue>

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