Skip to content

Commit 619e564

Browse files
committed
CSHARP-728: fixed bug where using old-style conventions would skip default conventions.
1 parent a1bdaa2 commit 619e564

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

MongoDB.Bson/Serialization/Conventions/Obsolete/ConventionProfile.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ private IEnumerable<IConvention> GetNewConventions()
315315
{
316316
var pack = new ConventionPack();
317317

318+
// need to process defaults...
319+
pack.Append(DefaultConventionPack.Instance);
320+
318321
// class mapping conventions
319322
if (MemberFinderConvention != null)
320323
{
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Copyright 2010-2013 10gen Inc.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
using MongoDB.Bson.Serialization;
17+
using MongoDB.Bson.Serialization.Conventions;
18+
using NUnit.Framework;
19+
20+
namespace MongoDB.BsonUnitTests.Jira.CSharp728
21+
{
22+
[TestFixture]
23+
public class CSharp728Tests
24+
{
25+
private class A
26+
{
27+
public string S { get; set; }
28+
}
29+
30+
[Test]
31+
public void TestConventionProfileStillUsesDefaults()
32+
{
33+
#pragma warning disable 618
34+
var conventions = new ConventionProfile();
35+
conventions.SetElementNameConvention(new CamelCaseElementNameConvention());
36+
BsonClassMap.RegisterConventions(conventions, t => t == typeof(A));
37+
#pragma warning restore 618
38+
var classMap = new BsonClassMap<A>();
39+
classMap.AutoMap();
40+
41+
var memberMap = classMap.GetMemberMap(x => x.S);
42+
43+
Assert.IsNotNull(memberMap);
44+
}
45+
}
46+
}

MongoDB.BsonUnitTests/MongoDB.BsonUnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<Compile Include="BsonUtilsTests.cs" />
8484
<Compile Include="IO\ByteArrayBufferTests.cs" />
8585
<Compile Include="IO\MultiChunkBufferTests.cs" />
86+
<Compile Include="Jira\CSharp728Tests.cs" />
8687
<Compile Include="Jira\CSharp708Tests.cs" />
8788
<Compile Include="Jira\CSharp476Tests.cs" />
8889
<Compile Include="Jira\CSharp624Tests.cs" />

0 commit comments

Comments
 (0)