Skip to content

Commit c9cf95b

Browse files
authored
CSHARP-5245: Make WireProtocol internal (#1437)
1 parent ce1a226 commit c9cf95b

File tree

60 files changed

+139
-1215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+139
-1215
lines changed

src/MongoDB.Driver/Core/WireProtocol/CommandMessageFieldDecryptor.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2019-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,21 +19,18 @@
1919
using MongoDB.Bson;
2020
using MongoDB.Bson.Serialization.Serializers;
2121
using MongoDB.Driver.Core.WireProtocol.Messages;
22-
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
2322

2423
namespace MongoDB.Driver.Core.WireProtocol
2524
{
26-
internal class CommandMessageFieldDecryptor
25+
internal sealed class CommandMessageFieldDecryptor
2726
{
2827
// private fields
2928
private readonly IBinaryDocumentFieldDecryptor _documentFieldDecryptor;
30-
private readonly MessageEncoderSettings _messageEncoderSettings;
3129

3230
// constructors
33-
public CommandMessageFieldDecryptor(IBinaryDocumentFieldDecryptor documentFieldDecryptor, MessageEncoderSettings messageEncoderSettings)
31+
public CommandMessageFieldDecryptor(IBinaryDocumentFieldDecryptor documentFieldDecryptor)
3432
{
3533
_documentFieldDecryptor = documentFieldDecryptor;
36-
_messageEncoderSettings = messageEncoderSettings;
3734
}
3835

3936
// public methods

src/MongoDB.Driver/Core/WireProtocol/CommandMessageFieldEncryptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2019-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.
@@ -26,7 +26,7 @@
2626

2727
namespace MongoDB.Driver.Core.WireProtocol
2828
{
29-
internal class CommandMessageFieldEncryptor
29+
internal sealed class CommandMessageFieldEncryptor
3030
{
3131
// private fields
3232
private readonly byte[] _buffer = new byte[1024];

src/MongoDB.Driver/Core/WireProtocol/CommandResponseHandling.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-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.
@@ -13,19 +13,9 @@
1313
* limitations under the License.
1414
*/
1515

16-
using System;
17-
using System.Collections.Generic;
18-
using System.Linq;
19-
using System.Text;
20-
using System.Threading.Tasks;
21-
using MongoDB.Driver.Core.Misc;
22-
2316
namespace MongoDB.Driver.Core.WireProtocol
2417
{
25-
/// <summary>
26-
/// Instructions for handling the response from a command.
27-
/// </summary>
28-
public enum CommandResponseHandling
18+
internal enum CommandResponseHandling
2919
{
3020
/// <summary>
3121
/// Return the response from the server.

src/MongoDB.Driver/Core/WireProtocol/CommandUsingCommandMessageWireProtocol.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2018-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.
@@ -33,7 +33,7 @@
3333

3434
namespace MongoDB.Driver.Core.WireProtocol
3535
{
36-
internal class CommandUsingCommandMessageWireProtocol<TCommandResult> : IWireProtocol<TCommandResult>
36+
internal sealed class CommandUsingCommandMessageWireProtocol<TCommandResult> : IWireProtocol<TCommandResult>
3737
{
3838
// private fields
3939
private readonly BsonDocument _additionalOptions; // TODO: can these be supported when using CommandMessage?
@@ -199,7 +199,7 @@ private CommandResponseMessage AutoDecryptFieldsIfNecessary(CommandResponseMessa
199199
}
200200
else
201201
{
202-
var messageFieldDecryptor = new CommandMessageFieldDecryptor(_documentFieldDecryptor, _messageEncoderSettings);
202+
var messageFieldDecryptor = new CommandMessageFieldDecryptor(_documentFieldDecryptor);
203203
return messageFieldDecryptor.DecryptFields(encryptedResponseMessage, cancellationToken);
204204
}
205205
}
@@ -212,7 +212,7 @@ private async Task<CommandResponseMessage> AutoDecryptFieldsIfNecessaryAsync(Com
212212
}
213213
else
214214
{
215-
var messageFieldDecryptor = new CommandMessageFieldDecryptor(_documentFieldDecryptor, _messageEncoderSettings);
215+
var messageFieldDecryptor = new CommandMessageFieldDecryptor(_documentFieldDecryptor);
216216
return await messageFieldDecryptor.DecryptFieldsAsync(encryptedResponseMessage, cancellationToken).ConfigureAwait(false);
217217
}
218218
}

src/MongoDB.Driver/Core/WireProtocol/CommandUsingQueryMessageWireProtocol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-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.
@@ -35,7 +35,7 @@
3535

3636
namespace MongoDB.Driver.Core.WireProtocol
3737
{
38-
internal class CommandUsingQueryMessageWireProtocol<TCommandResult> : IWireProtocol<TCommandResult>
38+
internal sealed class CommandUsingQueryMessageWireProtocol<TCommandResult> : IWireProtocol<TCommandResult>
3939
{
4040
// fields
4141
private readonly BsonDocument _additionalOptions;

src/MongoDB.Driver/Core/WireProtocol/CommandWireProtocol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-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.
@@ -29,7 +29,7 @@
2929

3030
namespace MongoDB.Driver.Core.WireProtocol
3131
{
32-
internal class CommandWireProtocol<TCommandResult> : IWireProtocol<TCommandResult>
32+
internal sealed class CommandWireProtocol<TCommandResult> : IWireProtocol<TCommandResult>
3333
{
3434
// private fields
3535
private readonly BsonDocument _additionalOptions;

src/MongoDB.Driver/Core/WireProtocol/CursorBatch.cs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-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,24 +19,14 @@
1919

2020
namespace MongoDB.Driver.Core.WireProtocol
2121
{
22-
/// <summary>
23-
/// Represents one result batch (returned from either a Query or a GetMore message)
24-
/// </summary>
25-
/// <typeparam name="TDocument">The type of the document.</typeparam>
26-
public struct CursorBatch<TDocument>
22+
internal readonly struct CursorBatch<TDocument>
2723
{
2824
// fields
2925
private readonly long _cursorId;
3026
private readonly IReadOnlyList<TDocument> _documents;
3127
private readonly BsonDocument _postBatchResumeToken;
3228

3329
// constructors
34-
/// <summary>
35-
/// Initializes a new instance of the <see cref="CursorBatch{TDocument}"/> struct.
36-
/// </summary>
37-
/// <param name="cursorId">The cursor identifier.</param>
38-
/// <param name="postBatchResumeToken">The post batch resume token.</param>
39-
/// <param name="documents">The documents.</param>
4030
public CursorBatch(
4131
long cursorId,
4232
BsonDocument postBatchResumeToken,
@@ -47,45 +37,22 @@ public CursorBatch(
4737
_documents = Ensure.IsNotNull(documents, nameof(documents));
4838
}
4939

50-
/// <summary>
51-
/// Initializes a new instance of the <see cref="CursorBatch{TDocument}"/> struct.
52-
/// </summary>
53-
/// <param name="cursorId">The cursor identifier.</param>
54-
/// <param name="documents">The documents.</param>
5540
public CursorBatch(long cursorId, IReadOnlyList<TDocument> documents)
5641
: this(cursorId, null, documents)
5742
{
5843
}
5944

6045
// properties
61-
/// <summary>
62-
/// Gets the cursor identifier.
63-
/// </summary>
64-
/// <value>
65-
/// The cursor identifier.
66-
/// </value>
6746
public long CursorId
6847
{
6948
get { return _cursorId; }
7049
}
7150

72-
/// <summary>
73-
/// Gets the documents.
74-
/// </summary>
75-
/// <value>
76-
/// The documents.
77-
/// </value>
7851
public IReadOnlyList<TDocument> Documents
7952
{
8053
get { return _documents; }
8154
}
8255

83-
/// <summary>
84-
/// Gets the post batch resume token.
85-
/// </summary>
86-
/// <value>
87-
/// The post batch resume token.
88-
/// </value>
8956
public BsonDocument PostBatchResumeToken
9057
{
9158
get { return _postBatchResumeToken; }

src/MongoDB.Driver/Core/WireProtocol/IWireProtocol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-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/Core/WireProtocol/Messages/CommandMessage.cs

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2018-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.
@@ -22,11 +22,7 @@
2222

2323
namespace MongoDB.Driver.Core.WireProtocol.Messages
2424
{
25-
/// <summary>
26-
/// Represents a command message.
27-
/// </summary>
28-
/// <seealso cref="MongoDB.Driver.Core.WireProtocol.Messages.MongoDBMessage" />
29-
public sealed class CommandMessage : MongoDBMessage
25+
internal sealed class CommandMessage : MongoDBMessage
3026
{
3127
// static
3228
private static readonly HashSet<string> __messagesNotToBeCompressed = new HashSet<string>
@@ -52,13 +48,6 @@ public sealed class CommandMessage : MongoDBMessage
5248
private readonly List<CommandMessageSection> _sections;
5349

5450
// constructors
55-
/// <summary>
56-
/// Initializes a new instance of the <see cref="CommandMessage" /> class.
57-
/// </summary>
58-
/// <param name="requestId">The request identifier.</param>
59-
/// <param name="responseTo">The response to.</param>
60-
/// <param name="sections">The sections.</param>
61-
/// <param name="moreToCome">if set to <c>true</c> [more to come].</param>
6251
public CommandMessage(
6352
int requestId,
6453
int responseTo,
@@ -77,19 +66,12 @@ public CommandMessage(
7766
}
7867

7968
// public properties
80-
/// <summary>
81-
/// Gets or sets a value indicating whether multiple responses might be returned from the server or not.
82-
/// </summary>
83-
/// <value>
84-
/// <c>true</c> if the server might return multiple responses; otherwise, <c>false</c>.
85-
/// </value>
8669
public bool ExhaustAllowed
8770
{
8871
get { return _exhaustAllowed; }
8972
set { _exhaustAllowed = value; }
9073
}
9174

92-
/// <inheritdoc />
9375
public override bool MayBeCompressed
9476
{
9577
get
@@ -107,67 +89,26 @@ public override bool MayBeCompressed
10789
}
10890
}
10991

110-
/// <inheritdoc />
11192
public override MongoDBMessageType MessageType => MongoDBMessageType.Command;
11293

113-
/// <summary>
114-
/// Gets or sets a value indicating whether another message immediately follows this one with no response expected.
115-
/// </summary>
116-
/// <value>
117-
/// <c>true</c> if another message immediately follows this one; otherwise, <c>false</c>.
118-
/// </value>
11994
public bool MoreToCome
12095
{
12196
get { return _moreToCome; }
12297
set { _moreToCome = value; }
12398
}
12499

125-
/// <summary>
126-
/// Gets or sets the delegate called to after the message has been written by the encoder.
127-
/// </summary>
128-
/// <value>
129-
/// The post write delegate.
130-
/// </value>
131100
public Action<IMessageEncoderPostProcessor> PostWriteAction
132101
{
133102
get { return _postWriteAction; }
134103
set { _postWriteAction = value; }
135104
}
136105

137-
/// <summary>
138-
/// Gets the request identifier.
139-
/// </summary>
140-
/// <value>
141-
/// The request identifier.
142-
/// </value>
143106
public int RequestId => _requestId;
144-
145-
/// <summary>
146-
/// Gets a value indicating whether a response is expected.
147-
/// </summary>
148-
/// <value>
149-
/// <c>true</c> if a response is expected; otherwise, <c>false</c>.
150-
/// </value>
151107
public bool ResponseExpected => !_moreToCome;
152-
153-
/// <summary>
154-
/// Gets the response to.
155-
/// </summary>
156-
/// <value>
157-
/// The response to.
158-
/// </value>
159108
public int ResponseTo => _responseTo;
160-
161-
/// <summary>
162-
/// Gets the sections.
163-
/// </summary>
164-
/// <value>
165-
/// The sections.
166-
/// </value>
167109
public IReadOnlyList<CommandMessageSection> Sections => _sections;
168110

169111
// public methods
170-
/// <inheritdoc />
171112
public override IMessageEncoder GetEncoder(IMessageEncoderFactory encoderFactory)
172113
{
173114
return encoderFactory.GetCommandMessageEncoder();

src/MongoDB.Driver/Core/WireProtocol/Messages/CommandMessageDisposer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2018-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.

0 commit comments

Comments
 (0)