Skip to content

Commit cebe0b6

Browse files
committed
- PR comments
1 parent 740fe75 commit cebe0b6

34 files changed

+355
-277
lines changed

src/MongoDB.Driver.Core/Core/Misc/Ensure.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ namespace MongoDB.Driver.Core.Misc
2727
[DebuggerStepThrough]
2828
public static class Ensure
2929
{
30+
/// <summary>
31+
/// Ensures that the value of a parameter is not null.
32+
/// </summary>
33+
/// <typeparam name="T">Type type of the value.</typeparam>
34+
/// <param name="value">The value of the parameter.</param>
35+
/// <param name="paramName">The name of the parameter.</param>
36+
/// <returns>The value of the parameter.</returns>
37+
public static Nullable<T> HasValue<T>(Nullable<T> value, string paramName) where T : struct
38+
{
39+
if (!value.HasValue)
40+
{
41+
throw new ArgumentException("The Nullable parameter must have a value.", paramName);
42+
}
43+
return value;
44+
}
45+
3046
/// <summary>
3147
/// Ensures that the value of a parameter is between a minimum and a maximum value.
3248
/// </summary>
@@ -65,36 +81,36 @@ public static T IsEqualTo<T>(T value, T comparand, string paramName)
6581
}
6682

6783
/// <summary>
68-
/// Ensures that the value of a parameter is greater than or equal to a comparand.
84+
/// Ensures that the value of a parameter is greater than a comparand.
6985
/// </summary>
7086
/// <typeparam name="T">Type type of the value.</typeparam>
7187
/// <param name="value">The value of the parameter.</param>
7288
/// <param name="comparand">The comparand.</param>
7389
/// <param name="paramName">The name of the parameter.</param>
7490
/// <returns>The value of the parameter.</returns>
75-
public static T IsGreaterThanOrEqualTo<T>(T value, T comparand, string paramName) where T : IComparable<T>
91+
public static T IsGreaterThan<T>(T value, T comparand, string paramName) where T : IComparable<T>
7692
{
77-
if (value.CompareTo(comparand) < 0)
93+
if (value.CompareTo(comparand) <= 0)
7894
{
79-
var message = string.Format("Value is not greater than or equal to {1}: {0}.", value, comparand);
95+
var message = $"Value is not greater than {comparand}: {value}.";
8096
throw new ArgumentOutOfRangeException(paramName, message);
8197
}
8298
return value;
8399
}
84100

85101
/// <summary>
86-
/// Ensures that the value of a parameter is greater than a comparand.
102+
/// Ensures that the value of a parameter is greater than or equal to a comparand.
87103
/// </summary>
88104
/// <typeparam name="T">Type type of the value.</typeparam>
89105
/// <param name="value">The value of the parameter.</param>
90106
/// <param name="comparand">The comparand.</param>
91107
/// <param name="paramName">The name of the parameter.</param>
92108
/// <returns>The value of the parameter.</returns>
93-
public static T IsGreaterThan<T>(T value, T comparand, string paramName) where T : IComparable<T>
109+
public static T IsGreaterThanOrEqualTo<T>(T value, T comparand, string paramName) where T : IComparable<T>
94110
{
95-
if (value.CompareTo(comparand) <= 0)
111+
if (value.CompareTo(comparand) < 0)
96112
{
97-
var message = $"Value is not greater than {comparand}: {value}.";
113+
var message = string.Format("Value is not greater than or equal to {1}: {0}.", value, comparand);
98114
throw new ArgumentOutOfRangeException(paramName, message);
99115
}
100116
return value;
@@ -232,22 +248,6 @@ public static IEnumerable<T> IsNotNullAndDoesNotContainAnyNulls<T>(IEnumerable<T
232248
return values;
233249
}
234250

235-
/// <summary>
236-
/// Ensures that the value of a parameter is not null.
237-
/// </summary>
238-
/// <typeparam name="T">Type type of the value.</typeparam>
239-
/// <param name="value">The value of the parameter.</param>
240-
/// <param name="paramName">The name of the parameter.</param>
241-
/// <returns>The value of the parameter.</returns>
242-
public static Nullable<T> HasValue<T>(Nullable<T> value, string paramName) where T : struct
243-
{
244-
if (!value.HasValue)
245-
{
246-
throw new ArgumentException("The Nullable parameter must have a value.", paramName);
247-
}
248-
return value;
249-
}
250-
251251
/// <summary>
252252
/// Ensures that the value of a parameter is not null or empty.
253253
/// </summary>

src/MongoDB.Driver/AggregateFluentBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public virtual IAggregateFluent<TNewResult> ReplaceWith<TNewResult>(AggregateExp
218218

219219
/// <inheritdoc />
220220
public virtual IAggregateFluent<TResult> Search(
221-
SearchDefinition<TResult> query,
221+
SearchDefinition<TResult> searchDefinition,
222222
SearchHighlightOptions<TResult> highlight = null,
223223
string indexName = null,
224224
SearchCountOptions count = null,

src/MongoDB.Driver/Search/CompoundSearchDefinitionFluent.cs renamed to src/MongoDB.Driver/Search/CompoundSearchDefinitionBuilder.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2016-present MongoDB Inc.
1+
/* Copyright 2010-present MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@
1919
namespace MongoDB.Driver.Search
2020
{
2121
/// <summary>
22-
/// Fluent interface for compound search definitions.
22+
/// A builder for compound search definitions.
2323
/// </summary>
2424
/// <typeparam name="TDocument">The type of the document.</typeparam>
25-
public sealed class CompoundSearchDefinitionFluent<TDocument>
25+
public sealed class CompoundSearchDefinitionBuilder<TDocument>
2626
{
2727
private List<SearchDefinition<TDocument>> _must;
2828
private List<SearchDefinition<TDocument>> _mustNot;
@@ -34,101 +34,101 @@ public sealed class CompoundSearchDefinitionFluent<TDocument>
3434
/// Adds clauses which must match to produce results.
3535
/// </summary>
3636
/// <param name="clauses">The clauses.</param>
37-
/// <returns>The compound fluent interface.</returns>
38-
public CompoundSearchDefinitionFluent<TDocument> Must(IEnumerable<SearchDefinition<TDocument>> clauses) =>
37+
/// <returns>The compound search definition builder.</returns>
38+
public CompoundSearchDefinitionBuilder<TDocument> Must(IEnumerable<SearchDefinition<TDocument>> clauses) =>
3939
AddClauses(ref _must, clauses);
4040

4141
/// <summary>
4242
/// Adds clauses which must match to produce results.
4343
/// </summary>
4444
/// <param name="clauses">The clauses.</param>
45-
/// <returns>The compound fluent interface.</returns>
46-
public CompoundSearchDefinitionFluent<TDocument> Must(params SearchDefinition<TDocument>[] clauses) =>
45+
/// <returns>The compound search definition builder.</returns>
46+
public CompoundSearchDefinitionBuilder<TDocument> Must(params SearchDefinition<TDocument>[] clauses) =>
4747
Must((IEnumerable<SearchDefinition<TDocument>>)clauses);
4848

4949
/// <summary>
5050
/// Adds clauses which must not match for a document to be included in the
5151
/// results.
5252
/// </summary>
5353
/// <param name="clauses">The clauses.</param>
54-
/// <returns>The compound fluent interface.</returns>
55-
public CompoundSearchDefinitionFluent<TDocument> MustNot(IEnumerable<SearchDefinition<TDocument>> clauses) =>
54+
/// <returns>The compound search definition builder.</returns>
55+
public CompoundSearchDefinitionBuilder<TDocument> MustNot(IEnumerable<SearchDefinition<TDocument>> clauses) =>
5656
AddClauses(ref _mustNot, clauses);
5757

5858
/// <summary>
5959
/// Adds clauses which must not match for a document to be included in the
6060
/// results.
6161
/// </summary>
6262
/// <param name="clauses">The clauses.</param>
63-
/// <returns>The compound fluent interface.</returns>
64-
public CompoundSearchDefinitionFluent<TDocument> MustNot(params SearchDefinition<TDocument>[] clauses) =>
63+
/// <returns>The compound search definition builder.</returns>
64+
public CompoundSearchDefinitionBuilder<TDocument> MustNot(params SearchDefinition<TDocument>[] clauses) =>
6565
MustNot((IEnumerable<SearchDefinition<TDocument>>)clauses);
6666

6767
/// <summary>
6868
/// Adds clauses which cause documents in the result set to be scored higher if
6969
/// they match.
7070
/// </summary>
7171
/// <param name="clauses">The clauses.</param>
72-
/// <returns>The compound fluent interface.</returns>
73-
public CompoundSearchDefinitionFluent<TDocument> Should(IEnumerable<SearchDefinition<TDocument>> clauses) =>
72+
/// <returns>The compound search definition builder.</returns>
73+
public CompoundSearchDefinitionBuilder<TDocument> Should(IEnumerable<SearchDefinition<TDocument>> clauses) =>
7474
AddClauses(ref _should, clauses);
7575

7676
/// <summary>
7777
/// Adds clauses which cause documents in the result set to be scored higher if
7878
/// they match.
7979
/// </summary>
8080
/// <param name="clauses">The clauses.</param>
81-
/// <returns>The compound fluent interface.</returns>
82-
public CompoundSearchDefinitionFluent<TDocument> Should(params SearchDefinition<TDocument>[] clauses) =>
81+
/// <returns>The compound search definition builder.</returns>
82+
public CompoundSearchDefinitionBuilder<TDocument> Should(params SearchDefinition<TDocument>[] clauses) =>
8383
Should((IEnumerable<SearchDefinition<TDocument>>)clauses);
8484

8585
/// <summary>
8686
/// Adds clauses which must all match for a document to be included in the
8787
/// results.
8888
/// </summary>
8989
/// <param name="clauses">The clauses.</param>
90-
/// <returns>The compound fluent interface.</returns>
91-
public CompoundSearchDefinitionFluent<TDocument> Filter(IEnumerable<SearchDefinition<TDocument>> clauses) =>
90+
/// <returns>The compound search definition builder.</returns>
91+
public CompoundSearchDefinitionBuilder<TDocument> Filter(IEnumerable<SearchDefinition<TDocument>> clauses) =>
9292
AddClauses(ref _filter, clauses);
9393

9494
/// <summary>
9595
/// Adds clauses which must all match for a document to be included in the
9696
/// results.
9797
/// </summary>
9898
/// <param name="clauses">The clauses.</param>
99-
/// <returns>The compound fluent interface.</returns>
100-
public CompoundSearchDefinitionFluent<TDocument> Filter(params SearchDefinition<TDocument>[] clauses) =>
99+
/// <returns>The compound search definition builder.</returns>
100+
public CompoundSearchDefinitionBuilder<TDocument> Filter(params SearchDefinition<TDocument>[] clauses) =>
101101
Filter((IEnumerable<SearchDefinition<TDocument>>)clauses);
102102

103103
/// <summary>
104104
/// Sets a value specifying the minimum number of should clauses the must match
105105
/// to include a document in the results.
106106
/// </summary>
107107
/// <param name="minimumShouldMatch">The value to set.</param>
108-
/// <returns>The compound fluent interface.</returns>
109-
public CompoundSearchDefinitionFluent<TDocument> MinimumShouldMatch(int minimumShouldMatch)
108+
/// <returns>The compound search definition builder.</returns>
109+
public CompoundSearchDefinitionBuilder<TDocument> MinimumShouldMatch(int minimumShouldMatch)
110110
{
111111
_minimumShouldMatch = minimumShouldMatch;
112112
return this;
113113
}
114114

115115
/// <summary>
116-
/// Constructs a search definition from the fluent interface.
116+
/// Constructs a search definition from the builder.
117117
/// </summary>
118118
/// <returns>A compound search definition.</returns>
119119
public SearchDefinition<TDocument> ToSearchDefinition() =>
120120
new CompoundSearchDefinition<TDocument>(_must, _mustNot, _should, _filter, _minimumShouldMatch);
121121

122122
/// <summary>
123-
/// Performs an implicit conversion from a <see cref="CompoundSearchDefinitionFluent{TDocument}"/>
123+
/// Performs an implicit conversion from a <see cref="CompoundSearchDefinitionBuilder{TDocument}"/>
124124
/// to a <see cref="SearchDefinition{TDocument}"/>.
125125
/// </summary>
126-
/// <param name="compound">The compound fluent interface.</param>
126+
/// <param name="builder">The compound search definition builder.</param>
127127
/// <returns>The result of the conversion.</returns>
128-
public static implicit operator SearchDefinition<TDocument>(CompoundSearchDefinitionFluent<TDocument> compound) =>
129-
compound.ToSearchDefinition();
128+
public static implicit operator SearchDefinition<TDocument>(CompoundSearchDefinitionBuilder<TDocument> builder) =>
129+
builder.ToSearchDefinition();
130130

131-
private CompoundSearchDefinitionFluent<TDocument> AddClauses(ref List<SearchDefinition<TDocument>> clauses, IEnumerable<SearchDefinition<TDocument>> newClauses)
131+
private CompoundSearchDefinitionBuilder<TDocument> AddClauses(ref List<SearchDefinition<TDocument>> clauses, IEnumerable<SearchDefinition<TDocument>> newClauses)
132132
{
133133
Ensure.IsNotNull(newClauses, nameof(newClauses));
134134
(clauses ??= new()).AddRange(newClauses);

src/MongoDB.Driver/Search/GeoShapeRelation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2016-present MongoDB Inc.
1+
/* Copyright 2010-present MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.

src/MongoDB.Driver/Search/GeoWithin.cs renamed to src/MongoDB.Driver/Search/GeoWithinArea.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2016-present MongoDB Inc.
1+
/* Copyright 2010-present MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
2020
namespace MongoDB.Driver.Search
2121
{
2222
/// <summary>
23-
/// Base class for objects specifying GeoWithin query
24-
/// search within.
23+
/// Base class for area argument for GeoWithin queries.
2524
/// </summary>
2625
/// <typeparam name="TCoordinates">The type of the coordinates.</typeparam>
2726
public abstract class GeoWithinArea<TCoordinates> where TCoordinates : GeoJsonCoordinates

0 commit comments

Comments
 (0)