[CSHARP-1996] Subclass with no additional properties from base class will trigger System.ArgumentOutOfRangeException Created: 09/Jun/17  Updated: 10/Nov/22  Resolved: 09/Nov/22

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

Type: Bug Priority: Minor - P4
Reporter: sflorisson Assignee: James Kovacs
Resolution: Cannot Reproduce Votes: 3
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

.Net 4.5


Issue Links:
Duplicate
is duplicated by CSHARP-2675 ArgumentOutOfRangeException when inse... Closed
is duplicated by CSHARP-2325 MongoDB C# Driver (2.7) and serializa... Closed

 Description   

See:
MongoDB.Bson.Tests.Serialization.Conventions.ImmutableTypeClassMapConventionTests

Using test class:
private class TestClassD : TestClassC
{
public TestClassD(string a, string b) : base(a, b) { }
}

Will result in:
System.ArgumentOutOfRangeException
The memberInfo argument must be for class TestClassD, but was for class TestClassC.
Parameter name: memberInfo

when making the following call:
var classMap = BsonClassMap.LookupClassMap(typeof(TestClassD));



 Comments   
Comment by James Kovacs [ 09/Nov/22 ]

Does not reproduce with the latest driver.

using MongoDB.Bson.Serialization;
 
var classMap = BsonClassMap.LookupClassMap(typeof(TestClassD));
 
class TestClassC
{
    public TestClassC(string a, string b) { }
}
 
class TestClassD : TestClassC
{
    public TestClassD(string a, string b) : base(a, b) { }
}

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