Skip to content

Commit dd085df

Browse files
committed
CSHARP-1413: Moved IndexOptionDefaults from Core to High.
1 parent 75cf839 commit dd085df

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ public void CreateCommand_should_return_expected_result_when_Capped_is_set(
152152
[Test]
153153
public void CreateCommand_should_return_expected_result_when_IndexOptionDefaults_is_set()
154154
{
155-
var value = new IndexOptionDefaults { StorageEngine = new BsonDocument("x", 1) };
155+
var value = new BsonDocument("storageEngine", new BsonDocument("x", 1));
156156
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
157157
{
158158
IndexOptionDefaults = value
159159
};
160160
var expectedResult = new BsonDocument
161161
{
162162
{ "create", _collectionNamespace.CollectionName },
163-
{ "indexOptionDefaults", new BsonDocument("storageEngine", new BsonDocument("x", 1)) }
163+
{ "indexOptionDefaults", value }
164164
};
165165

166166
var result = subject.CreateCommand();
@@ -472,7 +472,7 @@ public void Execute_should_create_collection_when_UsePowerOf2Sizes_is_set(
472472
public void IndexOptionDefaults_should_work()
473473
{
474474
var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);
475-
var value = new IndexOptionDefaults { StorageEngine = new BsonDocument("x", 1) };
475+
var value = new BsonDocument("storageEngine", new BsonDocument("x", 1));
476476
subject.IndexOptionDefaults.Should().BeNull();
477477

478478
subject.IndexOptionDefaults = value;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class CreateCollectionOperation : IWriteOperation<BsonDocument>
3333
private bool? _autoIndexId;
3434
private bool? _capped;
3535
private readonly CollectionNamespace _collectionNamespace;
36-
private IndexOptionDefaults _indexOptionDefaults;
36+
private BsonDocument _indexOptionDefaults;
3737
private long? _maxDocuments;
3838
private long? _maxSize;
3939
private readonly MessageEncoderSettings _messageEncoderSettings;
@@ -99,7 +99,7 @@ public CollectionNamespace CollectionNamespace
9999
/// <value>
100100
/// The index option defaults.
101101
/// </value>
102-
public IndexOptionDefaults IndexOptionDefaults
102+
public BsonDocument IndexOptionDefaults
103103
{
104104
get { return _indexOptionDefaults; }
105105
set { _indexOptionDefaults = value; }
@@ -212,7 +212,7 @@ internal BsonDocument CreateCommand()
212212
{ "max", () => _maxDocuments.Value, _maxDocuments.HasValue },
213213
{ "flags", () => _usePowerOf2Sizes.Value ? 1 : 0, _usePowerOf2Sizes.HasValue},
214214
{ "storageEngine", () => _storageEngine, _storageEngine != null },
215-
{ "indexOptionDefaults", () => _indexOptionDefaults.ToBsonDocument(), _indexOptionDefaults != null },
215+
{ "indexOptionDefaults", _indexOptionDefaults, _indexOptionDefaults != null },
216216
{ "validator", _validator, _validator != null },
217217
{ "validationAction", () => _validationAction.Value.ToString().ToLowerInvariant(), _validationAction.HasValue },
218218
{ "validationLevel", () => _validationLevel.Value.ToString().ToLowerInvariant(), _validationLevel.HasValue }

src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
<Compile Include="Core\Operations\CreateIndexesUsingInsertOperation.cs" />
140140
<Compile Include="Core\Operations\DocumentValidationAction.cs" />
141141
<Compile Include="Core\Operations\DocumentValidationLevel.cs" />
142-
<Compile Include="Core\Operations\IndexOptionDefaults.cs" />
143142
<Compile Include="Core\Operations\ListCollectionsUsingCommandOperation.cs" />
144143
<Compile Include="Core\Operations\ListCollectionsUsingQueryOperation.cs" />
145144
<Compile Include="Core\Operations\ListIndexesUsingCommandOperation.cs" />

src/MongoDB.Driver.Core/Core/Operations/IndexOptionDefaults.cs renamed to src/MongoDB.Driver/IndexOptionDefaults.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
using MongoDB.Bson;
1717

18-
namespace MongoDB.Driver.Core.Operations
18+
namespace MongoDB.Driver
1919
{
2020
/// <summary>
2121
/// Represents index option defaults.
@@ -35,12 +35,12 @@ public BsonDocument StorageEngine
3535
set { _storageEngine = value; }
3636
}
3737

38-
// public methods
38+
// internal methods
3939
/// <summary>
4040
/// Returns this instance represented as a BsonDocument.
4141
/// </summary>
4242
/// <returns>A BsonDocument.</returns>
43-
public BsonDocument ToBsonDocument()
43+
internal BsonDocument ToBsonDocument()
4444
{
4545
return new BsonDocument
4646
{

src/MongoDB.Driver/MongoDB.Driver.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<Compile Include="CreateIndexModel.cs" />
8181
<Compile Include="FilteredMongoCollectionBase.cs" />
8282
<Compile Include="IndexKeysDefinition.cs" />
83+
<Compile Include="IndexOptionDefaults.cs" />
8384
<Compile Include="Linq\AggregateQueryableExecutionModel.cs" />
8485
<Compile Include="Linq\ExecutionPlanBuilder.cs" />
8586
<Compile Include="Linq\ExpressionHelper.cs" />

src/MongoDB.Driver/MongoDatabaseImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private Task CreateCollectionHelperAsync<TDocument>(string name, CreateCollectio
162162
{
163163
AutoIndexId = options.AutoIndexId,
164164
Capped = options.Capped,
165-
IndexOptionDefaults = options.IndexOptionDefaults,
165+
IndexOptionDefaults = options.IndexOptionDefaults?.ToBsonDocument(),
166166
MaxDocuments = options.MaxDocuments,
167167
MaxSize = options.MaxSize,
168168
StorageEngine = options.StorageEngine,

0 commit comments

Comments
 (0)