<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:48:37 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-4565] [BsonSerializer] property attribute with custom dictionary breaks in 2.19</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4565</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;In version 2.18 (and before) we used a property attribute to define a custom dictionary serializer as below:&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonSerializer(typeof(CustomDictionarySerializer&amp;lt;Dictionary&amp;lt;AccountConfigType, string&amp;gt;,&#160; EnumStringSerializer&amp;lt;AccountConfigType&amp;gt;, CustomObjectSerializer&amp;lt;string&amp;gt;&amp;gt;))&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;But after upgrading to 2.19,&#160; we would get the error:&lt;/p&gt;

&lt;p&gt;System.TypeInitializationException : The type initializer for &apos;i3vDB.Collections.Account&apos; threw an exception.&lt;br/&gt;
&#160; ----&amp;gt; System.ArgumentException : Value type of serializer is System.Collections.Generic.Dictionary`2[&lt;span class=&quot;error&quot;&gt;&amp;#91;Lib.Shared.Enum.AccountConfigType, Lib.Shared, Version=2.1.4.1, Culture=neutral, PublicKeyToken=null&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&amp;#93;&lt;/span&gt;] and does not match member type System.Collections.Generic.Dictionary`2[&lt;span class=&quot;error&quot;&gt;&amp;#91;Lib.Shared.Enum.AccountConfigType, &amp;quot;Lib.Shared &amp;quot;, Version=2.1.4.1, Culture=neutral, PublicKeyToken=null&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&amp;#93;&lt;/span&gt;]. (Parameter &apos;serializer&apos;)&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Removing the property attribute, and instead using the below fixes the issue.&lt;/p&gt;

&lt;p&gt;BsonSerializer.RegisterGenericSerializerDefinition(typeof(Dictionary&amp;lt;AccountConfigType, string&amp;gt;),&#160; typeof(CustomDictionarySerializer&amp;lt;Dictionary&amp;lt;AccountConfigType, string&amp;gt;,&#160; &#160; &#160; &#160; &#160; &#160;EnumStringSerializer&amp;lt;AccountConfigType&amp;gt;, CustomObjectSerializer&amp;lt;string&amp;gt;&amp;gt;));&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;I should also note that if you have both the property attribute and the explicit registration, it throws the same exception.&#160; &#160; I did not test any other custom serializers as we didn&apos;t have any others specified by property attribute.&lt;/p&gt;

&lt;p&gt;I don&apos;t know if it&apos;s significant as it could just be caused by the exception output, but the TYPE X doesn&apos;t match TYPE X message only differs in Lib.Shared.&#160; &#160;The second instance is in quotes and has a space at the end.&#160; &#160;They are otherwise identical.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2285341">CSHARP-4565</key>
            <summary>[BsonSerializer] property attribute with custom dictionary breaks in 2.19</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="13202">Works as Designed</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="tim.arheit@payschools.com">Tim Arheit</reporter>
                        <labels>
                    </labels>
                <created>Thu, 9 Mar 2023 23:58:32 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:38 +0000</updated>
                            <resolved>Thu, 23 Mar 2023 15:27:55 +0000</resolved>
                                    <version>2.19.0</version>
                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5295729" author="rstam" created="Thu, 23 Mar 2023 15:27:44 +0000"  >&lt;p&gt;Thank you for letting us know that you figured out the issue. I will go ahead and close this issue.&lt;/p&gt;</comment>
                            <comment id="5268686" author="JIRAUSER1273092" created="Mon, 13 Mar 2023 18:36:19 +0000"  >&lt;p&gt;Tracked the issue down to a trailing space in the assembly name.&#160; Not sure why it didn&apos;t show up before.&#160;&lt;/p&gt;</comment>
                    </comments>
                    <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_14266" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Documentation Changes Summary</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1.  What would you like to communicate to the user about this feature?&lt;br/&gt;
2.  Would you like the user to see examples of the syntax and/or executable code and its output?&lt;br/&gt;
3.  Which versions of the driver/connector does this apply to?&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i1i18w:</customfieldvalue>

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