Skip to content

Commit a9f296c

Browse files
author
rstam
committed
Fixed CSHARP-447. BsonArray.Contains now returns false instead of throwing ArgumentNullException when called with null argument. Query.All, Query.In and Query.NotIn now handle nulls in the list of values according to functional construction semantics and therefore just skip them. (Not sure why git thinks CSharpDriverDocs.shfbproj is changed, probably because core.autocrlf was not set correctly when it was last changed).
1 parent 8fa154b commit a9f296c

File tree

5 files changed

+267
-180
lines changed

5 files changed

+267
-180
lines changed

Bson/ObjectModel/BsonArray.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,8 @@ public override int CompareTo(BsonValue other)
647647
/// <returns>True if the array contains the value.</returns>
648648
public bool Contains(BsonValue value)
649649
{
650-
if (value == null)
651-
{
652-
throw new ArgumentNullException("value");
653-
}
650+
// don't throw ArgumentNullException if value is null
651+
// just let _values.Contains return false
654652
return _values.Contains(value);
655653
}
656654

BsonUnitTests/ObjectModel/BsonArrayTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void TestContains()
171171
public void TestContainsNull()
172172
{
173173
var array = new BsonArray { 1, 2 };
174-
Assert.Throws<ArgumentNullException>(() => { array.Contains(null); });
174+
Assert.IsFalse(array.Contains(null));
175175
}
176176

177177
[Test]
@@ -427,7 +427,7 @@ public void TestCreateStringArrayNull()
427427
[Test]
428428
public void TestCreateFromObject()
429429
{
430-
var value = (object)new object[] { 1, 1.5, null };
430+
var value = (object)new object[] { 1, 1.5, null }; // null will be mapped to BsonNull.Value
431431
var array = BsonArray.Create(value);
432432
Assert.AreEqual(3, array.Count);
433433
Assert.IsInstanceOf<BsonInt32>(array[0]);

CSharpDriverDocs.shfbproj

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3-
<PropertyGroup>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3+
<PropertyGroup>
44
<!-- The configuration and platform will be used to determine which
55
assemblies to include from solution and project documentation
6-
sources -->
7-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9-
<SchemaVersion>2.0</SchemaVersion>
10-
<ProjectGuid>{cf31cff3-1925-457c-8775-e08bcd39e49f}</ProjectGuid>
11-
<SHFBSchemaVersion>1.9.3.0</SHFBSchemaVersion>
6+
sources -->
7+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9+
<SchemaVersion>2.0</SchemaVersion>
10+
<ProjectGuid>{cf31cff3-1925-457c-8775-e08bcd39e49f}</ProjectGuid>
11+
<SHFBSchemaVersion>1.9.3.0</SHFBSchemaVersion>
1212
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
13-
Studio adds them anyway -->
14-
<AssemblyName>Documentation</AssemblyName>
15-
<RootNamespace>Documentation</RootNamespace>
16-
<Name>Documentation</Name>
17-
<!-- SHFB properties -->
18-
<OutputPath>.\Help\</OutputPath>
19-
<HtmlHelpName>CSharpDriverDocs</HtmlHelpName>
20-
<Language>en-US</Language>
21-
<DocumentationSources>
22-
<DocumentationSource sourceFile="Bson\Bson.csproj" xmlns="" />
23-
<DocumentationSource sourceFile="Driver\Driver.csproj" xmlns="" />
24-
</DocumentationSources>
25-
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
26-
<HelpTitle>MongoDB C# Driver API Documentation</HelpTitle>
27-
<NamespaceSummaries>
28-
<NamespaceSummaryItem name="MongoDB.Bson" isDocumented="True">The MongoDB.Bson top level namespace and its child namespaces contain the classes for managing Bson data. The top level MongoDB.Bson namespace contains the classes that represent all the basic Bson Types.</NamespaceSummaryItem>
29-
<NamespaceSummaryItem name="MongoDB.Bson.IO" isDocumented="True">The MongoDB.Bson.IO namespace contains the types that allow reading and writing of Bson data.</NamespaceSummaryItem>
30-
<NamespaceSummaryItem name="MongoDB.Bson.Serialization" isDocumented="True">The MongoDB.Bson.Serialization namespace contains the types used in the serialization and deserialization of Bson data. It also contains the base interfaces to be implemented by the actual serializers.</NamespaceSummaryItem>
31-
<NamespaceSummaryItem name="(global)" isDocumented="False" />
32-
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Attributes" isDocumented="True">The MongoDB.Bson.Serialization.Attributes namespace contains the Attributes used to control Bson serialization/deserialization.</NamespaceSummaryItem>
33-
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Conventions" isDocumented="True">The various conventions used during serialization/deserialization of Bson data are represented by the types in the MongoDB.Bson.Serialization.Conventions namespace.</NamespaceSummaryItem>
34-
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.IdGenerators" isDocumented="True">The various id generators used in the serialization/deserialization of Bson data are represented in this namespace.</NamespaceSummaryItem>
35-
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Options" isDocumented="True">The MongoDB.Bson.Serialization.Options namespace contains the classes that represent the serialization options for specific types such as DateTime, Document etc.</NamespaceSummaryItem>
36-
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Serializers" isDocumented="True">The MongoDB.Bson.Serialization.Serializers namespace contains the serializers for the various Bson and base .Net types</NamespaceSummaryItem>
37-
<NamespaceSummaryItem name="MongoDB.Driver" isDocumented="True">The MongoDB.Driver namespace contains all the basic types and classes that compose the MongoDB driver. It contains the classes needed for most interactions with the database.</NamespaceSummaryItem>
38-
<NamespaceSummaryItem name="MongoDB.Driver.Builders" isDocumented="True">The MongoDB.Driver.Builders namespace contains helper classes (builders) that can be used to construct various options used in the driver.</NamespaceSummaryItem>
39-
<NamespaceSummaryItem name="MongoDB.Driver.GridFS" isDocumented="True">The classes used to interact with MongoDB GridFS are part of the MongoDB.Driver.GridFS namespace.</NamespaceSummaryItem>
40-
<NamespaceSummaryItem name="MongoDB.Driver.Internal" isDocumented="True">The MongoDB.Driver.Internal namespace contains internal classes used by the driver such as ConnectionPool.</NamespaceSummaryItem>
41-
<NamespaceSummaryItem name="MongoDB.Driver.Wrappers" isDocumented="True">Wrapped versions of various classes for use in serialization are present in the MongoDB.Driver.Wrappers namespace.</NamespaceSummaryItem>
42-
<NamespaceSummaryItem name="MongoDB.Driver.Linq" isDocumented="True">The MongoDB.Driver.Linq namespace contains the LINQ related classes.</NamespaceSummaryItem>
43-
</NamespaceSummaries>
44-
<CopyrightText>Copyright 2010-2012 10gen Inc.</CopyrightText>
45-
<FeedbackEMailAddress>craig.wilson%4010gen.com, robert%4010gen.com sridhar%4010gen.com</FeedbackEMailAddress>
46-
<FeedbackEMailLinkText>CSharp driver API doc</FeedbackEMailLinkText>
47-
<FrameworkVersion>.NET 3.5</FrameworkVersion>
48-
<HelpFileVersion>1.4.1.4490</HelpFileVersion>
49-
</PropertyGroup>
13+
Studio adds them anyway -->
14+
<AssemblyName>Documentation</AssemblyName>
15+
<RootNamespace>Documentation</RootNamespace>
16+
<Name>Documentation</Name>
17+
<!-- SHFB properties -->
18+
<OutputPath>.\Help\</OutputPath>
19+
<HtmlHelpName>CSharpDriverDocs</HtmlHelpName>
20+
<Language>en-US</Language>
21+
<DocumentationSources>
22+
<DocumentationSource sourceFile="Bson\Bson.csproj" xmlns="" />
23+
<DocumentationSource sourceFile="Driver\Driver.csproj" xmlns="" />
24+
</DocumentationSources>
25+
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
26+
<HelpTitle>MongoDB C# Driver API Documentation</HelpTitle>
27+
<NamespaceSummaries>
28+
<NamespaceSummaryItem name="MongoDB.Bson" isDocumented="True">The MongoDB.Bson top level namespace and its child namespaces contain the classes for managing Bson data. The top level MongoDB.Bson namespace contains the classes that represent all the basic Bson Types.</NamespaceSummaryItem>
29+
<NamespaceSummaryItem name="MongoDB.Bson.IO" isDocumented="True">The MongoDB.Bson.IO namespace contains the types that allow reading and writing of Bson data.</NamespaceSummaryItem>
30+
<NamespaceSummaryItem name="MongoDB.Bson.Serialization" isDocumented="True">The MongoDB.Bson.Serialization namespace contains the types used in the serialization and deserialization of Bson data. It also contains the base interfaces to be implemented by the actual serializers.</NamespaceSummaryItem>
31+
<NamespaceSummaryItem name="(global)" isDocumented="False" />
32+
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Attributes" isDocumented="True">The MongoDB.Bson.Serialization.Attributes namespace contains the Attributes used to control Bson serialization/deserialization.</NamespaceSummaryItem>
33+
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Conventions" isDocumented="True">The various conventions used during serialization/deserialization of Bson data are represented by the types in the MongoDB.Bson.Serialization.Conventions namespace.</NamespaceSummaryItem>
34+
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.IdGenerators" isDocumented="True">The various id generators used in the serialization/deserialization of Bson data are represented in this namespace.</NamespaceSummaryItem>
35+
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Options" isDocumented="True">The MongoDB.Bson.Serialization.Options namespace contains the classes that represent the serialization options for specific types such as DateTime, Document etc.</NamespaceSummaryItem>
36+
<NamespaceSummaryItem name="MongoDB.Bson.Serialization.Serializers" isDocumented="True">The MongoDB.Bson.Serialization.Serializers namespace contains the serializers for the various Bson and base .Net types</NamespaceSummaryItem>
37+
<NamespaceSummaryItem name="MongoDB.Driver" isDocumented="True">The MongoDB.Driver namespace contains all the basic types and classes that compose the MongoDB driver. It contains the classes needed for most interactions with the database.</NamespaceSummaryItem>
38+
<NamespaceSummaryItem name="MongoDB.Driver.Builders" isDocumented="True">The MongoDB.Driver.Builders namespace contains helper classes (builders) that can be used to construct various options used in the driver.</NamespaceSummaryItem>
39+
<NamespaceSummaryItem name="MongoDB.Driver.GridFS" isDocumented="True">The classes used to interact with MongoDB GridFS are part of the MongoDB.Driver.GridFS namespace.</NamespaceSummaryItem>
40+
<NamespaceSummaryItem name="MongoDB.Driver.Internal" isDocumented="True">The MongoDB.Driver.Internal namespace contains internal classes used by the driver such as ConnectionPool.</NamespaceSummaryItem>
41+
<NamespaceSummaryItem name="MongoDB.Driver.Wrappers" isDocumented="True">Wrapped versions of various classes for use in serialization are present in the MongoDB.Driver.Wrappers namespace.</NamespaceSummaryItem>
42+
<NamespaceSummaryItem name="MongoDB.Driver.Linq" isDocumented="True">The MongoDB.Driver.Linq namespace contains the LINQ related classes.</NamespaceSummaryItem>
43+
</NamespaceSummaries>
44+
<CopyrightText>Copyright 2010-2012 10gen Inc.</CopyrightText>
45+
<FeedbackEMailAddress>craig.wilson%4010gen.com, robert%4010gen.com sridhar%4010gen.com</FeedbackEMailAddress>
46+
<FeedbackEMailLinkText>CSharp driver API doc</FeedbackEMailLinkText>
47+
<FrameworkVersion>.NET 3.5</FrameworkVersion>
48+
<HelpFileVersion>1.4.1.4490</HelpFileVersion>
49+
</PropertyGroup>
5050
<!-- There are no properties for these groups. AnyCPU needs to appear in
5151
order for Visual Studio to perform the build. The others are optional
52-
common platform types that may appear. -->
53-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
54-
</PropertyGroup>
55-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
56-
</PropertyGroup>
57-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
58-
</PropertyGroup>
59-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
60-
</PropertyGroup>
61-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
62-
</PropertyGroup>
63-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
64-
</PropertyGroup>
65-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
66-
</PropertyGroup>
67-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
68-
</PropertyGroup>
69-
<!-- Import the SHFB build targets -->
70-
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
52+
common platform types that may appear. -->
53+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
54+
</PropertyGroup>
55+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
56+
</PropertyGroup>
57+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
58+
</PropertyGroup>
59+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
60+
</PropertyGroup>
61+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
62+
</PropertyGroup>
63+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
64+
</PropertyGroup>
65+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
66+
</PropertyGroup>
67+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
68+
</PropertyGroup>
69+
<!-- Import the SHFB build targets -->
70+
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
7171
</Project>

0 commit comments

Comments
 (0)