[CSHARP-637] Fluent Lambda Expressions Don't Resolve Interfaces Created: 29/Nov/12  Updated: 20/Mar/14  Resolved: 24/Jan/13

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

Type: Bug Priority: Minor - P4
Reporter: Alexander Nagy Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Issue Links:
Related
related to CSHARP-708 BsonClassMap.SetIdMember fails for lh... Closed

 Description   

This was actually reported by MARCOSB on GitHub to me in the comments for a pull request I made here: https://github.com/mongodb/mongo-csharp-driver/commit/5a62ca86fba984803e445a1d182bc125a56c7714

public interface IMyInterface
{
string SomeField

{ get; set; }
}

public class MyClass : IMyInterface
{
[BsonElement("bla")]
public string SomeField { get; set; }

}

public class HelperClass<T>
where T : IMyInterface
{
public void DoSomething()

{ var classMapForT = new BsonClassMap<T>(); classMapForT.AutoMap(); // This will throw an exception - but seems like a reasonable use-case, right? classMapForT.MapMember(t => t.SomeField); }

}

I believe it is a regression; I will issue a fix for this.



 Comments   
Comment by auto [ 24/Jan/13 ]

Author:

{u'date': u'2012-12-10T22:29:07Z', u'email': u'optimiz3@gmail.com', u'name': u'optimiz3'}

Message: Fix CSHARP-637: Fluent Lambda Expressions Don't Resolve Interfaces

Accidental regression from https://github.com/mongodb/mongo-csharp-driver/commit/5a62ca86fba984803e445a1d182bc125a56c7714 caused generic interface member mappings to throw.

Update - added code to handle non-trivial edge case of explicit interface implementations caught during code review of JIRA-637 and rebased off of latest master changes.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6a37b6a811b0456125c7cbaf6a0ac527e694979e

Comment by Craig Wilson [ 10/Dec/12 ]

In code review.

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