<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:40:48 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-1837] Generic ICustomBsonTypeMapper with support for inheritance</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1837</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;Currently, there is no driver-supported way to convert a generic type to a BsonValue in a custom way, because BsonTypeMapper.RegisterCustomTypeMapper BsonTypeMapper.TryMapToBsonValue uses a specific type. I would like to propose the ability to register custom type mappers by their corresponding types&apos; generic template definition (in a separate dictionary) and making a two-pass check, first using a concrete type, and second &amp;#8211; a type template.&lt;/p&gt;

&lt;p&gt;Also, going up the inheritance chain when testing might be beneficial to allow for proper base class-related implementations. This of course will incur a performance hit, but considering that custom mapping is done right before failing out, I consider the impact of this possible performance being low.&lt;/p&gt;

&lt;p&gt;This is going to help in situations like ours, where we have many primitive-based domain types, that inherit from a certain generic base class, but have the same basic inner representation. While automatic serialization via IBsonSerializers is wonderful, sometimes manual BsonDocument manipulation is warranted, and in this case we have to resort to extension methods that aid with BsonValue conversion, but this solution is clumsy and error-prone.&lt;/p&gt;


&lt;p&gt;The generic template change is fully backwards compatible (if you don&apos;t take into account non-previously-working generic template registrations now working).&lt;br/&gt;
The inheritance change is not backwards compatible, but I do not believe that the scope of the change will have a significant impact on real existing code.&lt;/p&gt;</description>
                <environment></environment>
        <key id="334004">CSHARP-1837</key>
            <summary>Generic ICustomBsonTypeMapper with support for inheritance</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="onyxmaster">Aristarkh Zagorodnikov</reporter>
                        <labels>
                    </labels>
                <created>Wed, 23 Nov 2016 21:37:51 +0000</created>
                <updated>Thu, 3 Dec 2020 18:21:06 +0000</updated>
                            <resolved>Thu, 3 Dec 2020 18:21:06 +0000</resolved>
                                    <version>2.3</version>
                                                    <component>BSON</component>
                    <component>Serialization</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1446127" author="onyxmaster" created="Wed, 30 Nov 2016 19:10:22 +0000"  >&lt;p&gt;Thank you for the info about BsonTypeMapper being considered obsolete, Robert.&lt;br/&gt;
Unfortunately, our scenarios often involve manual BsonDocument creation. Well, it appears that we have to live with this and invent something to handle this for us. Maybe we should move to more automated BsonDocument generation.&lt;/p&gt;</comment>
                            <comment id="1446054" author="rstam" created="Wed, 30 Nov 2016 18:17:52 +0000"  >&lt;p&gt;This sounds like a reasonable request except for the fact that we consider the BsonTypeMapper to be obsolete. It is from an ancient time before serialization was added to the driver.&lt;/p&gt;

&lt;p&gt;The proper way to convert an arbitrary POCO to a BsonDocument is to serialize it using a BsonDocumentWriter.&lt;/p&gt;

&lt;p&gt;I&apos;ll leave this ticket open while we decide whether enhancing BsonTypeMapper in any way is the right thing to do.&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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hss713:</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>