Skip to content

Commit d27b01b

Browse files
committed
Fixed warnings and failing tests on Mono.
1 parent 00d67cd commit d27b01b

22 files changed

+103
-108
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ codereview.rc
1515
# GhostDoc artifacts
1616
CSharpDriver.sln.GhostDoc.xml
1717

18+
# Mac OS artifacts
19+
.DS_Store
20+
1821
# MonoDevelop artifacts
1922
*.pidb
2023
*.userprefs

src/CSharpDriver-Mono.sln

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,43 @@
11

2-
Microsoft Visual Studio Solution File, Format Version 11.00
3-
# Visual Studio 2010
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
46
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Bson", "MongoDB.Bson\MongoDB.Bson.csproj", "{0E9A3A2A-49CD-4F6C-847C-DC79B4B65CE6}"
57
EndProject
68
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Bson.Tests", "MongoDB.Bson.Tests\MongoDB.Bson.Tests.csproj", "{10A5FAC2-E26F-4726-B888-26D5B849F805}"
79
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver", "MongoDB.Driver\MongoDB.Driver.csproj", "{AE5166CD-76B0-4911-BD80-CED9521F37A1}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Tests", "MongoDB.Driver.Tests\MongoDB.Driver.Tests.csproj", "{FBBF0D71-107F-49C4-8858-B3A4DC24AA33}"
13+
EndProject
814
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Core", "MongoDB.Driver.Core\MongoDB.Driver.Core.csproj", "{DA56482A-5D8F-41E0-85E6-1F22B310F91B}"
915
EndProject
1016
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Core.Tests", "MongoDB.Driver.Core.Tests\MongoDB.Driver.Core.Tests.csproj", "{B7AE6291-4D43-44D8-9FD1-A0D651330927}"
1117
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver", "MongoDB.Driver\MongoDB.Driver.csproj", "{AE5166CD-76B0-4911-BD80-CED9521F37A1}"
18+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bson", "Bson", "{02386664-8BF7-4E57-A24E-B059B8F997F0}"
1319
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Tests", "MongoDB.Driver.Tests\MongoDB.Driver.Tests.csproj", "{FBBF0D71-107F-49C4-8858-B3A4DC24AA33}"
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{475393A0-310D-4EEE-8E3F-F196A96B2A99}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Driver", "Driver", "{11282844-4584-4F65-9857-D4329046E84D}"
1523
EndProject
1624
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Bson.TestHelpers", "MongoDB.Bson.TestHelpers\MongoDB.Bson.TestHelpers.csproj", "{6AC4638E-EC69-46AA-B6AA-C5CF227D14AE}"
1725
EndProject
1826
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Core.TestHelpers", "MongoDB.Driver.Core.TestHelpers\MongoDB.Driver.Core.TestHelpers.csproj", "{26C8E1F2-D859-4ED0-A1A7-DE0B32F81084}"
1927
EndProject
20-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00502D63-7789-410D-B6BE-5F16327FF810}"
21-
ProjectSection(SolutionItems) = preProject
22-
CodeAnalysisRuleSet.ruleset = CodeAnalysisRuleSet.ruleset
23-
CustomDictionary.xml = CustomDictionary.xml
24-
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
25-
README.md = README.md
26-
uuidhelpers.js = uuidhelpers.js
27-
EndProjectSection
28-
EndProject
29-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Release Notes", "Release Notes", "{AA4F6FD3-8844-4DF1-9944-0364C934B3F7}"
30-
ProjectSection(SolutionItems) = preProject
31-
Release Notes\Change Log v1.4-Bson.txt = Release Notes\Change Log v1.4-Bson.txt
32-
Release Notes\Change Log v1.4-Driver.txt = Release Notes\Change Log v1.4-Driver.txt
33-
Release Notes\Change Log v1.4.1-Bson.txt = Release Notes\Change Log v1.4.1-Bson.txt
34-
Release Notes\Change Log v1.4.1-Driver.txt = Release Notes\Change Log v1.4.1-Driver.txt
35-
Release Notes\Change Log v1.4.2-Bson.txt = Release Notes\Change Log v1.4.2-Bson.txt
36-
Release Notes\Change Log v1.4.2-Driver.txt = Release Notes\Change Log v1.4.2-Driver.txt
37-
Release Notes\Release Notes v0.11.txt = Release Notes\Release Notes v0.11.txt
38-
Release Notes\Release Notes v0.7.txt = Release Notes\Release Notes v0.7.txt
39-
Release Notes\Release Notes v0.9.txt = Release Notes\Release Notes v0.9.txt
40-
Release Notes\Release Notes v1.0.txt = Release Notes\Release Notes v1.0.txt
41-
Release Notes\Release Notes v1.1.txt = Release Notes\Release Notes v1.1.txt
42-
Release Notes\Release Notes v1.2.txt = Release Notes\Release Notes v1.2.txt
43-
Release Notes\Release Notes v1.3.1.txt = Release Notes\Release Notes v1.3.1.txt
44-
Release Notes\Release Notes v1.3.txt = Release Notes\Release Notes v1.3.txt
45-
Release Notes\Release Notes v1.4.1.md = Release Notes\Release Notes v1.4.1.md
46-
Release Notes\Release Notes v1.4.2.md = Release Notes\Release Notes v1.4.2.md
47-
Release Notes\Release Notes v1.4.md = Release Notes\Release Notes v1.4.md
48-
EndProjectSection
28+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.TestConsoleApplication", "MongoDB.Driver.TestConsoleApplication\MongoDB.Driver.TestConsoleApplication.csproj", "{858FA1E8-831B-4B4B-A29F-B1F4332DF6A7}"
29+
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Legacy", "MongoDB.Driver.Legacy\MongoDB.Driver.Legacy.csproj", "{97962946-AA1E-4308-B7A7-6AD92BDBC358}"
31+
EndProject
32+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Legacy.Tests", "MongoDB.Driver.Legacy.Tests\MongoDB.Driver.Legacy.Tests.csproj", "{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69}"
33+
EndProject
34+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.TestHelpers", "MongoDB.Driver.TestHelpers\MongoDB.Driver.TestHelpers.csproj", "{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF}"
35+
EndProject
36+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Legacy.TestHelpers", "MongoDB.Driver.Legacy.TestHelpers\MongoDB.Driver.Legacy.TestHelpers.csproj", "{02AB2E44-785A-4D39-99C0-29F93A02EF84}"
37+
EndProject
38+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Legacy", "Legacy", "{C0AC2FCF-37FB-4A64-ACC6-8490DC15091D}"
39+
EndProject
40+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{391D831D-5AC7-43F8-8BCB-6AE81B027658}"
4941
EndProject
5042
Global
5143
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -61,14 +53,6 @@ Global
6153
{10A5FAC2-E26F-4726-B888-26D5B849F805}.Debug|Any CPU.Build.0 = Debug|Any CPU
6254
{10A5FAC2-E26F-4726-B888-26D5B849F805}.Release|Any CPU.ActiveCfg = Release|Any CPU
6355
{10A5FAC2-E26F-4726-B888-26D5B849F805}.Release|Any CPU.Build.0 = Release|Any CPU
64-
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65-
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Debug|Any CPU.Build.0 = Debug|Any CPU
66-
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Release|Any CPU.ActiveCfg = Release|Any CPU
67-
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Release|Any CPU.Build.0 = Release|Any CPU
68-
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69-
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Debug|Any CPU.Build.0 = Debug|Any CPU
70-
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Release|Any CPU.ActiveCfg = Release|Any CPU
71-
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Release|Any CPU.Build.0 = Release|Any CPU
7256
{AE5166CD-76B0-4911-BD80-CED9521F37A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
7357
{AE5166CD-76B0-4911-BD80-CED9521F37A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
7458
{AE5166CD-76B0-4911-BD80-CED9521F37A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -77,6 +61,14 @@ Global
7761
{FBBF0D71-107F-49C4-8858-B3A4DC24AA33}.Debug|Any CPU.Build.0 = Debug|Any CPU
7862
{FBBF0D71-107F-49C4-8858-B3A4DC24AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU
7963
{FBBF0D71-107F-49C4-8858-B3A4DC24AA33}.Release|Any CPU.Build.0 = Release|Any CPU
64+
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65+
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Debug|Any CPU.Build.0 = Debug|Any CPU
66+
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Release|Any CPU.ActiveCfg = Release|Any CPU
67+
{DA56482A-5D8F-41E0-85E6-1F22B310F91B}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69+
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Debug|Any CPU.Build.0 = Debug|Any CPU
70+
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Release|Any CPU.ActiveCfg = Release|Any CPU
71+
{B7AE6291-4D43-44D8-9FD1-A0D651330927}.Release|Any CPU.Build.0 = Release|Any CPU
8072
{6AC4638E-EC69-46AA-B6AA-C5CF227D14AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8173
{6AC4638E-EC69-46AA-B6AA-C5CF227D14AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
8274
{6AC4638E-EC69-46AA-B6AA-C5CF227D14AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -85,11 +77,43 @@ Global
8577
{26C8E1F2-D859-4ED0-A1A7-DE0B32F81084}.Debug|Any CPU.Build.0 = Debug|Any CPU
8678
{26C8E1F2-D859-4ED0-A1A7-DE0B32F81084}.Release|Any CPU.ActiveCfg = Release|Any CPU
8779
{26C8E1F2-D859-4ED0-A1A7-DE0B32F81084}.Release|Any CPU.Build.0 = Release|Any CPU
80+
{858FA1E8-831B-4B4B-A29F-B1F4332DF6A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81+
{858FA1E8-831B-4B4B-A29F-B1F4332DF6A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
82+
{858FA1E8-831B-4B4B-A29F-B1F4332DF6A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
83+
{858FA1E8-831B-4B4B-A29F-B1F4332DF6A7}.Release|Any CPU.Build.0 = Release|Any CPU
84+
{97962946-AA1E-4308-B7A7-6AD92BDBC358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85+
{97962946-AA1E-4308-B7A7-6AD92BDBC358}.Debug|Any CPU.Build.0 = Debug|Any CPU
86+
{97962946-AA1E-4308-B7A7-6AD92BDBC358}.Release|Any CPU.ActiveCfg = Release|Any CPU
87+
{97962946-AA1E-4308-B7A7-6AD92BDBC358}.Release|Any CPU.Build.0 = Release|Any CPU
88+
{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
89+
{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69}.Debug|Any CPU.Build.0 = Debug|Any CPU
90+
{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69}.Release|Any CPU.ActiveCfg = Release|Any CPU
91+
{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69}.Release|Any CPU.Build.0 = Release|Any CPU
92+
{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
93+
{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
94+
{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
95+
{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF}.Release|Any CPU.Build.0 = Release|Any CPU
96+
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
97+
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Debug|Any CPU.Build.0 = Debug|Any CPU
98+
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Release|Any CPU.ActiveCfg = Release|Any CPU
99+
{02AB2E44-785A-4D39-99C0-29F93A02EF84}.Release|Any CPU.Build.0 = Release|Any CPU
88100
EndGlobalSection
89101
GlobalSection(SolutionProperties) = preSolution
90102
HideSolutionNode = FALSE
91103
EndGlobalSection
92104
GlobalSection(NestedProjects) = preSolution
93-
{AA4F6FD3-8844-4DF1-9944-0364C934B3F7} = {00502D63-7789-410D-B6BE-5F16327FF810}
105+
{0E9A3A2A-49CD-4F6C-847C-DC79B4B65CE6} = {02386664-8BF7-4E57-A24E-B059B8F997F0}
106+
{10A5FAC2-E26F-4726-B888-26D5B849F805} = {02386664-8BF7-4E57-A24E-B059B8F997F0}
107+
{AE5166CD-76B0-4911-BD80-CED9521F37A1} = {11282844-4584-4F65-9857-D4329046E84D}
108+
{FBBF0D71-107F-49C4-8858-B3A4DC24AA33} = {11282844-4584-4F65-9857-D4329046E84D}
109+
{DA56482A-5D8F-41E0-85E6-1F22B310F91B} = {475393A0-310D-4EEE-8E3F-F196A96B2A99}
110+
{B7AE6291-4D43-44D8-9FD1-A0D651330927} = {475393A0-310D-4EEE-8E3F-F196A96B2A99}
111+
{6AC4638E-EC69-46AA-B6AA-C5CF227D14AE} = {02386664-8BF7-4E57-A24E-B059B8F997F0}
112+
{26C8E1F2-D859-4ED0-A1A7-DE0B32F81084} = {475393A0-310D-4EEE-8E3F-F196A96B2A99}
113+
{858FA1E8-831B-4B4B-A29F-B1F4332DF6A7} = {391D831D-5AC7-43F8-8BCB-6AE81B027658}
114+
{97962946-AA1E-4308-B7A7-6AD92BDBC358} = {C0AC2FCF-37FB-4A64-ACC6-8490DC15091D}
115+
{4F42BA31-AAA3-4BD4-A4F2-7F7A53940D69} = {C0AC2FCF-37FB-4A64-ACC6-8490DC15091D}
116+
{89B92FFF-4126-4D9A-93C8-2BD7E0CD82FF} = {11282844-4584-4F65-9857-D4329046E84D}
117+
{02AB2E44-785A-4D39-99C0-29F93A02EF84} = {C0AC2FCF-37FB-4A64-ACC6-8490DC15091D}
94118
EndGlobalSection
95119
EndGlobal

src/MongoDB.Bson.Tests/IO/BsonStreamExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public void ReadBytes_with_buffer_should_throw_when_at_end_of_stream(
287287
{
288288
var bytes = Enumerable.Range(0, length).Select(n => (byte)n).ToArray();
289289

290-
using (var memoryStream = new MemoryStream(length))
290+
using (var memoryStream = new MemoryStream(bytes))
291291
using (var stream = new BsonStreamAdapter(memoryStream))
292292
{
293293
var buffer = new byte[length + 1];

src/MongoDB.Bson.Tests/IO/ByteBufferSliceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void AccessBackingBytes_should_adjust_position()
4747
var subject = CreateSubjectWithFakeBuffer();
4848
subject.Buffer.AccessBackingBytes(1).Returns(new ArraySegment<byte>(new byte[3], 1, 2));
4949

50-
var result = subject.AccessBackingBytes(0);
50+
subject.AccessBackingBytes(0);
5151

5252
subject.Buffer.Received(1).AccessBackingBytes(1);
5353
}
@@ -248,7 +248,7 @@ public void GetByte_should_adjust_position()
248248
var subject = CreateSubjectWithFakeBuffer();
249249
var buffer = subject.Buffer;
250250

251-
var result = subject.GetByte(0);
251+
subject.GetByte(0);
252252

253253
buffer.Received(1).GetByte(1);
254254
}

src/MongoDB.Bson.Tests/IO/ByteBufferStreamTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ public void ReadSlice_should_return_expected_result(int length, byte[] bytes)
734734
var subject = new ByteBufferStream(buffer);
735735
var expectedPosition = length;
736736

737-
var result = subject.ReadSlice();
737+
subject.ReadSlice();
738738

739739
subject.Position.Should().Be(expectedPosition);
740740
subject.Buffer.Received(1).GetSlice(0, bytes.Length);

src/MongoDB.Bson.Tests/IO/InputBufferChunkSourceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void GetChunk_should_round_requestedSize_to_power_of_2_without_wasting_to
215215
var subject = new InputBufferChunkSource(baseSource, maxUnpooledChunkSize: 0, minChunkSize: 4, maxChunkSize: 16);
216216
baseSource.GetChunk(Arg.Any<int>()).Returns(Substitute.For<IBsonChunk>());
217217

218-
var chunk = subject.GetChunk(requestedSize);
218+
subject.GetChunk(requestedSize);
219219

220220
baseSource.Received(1).GetChunk(roundedSize);
221221
}

src/MongoDB.Bson.Tests/ObjectModel/BsonValueEqualsTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,11 @@ public void TestBsonElementEquals()
305305
Assert.IsFalse(a == c);
306306
Assert.IsFalse(a == d);
307307
Assert.IsFalse(c == d);
308-
Assert.IsFalse(a == null);
309-
Assert.IsFalse(null == a);
310308

311309
Assert.IsFalse(a != b);
312310
Assert.IsTrue(a != c);
313311
Assert.IsTrue(a != d);
314312
Assert.IsTrue(c != d);
315-
Assert.IsTrue(a != null);
316-
Assert.IsTrue(null != a);
317313
}
318314

319315
[Test]

src/MongoDB.Bson/ObjectModel/BsonDocument.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,6 @@ public static BsonDocument Parse(string json)
376376
/// <returns>The document (so method calls can be chained).</returns>
377377
public virtual BsonDocument Add(BsonElement element)
378378
{
379-
if (element == null)
380-
{
381-
throw new ArgumentNullException("element");
382-
}
383-
384379
var isDuplicate = IndexOfName(element.Name) != -1;
385380
if (isDuplicate && !_allowDuplicateNames)
386381
{
@@ -963,10 +958,6 @@ public virtual int IndexOfName(string name)
963958
/// <param name="element">The element.</param>
964959
public virtual void InsertAt(int index, BsonElement element)
965960
{
966-
if (element == null)
967-
{
968-
throw new ArgumentNullException("element");
969-
}
970961
var isDuplicate = IndexOfName(element.Name) != -1;
971962
if (isDuplicate && !_allowDuplicateNames)
972963
{
@@ -1072,11 +1063,6 @@ public virtual void RemoveAt(int index)
10721063
/// <param name="element">The element to remove.</param>
10731064
public virtual void RemoveElement(BsonElement element)
10741065
{
1075-
if (element == null)
1076-
{
1077-
throw new ArgumentNullException("element");
1078-
}
1079-
10801066
if (_elements.Remove(element))
10811067
{
10821068
RebuildIndexes();
@@ -1127,11 +1113,6 @@ public virtual BsonDocument Set(string name, BsonValue value)
11271113
/// <returns>The document.</returns>
11281114
public virtual BsonDocument SetElement(int index, BsonElement element)
11291115
{
1130-
if (element == null)
1131-
{
1132-
throw new ArgumentNullException("element");
1133-
}
1134-
11351116
var oldName = _elements[index].Name;
11361117
_elements[index] = element;
11371118

@@ -1150,10 +1131,6 @@ public virtual BsonDocument SetElement(int index, BsonElement element)
11501131
/// <returns>The document.</returns>
11511132
public virtual BsonDocument SetElement(BsonElement element)
11521133
{
1153-
if (element == null)
1154-
{
1155-
throw new ArgumentNullException("element");
1156-
}
11571134
var index = IndexOfName(element.Name);
11581135
if (index != -1)
11591136
{

src/MongoDB.Driver.Core.Tests/Core/Connections/TcpStreamFactoryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public async Task CreateStreamAsync_should_call_the_socketConfigurator()
5959
var subject = new TcpStreamFactory(settings);
6060
var endPoint = CoreTestConfiguration.ConnectionString.Hosts[0];
6161

62-
var stream = await subject.CreateStreamAsync(endPoint, CancellationToken.None);
62+
await subject.CreateStreamAsync(endPoint, CancellationToken.None);
6363

6464
socketConfiguratorWasCalled.Should().BeTrue();
6565
}
@@ -90,7 +90,7 @@ public async Task SocketConfigurator_can_be_used_to_set_keepAlive()
9090
var socketProperty = typeof(NetworkStream).GetProperty("Socket", BindingFlags.NonPublic | BindingFlags.Instance);
9191
var socket = (Socket)socketProperty.GetValue(stream);
9292
var keepAlive = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive);
93-
keepAlive.Should().Be(1);
93+
keepAlive.Should().NotBe(0); // .NET returns 1 but Mono returns 8
9494
}
9595
}
9696
}

src/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public async Task ExecuteAsync_should_return_expected_results()
7474
{
7575
await EnsureTestDataAsync();
7676

77-
var query = new BsonDocument();
7877
var mapFunction = "function() { emit(this.x, this.v); }";
7978
var reduceFunction = "function(key, values) { var sum = 0; for (var i = 0; i < values.length; i++) { sum += values[i]; }; return sum; }";
8079
var subject = new MapReduceOperation<BsonDocument>(_collectionNamespace, mapFunction, reduceFunction, _resultSerializer, _messageEncoderSettings);

src/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOutputToCollectionOperationTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class MapReduceOutputToCollectionOperationTests : OperationTestBase
3636
// fields
3737
private readonly BsonJavaScript _mapFunction = "map";
3838
private CollectionNamespace _outputCollectionNamespace;
39-
private readonly BsonDocument _query = new BsonDocument("query", 1);
4039
private readonly BsonJavaScript _reduceFunction = "reduce";
4140

4241
// setup methods
@@ -158,6 +157,18 @@ public void ExecuteAsync_should_throw_when_binding_is_null()
158157
action.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("binding");
159158
}
160159

160+
[Test]
161+
public void Filter_should_get_and_set_value()
162+
{
163+
var subject = new MapReduceOutputToCollectionOperation(_collectionNamespace, _outputCollectionNamespace, _mapFunction, _reduceFunction, _messageEncoderSettings);
164+
var value = new BsonDocument("_id", 1);
165+
166+
subject.Filter = value;
167+
var result = subject.Filter;
168+
169+
result.Should().Be(value);
170+
}
171+
161172
[Test]
162173
public void NonAtomicOutput_should_get_and_set_value()
163174
{

src/MongoDB.Driver.Core.Tests/WriteConcernTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ namespace MongoDB.Driver
2727
[TestFixture]
2828
public class WriteConcernTests
2929
{
30-
private static readonly WriteConcern __default = new WriteConcern();
31-
3230
[Test]
3331
public void Acknowledged_should_return_expected_result()
3432
{

src/MongoDB.Driver.Core/Core/Operations/ListIndexesOperation.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ private async Task<IAsyncCursor<BsonDocument>> ExecuteUsingCommandAsync(IChannel
131131

132132
private async Task<IAsyncCursor<BsonDocument>> ExecuteUsingQueryAsync(IChannelSourceHandle channelSource, ReadPreference readPreference, CancellationToken cancellationToken)
133133
{
134-
var indexes = new List<BsonDocument>();
135-
136134
var systemIndexesCollection = _collectionNamespace.DatabaseNamespace.SystemIndexesCollection;
137135
var filter = new BsonDocument("ns", _collectionNamespace.FullName);
138136
var operation = new FindOperation<BsonDocument>(systemIndexesCollection, BsonDocumentSerializer.Instance, _messageEncoderSettings)

0 commit comments

Comments
 (0)