<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:44 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-1485] NullReferenceException when saving an ExpandoObject property</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1485</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I have a class like:&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;   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;	public class TagRecord&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;	{&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		public Guid Id { get; set; }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		....&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		public ExpandoObject ExtraData { get; set; }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;	}&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;When I trying to insert it in MongoDb without setting ExtraData property (so leaving it to null) I get a NullReferenceException exception.&lt;br/&gt;
If I simply change the type to &quot;Object&quot; all is working fine, also when I actually save it with an ExpandoObject instance.&lt;/p&gt;</description>
                <environment></environment>
        <key id="240650">CSHARP-1485</key>
            <summary>NullReferenceException when saving an ExpandoObject property</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="9">Done</resolution>
                                        <assignee username="james.kovacs@mongodb.com">James Kovacs</assignee>
                                    <reporter username="davide.icardi@gmail.com">Davide Icardi</reporter>
                        <labels>
                    </labels>
                <created>Mon, 23 Nov 2015 10:07:30 +0000</created>
                <updated>Tue, 16 Nov 2021 13:40:07 +0000</updated>
                            <resolved>Mon, 7 Jun 2021 20:18:10 +0000</resolved>
                                    <version>2.1.1</version>
                                    <fixVersion>2.13.0</fixVersion>
                                    <component>Serialization</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="3863496" author="xgen-internal-githook" created="Mon, 7 Jun 2021 20:17:19 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;James Kovacs&apos;, &apos;email&apos;: &apos;jkovacs@post.harvard.edu&apos;, &apos;username&apos;: &apos;JamesKovacs&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1485&quot; title=&quot;NullReferenceException when saving an ExpandoObject property&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1485&quot;&gt;&lt;del&gt;CSHARP-1485&lt;/del&gt;&lt;/a&gt;: Fix ExpandoObject serialization to permit nulls. (#542)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/commit/d3f75f880e5e67fc268a56681acc58a07ce497e2&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/commit/d3f75f880e5e67fc268a56681acc58a07ce497e2&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3858767" author="james.kovacs" created="Thu, 3 Jun 2021 22:00:33 +0000"  >&lt;p&gt;Hi, Brecht,&lt;/p&gt;

&lt;p&gt;Thank you for bringing this back to our attention. I have confirmed that it is still an issue in the latest version of the driver and I have implemented a fix, which will be available in an upcoming release.&lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br/&gt;
James&lt;/p&gt;</comment>
                            <comment id="3849272" author="brecht.vanhaesebrouck@sea-invest.com" created="Mon, 31 May 2021 07:19:15 +0000"  >&lt;p&gt;I just had the same problem (with the most recent version of the driver)&lt;/p&gt;</comment>
                            <comment id="1389161" author="davide.icardi@gmail.com" created="Tue, 20 Sep 2016 19:38:35 +0000"  >&lt;p&gt;Here a very easy example to reproduce the error:&lt;/p&gt;

&lt;p&gt;		public class MyClass&lt;br/&gt;
		{&lt;br/&gt;
			public ExpandoObject MyProperty1 &lt;/p&gt;
{ get; set; }
&lt;p&gt;		}&lt;/p&gt;

&lt;p&gt;		var myClass = new MyClass&lt;/p&gt;
{MyProperty1 = null}
&lt;p&gt;;&lt;br/&gt;
		var bson = myClass.ToBson(); // throw NullReferenceException&lt;/p&gt;

&lt;p&gt;		var myClass = new MyClass&lt;/p&gt;
{MyProperty1 = new ExpandoObject()}
&lt;p&gt;;&lt;br/&gt;
		var bson = myClass.ToBson(); // OK&lt;/p&gt;</comment>
                            <comment id="1168776" author="davide.icardi@gmail.com" created="Wed, 10 Feb 2016 01:41:37 +0000"  >&lt;p&gt;Sorry for the late response ....&lt;br/&gt;
It will throw NullReferenceException on DynamicDocumentBaseSerializer.Serialize. Looking at the code I cannot see any null checking before calling:&lt;/p&gt;

&lt;p&gt;     var metaObject = value.GetMetaObject(Expression.Constant(value));&lt;/p&gt;

&lt;p&gt;A similar problem is during deserialize on the DynamicDocumentBaseSerializer.Deserialize because It doesn&apos;t handle BsonType.Null.&lt;/p&gt;

&lt;p&gt;There is a reason for this? I have tried creating a NullableExpandoObjectSerializer and checking for null on both Serialize and Deserialize and seems to work as expected.&lt;/p&gt;

&lt;p&gt;thanks&lt;/p&gt;</comment>
                            <comment id="1095615" author="craiggwilson" created="Mon, 23 Nov 2015 13:18:23 +0000"  >&lt;p&gt;Thanks for the report Davide. Could you provide a stack trace?&lt;/p&gt;

&lt;p&gt;Craig&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="10038"><![CDATA[Fully Compatible]]></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|hraxd3:</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>