Skip to content

Commit abe8da1

Browse files
authored
CSHARP-3660: Remove oppressive language from the source code. (mongodb#586)
1 parent 44a8a50 commit abe8da1

File tree

74 files changed

+926
-870
lines changed

Some content is hidden

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

74 files changed

+926
-870
lines changed

src/MongoDB.Driver.Core/Core/Authentication/AuthenticationHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void Authenticate(IConnection connection, ConnectionDescription de
3636
Ensure.IsNotNull(authenticators, nameof(authenticators));
3737

3838
// authentication is currently broken on arbiters
39-
if (!description.IsMasterResult.IsArbiter)
39+
if (!description.HelloResult.IsArbiter)
4040
{
4141
foreach (var authenticator in authenticators)
4242
{
@@ -52,7 +52,7 @@ public static async Task AuthenticateAsync(IConnection connection, ConnectionDes
5252
Ensure.IsNotNull(authenticators, nameof(authenticators));
5353

5454
// authentication is currently broken on arbiters
55-
if (!description.IsMasterResult.IsArbiter)
55+
if (!description.HelloResult.IsArbiter)
5656
{
5757
foreach (var authenticator in authenticators)
5858
{

src/MongoDB.Driver.Core/Core/Authentication/DefaultAuthenticator.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public void Authenticate(IConnection connection, ConnectionDescription descripti
8484
// If we don't have SaslSupportedMechs as part of the response, that means we didn't piggyback the initial
8585
// hello or legacy hello request and should query the server (provided that the server >= 4.0), merging results into
8686
// a new ConnectionDescription
87-
if (!description.IsMasterResult.HasSaslSupportedMechs
87+
if (!description.HelloResult.HasSaslSupportedMechs
8888
&& Feature.ScramSha256Authentication.IsSupported(description.ServerVersion))
8989
{
90-
var command = CustomizeInitialIsMasterCommand(HelloHelper.CreateCommand(_serverApi));
90+
var command = CustomizeInitialHelloCommand(HelloHelper.CreateCommand(_serverApi));
9191
var helloProtocol = HelloHelper.CreateProtocol(command, _serverApi);
9292
var helloResult = HelloHelper.GetResult(connection, helloProtocol, cancellationToken);
93-
var mergedHelloResult = new IsMasterResult(description.IsMasterResult.Wrapped.Merge(helloResult.Wrapped));
93+
var mergedHelloResult = new HelloResult(description.HelloResult.Wrapped.Merge(helloResult.Wrapped));
9494
description = new ConnectionDescription(
9595
description.ConnectionId,
9696
mergedHelloResult,
@@ -110,13 +110,13 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
110110
// If we don't have SaslSupportedMechs as part of the response, that means we didn't piggyback the initial
111111
// hello or legacy hello request and should query the server (provided that the server >= 4.0), merging results into
112112
// a new ConnectionDescription
113-
if (!description.IsMasterResult.HasSaslSupportedMechs
113+
if (!description.HelloResult.HasSaslSupportedMechs
114114
&& Feature.ScramSha256Authentication.IsSupported(description.ServerVersion))
115115
{
116-
var command = CustomizeInitialIsMasterCommand(HelloHelper.CreateCommand(_serverApi));
116+
var command = CustomizeInitialHelloCommand(HelloHelper.CreateCommand(_serverApi));
117117
var helloProtocol = HelloHelper.CreateProtocol(command, _serverApi);
118118
var helloResult = await HelloHelper.GetResultAsync(connection, helloProtocol, cancellationToken).ConfigureAwait(false);
119-
var mergedHelloResult = new IsMasterResult(description.IsMasterResult.Wrapped.Merge(helloResult.Wrapped));
119+
var mergedHelloResult = new HelloResult(description.HelloResult.Wrapped.Merge(helloResult.Wrapped));
120120
description = new ConnectionDescription(
121121
description.ConnectionId,
122122
mergedHelloResult,
@@ -128,12 +128,12 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
128128
}
129129

130130
/// <inheritdoc/>
131-
public BsonDocument CustomizeInitialIsMasterCommand(BsonDocument isMasterCommand)
131+
public BsonDocument CustomizeInitialHelloCommand(BsonDocument helloCommand)
132132
{
133133
var saslSupportedMechs = CreateSaslSupportedMechsRequest(_credential.Source, _credential.Username);
134-
isMasterCommand = isMasterCommand.Merge(saslSupportedMechs);
134+
helloCommand = helloCommand.Merge(saslSupportedMechs);
135135
_speculativeAuthenticator = new ScramSha256Authenticator(_credential, _randomStringGenerator, _serverApi);
136-
return _speculativeAuthenticator.CustomizeInitialIsMasterCommand(isMasterCommand);
136+
return _speculativeAuthenticator.CustomizeInitialHelloCommand(helloCommand);
137137
}
138138

139139
private static BsonDocument CreateSaslSupportedMechsRequest(string authenticationDatabaseName, string userName)
@@ -146,11 +146,11 @@ private IAuthenticator CreateAuthenticator(IConnection connection, ConnectionDes
146146
{
147147
// If a saslSupportedMechs field was present in the hello or legacy hello results for mechanism negotiation,
148148
// then it MUST be inspected to select a default mechanism.
149-
if (description.IsMasterResult.HasSaslSupportedMechs)
149+
if (description.HelloResult.HasSaslSupportedMechs)
150150
{
151151
// If SCRAM-SHA-256 is present in the list of mechanisms, then it MUST be used as the default;
152152
// otherwise, SCRAM-SHA-1 MUST be used as the default, regardless of whether SCRAM-SHA-1 is in the list.
153-
return description.IsMasterResult.SaslSupportedMechs.Contains("SCRAM-SHA-256")
153+
return description.HelloResult.SaslSupportedMechs.Contains("SCRAM-SHA-256")
154154
? (IAuthenticator)new ScramSha256Authenticator(_credential, _randomStringGenerator, _serverApi)
155155
: new ScramSha1Authenticator(_credential, _randomStringGenerator, _serverApi);
156156
}
@@ -167,7 +167,7 @@ private IAuthenticator GetOrCreateAuthenticator(IConnection connection, Connecti
167167
{
168168
/* It is possible to have Hello["SpeculativeAuthenticate"] != null and for
169169
* _speculativeScramSha256Authenticator to be null in the case of multiple authenticators */
170-
var speculativeAuthenticateResult = description.IsMasterResult.SpeculativeAuthenticate;
170+
var speculativeAuthenticateResult = description.HelloResult.SpeculativeAuthenticate;
171171
var canUseSpeculativeAuthenticator = _speculativeAuthenticator != null && speculativeAuthenticateResult != null;
172172
return canUseSpeculativeAuthenticator ? _speculativeAuthenticator : CreateAuthenticator(connection, description);
173173
}

src/MongoDB.Driver.Core/Core/Authentication/IAuthenticator.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* limitations under the License.
1414
*/
1515

16-
using System;
1716
using System.Threading;
1817
using System.Threading.Tasks;
1918
using MongoDB.Bson;
@@ -52,10 +51,10 @@ public interface IAuthenticator
5251
Task AuthenticateAsync(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken);
5352

5453
/// <summary>
55-
/// Optionally customizes isMaster command.
54+
/// Optionally customizes hello or legacy hello command.
5655
/// </summary>
57-
/// <param name="isMasterCommand">Initial isMaster command.</param>
58-
/// <returns>Optionally mutated isMaster command.</returns>
59-
BsonDocument CustomizeInitialIsMasterCommand(BsonDocument isMasterCommand);
56+
/// <param name="helloCommand">Initial command.</param>
57+
/// <returns>Optionally mutated command.</returns>
58+
BsonDocument CustomizeInitialHelloCommand(BsonDocument helloCommand);
6059
}
6160
}

src/MongoDB.Driver.Core/Core/Authentication/MongoDBCRAuthenticator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
118118
}
119119

120120
/// <inheritdoc/>
121-
public BsonDocument CustomizeInitialIsMasterCommand(BsonDocument isMasterCommand)
121+
public BsonDocument CustomizeInitialHelloCommand(BsonDocument helloCommand)
122122
{
123-
return isMasterCommand;
123+
return helloCommand;
124124
}
125125

126126
// private methods

src/MongoDB.Driver.Core/Core/Authentication/MongoDBX509Authenticator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void Authenticate(IConnection connection, ConnectionDescription descripti
8282
Ensure.IsNotNull(description, nameof(description));
8383
EnsureUsernameIsNotNullOrNullIsSupported(connection, description);
8484

85-
if (description.IsMasterResult.SpeculativeAuthenticate != null)
85+
if (description.HelloResult.SpeculativeAuthenticate != null)
8686
{
8787
return;
8888
}
@@ -105,7 +105,7 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
105105
Ensure.IsNotNull(description, nameof(description));
106106
EnsureUsernameIsNotNullOrNullIsSupported(connection, description);
107107

108-
if (description.IsMasterResult.SpeculativeAuthenticate != null)
108+
if (description.HelloResult.SpeculativeAuthenticate != null)
109109
{
110110
return;
111111
}
@@ -122,10 +122,10 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
122122
}
123123

124124
/// <inheritdoc/>
125-
public BsonDocument CustomizeInitialIsMasterCommand(BsonDocument isMasterCommand)
125+
public BsonDocument CustomizeInitialHelloCommand(BsonDocument helloCommand)
126126
{
127-
isMasterCommand.Add("speculativeAuthenticate", CreateAuthenticateCommand());
128-
return isMasterCommand;
127+
helloCommand.Add("speculativeAuthenticate", CreateAuthenticateCommand());
128+
return helloCommand;
129129
}
130130

131131
// private methods

src/MongoDB.Driver.Core/Core/Authentication/SaslAuthenticator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void Authenticate(IConnection connection, ConnectionDescription descripti
8484
{
8585
ISaslStep currentStep;
8686
BsonDocument command;
87-
var speculativeAuthenticateResult = description.IsMasterResult.SpeculativeAuthenticate;
87+
var speculativeAuthenticateResult = description.HelloResult.SpeculativeAuthenticate;
8888
if (_speculativeFirstStep != null && speculativeAuthenticateResult != null)
8989
{
9090
currentStep = Transition(conversation, _speculativeFirstStep, speculativeAuthenticateResult, out command);
@@ -123,7 +123,7 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
123123
{
124124
ISaslStep currentStep;
125125
BsonDocument command;
126-
var speculativeAuthenticateResult = description.IsMasterResult.SpeculativeAuthenticate;
126+
var speculativeAuthenticateResult = description.HelloResult.SpeculativeAuthenticate;
127127
if (_speculativeFirstStep != null && speculativeAuthenticateResult != null)
128128
{
129129
currentStep = Transition(conversation, _speculativeFirstStep, speculativeAuthenticateResult, out command);
@@ -153,9 +153,9 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
153153
}
154154

155155
/// <inheritdoc/>
156-
public virtual BsonDocument CustomizeInitialIsMasterCommand(BsonDocument isMasterCommand)
156+
public virtual BsonDocument CustomizeInitialHelloCommand(BsonDocument helloCommand)
157157
{
158-
return isMasterCommand;
158+
return helloCommand;
159159
}
160160

161161
private protected virtual BsonDocument CreateStartCommand(ISaslStep currentStep)

src/MongoDB.Driver.Core/Core/Authentication/ScramShaAuthenticator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ internal ScramShaAuthenticator(
129129
public override string DatabaseName => _databaseName;
130130

131131
/// <inheritdoc/>
132-
public override BsonDocument CustomizeInitialIsMasterCommand(BsonDocument isMasterCommand)
132+
public override BsonDocument CustomizeInitialHelloCommand(BsonDocument helloCommand)
133133
{
134-
isMasterCommand = base.CustomizeInitialIsMasterCommand(isMasterCommand);
134+
helloCommand = base.CustomizeInitialHelloCommand(helloCommand);
135135
_speculativeFirstStep = _mechanism.Initialize(connection: null, conversation: null, description: null);
136136
var firstCommand = CreateStartCommand(_speculativeFirstStep);
137137
firstCommand.Add("db", DatabaseName);
138-
isMasterCommand.Add("speculativeAuthenticate", firstCommand);
139-
return isMasterCommand;
138+
helloCommand.Add("speculativeAuthenticate", firstCommand);
139+
return helloCommand;
140140
}
141141

142142
private protected override BsonDocument CreateStartCommand(ISaslStep currentStep)

src/MongoDB.Driver.Core/Core/Connections/ConnectionDescription.cs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class ConnectionDescription : IEquatable<ConnectionDescription>
3131
private readonly BuildInfoResult _buildInfoResult;
3232
private readonly IReadOnlyList<CompressorType> _compressors;
3333
private readonly ConnectionId _connectionId;
34-
private readonly IsMasterResult _isMasterResult;
34+
private readonly HelloResult _helloResult;
3535
private readonly int _maxBatchCount;
3636
private readonly int _maxDocumentSize;
3737
private readonly int _maxMessageSize;
@@ -43,19 +43,19 @@ public sealed class ConnectionDescription : IEquatable<ConnectionDescription>
4343
/// Initializes a new instance of the <see cref="ConnectionDescription"/> class.
4444
/// </summary>
4545
/// <param name="connectionId">The connection identifier.</param>
46-
/// <param name="isMasterResult">The issMaster result.</param>
46+
/// <param name="helloResult">The hello result.</param>
4747
/// <param name="buildInfoResult">The buildInfo result.</param>
48-
public ConnectionDescription(ConnectionId connectionId, IsMasterResult isMasterResult, BuildInfoResult buildInfoResult)
48+
public ConnectionDescription(ConnectionId connectionId, HelloResult helloResult, BuildInfoResult buildInfoResult)
4949
{
5050
_connectionId = Ensure.IsNotNull(connectionId, nameof(connectionId));
5151
_buildInfoResult = Ensure.IsNotNull(buildInfoResult, nameof(buildInfoResult));
52-
_isMasterResult = Ensure.IsNotNull(isMasterResult, nameof(isMasterResult));
52+
_helloResult = Ensure.IsNotNull(helloResult, nameof(helloResult));
5353

54-
_compressors = Ensure.IsNotNull(_isMasterResult.Compressions, "compressions");
55-
_maxBatchCount = isMasterResult.MaxBatchCount;
56-
_maxDocumentSize = isMasterResult.MaxDocumentSize;
57-
_maxMessageSize = isMasterResult.MaxMessageSize;
58-
_serviceId = isMasterResult.ServiceId;
54+
_compressors = Ensure.IsNotNull(_helloResult.Compressions, "compressions");
55+
_maxBatchCount = helloResult.MaxBatchCount;
56+
_maxDocumentSize = helloResult.MaxDocumentSize;
57+
_maxMessageSize = helloResult.MaxMessageSize;
58+
_serviceId = helloResult.ServiceId;
5959
_serverVersion = buildInfoResult.ServerVersion;
6060
}
6161

@@ -91,14 +91,26 @@ public ConnectionId ConnectionId
9191
}
9292

9393
/// <summary>
94-
/// Gets the isMaster result.
94+
/// Gets the hello result.
9595
/// </summary>
9696
/// <value>
97-
/// The isMaster result.
97+
/// The hello result.
9898
/// </value>
99+
public HelloResult HelloResult
100+
{
101+
get { return _helloResult; }
102+
}
103+
104+
/// <summary>
105+
/// Gets the hello result.
106+
/// </summary>
107+
/// <value>
108+
/// The hello result.
109+
/// </value>
110+
[Obsolete("Use HelloResult instead.")]
99111
public IsMasterResult IsMasterResult
100112
{
101-
get { return _isMasterResult; }
113+
get { return new IsMasterResult(_helloResult.Wrapped); }
102114
}
103115

104116
/// <summary>
@@ -179,7 +191,7 @@ public bool Equals(ConnectionDescription other)
179191
return
180192
_buildInfoResult.Equals(other._buildInfoResult) &&
181193
_connectionId.StructurallyEquals(other._connectionId) &&
182-
_isMasterResult.Equals(other._isMasterResult);
194+
_helloResult.Equals(other._helloResult);
183195
}
184196

185197
/// <inheritdoc/>
@@ -194,7 +206,7 @@ public override int GetHashCode()
194206
return new Hasher()
195207
.Hash(_buildInfoResult)
196208
.Hash(_connectionId)
197-
.Hash(_isMasterResult)
209+
.Hash(_helloResult)
198210
.GetHashCode();
199211
}
200212

@@ -205,7 +217,7 @@ public override int GetHashCode()
205217
/// <returns>A connection description.</returns>
206218
public ConnectionDescription WithConnectionId(ConnectionId value)
207219
{
208-
return _connectionId.StructurallyEquals(value) ? this : new ConnectionDescription(value, _isMasterResult, _buildInfoResult);
220+
return _connectionId.StructurallyEquals(value) ? this : new ConnectionDescription(value, _helloResult, _buildInfoResult);
209221
}
210222
}
211223
}

src/MongoDB.Driver.Core/Core/Connections/ConnectionInitializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public ConnectionDescription Authenticate(IConnection connection, ConnectionDesc
5454
var authenticators = GetAuthenticators(connection.Settings);
5555
AuthenticationHelper.Authenticate(connection, description, authenticators, cancellationToken);
5656

57-
var connectionIdServerValue = description.IsMasterResult.ConnectionIdServerValue;
57+
var connectionIdServerValue = description.HelloResult.ConnectionIdServerValue;
5858
if (connectionIdServerValue.HasValue)
5959
{
6060
description = UpdateConnectionIdWithServerValue(description, connectionIdServerValue.Value);
@@ -85,7 +85,7 @@ public async Task<ConnectionDescription> AuthenticateAsync(IConnection connectio
8585
var authenticators = GetAuthenticators(connection.Settings);
8686
await AuthenticationHelper.AuthenticateAsync(connection, description, authenticators, cancellationToken).ConfigureAwait(false);
8787

88-
var connectionIdServerValue = description.IsMasterResult.ConnectionIdServerValue;
88+
var connectionIdServerValue = description.HelloResult.ConnectionIdServerValue;
8989
if (connectionIdServerValue.HasValue)
9090
{
9191
description = UpdateConnectionIdWithServerValue(description, connectionIdServerValue.Value);

src/MongoDB.Driver.Core/Core/Connections/HelloHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal static BsonDocument CreateCommand(ServerApi serverApi, bool helloOk = f
6363

6464
internal static BsonDocument CustomizeCommand(BsonDocument command, IReadOnlyList<IAuthenticator> authenticators)
6565
{
66-
return authenticators.Count == 1 ? authenticators[0].CustomizeInitialIsMasterCommand(command) : command;
66+
return authenticators.Count == 1 ? authenticators[0].CustomizeInitialHelloCommand(command) : command;
6767
}
6868

6969
internal static CommandWireProtocol<BsonDocument> CreateProtocol(
@@ -81,15 +81,15 @@ internal static CommandWireProtocol<BsonDocument> CreateProtocol(
8181
serverApi);
8282
}
8383

84-
internal static IsMasterResult GetResult(
84+
internal static HelloResult GetResult(
8585
IConnection connection,
8686
CommandWireProtocol<BsonDocument> helloProtocol,
8787
CancellationToken cancellationToken)
8888
{
8989
try
9090
{
9191
var helloResultDocument = helloProtocol.Execute(connection, cancellationToken);
92-
return new IsMasterResult(helloResultDocument);
92+
return new HelloResult(helloResultDocument);
9393
}
9494
catch (MongoCommandException ex) when (ex.Code == 11)
9595
{
@@ -100,15 +100,15 @@ internal static IsMasterResult GetResult(
100100
}
101101
}
102102

103-
internal static async Task<IsMasterResult> GetResultAsync(
103+
internal static async Task<HelloResult> GetResultAsync(
104104
IConnection connection,
105105
CommandWireProtocol<BsonDocument> helloProtocol,
106106
CancellationToken cancellationToken)
107107
{
108108
try
109109
{
110110
var helloResultDocument = await helloProtocol.ExecuteAsync(connection, cancellationToken).ConfigureAwait(false);
111-
return new IsMasterResult(helloResultDocument);
111+
return new HelloResult(helloResultDocument);
112112
}
113113
catch (MongoCommandException ex) when (ex.Code == 11)
114114
{

0 commit comments

Comments
 (0)