<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:51 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-446] 1.4.1 Breaking change SetDocumentId is not quite documented (or good at all)</title>
                <link>https://jira.mongodb.org/browse/CSHARP-446</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Thank you for the new version.&lt;/p&gt;

&lt;p&gt;Release notes:&lt;br/&gt;
&amp;gt; There are no breaking changes in this release.&lt;/p&gt;

&lt;p&gt;There is a breaking change. It is mentioned in &quot;Change Log v1.4.1-Bson.txt&quot;:&lt;br/&gt;
BsonDocument.cs&lt;br/&gt;
changed SetDocumentId to assume Id is already of type BsonValue&lt;/p&gt;

&lt;p&gt;Thus, when I call it with `int`, as I used to, then I get the exception:&lt;br/&gt;
Unable to cast object of type &apos;System.Int32&apos; to type &apos;MongoDB.Bson.BsonValue&apos;.&lt;/p&gt;

&lt;p&gt;The method `SetDocumentId(object id)` is confusing now. It accepts `object id` but internally does:&lt;br/&gt;
var idBsonValue = (BsonValue)id;&lt;/p&gt;

&lt;p&gt;This is unsafe and even not documented in code comments. Either this method should accept `BsonValue` or it should handle any suitable objects, as it did before.&lt;/p&gt;</description>
                <environment></environment>
        <key id="36555">CSHARP-446</key>
            <summary>1.4.1 Breaking change SetDocumentId is not quite documented (or good at all)</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="nightroman">Roman Kuzmin</reporter>
                        <labels>
                    </labels>
                <created>Wed, 18 Apr 2012 06:27:42 +0000</created>
                <updated>Thu, 2 Apr 2015 18:28:29 +0000</updated>
                            <resolved>Sun, 22 Apr 2012 21:17:34 +0000</resolved>
                                    <version>1.4.1</version>
                                    <fixVersion>1.4.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="112406" author="rstam" created="Sun, 22 Apr 2012 21:17:19 +0000"  >&lt;p&gt;BsonDocument methods GetDocumentId and SetDocumentId have been changed to be temporarily backward compatible with 1.4.0 and earlier. However, these methods were intended to be private, and all IBsonSerializable methods that were accidentally made public have been marked as deprecated and will be made private by explicit implementation in a future release.&lt;/p&gt;</comment>
                            <comment id="112331" author="rstam" created="Sun, 22 Apr 2012 00:00:31 +0000"  >&lt;p&gt;SetDocumentId should have been a private method but leaked out to the public API of BsonDocument because the IBsonSerializable methods were not explicitly implemented.&lt;/p&gt;

&lt;p&gt;We did not expect this to be a breaking change because we thought of the SetDocumentId method as being internal. The expected usage of SetDocumentId is that the callers will always pass in an id of the expected type, and in the case of BsonDocument the expected type is a BsonValue (hence the cast to BsonValue). The previous implementation of this method violated that expectation by converting any object type passed to BsonValue (it should have been a BsonValue already).&lt;/p&gt;

&lt;p&gt;For 1.4.2 we will revert the behavior of SetDocumentId to be backward compatible with 1.4, but at the same time we are going to mark it as obsolete and in a subsequent release we are going to remove it from the public API.&lt;/p&gt;

&lt;p&gt;The best way to set the _id of a BsonDocument is:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;document[&quot;_id&quot;] = id;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Note that GetDocumentId method also has a breaking change. It now always returns a BsonValue. It also is going to be marked obsolete and removed from the public API in a subsequent release.&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|hrh7on:</customfieldvalue>

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