Skip to content

Commit a8770ab

Browse files
authored
Style | Enforce Braces via EditorConfig (#3645)
1 parent 16e2cbe commit a8770ab

File tree

82 files changed

+1218
-6
lines changed

Some content is hidden

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

82 files changed

+1218
-6
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ csharp_indent_case_contents = true
3535
csharp_indent_switch_labels = true
3636
csharp_indent_labels = one_less_than_current
3737

38+
# Require braces around if/for/while/etc
39+
csharp_prefer_braces = true:warning
40+
3841
# avoid this. unless absolutely necessary
3942
dotnet_style_qualification_for_field = false:suggestion
4043
dotnet_style_qualification_for_property = false:suggestion

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ internal void SetActiveConnectionAndResult(TaskCompletionSource<object> completi
212212
if (!parser.MARSOn)
213213
{
214214
if (activeConnection.AsyncCommandInProgress)
215+
{
215216
throw SQL.MARSUnsupportedOnConnection();
217+
}
216218
}
217219
_cachedAsyncConnection = activeConnection;
218220

@@ -3066,7 +3068,9 @@ private void GenerateEnclavePackage()
30663068

30673069
string enclaveType = this._activeConnection.Parser.EnclaveType;
30683070
if (string.IsNullOrWhiteSpace(enclaveType))
3071+
{
30693072
throw SQL.EnclaveTypeNullForEnclaveBasedQuery();
3073+
}
30703074

30713075
SqlConnectionAttestationProtocol attestationProtocol = this._activeConnection.AttestationProtocol;
30723076
if (attestationProtocol == SqlConnectionAttestationProtocol.NotSpecified)
@@ -4043,10 +4047,15 @@ private SqlParameter GetParameterForOutputValueExtraction(SqlParameterCollection
40434047
}
40444048
}
40454049
}
4050+
40464051
if (foundParam)
4052+
{
40474053
return thisParam;
4054+
}
40484055
else
4056+
{
40494057
return null;
4058+
}
40504059
}
40514060

40524061
private void GetRPCObject(int systemParamCount, int userParamCount, ref _SqlRPC rpc, bool forSpDescribeParameterEncryption = false)
@@ -4507,7 +4516,9 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
45074516
sqlParam.Validate(i, CommandType.StoredProcedure == CommandType);
45084517
// skip ReturnValue parameters; we never send them to the server
45094518
if (!ShouldSendParameter(sqlParam, includeReturnValue))
4519+
{
45104520
continue;
4521+
}
45114522

45124523
// add our separator for the ith parameter
45134524
if (fAddSeparator)
@@ -4529,7 +4540,9 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
45294540
{
45304541
string fullTypeName = sqlParam.UdtTypeName;
45314542
if (string.IsNullOrEmpty(fullTypeName))
4543+
{
45324544
throw SQL.MustSetUdtTypeNameForUdtParams();
4545+
}
45334546

45344547
paramList.Append(ParseAndQuoteIdentifier(fullTypeName, true /* is UdtTypeName */));
45354548
}
@@ -4625,14 +4638,18 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
46254638
int actualBytes = parser.GetEncodingCharLength(s, sqlParam.GetActualSize(), sqlParam.Offset, null);
46264639
// if actual number of bytes is greater than the user given number of chars, use actual bytes
46274640
if (actualBytes > size)
4641+
{
46284642
size = actualBytes;
4643+
}
46294644
}
46304645
}
46314646

46324647
// If the user specifies a 0-sized parameter for a variable len field
46334648
// pass over max size (8000 bytes or 4000 characters for wide types)
46344649
if (0 == size)
4650+
{
46354651
size = mt.IsSizeInCharacters ? (TdsEnums.MAXSIZE >> 1) : TdsEnums.MAXSIZE;
4652+
}
46364653

46374654
paramList.Append(size);
46384655
paramList.Append(')');

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ public void AssertUnrecoverableStateCountIsCorrect()
9696
foreach (var state in _delta)
9797
{
9898
if (state != null && !state._recoverable)
99+
{
99100
unrecoverableCount++;
101+
}
100102
}
101103
Debug.Assert(unrecoverableCount == _unrecoverableStatesCount, "Unrecoverable count does not match");
102104
}
@@ -1611,7 +1613,9 @@ private void LoginNoFailover(ServerInfo serverInfo,
16111613
// Re-allocate parser each time to make sure state is known
16121614
// RFC 50002652 - if parser was created by previous attempt, dispose it to properly close the socket, if created
16131615
if (_parser != null)
1616+
{
16141617
_parser.Disconnect();
1618+
}
16151619

16161620
_parser = new TdsParser(ConnectionOptions.MARS, ConnectionOptions.Asynchronous);
16171621
Debug.Assert(SniContext.Undefined == Parser._physicalStateObj.SniContext, $"SniContext should be Undefined; actual Value: {Parser._physicalStateObj.SniContext}");
@@ -2512,7 +2516,9 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
25122516

25132517
SqlAuthenticationProvider authProvider = SqlAuthenticationProvider.GetProvider(ConnectionOptions.Authentication);
25142518
if (authProvider == null && _accessTokenCallback == null)
2519+
{
25152520
throw SQL.CannotFindAuthProvider(ConnectionOptions.Authentication.ToString());
2521+
}
25162522

25172523
// retry getting access token once if MsalException.error_code is unknown_error.
25182524
// extra logic to deal with HTTP 429 (Retry after).

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ private void ReadSniError(TdsParserStateObject stateObj, uint error)
184184
_parser.Disconnect();
185185
}
186186
else
187+
{
187188
fail = true; // We aren't yet logged in - just fail.
189+
}
188190
}
189191
}
190192
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.netfx.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ internal void SetActiveConnectionAndResult(TaskCompletionSource<object> completi
211211
if (activeConnection != null && !parser.MARSOn)
212212
{
213213
if (activeConnection.AsyncCommandInProgress)
214+
{
214215
throw SQL.MARSUnsupportedOnConnection();
216+
}
215217
}
216218
_cachedAsyncConnection = activeConnection;
217219

@@ -3012,7 +3014,9 @@ private void GenerateEnclavePackage()
30123014

30133015
string enclaveType = this._activeConnection.Parser.EnclaveType;
30143016
if (string.IsNullOrWhiteSpace(enclaveType))
3017+
{
30153018
throw SQL.EnclaveTypeNullForEnclaveBasedQuery();
3019+
}
30163020

30173021
SqlConnectionAttestationProtocol attestationProtocol = this._activeConnection.AttestationProtocol;
30183022
if (attestationProtocol == SqlConnectionAttestationProtocol.NotSpecified)
@@ -3692,11 +3696,15 @@ private static void OnDone(TdsParserStateObject stateObj, int index, IList<_SqlR
36923696
internal void OnReturnStatus(int status)
36933697
{
36943698
if (_inPrepare)
3699+
{
36953700
return;
3701+
}
36963702

36973703
// Don't set the return status if this is the status for sp_describe_parameter_encryption.
36983704
if (IsDescribeParameterEncryptionRPCCurrentlyInProgress)
3705+
{
36993706
return;
3707+
}
37003708

37013709
SqlParameterCollection parameters = _parameters;
37023710
if (_batchRPCMode)
@@ -3961,10 +3969,15 @@ private SqlParameter GetParameterForOutputValueExtraction(SqlParameterCollection
39613969
}
39623970
}
39633971
}
3972+
39643973
if (foundParam)
3974+
{
39653975
return thisParam;
3976+
}
39663977
else
3978+
{
39673979
return null;
3980+
}
39683981
}
39693982

39703983
private void GetRPCObject(int systemParamCount, int userParamCount, ref _SqlRPC rpc, bool forSpDescribeParameterEncryption = false)
@@ -4436,7 +4449,9 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
44364449
sqlParam.Validate(i, CommandType.StoredProcedure == CommandType);
44374450
// skip ReturnValue parameters; we never send them to the server
44384451
if (!ShouldSendParameter(sqlParam, includeReturnValue))
4452+
{
44394453
continue;
4454+
}
44404455

44414456
// add our separator for the ith parameter
44424457
if (fAddSeparator)
@@ -4458,7 +4473,9 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
44584473
{
44594474
string fullTypeName = sqlParam.UdtTypeName;
44604475
if (string.IsNullOrEmpty(fullTypeName))
4476+
{
44614477
throw SQL.MustSetUdtTypeNameForUdtParams();
4478+
}
44624479

44634480
paramList.Append(ParseAndQuoteIdentifier(fullTypeName, true /* is UdtTypeName */));
44644481
}
@@ -4554,7 +4571,9 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
45544571
int actualBytes = parser.GetEncodingCharLength(s, sqlParam.GetActualSize(), sqlParam.Offset, null);
45554572
// if actual number of bytes is greater than the user given number of chars, use actual bytes
45564573
if (actualBytes > size)
4574+
{
45574575
size = actualBytes;
4576+
}
45584577
}
45594578
}
45604579

@@ -4573,7 +4592,9 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
45734592

45744593
// set the output bit for Output or InputOutput parameters
45754594
if (sqlParam.Direction != ParameterDirection.Input)
4595+
{
45764596
paramList.Append(" " + TdsEnums.PARAM_OUTPUT);
4597+
}
45774598
}
45784599

45794600
return paramList.ToString();

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ public void AssertUnrecoverableStateCountIsCorrect()
9797
foreach (var state in _delta)
9898
{
9999
if (state != null && !state._recoverable)
100+
{
100101
unrecoverableCount++;
102+
}
101103
}
102104
Debug.Assert(unrecoverableCount == _unrecoverableStatesCount, "Unrecoverable count does not match");
103105
}
@@ -1635,7 +1637,9 @@ private void LoginNoFailover(ServerInfo serverInfo,
16351637
// Re-allocate parser each time to make sure state is known
16361638
// RFC 50002652 - if parser was created by previous attempt, dispose it to properly close the socket, if created
16371639
if (_parser != null)
1640+
{
16381641
_parser.Disconnect();
1642+
}
16391643

16401644
_parser = new TdsParser(ConnectionOptions.MARS, ConnectionOptions.Asynchronous);
16411645
Debug.Assert(SniContext.Undefined == Parser._physicalStateObj.SniContext, $"SniContext should be Undefined; actual Value: {Parser._physicalStateObj.SniContext}");
@@ -2566,7 +2570,9 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
25662570

25672571
SqlAuthenticationProvider authProvider = SqlAuthenticationProvider.GetProvider(ConnectionOptions.Authentication);
25682572
if (authProvider == null && _accessTokenCallback == null)
2573+
{
25692574
throw SQL.CannotFindAuthProvider(ConnectionOptions.Authentication.ToString());
2575+
}
25702576

25712577
// retry getting access token once if MsalException.error_code is unknown_error.
25722578
// extra logic to deal with HTTP 429 (Retry after).

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.netfx.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ private void ReadSniError(TdsParserStateObject stateObj, uint error)
190190
_parser.Disconnect();
191191
}
192192
else
193+
{
193194
fail = true; // We aren't yet logged in - just fail.
195+
}
194196
}
195197
}
196198
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,9 @@ internal static Delegate FindBuilder(MulticastDelegate mcd)
622622
foreach (Delegate del in mcd?.GetInvocationList())
623623
{
624624
if (del.Target is DbCommandBuilder)
625+
{
625626
return del;
627+
}
626628
}
627629

628630
return null;

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionOptions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,24 @@ public bool ConvertValueToBoolean(string keyName, bool defaultValue)
165165
internal static bool ConvertValueToBooleanInternal(string keyName, string stringValue)
166166
{
167167
if (CompareInsensitiveInvariant(stringValue, "true") || CompareInsensitiveInvariant(stringValue, "yes"))
168+
{
168169
return true;
170+
}
169171
else if (CompareInsensitiveInvariant(stringValue, "false") || CompareInsensitiveInvariant(stringValue, "no"))
172+
{
170173
return false;
174+
}
171175
else
172176
{
173177
string tmp = stringValue.Trim(); // Remove leading & trailing whitespace.
174178
if (CompareInsensitiveInvariant(tmp, "true") || CompareInsensitiveInvariant(tmp, "yes"))
179+
{
175180
return true;
181+
}
176182
else if (CompareInsensitiveInvariant(tmp, "false") || CompareInsensitiveInvariant(tmp, "no"))
183+
{
177184
return false;
185+
}
178186
else
179187
{
180188
throw ADP.InvalidConnectionOptionValue(keyName);

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionStringUtilities.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,24 @@ internal static bool ConvertToIntegratedSecurity(object value)
5656
if (value is string svalue)
5757
{
5858
if (StringComparer.OrdinalIgnoreCase.Equals(svalue, "sspi") || StringComparer.OrdinalIgnoreCase.Equals(svalue, "true") || StringComparer.OrdinalIgnoreCase.Equals(svalue, "yes"))
59+
{
5960
return true;
61+
}
6062
else if (StringComparer.OrdinalIgnoreCase.Equals(svalue, "false") || StringComparer.OrdinalIgnoreCase.Equals(svalue, "no"))
63+
{
6164
return false;
65+
}
6266
else
6367
{
6468
string tmp = svalue.Trim(); // Remove leading & trailing white space.
6569
if (StringComparer.OrdinalIgnoreCase.Equals(tmp, "sspi") || StringComparer.OrdinalIgnoreCase.Equals(tmp, "true") || StringComparer.OrdinalIgnoreCase.Equals(tmp, "yes"))
70+
{
6671
return true;
72+
}
6773
else if (StringComparer.OrdinalIgnoreCase.Equals(tmp, "false") || StringComparer.OrdinalIgnoreCase.Equals(tmp, "no"))
74+
{
6875
return false;
76+
}
6977
}
7078
return bool.Parse(svalue);
7179
}

0 commit comments

Comments
 (0)