Skip to content

Commit f2c4bfd

Browse files
authored
Put 'null' on the right side of a binary expression (#5590)
Fixes #5589.
1 parent df64529 commit f2c4bfd

File tree

76 files changed

+194
-201
lines changed

Some content is hidden

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

76 files changed

+194
-201
lines changed

src/Build.UnitTests/BackEnd/MockTaskBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public Task<WorkUnitResult> ExecuteTask(TargetLoggingContext targetLoggingContex
9292
}
9393

9494
ProjectOnErrorInstance errorTask = task as ProjectOnErrorInstance;
95-
if (null != errorTask)
95+
if (errorTask != null)
9696
{
9797
ErrorTasks.Add(errorTask);
9898
}

src/Build.UnitTests/BackEnd/RequestBuilder_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public Task<BuildResult> BuildTargets(ProjectLoggingContext loggingContext, Buil
373373
return Task<BuildResult>.FromResult(result);
374374
}
375375

376-
if (null != _newRequests)
376+
if (_newRequests != null)
377377
{
378378
string[] projectFiles = new string[_newRequests.Length];
379379
PropertyDictionary<ProjectPropertyInstance>[] properties = new PropertyDictionary<ProjectPropertyInstance>[_newRequests.Length];

src/Build.UnitTests/Evaluation/ExpressionShredder_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ private void VerifySplitSemiColonSeparatedList(string input, params string[] exp
442442
var actual = ExpressionShredder.SplitSemiColonSeparatedList(input);
443443
Console.WriteLine(input);
444444

445-
if (null == expected)
445+
if (expected == null)
446446
{
447447
// passing "null" means you expect an empty array back
448448
expected = new string[] { };

src/Build.UnitTests/FileLogger_Tests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void BasicNoExistingFile()
6969
}
7070
finally
7171
{
72-
if (null != log) File.Delete(log);
72+
if (log != null) File.Delete(log);
7373
}
7474
}
7575

@@ -92,7 +92,7 @@ public void InvalidFile()
9292
}
9393
finally
9494
{
95-
if (null != log) File.Delete(log);
95+
if (log != null) File.Delete(log);
9696
}
9797
}
9898
);
@@ -121,7 +121,7 @@ public void SpecificVerbosity()
121121
}
122122
finally
123123
{
124-
if (null != log) File.Delete(log);
124+
if (log != null) File.Delete(log);
125125
}
126126
}
127127

@@ -194,7 +194,7 @@ public void InvalidEncoding()
194194
}
195195
finally
196196
{
197-
if (null != log) File.Delete(log);
197+
if (log != null) File.Delete(log);
198198
}
199199
}
200200
);
@@ -220,7 +220,7 @@ public void ValidEncoding()
220220
}
221221
finally
222222
{
223-
if (null != log) File.Delete(log);
223+
if (log != null) File.Delete(log);
224224
}
225225
}
226226

@@ -245,7 +245,7 @@ public void ValidEncoding2()
245245
}
246246
finally
247247
{
248-
if (null != log) File.Delete(log);
248+
if (log != null) File.Delete(log);
249249
}
250250
}
251251

@@ -287,7 +287,7 @@ public void BasicExistingFileNoAppend()
287287
}
288288
finally
289289
{
290-
if (null != log) File.Delete(log);
290+
if (log != null) File.Delete(log);
291291
}
292292
}
293293

@@ -308,7 +308,7 @@ public void BasicExistingFileAppend()
308308
}
309309
finally
310310
{
311-
if (null != log) File.Delete(log);
311+
if (log != null) File.Delete(log);
312312
}
313313
}
314314

src/Build/BackEnd/BuildManager/BuildManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ public GraphBuildResult Build(BuildParameters parameters, GraphBuildRequestData
891891
/// </summary>
892892
public void ShutdownAllNodes()
893893
{
894-
if (null == _nodeManager)
894+
if (_nodeManager == null)
895895
{
896896
_nodeManager = ((IBuildComponentHost)this).GetComponent(BuildComponentType.NodeManager) as INodeManager;
897897
}
@@ -1971,7 +1971,7 @@ private void PerformSchedulingActions(IEnumerable<ScheduleResponse> responses)
19711971
{
19721972
NodeInfo createdNode = _nodeManager.CreateNode(GetNodeConfiguration(), response.RequiredNodeType);
19731973

1974-
if (null != createdNode)
1974+
if (createdNode != null)
19751975
{
19761976
_noNodesActiveEvent.Reset();
19771977
_activeNodes.Add(createdNode.NodeId);
@@ -2142,7 +2142,7 @@ private void CheckAllSubmissionsComplete(BuildRequestDataFlags? flags)
21422142
/// </summary>
21432143
private NodeConfiguration GetNodeConfiguration()
21442144
{
2145-
if (null == _nodeConfiguration)
2145+
if (_nodeConfiguration == null)
21462146
{
21472147
// Get the remote loggers
21482148
ILoggingService loggingService = ((IBuildComponentHost)this).GetComponent(BuildComponentType.LoggingService) as ILoggingService;

src/Build/BackEnd/BuildManager/BuildSubmission.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private void CheckForCompletion()
200200
{
201201
_completionEvent.Set();
202202

203-
if (null != _completionCallback)
203+
if (_completionCallback != null)
204204
{
205205
void Callback(object state)
206206
{

src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ private void BuildRequestEntry_StateChanged(BuildRequestEntry entry, BuildReques
615615
private void RaiseRequestComplete(BuildRequest request, BuildResult result)
616616
{
617617
RequestCompleteDelegate requestComplete = OnRequestComplete;
618-
if (null != requestComplete)
618+
if (requestComplete != null)
619619
{
620620
TraceEngine("RRC: Reporting result for request {0}({1}) (nr {2}).", request.GlobalRequestId, request.ConfigurationId, request.NodeRequestId);
621621
requestComplete(request, result);
@@ -718,7 +718,7 @@ private void EvaluateRequestStates()
718718

719719
// This request is ready to be built
720720
case BuildRequestEntryState.Ready:
721-
if (null == firstReadyEntry)
721+
if (firstReadyEntry == null)
722722
{
723723
firstReadyEntry = currentEntry;
724724
}
@@ -747,9 +747,9 @@ private void EvaluateRequestStates()
747747
}
748748

749749
// Update current engine status and start the next request, if applicable.
750-
if (null == activeEntry)
750+
if (activeEntry == null)
751751
{
752-
if (null != firstReadyEntry)
752+
if (firstReadyEntry != null)
753753
{
754754
// We are now active because we have an entry which is building.
755755
ChangeStatus(BuildRequestEngineStatus.Active);

src/Build/BackEnd/Components/Caching/ResultsCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private static bool CheckResults(BuildResult result, List<string> targets, HashS
312312
{
313313
if (!result.HasResultsForTarget(target) || (result[target].ResultCode == TargetResultCode.Skipped && !skippedResultsAreOK))
314314
{
315-
if (null != targetsMissingResults)
315+
if (targetsMissingResults != null)
316316
{
317317
targetsMissingResults.Add(target);
318318
returnValue = false;

src/Build/BackEnd/Components/Communications/NodeEndpointInProc.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ internal static EndpointPair CreateInProcEndpoints(EndpointMode mode, IBuildComp
252252
/// <param name="newStatus">The new status of the endpoint link.</param>
253253
private void RaiseLinkStatusChanged(LinkStatus newStatus)
254254
{
255-
if (null != OnLinkStatusChanged)
255+
if (OnLinkStatusChanged != null)
256256
{
257257
LinkStatusChangedDelegate linkStatusDelegate = OnLinkStatusChanged;
258258
linkStatusDelegate(this, newStatus);
@@ -326,8 +326,8 @@ private void EnqueuePacket(INodePacket packet)
326326
{
327327
ErrorUtilities.VerifyThrowArgumentNull(packet, nameof(packet));
328328
ErrorUtilities.VerifyThrow(_mode == EndpointMode.Asynchronous, "EndPoint mode is synchronous, should be asynchronous");
329-
ErrorUtilities.VerifyThrow(null != _packetQueue, "packetQueue is null");
330-
ErrorUtilities.VerifyThrow(null != _packetAvailable, "packetAvailable is null");
329+
ErrorUtilities.VerifyThrow(_packetQueue != null, "packetQueue is null");
330+
ErrorUtilities.VerifyThrow(_packetAvailable != null, "packetAvailable is null");
331331

332332
_packetQueue.Enqueue(packet);
333333
_packetAvailable.Set();
@@ -340,10 +340,10 @@ private void InitializeAsyncPacketThread()
340340
{
341341
lock (_asyncDataMonitor)
342342
{
343-
ErrorUtilities.VerifyThrow(null == _packetPump, "packetPump != null");
344-
ErrorUtilities.VerifyThrow(null == _packetAvailable, "packetAvailable != null");
345-
ErrorUtilities.VerifyThrow(null == _terminatePacketPump, "terminatePacketPump != null");
346-
ErrorUtilities.VerifyThrow(null == _packetQueue, "packetQueue != null");
343+
ErrorUtilities.VerifyThrow(_packetPump == null, "packetPump != null");
344+
ErrorUtilities.VerifyThrow(_packetAvailable == null, "packetAvailable != null");
345+
ErrorUtilities.VerifyThrow(_terminatePacketPump == null, "terminatePacketPump != null");
346+
ErrorUtilities.VerifyThrow(_packetQueue == null, "packetQueue != null");
347347

348348
#if FEATURE_THREAD_CULTURE
349349
_packetPump = new Thread(PacketPumpProc);
@@ -377,10 +377,10 @@ private void TerminateAsyncPacketThread()
377377
{
378378
lock (_asyncDataMonitor)
379379
{
380-
ErrorUtilities.VerifyThrow(null != _packetPump, "packetPump == null");
381-
ErrorUtilities.VerifyThrow(null != _packetAvailable, "packetAvailable == null");
382-
ErrorUtilities.VerifyThrow(null != _terminatePacketPump, "terminatePacketPump == null");
383-
ErrorUtilities.VerifyThrow(null != _packetQueue, "packetQueue == null");
380+
ErrorUtilities.VerifyThrow(_packetPump != null, "packetPump == null");
381+
ErrorUtilities.VerifyThrow(_packetAvailable != null, "packetAvailable == null");
382+
ErrorUtilities.VerifyThrow(_terminatePacketPump != null, "terminatePacketPump == null");
383+
ErrorUtilities.VerifyThrow(_packetQueue != null, "packetQueue == null");
384384

385385
_terminatePacketPump.Set();
386386
if (!_packetPump.Join((int)new TimeSpan(0, 0, BuildParameters.EndpointShutdownTimeout).TotalMilliseconds))

src/Build/BackEnd/Components/Communications/NodeManager.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ public void ShutdownConnectedNodes(bool enableReuse)
156156
}
157157

158158
_nodesShutdown = true;
159-
160159
_inProcNodeProvider?.ShutdownConnectedNodes(enableReuse);
161-
162160
_outOfProcNodeProvider?.ShutdownConnectedNodes(enableReuse);
163161
}
164162

@@ -316,7 +314,7 @@ private void RemoveNodeFromMapping(int nodeId)
316314
private int AttemptCreateNode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration)
317315
{
318316
// If no provider was passed in, we obviously can't create a node.
319-
if (null == nodeProvider)
317+
if (nodeProvider == null)
320318
{
321319
ErrorUtilities.ThrowInternalError("No node provider provided.");
322320
return InvalidNodeId;

0 commit comments

Comments
 (0)