[CSHARP-1559] Impossible to create BsonClassMap for Immutable Type that Inherits Created: 10/Feb/16 Updated: 15/Jan/20 Resolved: 15/Jan/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | 2.11.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Forest Johnson | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 4 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
See the function I have that creates a class map for my immutable types below. I am getting the error
I am working on implementing this on my fork and will submit a PR once done.
|
| Comments |
| Comment by Aristarkh Zagorodnikov [ 15/Jan/20 ] | |||||||||||||||||||||||||||||||||
|
Looking forward for this improvement as we were considering forking the driver and maintaining a separate build to fix this. | |||||||||||||||||||||||||||||||||
| Comment by Dmitry Lukyanov (Inactive) [ 15/Jan/20 ] | |||||||||||||||||||||||||||||||||
|
This ticket will be implemented in the scope of | |||||||||||||||||||||||||||||||||
| Comment by Aristarkh Zagorodnikov [ 19/Dec/19 ] | |||||||||||||||||||||||||||||||||
|
It would be very beneficial to fix this, since currently modelling using inherited immutable types is next to impossible. | |||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 11/Jan/18 ] | |||||||||||||||||||||||||||||||||
|
I can reproduce this using the following minimal scenario:
| |||||||||||||||||||||||||||||||||
| Comment by Forest Johnson [ 10/Feb/16 ] | |||||||||||||||||||||||||||||||||
|
Hey yall. I implemented this on my fork and it works in our app! For now I have just added a new public method MapMemberSpecificallyForImmutableTypes to BsonClassMap as a quick hacky fix. Maybe we can instead make that one private, and define a new public method MapConstructorForImmutableType(ConstructorInfo, MemberInfo[]) which in turn calls MapMemberSpecificallyForImmutableTypes for each MemberInfo listed. Alternatively nothing changes and we just use MapCreator(Delegate @delegate) in our app. Would that work? I don't know. We might end up doing that anyway later on. | |||||||||||||||||||||||||||||||||
| Comment by Forest Johnson [ 10/Feb/16 ] | |||||||||||||||||||||||||||||||||
|
Initially when I posted this I had seriously messed up the markup, but it looks like someone corrected it for me. Thanks. Here is a gist version of the description that I created since I couldn't edit the description: https://gist.github.com/forestjohnsonilm/2d9c023e5f486198c01e |