<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:42:19 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-2354] BsonDocument constructor fails to copy documents with duplicate element names</title>
                <link>https://jira.mongodb.org/browse/CSHARP-2354</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;The following code fails:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;var doc = new BsonDocument() { AllowDuplicateNames = true };&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;doc.Add(&quot;x&quot;, 1);&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;doc.Add(&quot;x&quot;, 2);&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;var doc2 = new BsonDocument(doc); // throws&lt;/tt&gt;&lt;/p&gt;

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

&lt;p&gt;This is because the parameter is treated as an IEnumerable&amp;lt;BsonElement&amp;gt;. This can be fixed by adding a new constructor:&lt;/p&gt;

&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br/&gt;
/// Initializes a new instance of the BsonDocument by coping elements from another BsonDocument.&lt;br/&gt;
/// &amp;lt;/summary&amp;gt;&lt;br/&gt;
/// &amp;lt;param name=&quot;document&quot;&amp;gt;The document whose elements will be copied&amp;lt;/param&amp;gt;&lt;/p&gt;

&lt;p&gt;public BsonDocument(BsonDocument document)&lt;br/&gt;
{&lt;br/&gt;
&lt;font color=&quot;#333333&quot;&gt;&#160; if (document == null)&lt;/font&gt;&lt;br/&gt;
&lt;font color=&quot;#333333&quot;&gt;&#160; {&lt;/font&gt;&lt;br/&gt;
&lt;font color=&quot;#333333&quot;&gt;&#160; &#160; throw new ArgumentNullException(&quot;document&quot;);&lt;/font&gt;&lt;br/&gt;
&lt;font color=&quot;#333333&quot;&gt;&#160; }&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&#160; _allowDuplicateNames = document.AllowDuplicateNames;&lt;br/&gt;
&#160; AddRange(document);&lt;br/&gt;
}&lt;/p&gt;

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

&lt;p&gt;This could be ambiguous if somebody tried to pass a RawBsonDocument or LazyBsonDocument, so two additional constructors may be useful:&lt;/p&gt;

&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br/&gt;
/// Initializes a new instance of the BsonDocument by coping elements from a LazyBsonDocument.&lt;br/&gt;
/// &amp;lt;/summary&amp;gt;&lt;br/&gt;
/// &amp;lt;param name=&quot;document&quot;&amp;gt;The document whose elements will be copied&amp;lt;/param&amp;gt;&lt;/p&gt;

&lt;p&gt;public BsonDocument(LazyBsonDocument document) : this((BsonDocument)document) { }&lt;/p&gt;


&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br/&gt;
/// Initializes a new instance of the BsonDocument by coping elements from a RawBsonDocument.&lt;br/&gt;
/// &amp;lt;/summary&amp;gt;&lt;br/&gt;
/// &amp;lt;param name=&quot;document&quot;&amp;gt;The document whose elements will be copied&amp;lt;/param&amp;gt;&lt;/p&gt;

&lt;p&gt;public BsonDocument(RawBsonDocument document) : this((BsonDocument)document) { }&lt;/p&gt;</description>
                <environment></environment>
        <key id="586179">CSHARP-2354</key>
            <summary>BsonDocument constructor fails to copy documents with duplicate element names</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="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="admilazz">Adam Milazzo</reporter>
                        <labels>
                    </labels>
                <created>Thu, 9 Aug 2018 19:50:49 +0000</created>
                <updated>Thu, 31 Mar 2022 00:44:51 +0000</updated>
                                                                            <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="1972007" author="admilazz" created="Thu, 9 Aug 2018 20:24:42 +0000"  >&lt;p&gt;Created pull request:&#160;&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/338&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/pull/338&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1971963" author="admilazz" created="Thu, 9 Aug 2018 20:00:56 +0000"  >&lt;p&gt;Also necessary is to add this line to the RawBsonDocument and LazyBsonDocument constructors:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;AllowDuplicateNames = true; // raw BSON always supports duplicate names&lt;/tt&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></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|htvqnr:</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>