<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39: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-1520] DictionaryInterfaceImplementerSerializer enum serialization bug</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1520</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;After migrating form driver 1.x to 2.x (2.2.0), we faced an issue with the&lt;/p&gt;

&lt;p&gt;DictionaryInterfaceImplementerSerializer using DictionaryRepresentation.ArrayOfDocuments&lt;/p&gt;

&lt;p&gt;where the dictionary is a &lt;/p&gt;

&lt;p&gt;Dictionary&amp;lt;MyEnumeration, bool&amp;gt;.&lt;/p&gt;

&lt;p&gt;The following stacktrace was generated for some documents:&lt;/p&gt;

&lt;p&gt;System.FormatException : An error occurred while deserializing the EnabledForProduct property of class CredMarket.Model.Branch: O valor &quot;0&quot; n&#227;o &#233; do tipo &quot;CredMarket.Model.Product&quot; e n&#227;o pode ser usado nesta cole&#231;&#227;o gen&#233;rica.&lt;br/&gt;
Nome do par&#226;metro: key&lt;br/&gt;
  ----&amp;gt; System.ArgumentException : O valor &quot;0&quot; n&#227;o &#233; do tipo &quot;CredMarket.Model.Product&quot; e n&#227;o pode ser usado nesta cole&#231;&#227;o gen&#233;rica.&lt;br/&gt;
Nome do par&#226;metro: key&lt;br/&gt;
   em MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeMemberValue(BsonDeserializationContext&#160;context,&#160;BsonMemberMap&#160;memberMap)&lt;br/&gt;
   em MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeClass(BsonDeserializationContext&#160;context)&lt;br/&gt;
   em MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext&#160;context,&#160;BsonDeserializationArgs&#160;args)&lt;br/&gt;
   em MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer`1&#160;serializer,&#160;BsonDeserializationContext&#160;context)&lt;br/&gt;
   em MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.ReplyMessageBinaryEncoder`1.ReadMessage()&lt;br/&gt;
   em MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageHelper.DecodeMessage(IByteBuffer&#160;buffer,&#160;IMessageEncoderSelector&#160;encoderSelector,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32&#160;responseTo,&#160;IMessageEncoderSelector&#160;encoderSelector,&#160;MessageEncoderSettings&#160;messageEncoderSettings,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquiredConnection.ReceiveMessage(Int32&#160;responseTo,&#160;IMessageEncoderSelector&#160;encoderSelector,&#160;MessageEncoderSettings&#160;messageEncoderSettings,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.WireProtocol.QueryWireProtocol`1.Execute(IConnection&#160;connection,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.Servers.ClusterableServer.ServerChannel.ExecuteProtocol(IWireProtocol`1&#160;protocol,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.Servers.ClusterableServer.ServerChannel.Query(CollectionNamespace&#160;collectionNamespace,&#160;BsonDocument&#160;query,&#160;BsonDocument&#160;fields,&#160;IElementNameValidator&#160;queryValidator,&#160;Int32&#160;skip,&#160;Int32&#160;batchSize,&#160;Boolean&#160;slaveOk,&#160;Boolean&#160;partialOk,&#160;Boolean&#160;noCursorTimeout,&#160;Boolean&#160;oplogReplay,&#160;Boolean&#160;tailableCursor,&#160;Boolean&#160;awaitData,&#160;IBsonSerializer`1&#160;serializer,&#160;MessageEncoderSettings&#160;messageEncoderSettings,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.Operations.FindOpcodeOperation`1.ExecuteProtocol(IChannelHandle&#160;channel,&#160;BsonDocument&#160;wrappedQuery,&#160;Boolean&#160;slaveOk,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.Operations.FindOpcodeOperation`1.Execute(IReadBinding&#160;binding,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding&#160;binding,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.OperationExecutor.ExecuteReadOperation(IReadBinding&#160;binding,&#160;IReadOperation`1&#160;operation,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation(IReadOperation`1&#160;operation,&#160;ReadPreference&#160;readPreference,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation(IReadOperation`1&#160;operation,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.MongoCollectionImpl`1.FindSync(FilterDefinition`1&#160;filter,&#160;FindOptions`2&#160;options,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.IAsyncCursorSourceExtensions.FirstOrDefault(IAsyncCursorSource`1&#160;source,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em MongoDB.Driver.IFindFluentExtensions.FirstOrDefault(IFindFluent`2&#160;find,&#160;CancellationToken&#160;cancellationToken)&lt;br/&gt;
   em CredMarket.Repository.MongoDB.SimpleRepository`1.FindOne(FilterDefinition`1&#160;f) na SimpleRepository.cs: line 99&lt;br/&gt;
   em CredMarket.Repository.MongoDB.SimpleRepository`1.GetById(String&#160;id) na SimpleRepository.cs: line 105&lt;br/&gt;
   em CredMarket.Tests.TestMongoDB2Serialization.TestBranchSerialization() na TestMongoDB2Serialization.cs: line 67&lt;br/&gt;
--ArgumentException&lt;br/&gt;
   em System.ThrowHelper.ThrowWrongKeyTypeArgumentException(Object&#160;key,&#160;Type&#160;targetType)&lt;br/&gt;
   em System.Collections.Generic.Dictionary`2.System.Collections.IDictionary.Add(Object&#160;key,&#160;Object&#160;value)&lt;br/&gt;
   em MongoDB.Bson.Serialization.Serializers.DictionarySerializerBase`1.DeserializeArrayRepresentation(BsonDeserializationContext&#160;context)&lt;br/&gt;
   em MongoDB.Bson.Serialization.Serializers.DictionarySerializerBase`1.DeserializeValue(BsonDeserializationContext&#160;context,&#160;BsonDeserializationArgs&#160;args)&lt;br/&gt;
   em MongoDB.Bson.Serialization.Serializers.ClassSerializerBase`1.Deserialize(BsonDeserializationContext&#160;context,&#160;BsonDeserializationArgs&#160;args)&lt;br/&gt;
   em MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext&#160;context,&#160;BsonDeserializationArgs&#160;args)&lt;br/&gt;
   em MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer&#160;serializer,&#160;BsonDeserializationContext&#160;context)&lt;br/&gt;
   em MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeMemberValue(BsonDeserializationContext&#160;context,&#160;BsonMemberMap&#160;memberMap)&lt;/p&gt;

&lt;p&gt;We nailed down the error to documents where the enum was of the underyling bson type &quot;1&quot; (Double). Documents with underlying bson type of &quot;16&quot; (Int 32)&lt;/p&gt;

&lt;p&gt;This issue does not happen with the 1.x driver.&lt;/p&gt;
</description>
                <environment>MongoDB 3.0.7</environment>
        <key id="245307">CSHARP-1520</key>
            <summary>DictionaryInterfaceImplementerSerializer enum serialization bug</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="danielp@bompracredito.com.br">Daniel Polistchuck</reporter>
                        <labels>
                    </labels>
                <created>Wed, 30 Dec 2015 19:25:10 +0000</created>
                <updated>Mon, 4 Jan 2016 14:04:30 +0000</updated>
                            <resolved>Mon, 4 Jan 2016 14:04:30 +0000</resolved>
                                    <version>2.2</version>
                                                    <component>BSON</component>
                    <component>Serialization</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="1125097" author="danielp@bompracredito.com.br" created="Mon, 4 Jan 2016 13:25:52 +0000"  >&lt;p&gt;Folks, please close this  ticket... I have found that I need to specify the serializes for key and value like this:&lt;/p&gt;


&lt;p&gt;BsonClassMap.RegisterClassMap&amp;lt;Document&amp;gt;(cm =&amp;gt;&lt;/p&gt;
{
    cm.AutoMap();
    cm.MapMember(c =&amp;gt; c.EnabledForProduct)
      .SetSerializer(new DictionaryInterfaceImplementerSerializer&amp;lt;Dictionary&amp;lt;Product, bool&amp;gt;&amp;gt;(DictionaryRepresentation.ArrayOfDocuments, 
                        BsonSerializer.LookupSerializer&amp;lt;int&amp;gt;(), 
                        BsonSerializer.LookupSerializer&amp;lt;bool&amp;gt;()));
}
&lt;p&gt;);&lt;/p&gt;</comment>
                            <comment id="1124216" author="danielp@bompracredito.com.br" created="Wed, 30 Dec 2015 20:05:22 +0000"  >&lt;p&gt;I submitted the ticket without reading it through.... where it reads:&lt;/p&gt;

&lt;p&gt;&quot;We nailed down the error to documents where the enum was of the underyling bson type &quot;1&quot; (Double). Documents with underlying bson type of &quot;16&quot; (Int 32)&quot;&lt;/p&gt;

&lt;p&gt;it should read&lt;/p&gt;

&lt;p&gt;&quot;We nailed down the error to documents where the enum was of the underyling bson type &quot;1&quot; (Double). Documents with underlying bson type of &quot;16&quot; (Int 32)&lt;b&gt;, deserialize correctly&lt;/b&gt;&quot;&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|hsf6s7:</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>