[CSHARP-1758] Camel case element name convention is not applied for extra element names Created: 29/Aug/16  Updated: 28/Sep/16  Resolved: 28/Sep/16

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Gediminas Backevicius Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I am not sure if it's bug, but in my opinion it is.

I am using CamelCaseElementNameConvention and I am expecting that all names will be converted to camel case.

  var convensions = new ConventionPack
  {
    new CamelCaseElementNameConvention()
  };
 
  ConventionRegistry.Register("default", convensions, x => true);

Lets say I have such class

public class MyDocument {
 
  public string Name { get; set; }
 
  [BsonExtraElements]
  public AdditionalInfo AdditionalInfo { get; set; } 
  /* class AdditionalInfo implements IDictionary<string, object> */
}

Then this class is serialised and stored in database, it looks like this

  {
    "name": "Tom",
    "Age": 24,
    "Gender": "male"
  }

I am expecting to have such result

  {
    "name": "Tom",
    "age": 24,
    "gender": "male"
  }



 Comments   
Comment by Craig Wilson [ 28/Sep/16 ]

Hi Gediminas,

I think your expectations are probably correct. However, it isn't how this was implemented and we can't change it now for backwards compatibility reasons. So, we'll have to leave it as is.

The extra elements stuff wasn't generally meant to be used as a grab bag for storing other stuff. It was originally meant to server as a place to put stuff in a document that wasn't mapped so as not to lose data. If you know you are going to be using fields, then you should map them.

Anyways, I'll close this as won't fix.
Craig

Generated at Wed Feb 07 21:40:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.