<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:16 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-587] Overwrite serializers in BsonSerializer</title>
                <link>https://jira.mongodb.org/browse/CSHARP-587</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;It would be nice if there was a way to override default serializers for primitive types. While it can be worked around by registering serializers before the sctor of BsonSerializer executes or by using Reflection, a more straight-forward way would probably be to include a version of BsonSerializer.RegisterSerializer that allows to overwrite serializers for already covered types.&lt;/p&gt;

&lt;p&gt;This stackoverflow question might be able to provide more context (note, I am not the original poster of said question): &lt;a href=&quot;http://stackoverflow.com/questions/12201812/mongodb-override-default-serializer-for-a-c-sharp-primitive-type/12636123#comment17048789_12636123&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://stackoverflow.com/questions/12201812/mongodb-override-default-serializer-for-a-c-sharp-primitive-type/12636123#comment17048789_12636123&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="52025">CSHARP-587</key>
            <summary>Overwrite serializers in BsonSerializer</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="manny">Manuel Warum</reporter>
                        <labels>
                    </labels>
                <created>Tue, 2 Oct 2012 12:19:37 +0000</created>
                <updated>Thu, 20 Mar 2014 14:35:41 +0000</updated>
                            <resolved>Thu, 11 Oct 2012 14:29:12 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="173741" author="craiggwilson" created="Thu, 11 Oct 2012 14:29:12 +0000"  >&lt;p&gt;This works as designed.&lt;/p&gt;</comment>
                            <comment id="170302" author="craiggwilson" created="Tue, 2 Oct 2012 13:06:12 +0000"  >&lt;p&gt;While I understand what you are saying, it isn&apos;t a good solution to enable changing the serializer for a type after it has already been used.  For instance, if this was possible, the below sequence of events would be awkward.&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;save an entity with a double&lt;/li&gt;
	&lt;li&gt;change the double&apos;s serializer&lt;/li&gt;
	&lt;li&gt;read the entity with a double&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Obviously, what would be read would be different than what was written, making the data un-uniform. &lt;/p&gt;

&lt;p&gt;As Robert mentioned in the StackOverflow question, you can replace the default serializers for primitive types.  The idea is that their is an implicit initialization phase for your applications, prior to any communication with MongoDB.  In this initialization area, you can do virtually anything.  The static ctor of BsonSerializer definitely runs prior to registration of new serializers (otherwise, .NET is broken).  The reason Robert&apos;s suggestion works is because the defaults are part of a lazy serializer registration system (IBsonSerializabionProvider).  Until a serializer for a type is needed, it isn&apos;t registered.  Therefore, if you register a serializer for a type (e.g. double) before it is used, then you have replaced the defaults.&lt;/p&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="51734">CSHARP-583</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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|hrj9if:</customfieldvalue>

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