diff --git a/src/Build.UnitTests/BackEnd/MockTaskBuilder.cs b/src/Build.UnitTests/BackEnd/MockTaskBuilder.cs index 5dd66b6e929..83e60f427af 100644 --- a/src/Build.UnitTests/BackEnd/MockTaskBuilder.cs +++ b/src/Build.UnitTests/BackEnd/MockTaskBuilder.cs @@ -92,7 +92,7 @@ public Task ExecuteTask(TargetLoggingContext targetLoggingContex } ProjectOnErrorInstance errorTask = task as ProjectOnErrorInstance; - if (null != errorTask) + if (errorTask != null) { ErrorTasks.Add(errorTask); } diff --git a/src/Build.UnitTests/BackEnd/RequestBuilder_Tests.cs b/src/Build.UnitTests/BackEnd/RequestBuilder_Tests.cs index ea23951d312..5e68ff11991 100644 --- a/src/Build.UnitTests/BackEnd/RequestBuilder_Tests.cs +++ b/src/Build.UnitTests/BackEnd/RequestBuilder_Tests.cs @@ -373,7 +373,7 @@ public Task BuildTargets(ProjectLoggingContext loggingContext, Buil return Task.FromResult(result); } - if (null != _newRequests) + if (_newRequests != null) { string[] projectFiles = new string[_newRequests.Length]; PropertyDictionary[] properties = new PropertyDictionary[_newRequests.Length]; diff --git a/src/Build.UnitTests/Evaluation/ExpressionShredder_Tests.cs b/src/Build.UnitTests/Evaluation/ExpressionShredder_Tests.cs index 660f95455c2..920b2b13a58 100644 --- a/src/Build.UnitTests/Evaluation/ExpressionShredder_Tests.cs +++ b/src/Build.UnitTests/Evaluation/ExpressionShredder_Tests.cs @@ -442,7 +442,7 @@ private void VerifySplitSemiColonSeparatedList(string input, params string[] exp var actual = ExpressionShredder.SplitSemiColonSeparatedList(input); Console.WriteLine(input); - if (null == expected) + if (expected == null) { // passing "null" means you expect an empty array back expected = new string[] { }; diff --git a/src/Build.UnitTests/FileLogger_Tests.cs b/src/Build.UnitTests/FileLogger_Tests.cs index 0fefab60bc5..e06c154ba57 100644 --- a/src/Build.UnitTests/FileLogger_Tests.cs +++ b/src/Build.UnitTests/FileLogger_Tests.cs @@ -69,7 +69,7 @@ public void BasicNoExistingFile() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } @@ -92,7 +92,7 @@ public void InvalidFile() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } ); @@ -121,7 +121,7 @@ public void SpecificVerbosity() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } @@ -194,7 +194,7 @@ public void InvalidEncoding() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } ); @@ -220,7 +220,7 @@ public void ValidEncoding() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } @@ -245,7 +245,7 @@ public void ValidEncoding2() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } @@ -287,7 +287,7 @@ public void BasicExistingFileNoAppend() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } @@ -308,7 +308,7 @@ public void BasicExistingFileAppend() } finally { - if (null != log) File.Delete(log); + if (log != null) File.Delete(log); } } diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs index c8a2838afbb..0e59f2e1fd6 100644 --- a/src/Build/BackEnd/BuildManager/BuildManager.cs +++ b/src/Build/BackEnd/BuildManager/BuildManager.cs @@ -891,7 +891,7 @@ public GraphBuildResult Build(BuildParameters parameters, GraphBuildRequestData /// public void ShutdownAllNodes() { - if (null == _nodeManager) + if (_nodeManager == null) { _nodeManager = ((IBuildComponentHost)this).GetComponent(BuildComponentType.NodeManager) as INodeManager; } @@ -1971,7 +1971,7 @@ private void PerformSchedulingActions(IEnumerable responses) { NodeInfo createdNode = _nodeManager.CreateNode(GetNodeConfiguration(), response.RequiredNodeType); - if (null != createdNode) + if (createdNode != null) { _noNodesActiveEvent.Reset(); _activeNodes.Add(createdNode.NodeId); @@ -2142,7 +2142,7 @@ private void CheckAllSubmissionsComplete(BuildRequestDataFlags? flags) /// private NodeConfiguration GetNodeConfiguration() { - if (null == _nodeConfiguration) + if (_nodeConfiguration == null) { // Get the remote loggers ILoggingService loggingService = ((IBuildComponentHost)this).GetComponent(BuildComponentType.LoggingService) as ILoggingService; diff --git a/src/Build/BackEnd/BuildManager/BuildSubmission.cs b/src/Build/BackEnd/BuildManager/BuildSubmission.cs index d6a02bd3650..3a53fbbf3ee 100644 --- a/src/Build/BackEnd/BuildManager/BuildSubmission.cs +++ b/src/Build/BackEnd/BuildManager/BuildSubmission.cs @@ -200,7 +200,7 @@ private void CheckForCompletion() { _completionEvent.Set(); - if (null != _completionCallback) + if (_completionCallback != null) { void Callback(object state) { diff --git a/src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs b/src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs index 2cf6ea5f8ed..bd5d8815eb6 100644 --- a/src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs +++ b/src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs @@ -615,7 +615,7 @@ private void BuildRequestEntry_StateChanged(BuildRequestEntry entry, BuildReques private void RaiseRequestComplete(BuildRequest request, BuildResult result) { RequestCompleteDelegate requestComplete = OnRequestComplete; - if (null != requestComplete) + if (requestComplete != null) { TraceEngine("RRC: Reporting result for request {0}({1}) (nr {2}).", request.GlobalRequestId, request.ConfigurationId, request.NodeRequestId); requestComplete(request, result); @@ -718,7 +718,7 @@ private void EvaluateRequestStates() // This request is ready to be built case BuildRequestEntryState.Ready: - if (null == firstReadyEntry) + if (firstReadyEntry == null) { firstReadyEntry = currentEntry; } @@ -747,9 +747,9 @@ private void EvaluateRequestStates() } // Update current engine status and start the next request, if applicable. - if (null == activeEntry) + if (activeEntry == null) { - if (null != firstReadyEntry) + if (firstReadyEntry != null) { // We are now active because we have an entry which is building. ChangeStatus(BuildRequestEngineStatus.Active); diff --git a/src/Build/BackEnd/Components/Caching/ResultsCache.cs b/src/Build/BackEnd/Components/Caching/ResultsCache.cs index cfbcaff2aeb..9ba79433501 100644 --- a/src/Build/BackEnd/Components/Caching/ResultsCache.cs +++ b/src/Build/BackEnd/Components/Caching/ResultsCache.cs @@ -312,7 +312,7 @@ private static bool CheckResults(BuildResult result, List targets, HashS { if (!result.HasResultsForTarget(target) || (result[target].ResultCode == TargetResultCode.Skipped && !skippedResultsAreOK)) { - if (null != targetsMissingResults) + if (targetsMissingResults != null) { targetsMissingResults.Add(target); returnValue = false; diff --git a/src/Build/BackEnd/Components/Communications/NodeEndpointInProc.cs b/src/Build/BackEnd/Components/Communications/NodeEndpointInProc.cs index 956a7f080f6..a8f9f39b37d 100644 --- a/src/Build/BackEnd/Components/Communications/NodeEndpointInProc.cs +++ b/src/Build/BackEnd/Components/Communications/NodeEndpointInProc.cs @@ -252,7 +252,7 @@ internal static EndpointPair CreateInProcEndpoints(EndpointMode mode, IBuildComp /// The new status of the endpoint link. private void RaiseLinkStatusChanged(LinkStatus newStatus) { - if (null != OnLinkStatusChanged) + if (OnLinkStatusChanged != null) { LinkStatusChangedDelegate linkStatusDelegate = OnLinkStatusChanged; linkStatusDelegate(this, newStatus); @@ -326,8 +326,8 @@ private void EnqueuePacket(INodePacket packet) { ErrorUtilities.VerifyThrowArgumentNull(packet, nameof(packet)); ErrorUtilities.VerifyThrow(_mode == EndpointMode.Asynchronous, "EndPoint mode is synchronous, should be asynchronous"); - ErrorUtilities.VerifyThrow(null != _packetQueue, "packetQueue is null"); - ErrorUtilities.VerifyThrow(null != _packetAvailable, "packetAvailable is null"); + ErrorUtilities.VerifyThrow(_packetQueue != null, "packetQueue is null"); + ErrorUtilities.VerifyThrow(_packetAvailable != null, "packetAvailable is null"); _packetQueue.Enqueue(packet); _packetAvailable.Set(); @@ -340,10 +340,10 @@ private void InitializeAsyncPacketThread() { lock (_asyncDataMonitor) { - ErrorUtilities.VerifyThrow(null == _packetPump, "packetPump != null"); - ErrorUtilities.VerifyThrow(null == _packetAvailable, "packetAvailable != null"); - ErrorUtilities.VerifyThrow(null == _terminatePacketPump, "terminatePacketPump != null"); - ErrorUtilities.VerifyThrow(null == _packetQueue, "packetQueue != null"); + ErrorUtilities.VerifyThrow(_packetPump == null, "packetPump != null"); + ErrorUtilities.VerifyThrow(_packetAvailable == null, "packetAvailable != null"); + ErrorUtilities.VerifyThrow(_terminatePacketPump == null, "terminatePacketPump != null"); + ErrorUtilities.VerifyThrow(_packetQueue == null, "packetQueue != null"); #if FEATURE_THREAD_CULTURE _packetPump = new Thread(PacketPumpProc); @@ -377,10 +377,10 @@ private void TerminateAsyncPacketThread() { lock (_asyncDataMonitor) { - ErrorUtilities.VerifyThrow(null != _packetPump, "packetPump == null"); - ErrorUtilities.VerifyThrow(null != _packetAvailable, "packetAvailable == null"); - ErrorUtilities.VerifyThrow(null != _terminatePacketPump, "terminatePacketPump == null"); - ErrorUtilities.VerifyThrow(null != _packetQueue, "packetQueue == null"); + ErrorUtilities.VerifyThrow(_packetPump != null, "packetPump == null"); + ErrorUtilities.VerifyThrow(_packetAvailable != null, "packetAvailable == null"); + ErrorUtilities.VerifyThrow(_terminatePacketPump != null, "terminatePacketPump == null"); + ErrorUtilities.VerifyThrow(_packetQueue != null, "packetQueue == null"); _terminatePacketPump.Set(); if (!_packetPump.Join((int)new TimeSpan(0, 0, BuildParameters.EndpointShutdownTimeout).TotalMilliseconds)) diff --git a/src/Build/BackEnd/Components/Communications/NodeManager.cs b/src/Build/BackEnd/Components/Communications/NodeManager.cs index 2ad71da07f0..79358a223fb 100644 --- a/src/Build/BackEnd/Components/Communications/NodeManager.cs +++ b/src/Build/BackEnd/Components/Communications/NodeManager.cs @@ -156,9 +156,7 @@ public void ShutdownConnectedNodes(bool enableReuse) } _nodesShutdown = true; - _inProcNodeProvider?.ShutdownConnectedNodes(enableReuse); - _outOfProcNodeProvider?.ShutdownConnectedNodes(enableReuse); } @@ -316,7 +314,7 @@ private void RemoveNodeFromMapping(int nodeId) private int AttemptCreateNode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration) { // If no provider was passed in, we obviously can't create a node. - if (null == nodeProvider) + if (nodeProvider == null) { ErrorUtilities.ThrowInternalError("No node provider provided."); return InvalidNodeId; diff --git a/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs b/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs index 49cca2f7e4d..0081265b99c 100644 --- a/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs +++ b/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs @@ -153,7 +153,7 @@ public void SendData(int nodeId, INodePacket packet) ErrorUtilities.VerifyThrowArgumentOutOfRange(nodeId == _inProcNodeId, "node"); ErrorUtilities.VerifyThrowArgumentNull(packet, nameof(packet)); - if (null == _inProcNode) + if (_inProcNode == null) { return; } @@ -167,7 +167,7 @@ public void SendData(int nodeId, INodePacket packet) /// Flag indicating if the nodes should prepare for reuse. public void ShutdownConnectedNodes(bool enableReuse) { - if (null != _inProcNode) + if (_inProcNode != null) { _inProcNodeEndpoint.SendData(new NodeBuildComplete(enableReuse)); } @@ -333,8 +333,8 @@ static internal IBuildComponent CreateComponent(BuildComponentType type) /// private bool InstantiateNode(INodePacketFactory factory) { - ErrorUtilities.VerifyThrow(null == _inProcNode, "In Proc node already instantiated."); - ErrorUtilities.VerifyThrow(null == _inProcNodeEndpoint, "In Proc node endpoint already instantiated."); + ErrorUtilities.VerifyThrow(_inProcNode == null, "In Proc node already instantiated."); + ErrorUtilities.VerifyThrow(_inProcNodeEndpoint == null, "In Proc node endpoint already instantiated."); NodeEndpointInProc.EndpointPair endpoints = NodeEndpointInProc.CreateInProcEndpoints(NodeEndpointInProc.EndpointMode.Synchronous, _componentHost); diff --git a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProc.cs b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProc.cs index 5fd62ffed9b..11ea72ba505 100644 --- a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProc.cs +++ b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProc.cs @@ -94,7 +94,7 @@ public bool CreateNode(int nodeId, INodePacketFactory factory, NodeConfiguration Handshake hostHandshake = new Handshake(CommunicationsUtilities.GetHandshakeOptions(taskHost: false, nodeReuse: ComponentHost.BuildParameters.EnableNodeReuse, lowPriority: ComponentHost.BuildParameters.LowPriority, is64Bit: EnvironmentUtilities.Is64BitProcess)); NodeContext context = GetNode(null, commandLineArgs, nodeId, factory, hostHandshake, NodeContextTerminated); - if (null != context) + if (context != null) { _nodeContexts[nodeId] = context; diff --git a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs index cae8c0b3b5e..644d47e931d 100644 --- a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs +++ b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs @@ -123,13 +123,13 @@ protected void ShutdownAllNodes(bool nodeReuse, NodeContextTerminateDelegate ter // Attempt to connect to the process with the handshake without low priority. Stream nodeStream = TryConnectToProcess(nodeProcess.Id, timeout, NodeProviderOutOfProc.GetHandshake(nodeReuse, false)); - if (null == nodeStream) + if (nodeStream == null) { // If we couldn't connect attempt to connect to the process with the handshake including low priority. nodeStream = TryConnectToProcess(nodeProcess.Id, timeout, NodeProviderOutOfProc.GetHandshake(nodeReuse, true)); } - if (null != nodeStream) + if (nodeStream != null) { // If we're able to connect to such a process, send a packet requesting its termination CommunicationsUtilities.Trace("Shutting down node with pid = {0}", nodeProcess.Id); diff --git a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs index 418ce50329e..ef746ed27d7 100644 --- a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs +++ b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs @@ -529,7 +529,7 @@ internal bool CreateNode(HandshakeOptions hostContext, INodePacketFactory factor NodeContextTerminated ); - if (null != context) + if (context != null) { _nodeContexts[hostContext] = context; diff --git a/src/Build/BackEnd/Components/Communications/TaskHostNodeManager.cs b/src/Build/BackEnd/Components/Communications/TaskHostNodeManager.cs index 5ec101d68a5..949c39b4720 100644 --- a/src/Build/BackEnd/Components/Communications/TaskHostNodeManager.cs +++ b/src/Build/BackEnd/Components/Communications/TaskHostNodeManager.cs @@ -73,7 +73,6 @@ public void SendData(int node, INodePacket packet) public void ShutdownConnectedNodes(bool enableReuse) { ErrorUtilities.VerifyThrow(!_componentShutdown, "We should never be calling ShutdownNodes after ShutdownComponent has been called"); - _outOfProcTaskHostNodeProvider?.ShutdownConnectedNodes(enableReuse); } diff --git a/src/Build/BackEnd/Components/Logging/LoggingService.cs b/src/Build/BackEnd/Components/Logging/LoggingService.cs index 93cbaff924a..f426366b7b1 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingService.cs @@ -1457,7 +1457,7 @@ private void InitializeLogger(ILogger logger, IEventSource sourceForLogger) try { INodeLogger nodeLogger = logger as INodeLogger; - if (null != nodeLogger) + if (nodeLogger != null) { nodeLogger.Initialize(sourceForLogger, _maxCPUCount); } diff --git a/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs b/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs index f0485c1d0eb..3e676950ea5 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs @@ -335,7 +335,7 @@ ElementLocation elementLocation // If we didn't find a bucket that matches this item, create a new one, adding // this item to the bucket. - if (null == matchingBucket) + if (matchingBucket == null) { matchingBucket = new ItemBucket(itemListsToBeBatched.Keys, itemMetadataValues, lookup, buckets.Count); diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs index 15b97e6a83d..31318d664b1 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs @@ -680,7 +680,7 @@ public string GetEscapedValue(string specifiedItemType, string name) public string GetEscapedValueIfPresent(string specifiedItemType, string name) { string value = null; - if (null == specifiedItemType || specifiedItemType == _itemType) + if (specifiedItemType == null || specifiedItemType == _itemType) { // Look in the addTable if (_addTable.TryGetValue(name, out value)) @@ -690,17 +690,17 @@ public string GetEscapedValueIfPresent(string specifiedItemType, string name) } // Look in the bucket table - if (null != _bucketTable) + if (_bucketTable != null) { value = _bucketTable.GetEscapedValueIfPresent(specifiedItemType, name); - if (null != value) + if (value != null) { return value; } } // Look in the item definition table - if (null != _itemDefinitionTable) + if (_itemDefinitionTable != null) { value = _itemDefinitionTable.GetEscapedValueIfPresent(specifiedItemType, name); } diff --git a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs index 8551bc19c43..00512fc9c9b 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs @@ -183,7 +183,7 @@ public void BuildRequest(NodeLoggingContext loggingContext, BuildRequestEntry en { ErrorUtilities.VerifyThrowArgumentNull(loggingContext, nameof(loggingContext)); ErrorUtilities.VerifyThrowArgumentNull(entry, nameof(entry)); - ErrorUtilities.VerifyThrow(null != _componentHost, "Host not set."); + ErrorUtilities.VerifyThrow(_componentHost != null, "Host not set."); ErrorUtilities.VerifyThrow(_targetBuilder == null, "targetBuilder not null"); ErrorUtilities.VerifyThrow(_nodeLoggingContext == null, "nodeLoggingContext not null"); ErrorUtilities.VerifyThrow(_requestEntry == null, "requestEntry not null"); @@ -726,7 +726,7 @@ private async Task BuildAndReport() } catch (InvalidProjectFileException ex) { - if (null != _projectLoggingContext) + if (_projectLoggingContext != null) { _projectLoggingContext.LogInvalidProjectFileError(ex); } @@ -764,7 +764,7 @@ private async Task BuildAndReport() { _blockType = BlockType.Unblocked; - if (null != thrownException) + if (thrownException != null) { ErrorUtilities.VerifyThrow(result == null, "Result already set when exception was thrown."); result = new BuildResult(_requestEntry.Request, thrownException); @@ -781,7 +781,7 @@ private async Task BuildAndReport() /// private void ReportResultAndCleanUp(BuildResult result) { - if (null != _projectLoggingContext) + if (_projectLoggingContext != null) { try { diff --git a/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs index d105588c94d..dc1132431ee 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs @@ -439,7 +439,7 @@ private async Task ProcessTargetStack(ITaskBuilder taskBuilder) } // And if we have dependencies to run, push them now. - if (null != dependencies) + if (dependencies != null) { await PushTargets(dependencies, currentTargetEntry, currentTargetEntry.Lookup, false, false, TargetBuiltReason.DependsOn); } diff --git a/src/Build/BackEnd/Components/RequestBuilder/TargetEntry.cs b/src/Build/BackEnd/Components/RequestBuilder/TargetEntry.cs index 6e7c3e077aa..98acfa7cee3 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TargetEntry.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TargetEntry.cs @@ -546,11 +546,8 @@ internal async Task ExecuteTarget(ITaskBuilder taskBuilder, BuildRequestEntry re // Make sure the Invalid Project error gets logged *before* TargetFinished. Otherwise, // the log is confusing. targetLoggingContext.LogInvalidProjectFileError(e); - entryForInference?.LeaveScope(); - entryForExecution?.LeaveScope(); - aggregateResult = aggregateResult.AggregateResult(new WorkUnitResult(WorkUnitResultCode.Failed, WorkUnitActionCode.Stop, null)); } finally @@ -718,7 +715,7 @@ internal List GetErrorTargets(ProjectLoggingContext project // If this target never executed (for instance, because one of its dependencies errored) then we need to // create a result for this target to report when it gets to the Completed state. - if (null == _targetResult) + if (_targetResult == null) { _targetResult = new TargetResult(Array.Empty(), new WorkUnitResult(WorkUnitResultCode.Failed, WorkUnitActionCode.Stop, null)); } @@ -747,7 +744,7 @@ internal TargetResult GatherResults() /// The lookup to enter with. internal void EnterLegacyCallTargetScope(Lookup lookup) { - if (null == _legacyCallTargetScopes) + if (_legacyCallTargetScopes == null) { _legacyCallTargetScopes = new Stack(); } @@ -783,7 +780,7 @@ internal void MarkForStop() /// internal void LeaveLegacyCallTargetScopes() { - if (null != _legacyCallTargetScopes) + if (_legacyCallTargetScopes != null) { while (_legacyCallTargetScopes.Count != 0) { diff --git a/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs index 9d3bcc3e05f..d3431b4bf8c 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs @@ -1179,7 +1179,7 @@ ItemBucket bucket { string taskParameterAttribute = _taskNode.GetParameter(taskParameterName); - if (null != taskParameterAttribute) + if (taskParameterAttribute != null) { ProjectTaskOutputItemInstance taskItemInstance = taskOutputSpecification as ProjectTaskOutputItemInstance; if (taskItemInstance != null) diff --git a/src/Build/BackEnd/Components/Scheduler/Scheduler.cs b/src/Build/BackEnd/Components/Scheduler/Scheduler.cs index b357b6149ce..4dc54d08360 100644 --- a/src/Build/BackEnd/Components/Scheduler/Scheduler.cs +++ b/src/Build/BackEnd/Components/Scheduler/Scheduler.cs @@ -1552,7 +1552,7 @@ private void HandleRequestBlockedByNewRequests(SchedulableRequest parentRequest, // directly here. We COULD simply report these as blocking the parent request and let the scheduler pick them up later when the parent // comes back up as schedulable, but we prefer to send the results back immediately so this request can (potentially) continue uninterrupted. ScheduleResponse response = TrySatisfyRequestFromCache(nodeForResults, request, skippedResultsDoNotCauseCacheMiss: _componentHost.BuildParameters.SkippedResultsDoNotCauseCacheMiss()); - if (null != response) + if (response != null) { TraceScheduler("Request {0} (node request {1}) satisfied from the cache.", request.GlobalRequestId, request.NodeRequestId); diff --git a/src/Build/BackEnd/Node/InProcNode.cs b/src/Build/BackEnd/Node/InProcNode.cs index 580187c97f4..0a5db6abbb2 100644 --- a/src/Build/BackEnd/Node/InProcNode.cs +++ b/src/Build/BackEnd/Node/InProcNode.cs @@ -287,7 +287,7 @@ private NodeEngineShutdownReason HandleShutdown(out Exception exception) try { // Clean up the engine - if (null != _buildRequestEngine && _buildRequestEngine.Status != BuildRequestEngineStatus.Uninitialized) + if (_buildRequestEngine != null && _buildRequestEngine.Status != BuildRequestEngineStatus.Uninitialized) { _buildRequestEngine.CleanupForBuild(); } @@ -338,7 +338,7 @@ private NodeEngineShutdownReason HandleShutdown(out Exception exception) exception = _shutdownException; - if (null != _loggingContext) + if (_loggingContext != null) { _loggingContext.LoggingService.OnLoggingThreadException -= OnLoggingThreadException; _loggingContext = null; diff --git a/src/Build/BackEnd/Node/OutOfProcNode.cs b/src/Build/BackEnd/Node/OutOfProcNode.cs index 4d170a3853c..0ae529953d0 100644 --- a/src/Build/BackEnd/Node/OutOfProcNode.cs +++ b/src/Build/BackEnd/Node/OutOfProcNode.cs @@ -424,7 +424,7 @@ private NodeEngineShutdownReason HandleShutdown(out Exception exception) CommunicationsUtilities.Trace("Shutting down with reason: {0}, and exception: {1}.", _shutdownReason, _shutdownException); // Clean up the engine - if (null != _buildRequestEngine && _buildRequestEngine.Status != BuildRequestEngineStatus.Uninitialized) + if (_buildRequestEngine != null && _buildRequestEngine.Status != BuildRequestEngineStatus.Uninitialized) { _buildRequestEngine.CleanupForBuild(); @@ -475,7 +475,7 @@ private NodeEngineShutdownReason HandleShutdown(out Exception exception) try { // Shut down logging, which will cause all queued logging messages to be sent. - if (null != _loggingContext && null != _loggingService) + if (_loggingContext != null && _loggingService != null) { _loggingContext.LogBuildFinished(true); ((IBuildComponent)_loggingService).ShutdownComponent(); @@ -484,7 +484,7 @@ private NodeEngineShutdownReason HandleShutdown(out Exception exception) finally { // Shut down logging, which will cause all queued logging messages to be sent. - if (null != _loggingContext && null != _loggingService) + if (_loggingContext != null && _loggingService != null) { _loggingContext.LoggingService.OnLoggingThreadException -= OnLoggingThreadException; _loggingContext = null; diff --git a/src/Build/BackEnd/Shared/BuildResult.cs b/src/Build/BackEnd/Shared/BuildResult.cs index ec0d6b998c9..b5bf9d3706d 100644 --- a/src/Build/BackEnd/Shared/BuildResult.cs +++ b/src/Build/BackEnd/Shared/BuildResult.cs @@ -334,7 +334,7 @@ public BuildResultCode OverallResult { get { - if (null != _requestException || _circularDependency || !_baseOverallResult) + if (_requestException != null || _circularDependency || !_baseOverallResult) { return BuildResultCode.Failure; } diff --git a/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs b/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs index 27ad473350a..2a98b2fdf32 100644 --- a/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs +++ b/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs @@ -294,7 +294,7 @@ bool ITaskExecutionHost.InitializeForBatch(TaskLoggingContext loggingContext, It // here. Instead, NDP will try to Load (not LoadFrom!) the task assembly into our AppDomain, and since // we originally used LoadFrom, it will fail miserably not knowing where to find it. // We need to temporarily subscribe to the AppDomain.AssemblyResolve event to fix it. - if (null == _resolver) + if (_resolver == null) { _resolver = new TaskEngineAssemblyResolver(); _resolver.Initialize(_taskFactoryWrapper.TaskFactoryLoadedType.Assembly.AssemblyFile); @@ -865,19 +865,19 @@ private TaskFactoryWrapper FindTaskInRegistry(IDictionary taskId if (!_intrinsicTasks.TryGetValue(_taskName, out TaskFactoryWrapper returnClass)) { returnClass = _projectInstance.TaskRegistry.GetRegisteredTask(_taskName, null, taskIdentityParameters, true /* exact match */, _targetLoggingContext, _taskLocation); - if (null == returnClass) + if (returnClass == null) { returnClass = _projectInstance.TaskRegistry.GetRegisteredTask(_taskName, null, taskIdentityParameters, false /* fuzzy match */, _targetLoggingContext, _taskLocation); - if (null == returnClass) + if (returnClass == null) { returnClass = _projectInstance.TaskRegistry.GetRegisteredTask(_taskName, null, null, true /* exact match */, _targetLoggingContext, _taskLocation); - if (null == returnClass) + if (returnClass == null) { returnClass = _projectInstance.TaskRegistry.GetRegisteredTask(_taskName, null, null, false /* fuzzy match */, _targetLoggingContext, _taskLocation); - if (null == returnClass) + if (returnClass == null) { _targetLoggingContext.LogError ( diff --git a/src/Build/Collections/CopyOnWritePropertyDictionary.cs b/src/Build/Collections/CopyOnWritePropertyDictionary.cs index 68f6cf3eaef..67ab4344b9a 100644 --- a/src/Build/Collections/CopyOnWritePropertyDictionary.cs +++ b/src/Build/Collections/CopyOnWritePropertyDictionary.cs @@ -251,7 +251,7 @@ IEnumerator IEnumerable.GetEnumerator() /// True if they are equivalent, false otherwise. public bool Equals(CopyOnWritePropertyDictionary other) { - if (null == other) + if (other == null) { return false; } diff --git a/src/Build/Collections/PropertyDictionary.cs b/src/Build/Collections/PropertyDictionary.cs index f9d871cc8f9..e3c17b24fae 100644 --- a/src/Build/Collections/PropertyDictionary.cs +++ b/src/Build/Collections/PropertyDictionary.cs @@ -264,7 +264,7 @@ IEnumerator IEnumerable.GetEnumerator() /// True if they are equivalent, false otherwise. public bool Equals(PropertyDictionary other) { - if (null == other) + if (other == null) { return false; } diff --git a/src/Build/Definition/ProjectCollection.cs b/src/Build/Definition/ProjectCollection.cs index 4b9c602b48b..8869625cae4 100644 --- a/src/Build/Definition/ProjectCollection.cs +++ b/src/Build/Definition/ProjectCollection.cs @@ -875,11 +875,11 @@ internal PropertyDictionary EnvironmentProperties // This is only done once, when the project collection is created. Any subsequent // environment changes will be ignored. Child nodes will be passed this set // of properties in their build parameters. - if (null == _environmentProperties) + if (_environmentProperties == null) { using (_locker.EnterWriteLock()) { - if (null == _environmentProperties) + if (_environmentProperties == null) { _environmentProperties = Utilities.GetEnvironmentProperties(); } diff --git a/src/Build/Definition/ProjectItem.cs b/src/Build/Definition/ProjectItem.cs index dc2d645a580..40b7b40eed9 100644 --- a/src/Build/Definition/ProjectItem.cs +++ b/src/Build/Definition/ProjectItem.cs @@ -344,7 +344,7 @@ internal ICollection MetadataCollection } // Finally any direct metadata win. - if (null != _directMetadata) + if (_directMetadata != null) { foreach (ProjectMetadata metadatum in _directMetadata) { @@ -452,7 +452,7 @@ public bool HasMetadata(string name) } ProjectMetadata metadatum = GetItemDefinitionMetadata(name); - if (null != metadatum) + if (metadatum != null) { return true; } @@ -488,13 +488,13 @@ string IItem.GetMetadataValueEscaped(string name) { ProjectMetadata metadatum = GetItemDefinitionMetadata(name); - if (null != metadatum && Expander.ExpressionMayContainExpandableExpressions(metadatum.EvaluatedValueEscaped)) + if (metadatum != null && Expander.ExpressionMayContainExpandableExpressions(metadatum.EvaluatedValueEscaped)) { Expander expander = new Expander(null, null, new BuiltInMetadataTable(this), FileSystems.Default); value = expander.ExpandIntoStringLeaveEscaped(metadatum.EvaluatedValueEscaped, ExpanderOptions.ExpandBuiltInMetadata, metadatum.Location); } - else if (null != metadatum) + else if (metadatum != null) { return metadatum.EvaluatedValueEscaped; } diff --git a/src/Build/Definition/ProjectProperty.cs b/src/Build/Definition/ProjectProperty.cs index 86006ce707a..a8e6b32e4a3 100644 --- a/src/Build/Definition/ProjectProperty.cs +++ b/src/Build/Definition/ProjectProperty.cs @@ -218,7 +218,7 @@ bool IEquatable.Equals(ProjectProperty other) return true; } - if (null == other) + if (other == null) { return false; } diff --git a/src/Build/Definition/Toolset.cs b/src/Build/Definition/Toolset.cs index d4319af557f..fc08972debb 100644 --- a/src/Build/Definition/Toolset.cs +++ b/src/Build/Definition/Toolset.cs @@ -253,7 +253,7 @@ public Toolset(string toolsVersion, string toolsPath, IDictionary(); - if (null != buildProperties) + if (buildProperties != null) { foreach (KeyValuePair keyValuePair in buildProperties) { @@ -701,7 +701,7 @@ internal static string[] GetTaskFiles(DirectoryGetFiles getFiles, ILoggingServic try { - if (null != getFiles) + if (getFiles != null) { defaultTasksFiles = getFiles(searchPath, taskPattern); } @@ -997,7 +997,7 @@ private void RegisterOverrideTasks(ILoggingService loggingServices, BuildEventCo { if (Path.IsPathRooted(_overrideTasksPath)) { - if (null != _directoryExists) + if (_directoryExists != null) { overrideDirectoryExists = _directoryExists(_overrideTasksPath); } @@ -1063,7 +1063,7 @@ private void LoadAndRegisterFromTasksFile(string[] defaultTaskFiles, ILoggingSer { ProjectUsingTaskElement usingTask = elementXml as ProjectUsingTaskElement; - if (null == usingTask) + if (usingTask == null) { ProjectErrorUtilities.ThrowInvalidProject ( diff --git a/src/Build/Definition/ToolsetConfigurationReader.cs b/src/Build/Definition/ToolsetConfigurationReader.cs index 8f7e7744551..9023f575257 100644 --- a/src/Build/Definition/ToolsetConfigurationReader.cs +++ b/src/Build/Definition/ToolsetConfigurationReader.cs @@ -119,7 +119,7 @@ private ToolsetConfigurationSection ConfigurationSection { get { - if (null == _configurationSection && !_configurationReadAttempted) + if (_configurationSection == null && !_configurationReadAttempted) { try { diff --git a/src/Build/Evaluation/Conditionals/Parser.cs b/src/Build/Evaluation/Conditionals/Parser.cs index 3255b2b6d8a..ac231b18964 100644 --- a/src/Build/Evaluation/Conditionals/Parser.cs +++ b/src/Build/Evaluation/Conditionals/Parser.cs @@ -174,7 +174,7 @@ private GenericExpressionNode ExprPrime(string expression, GenericExpressionNode private GenericExpressionNode BooleanTerm(string expression) { GenericExpressionNode node = RelationalExpr(expression); - if (null == node) + if (node == null) { errorPosition = _lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); @@ -196,7 +196,7 @@ private GenericExpressionNode BooleanTermPrime(string expression, GenericExpress else if (Same(expression, Token.TokenType.And)) { GenericExpressionNode rhs = RelationalExpr(expression); - if (null == rhs) + if (rhs == null) { errorPosition = _lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); @@ -218,7 +218,7 @@ private GenericExpressionNode RelationalExpr(string expression) { { GenericExpressionNode lhs = Factor(expression); - if (null == lhs) + if (lhs == null) { errorPosition = _lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); @@ -382,7 +382,7 @@ private bool Same(string expression, Token.TokenType token) if (!_lexer.Advance()) { errorPosition = _lexer.GetErrorPosition(); - if (null != _lexer.UnexpectedlyFound) + if (_lexer.UnexpectedlyFound != null) { ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, _lexer.GetErrorResource(), expression, errorPosition, _lexer.UnexpectedlyFound); } diff --git a/src/Build/Evaluation/Expander.cs b/src/Build/Evaluation/Expander.cs index cf6f39fac6c..4322d3fcaa2 100644 --- a/src/Build/Evaluation/Expander.cs +++ b/src/Build/Evaluation/Expander.cs @@ -1559,7 +1559,7 @@ private static string ExpandRegistryValue(string registryExpression, IElementLoc object valueFromRegistry = Registry.GetValue(registryKeyName, valueName, null /* default if key or value name is not found */); - if (null != valueFromRegistry) + if (valueFromRegistry != null) { // Convert the result to a string that is reasonable for MSBuild result = ConvertToString(valueFromRegistry); diff --git a/src/Build/Instance/ProjectInstance.cs b/src/Build/Instance/ProjectInstance.cs index 8c268c88cc5..f6de1df07f3 100644 --- a/src/Build/Instance/ProjectInstance.cs +++ b/src/Build/Instance/ProjectInstance.cs @@ -2215,7 +2215,7 @@ internal bool Build(string[] targets, IEnumerable loggers, IEnumerable< { VerifyThrowNotImmutable(); - if (null == targets) + if (targets == null) { targets = Array.Empty(); } diff --git a/src/Build/Instance/ProjectItemInstance.cs b/src/Build/Instance/ProjectItemInstance.cs index 247b999052e..716439edbf7 100644 --- a/src/Build/Instance/ProjectItemInstance.cs +++ b/src/Build/Instance/ProjectItemInstance.cs @@ -1253,14 +1253,14 @@ public string GetMetadataEscaped(string metadataName) metadatum = GetItemDefinitionMetadata(metadataName); - if (null != metadatum && Expander.ExpressionMayContainExpandableExpressions(metadatum.EvaluatedValueEscaped)) + if (metadatum != null && Expander.ExpressionMayContainExpandableExpressions(metadatum.EvaluatedValueEscaped)) { Expander expander = new Expander(null, null, new BuiltInMetadataTable(null, this), FileSystems.Default); // We don't have a location to use, but this is very unlikely to error return expander.ExpandIntoStringLeaveEscaped(metadatum.EvaluatedValueEscaped, ExpanderOptions.ExpandBuiltInMetadata, ElementLocation.EmptyLocation); } - else if (null != metadatum) + else if (metadatum != null) { return metadatum.EvaluatedValueEscaped; } diff --git a/src/Build/Instance/TaskRegistry.cs b/src/Build/Instance/TaskRegistry.cs index 0886986ce08..ef40362e4eb 100644 --- a/src/Build/Instance/TaskRegistry.cs +++ b/src/Build/Instance/TaskRegistry.cs @@ -198,7 +198,7 @@ internal IDictionary> TaskReg { get { - if (null == _taskRegistrations) + if (_taskRegistrations == null) { _taskRegistrations = CreateRegisteredTaskDictionary(); } diff --git a/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs b/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs index fd92582d161..755391e0e38 100644 --- a/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs +++ b/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs @@ -530,12 +530,12 @@ public override void ProjectStartedHandler(object sender, ProjectStartedEventArg { DisplayDeferredProjectStartedEvent(e.BuildEventContext); } - if (null != e.Properties) + if (e.Properties != null) { WriteProperties(e, e.Properties); } - if (null != e.Items) + if (e.Items != null) { WriteItems(e, e.Items); } diff --git a/src/Build/Logging/SerialConsoleLogger.cs b/src/Build/Logging/SerialConsoleLogger.cs index 31a0cd14deb..1f38a87c5e8 100644 --- a/src/Build/Logging/SerialConsoleLogger.cs +++ b/src/Build/Logging/SerialConsoleLogger.cs @@ -265,13 +265,13 @@ public override void ProjectStartedHandler(object sender, ProjectStartedEventArg if (Verbosity == LoggerVerbosity.Diagnostic && showItemAndPropertyList) { - if (null != e.Properties) + if (e.Properties != null) { var propertyList = ExtractPropertyList(e.Properties); WriteProperties(propertyList); } - if (null != e.Items) + if (e.Items != null) { SortedList itemList = ExtractItemList(e.Items); WriteItems(itemList); diff --git a/src/Build/Utilities/RegistryKeyWrapper.cs b/src/Build/Utilities/RegistryKeyWrapper.cs index 6aefdb6e990..5db9a22e37c 100644 --- a/src/Build/Utilities/RegistryKeyWrapper.cs +++ b/src/Build/Utilities/RegistryKeyWrapper.cs @@ -202,7 +202,7 @@ public virtual RegistryKeyWrapper OpenSubKey(string name) /// public virtual bool Exists() { - return null != WrappedKey; + return WrappedKey != null; } /// diff --git a/src/Deprecated/Conversion/AdditionalOptionsParser.cs b/src/Deprecated/Conversion/AdditionalOptionsParser.cs index 6edd700bbd5..1695918ddb2 100644 --- a/src/Deprecated/Conversion/AdditionalOptionsParser.cs +++ b/src/Deprecated/Conversion/AdditionalOptionsParser.cs @@ -208,7 +208,7 @@ ProjectPropertyGroupElement configPropertyGroup ) { // Trivial case - if (null == additionalOptionsValue) + if (additionalOptionsValue == null) { return; } @@ -300,7 +300,7 @@ private bool ExtractSwitchInfo(CompSwitchInfo compSwitchInfo, string compSwitch) } } // No no... we arent dealing with the correct switchInfo - if (null == matchedID) + if (matchedID == null) { return false; } @@ -325,7 +325,7 @@ private bool ExtractSwitchInfo(CompSwitchInfo compSwitchInfo, string compSwitch) switchVal = false; } } - if (null != switchVal) + if (switchVal != null) { compSwitchInfo.SwitchValue = switchVal; } @@ -340,7 +340,7 @@ private bool ExtractSwitchInfo(CompSwitchInfo compSwitchInfo, string compSwitch) { switchVal = compSwitch.Substring(matchedID.Length); } - if (null != switchVal) + if (switchVal != null) { compSwitchInfo.SwitchValue = switchVal; } @@ -352,7 +352,7 @@ private bool ExtractSwitchInfo(CompSwitchInfo compSwitchInfo, string compSwitch) case SwitchValueType.SVT_MultiString: Debug.Assert( - null != compSwitchInfo.SwitchValue, + compSwitchInfo.SwitchValue != null, "Non null switch value expected for a multistring switch: " + matchedID ); @@ -360,7 +360,7 @@ private bool ExtractSwitchInfo(CompSwitchInfo compSwitchInfo, string compSwitch) { switchVal = compSwitch.Substring(matchedID.Length); } - if (null != switchVal) + if (switchVal != null) { ((StringBuilder)(compSwitchInfo.SwitchValue)).Append(switchVal); ((StringBuilder)(compSwitchInfo.SwitchValue)).Append(";"); @@ -398,7 +398,7 @@ private void PopulatePropertyGroup(ProjectPropertyGroupElement configPropertyGro switch (compSwitchInfo.SwitchValueType) { case SwitchValueType.SVT_Boolean: - if (null != compSwitchInfo.SwitchValue) + if (compSwitchInfo.SwitchValue != null) { configPropertyGroup.AddProperty( propertyName, @@ -408,7 +408,7 @@ private void PopulatePropertyGroup(ProjectPropertyGroupElement configPropertyGro break; case SwitchValueType.SVT_String: - if (null != compSwitchInfo.SwitchValue) + if (compSwitchInfo.SwitchValue != null) { configPropertyGroup.AddProperty( propertyName, @@ -418,7 +418,7 @@ private void PopulatePropertyGroup(ProjectPropertyGroupElement configPropertyGro break; case SwitchValueType.SVT_MultiString: - Debug.Assert(null != compSwitchInfo.SwitchValue, "Expected non null value for multistring switch"); + Debug.Assert(compSwitchInfo.SwitchValue != null, "Expected non null value for multistring switch"); if (0 != ((StringBuilder)(compSwitchInfo.SwitchValue)).Length) { configPropertyGroup.AddProperty( diff --git a/src/Deprecated/Engine/Conditionals/Parser.cs b/src/Deprecated/Engine/Conditionals/Parser.cs index f42eecf7285..685b1e08d1c 100644 --- a/src/Deprecated/Engine/Conditionals/Parser.cs +++ b/src/Deprecated/Engine/Conditionals/Parser.cs @@ -176,7 +176,7 @@ private GenericExpressionNode ExprPrime(string expression, GenericExpressionNode private GenericExpressionNode BooleanTerm(string expression) { GenericExpressionNode node = RelationalExpr(expression); - if (null == node) + if (node == null) { errorPosition = lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, this.conditionAttribute, "UnexpectedTokenInCondition", expression, lexer.IsNextString(), errorPosition); @@ -198,7 +198,7 @@ private GenericExpressionNode BooleanTermPrime(string expression, GenericExpress else if (Same(expression, Token.TokenType.And)) { GenericExpressionNode rhs = RelationalExpr(expression); - if (null == rhs) + if (rhs == null) { errorPosition = lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, this.conditionAttribute, "UnexpectedTokenInCondition", expression, lexer.IsNextString(), errorPosition); @@ -220,7 +220,7 @@ private GenericExpressionNode RelationalExpr(string expression) { { GenericExpressionNode lhs = Factor(expression); - if (null == lhs) + if (lhs == null) { errorPosition = lexer.GetErrorPosition(); ProjectErrorUtilities.VerifyThrowInvalidProject(false, this.conditionAttribute, "UnexpectedTokenInCondition", expression, lexer.IsNextString(), errorPosition); @@ -382,7 +382,7 @@ private bool Same(string expression, Token.TokenType token) if (!lexer.Advance()) { errorPosition = lexer.GetErrorPosition(); - if (null != lexer.UnexpectedlyFound) + if (lexer.UnexpectedlyFound != null) { ProjectErrorUtilities.VerifyThrowInvalidProject(false, this.conditionAttribute, lexer.GetErrorResource(), expression, errorPosition, lexer.UnexpectedlyFound); } diff --git a/src/Deprecated/Engine/Engine/BatchingEngine.cs b/src/Deprecated/Engine/Engine/BatchingEngine.cs index f7665e917bc..e904d7978df 100644 --- a/src/Deprecated/Engine/Engine/BatchingEngine.cs +++ b/src/Deprecated/Engine/Engine/BatchingEngine.cs @@ -337,7 +337,7 @@ Dictionary consumedMetadataReferences // If we didn't find a bucket that matches this item, create a new one, adding // this item to the bucket. - if (null == matchingBucket) + if (matchingBucket == null) { matchingBucket = new ItemBucket(itemListsToBeBatched.Keys, itemMetadataValues, lookup, buckets.Count); diff --git a/src/Deprecated/Engine/Engine/BuildResult.cs b/src/Deprecated/Engine/Engine/BuildResult.cs index a76383ad0e9..2e09508f9b9 100644 --- a/src/Deprecated/Engine/Engine/BuildResult.cs +++ b/src/Deprecated/Engine/Engine/BuildResult.cs @@ -232,7 +232,7 @@ internal int TaskTime internal void ConvertToTaskItems() { // If outputsByTarget was null then we dont have to re-create anything as nothing was passed over - if (null != outputsByTarget) + if (outputsByTarget != null) { string[] keys = new string[outputsByTarget.Count]; outputsByTarget.Keys.CopyTo(keys, 0); diff --git a/src/Deprecated/Engine/Engine/Engine.cs b/src/Deprecated/Engine/Engine/Engine.cs index 17c9eebaee8..7b90112b51b 100644 --- a/src/Deprecated/Engine/Engine/Engine.cs +++ b/src/Deprecated/Engine/Engine/Engine.cs @@ -2080,7 +2080,7 @@ private void StartRootProjectBuild(BuildRequest buildRequest, Project project) // There should be no projects in the ProjectManager with the same full path, global properties and tools version // as any of the loaded projects. If there are, something went badly awry, because // we were supposed to have deleted them after the last build. - ErrorUtilities.VerifyThrow(null == this.cacheOfBuildingProjects.GetProject(loadedProject.FullFileName, loadedProject.GlobalProperties, loadedProject.ToolsVersion), + ErrorUtilities.VerifyThrow(this.cacheOfBuildingProjects.GetProject(loadedProject.FullFileName, loadedProject.GlobalProperties, loadedProject.ToolsVersion) == null, "Project shouldn't be in ProjectManager already."); // Add the loaded project to the list of projects being built, just diff --git a/src/Deprecated/Engine/Engine/Expander.cs b/src/Deprecated/Engine/Engine/Expander.cs index 1b383e90847..0b277a679bf 100644 --- a/src/Deprecated/Engine/Engine/Expander.cs +++ b/src/Deprecated/Engine/Engine/Expander.cs @@ -906,7 +906,7 @@ private string ExpandRegistryValue(string registryExpression, XmlNode node) object valueFromRegistry = Registry.GetValue(registryKeyName, valueName, null /* default if key or value name is not found */); - if (null != valueFromRegistry) + if (valueFromRegistry != null) { // Convert the result to a string that is reasonable for MSBuild result = ConvertToString(valueFromRegistry); diff --git a/src/Deprecated/Engine/Engine/Project.cs b/src/Deprecated/Engine/Engine/Project.cs index 0fd05ada9a1..da38c4e5831 100644 --- a/src/Deprecated/Engine/Engine/Project.cs +++ b/src/Deprecated/Engine/Engine/Project.cs @@ -426,7 +426,7 @@ string toolsVersion // If the toolsVersion is null, we will use the value specified in // the Project element's ToolsVersion attribute, or else the default if that // attribute is not present. - if (null != toolsVersion) + if (toolsVersion != null) { this.ToolsVersion = toolsVersion; } @@ -3973,7 +3973,7 @@ bool importedProject case XMakeElements.projectExtensions: if (!importedProject) { - ProjectErrorUtilities.VerifyThrowInvalidProject(null == this.projectExtensionsNode, childElement, + ProjectErrorUtilities.VerifyThrowInvalidProject(this.projectExtensionsNode == null, childElement, "DuplicateProjectExtensions"); this.projectExtensionsNode = childElement; diff --git a/src/Deprecated/Engine/Engine/RegistryKeyWrapper.cs b/src/Deprecated/Engine/Engine/RegistryKeyWrapper.cs index 1f2265708cb..e6e4d42be8e 100644 --- a/src/Deprecated/Engine/Engine/RegistryKeyWrapper.cs +++ b/src/Deprecated/Engine/Engine/RegistryKeyWrapper.cs @@ -179,7 +179,7 @@ public virtual RegistryKeyWrapper OpenSubKey(string name) /// public virtual bool Exists() { - return null != WrappedKey; + return WrappedKey != null; } /// diff --git a/src/Deprecated/Engine/Engine/TaskEngine.cs b/src/Deprecated/Engine/Engine/TaskEngine.cs index 87c4b14d9b6..50618e45403 100644 --- a/src/Deprecated/Engine/Engine/TaskEngine.cs +++ b/src/Deprecated/Engine/Engine/TaskEngine.cs @@ -203,7 +203,7 @@ private AppDomain PrepareAppDomain() // here. Instead, NDP will try to Load (not LoadFrom!) the task assembly into our AppDomain, and since // we originally used LoadFrom, it will fail miserably not knowing where to find it. // We need to temporarily subscribe to the AppDomain.AssemblyResolve event to fix it. - if (null == resolver) + if (resolver == null) { resolver = new TaskEngineAssemblyResolver(); resolver.Initialize(TaskClass.Assembly.AssemblyFile); diff --git a/src/Deprecated/Engine/Engine/ToolsetConfigurationReader.cs b/src/Deprecated/Engine/Engine/ToolsetConfigurationReader.cs index c9408a24eff..4b129cf256b 100644 --- a/src/Deprecated/Engine/Engine/ToolsetConfigurationReader.cs +++ b/src/Deprecated/Engine/Engine/ToolsetConfigurationReader.cs @@ -131,7 +131,7 @@ private ToolsetConfigurationSection ConfigurationSection { get { - if (null == configurationSection && !configurationReadAttempted) + if (configurationSection == null && !configurationReadAttempted) { try { @@ -148,7 +148,7 @@ private ToolsetConfigurationSection ConfigurationSection // If section definition is not present and section is also not present, this value is null // If the section definition is not present and section is present, then this value is null - if (null != configuration) + if (configuration != null) { configurationSection = configuration.GetSection("msbuildToolsets") as ToolsetConfigurationSection; } diff --git a/src/Deprecated/Engine/Logging/BaseConsoleLogger.cs b/src/Deprecated/Engine/Logging/BaseConsoleLogger.cs index da82e751c59..f7fe92fa404 100644 --- a/src/Deprecated/Engine/Logging/BaseConsoleLogger.cs +++ b/src/Deprecated/Engine/Logging/BaseConsoleLogger.cs @@ -173,7 +173,7 @@ public int Compare(Object a, Object b) internal string IndentString(string s, int indent) { // It's possible the event has a null message - if (null == s) + if (s == null) { s = String.Empty; } diff --git a/src/Deprecated/Engine/Logging/ParallelLogger/ParallelConsoleLogger.cs b/src/Deprecated/Engine/Logging/ParallelLogger/ParallelConsoleLogger.cs index 254a37d2b70..4aa273db8c9 100644 --- a/src/Deprecated/Engine/Logging/ParallelLogger/ParallelConsoleLogger.cs +++ b/src/Deprecated/Engine/Logging/ParallelLogger/ParallelConsoleLogger.cs @@ -499,12 +499,12 @@ public override void ProjectStartedHandler(object sender, ProjectStartedEventArg { DisplayDeferredProjectStartedEvent(e.BuildEventContext); } - if (null != e.Properties) + if (e.Properties != null) { WriteProperties(e, e.Properties); } - if (null != e.Items) + if (e.Items != null) { WriteItems(e, e.Items); } diff --git a/src/Deprecated/Engine/Logging/SerialConsoleLogger.cs b/src/Deprecated/Engine/Logging/SerialConsoleLogger.cs index e31ed6ddc4b..751e4b0717b 100644 --- a/src/Deprecated/Engine/Logging/SerialConsoleLogger.cs +++ b/src/Deprecated/Engine/Logging/SerialConsoleLogger.cs @@ -267,13 +267,13 @@ public override void ProjectStartedHandler(object sender, ProjectStartedEventArg if (Verbosity == LoggerVerbosity.Diagnostic && showItemAndPropertyList) { - if (null != e.Properties) + if (e.Properties != null) { ArrayList propertyList = ExtractPropertyList(e.Properties); WriteProperties(propertyList); } - if (null != e.Items) + if (e.Items != null) { SortedList itemList = ExtractItemList(e.Items); WriteItems(itemList); diff --git a/src/Deprecated/Engine/Shared/EventArgsFormatting.cs b/src/Deprecated/Engine/Shared/EventArgsFormatting.cs index 98ef3cf76bb..9a9623e2303 100644 --- a/src/Deprecated/Engine/Shared/EventArgsFormatting.cs +++ b/src/Deprecated/Engine/Shared/EventArgsFormatting.cs @@ -207,7 +207,7 @@ int threadId } // A null message is allowed and is to be treated as a blank line. - if (null == message) + if (message == null) { message = String.Empty; } diff --git a/src/Deprecated/Engine/Shared/FrameworkLocationHelper.cs b/src/Deprecated/Engine/Shared/FrameworkLocationHelper.cs index fb7f123ac0f..156bc7a8437 100644 --- a/src/Deprecated/Engine/Shared/FrameworkLocationHelper.cs +++ b/src/Deprecated/Engine/Shared/FrameworkLocationHelper.cs @@ -429,14 +429,14 @@ string registryKeyName .LocalMachine .OpenSubKey(registryBaseKeyName); - if (null == baseKey) + if (baseKey == null) { return null; } object keyValue = baseKey.GetValue(registryKeyName); - if (null == keyValue) + if (keyValue == null) { return null; } diff --git a/src/Deprecated/Engine/Solution/VCWrapperProject.cs b/src/Deprecated/Engine/Solution/VCWrapperProject.cs index d3f285613c1..fe252f31141 100644 --- a/src/Deprecated/Engine/Solution/VCWrapperProject.cs +++ b/src/Deprecated/Engine/Solution/VCWrapperProject.cs @@ -265,7 +265,7 @@ private static string GenerateFullPathToTool(RegistryView registryView) string location = TryLocationFromRegistry(baseKey, vs9RegKey, vs9InstallDirValueName, vs9RelativePathToVCBuildLayouts, vs9RelativePathToVCBuildBatch); - if (null != location) + if (location != null) { return location; } @@ -274,7 +274,7 @@ private static string GenerateFullPathToTool(RegistryView registryView) location = TryLocationFromRegistry(baseKey, vc9RegKey, vc9InstallDirValueName, vc9RelativePathToVCBuildLayouts, vc9RelativePathToVCBuildBatch); - if (null != location) + if (location != null) { return location; } @@ -325,7 +325,7 @@ private static string TryLocationFromRegistry(RegistryKey root, string subKeyNam // if not found in layouts location, try the alternate dir if any, // which contains vcbuild for batch installs - if (null != relativePathFromValueOnBatch) + if (relativePathFromValueOnBatch != null) { vcBuildPath = Path.Combine(rootDir, relativePathFromValueOnBatch); if (File.Exists(vcBuildPath)) diff --git a/src/Framework/XamlTypes/Rule.cs b/src/Framework/XamlTypes/Rule.cs index caac61eec3a..5893a27acf7 100644 --- a/src/Framework/XamlTypes/Rule.cs +++ b/src/Framework/XamlTypes/Rule.cs @@ -422,7 +422,7 @@ public List EvaluatedCategories // check-lock-check pattern DOESN'T work here because two fields get initialized within this lazy initialization method. lock (_syncObject) { - if (null == _evaluatedCategories) + if (_evaluatedCategories == null) { CreateCategoryNamePropertyListMap(); } @@ -453,7 +453,7 @@ public OrderedDictionary GetPropertiesByCategory() // check-lock-check pattern DOESN'T work here because two fields get initialized within this lazy initialization method. lock (_syncObject) { - if (null == _categoryNamePropertyListMap) + if (_categoryNamePropertyListMap == null) { CreateCategoryNamePropertyListMap(); } @@ -471,7 +471,7 @@ public IList GetPropertiesInCategory(string categoryName) // check-lock-check pattern DOESN'T work here because two fields get initialized within this lazy initialization method. lock (_syncObject) { - if (null == _categoryNamePropertyListMap) + if (_categoryNamePropertyListMap == null) { CreateCategoryNamePropertyListMap(); } @@ -557,7 +557,7 @@ public IEnumerable GetSchemaObjects(Type type) /// private void Initialize() { - if (null != Properties) + if (Properties != null) { // Set parent pointers on all containing properties. foreach (BaseProperty property in Properties) @@ -577,7 +577,7 @@ private void CreateCategoryNamePropertyListMap() { _evaluatedCategories = new List(); - if (null != Categories) + if (Categories != null) { _evaluatedCategories.AddRange(Categories); } diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index c86b15d73dc..749f3a2b681 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -752,7 +752,7 @@ string [] commandLine catch (LoggerException e) { // display the localized message from the outer exception in canonical format - if (null != e.ErrorCode) + if (e.ErrorCode != null) { // Brief prefix to indicate that it's a logger failure, and provide the "error" indication Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("LoggerFailurePrefixNoErrorCode", e.ErrorCode, e.Message)); @@ -764,7 +764,7 @@ string [] commandLine Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("LoggerFailurePrefixWithErrorCode", e.Message)); } - if (null != e.InnerException) + if (e.InnerException != null) { // write out exception details -- don't bother triggering Watson, because most of these exceptions will be coming // from buggy loggers written by users diff --git a/src/Shared/AssemblyFolders/AssemblyFoldersEx.cs b/src/Shared/AssemblyFolders/AssemblyFoldersEx.cs index cc6b96b05ce..da266d8220e 100644 --- a/src/Shared/AssemblyFolders/AssemblyFoldersEx.cs +++ b/src/Shared/AssemblyFolders/AssemblyFoldersEx.cs @@ -261,7 +261,7 @@ OpenBaseKey openBaseKey string directoryName = getRegistrySubKeyDefaultValue(baseKey, directoryKey.RegistryKey); - if (null != directoryName) + if (directoryName != null) { _uniqueDirectoryPaths.Add(directoryName); _directoryNames.Add(new AssemblyFoldersExInfo(hive, view, directoryKey.RegistryKey, directoryName, directoryKey.TargetFrameworkVersion)); diff --git a/src/Shared/EventArgsFormatting.cs b/src/Shared/EventArgsFormatting.cs index a3556a8cc07..f23ffcf69f1 100644 --- a/src/Shared/EventArgsFormatting.cs +++ b/src/Shared/EventArgsFormatting.cs @@ -320,7 +320,7 @@ string logOutputProperties } // A null message is allowed and is to be treated as a blank line. - if (null == message) + if (message == null) { message = String.Empty; } diff --git a/src/Shared/NodeEndpointOutOfProcBase.cs b/src/Shared/NodeEndpointOutOfProcBase.cs index 88b6cb2966b..d634e02563c 100644 --- a/src/Shared/NodeEndpointOutOfProcBase.cs +++ b/src/Shared/NodeEndpointOutOfProcBase.cs @@ -292,9 +292,8 @@ private void InternalDisconnect() private void EnqueuePacket(INodePacket packet) { ErrorUtilities.VerifyThrowArgumentNull(packet, nameof(packet)); - ErrorUtilities.VerifyThrow(null != _packetQueue, "packetQueue is null"); - ErrorUtilities.VerifyThrow(null != _packetAvailable, "packetAvailable is null"); - + ErrorUtilities.VerifyThrow(_packetQueue != null, "packetQueue is null"); + ErrorUtilities.VerifyThrow(_packetAvailable != null, "packetAvailable is null"); _packetQueue.Enqueue(packet); _packetAvailable.Set(); } diff --git a/src/Shared/TaskLoggingHelper.cs b/src/Shared/TaskLoggingHelper.cs index fe6d67f1c8c..7e27f0e68a2 100644 --- a/src/Shared/TaskLoggingHelper.cs +++ b/src/Shared/TaskLoggingHelper.cs @@ -1313,7 +1313,7 @@ public bool LogMessageFromText(string lineOfText, MessageImportance messageImpor bool isError = false; CanonicalError.Parts messageParts = CanonicalError.Parse(lineOfText); - if (null == messageParts) + if (messageParts == null) { // Line was not recognized as a canonical error. Log it as a message. LogMessage(messageImportance, lineOfText); diff --git a/src/Shared/ToolsetElement.cs b/src/Shared/ToolsetElement.cs index e08128daad5..4f8451872ab 100644 --- a/src/Shared/ToolsetElement.cs +++ b/src/Shared/ToolsetElement.cs @@ -36,7 +36,7 @@ internal static ToolsetConfigurationSection ReadToolsetConfigurationSection(Conf // If section definition is present and section is not present, this value is not null // If section definition is not present and section is also not present, this value is null // If the section definition is not present and section is present, then this value is null - if (null != configuration) + if (configuration != null) { ConfigurationSection msbuildSection = configuration.GetSection("msbuildToolsets"); configurationSection = msbuildSection as ToolsetConfigurationSection; diff --git a/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs b/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs index 95ffcfdd9b9..655a31544a6 100644 --- a/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs +++ b/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs @@ -396,11 +396,11 @@ public void ForceSomeOutOfDate() } finally { - if (null != firstResx) File.Delete(firstResx); - if (null != secondResx) File.Delete(secondResx); - if (null != cache) File.Delete(cache); - if (null != firstResx) File.Delete(Path.ChangeExtension(firstResx, ".resources")); - if (null != secondResx) File.Delete(Path.ChangeExtension(secondResx, ".resources")); + if (firstResx != null) File.Delete(firstResx); + if (secondResx != null) File.Delete(secondResx); + if (cache != null) File.Delete(cache); + if (firstResx != null) File.Delete(Path.ChangeExtension(firstResx, ".resources")); + if (secondResx != null) File.Delete(Path.ChangeExtension(secondResx, ".resources")); } } @@ -1272,10 +1272,10 @@ public void FailedResXReader() } finally { - if (null != resxFile1) File.Delete(resxFile1); - if (null != resxFile2) File.Delete(resxFile2); - if (null != resourcesFile1) File.Delete(resourcesFile1); - if (null != resourcesFile2) File.Delete(resourcesFile2); + if (resxFile1 != null) File.Delete(resxFile1); + if (resxFile2 != null) File.Delete(resxFile2); + if (resourcesFile1 != null) File.Delete(resourcesFile1); + if (resourcesFile2 != null) File.Delete(resourcesFile2); } } @@ -1332,10 +1332,10 @@ public void FailedResXReaderWithAllOutputResourcesSpecified() } finally { - if (null != resxFile1) File.Delete(resxFile1); - if (null != resxFile2) File.Delete(resxFile2); - if (null != resourcesFile1) File.Delete(resourcesFile1); - if (null != resourcesFile2) File.Delete(resourcesFile2); + if (resxFile1 != null) File.Delete(resxFile1); + if (resxFile2 != null) File.Delete(resxFile2); + if (resourcesFile1 != null) File.Delete(resourcesFile1); + if (resourcesFile2 != null) File.Delete(resourcesFile2); } } @@ -1417,8 +1417,8 @@ public void InvalidStateFile() } finally { - if (null != resxFile) File.Delete(resxFile); - if (null != resourcesFile) File.Delete(resourcesFile); + if (resxFile != null) File.Delete(resxFile); + if (resourcesFile != null) File.Delete(resourcesFile); } } @@ -2118,10 +2118,10 @@ public void StronglyTypedResourceWithMoreThanOneInputResourceFile() } finally { - if (null != resxFile) File.Delete(resxFile); - if (null != resxFile2) File.Delete(resxFile2); - if (null != resxFile) File.Delete(Path.ChangeExtension(resxFile, ".resources")); - if (null != resxFile2) File.Delete(Path.ChangeExtension(resxFile2, ".resources")); + if (resxFile != null) File.Delete(resxFile); + if (resxFile2 != null) File.Delete(resxFile2); + if (resxFile != null) File.Delete(Path.ChangeExtension(resxFile, ".resources")); + if (resxFile2 != null) File.Delete(Path.ChangeExtension(resxFile2, ".resources")); } } @@ -2266,7 +2266,7 @@ public void StronglyTypedResourceFilenameWithoutLanguage() } finally { - if (null != txtFile) File.Delete(txtFile); + if (txtFile != null) File.Delete(txtFile); } } diff --git a/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs b/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs index 4a6358c57a5..2beea1736da 100644 --- a/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs +++ b/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs @@ -1615,10 +1615,10 @@ public void FailedResXReader() } finally { - if (null != resxFile1) File.Delete(resxFile1); - if (null != resxFile2) File.Delete(resxFile2); - if (null != resourcesFile1) File.Delete(resourcesFile1); - if (null != resourcesFile2) File.Delete(resourcesFile2); + if (resxFile1 != null) File.Delete(resxFile1); + if (resxFile2 != null) File.Delete(resxFile2); + if (resourcesFile1 != null) File.Delete(resourcesFile1); + if (resourcesFile2 != null) File.Delete(resourcesFile2); } } @@ -1672,10 +1672,10 @@ public void FailedResXReaderWithAllOutputResourcesSpecified() } finally { - if (null != resxFile1) File.Delete(resxFile1); - if (null != resxFile2) File.Delete(resxFile2); - if (null != resourcesFile1) File.Delete(resourcesFile1); - if (null != resourcesFile2) File.Delete(resourcesFile2); + if (resxFile1 != null) File.Delete(resxFile1); + if (resxFile2 != null) File.Delete(resxFile2); + if (resourcesFile1 != null) File.Delete(resourcesFile1); + if (resourcesFile2 != null) File.Delete(resourcesFile2); } } @@ -1756,8 +1756,8 @@ public void InvalidStateFile() } finally { - if (null != resxFile) File.Delete(resxFile); - if (null != resourcesFile) File.Delete(resourcesFile); + if (resxFile != null) File.Delete(resxFile); + if (resourcesFile != null) File.Delete(resourcesFile); } } @@ -2486,10 +2486,10 @@ public void StronglyTypedResourceWithMoreThanOneInputResourceFile() } finally { - if (null != resxFile) File.Delete(resxFile); - if (null != resxFile2) File.Delete(resxFile2); - if (null != resxFile) File.Delete(Path.ChangeExtension(resxFile, ".resources")); - if (null != resxFile2) File.Delete(Path.ChangeExtension(resxFile2, ".resources")); + if (resxFile != null) File.Delete(resxFile); + if (resxFile2 != null) File.Delete(resxFile2); + if (resxFile != null) File.Delete(Path.ChangeExtension(resxFile, ".resources")); + if (resxFile2 != null) File.Delete(Path.ChangeExtension(resxFile2, ".resources")); } } @@ -2628,7 +2628,7 @@ public void StronglyTypedResourceFilenameWithoutLanguage() } finally { - if (null != txtFile) File.Delete(txtFile); + if (txtFile != null) File.Delete(txtFile); } } diff --git a/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs b/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs index df6dba76fed..029dc8ba6d2 100644 --- a/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs +++ b/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs @@ -2753,7 +2753,7 @@ private void PopulateSuggestedRedirects(List idealAssemblyRem List conflictVictims = reference.GetConflictVictims(); // Skip any remapping that has no conflict victims since a redirect will not help. - if (null == conflictVictims || 0 == conflictVictims.Count) + if (conflictVictims == null || 0 == conflictVictims.Count) { continue; } diff --git a/src/Tasks/CreateItem.cs b/src/Tasks/CreateItem.cs index 472f4e0c5a8..cb7bd833620 100644 --- a/src/Tasks/CreateItem.cs +++ b/src/Tasks/CreateItem.cs @@ -99,7 +99,7 @@ private List CreateOutputItems(Dictionary metadataTab ) { ITaskItem newItem = i; - if (null != metadataTable) + if (metadataTable != null) { foreach (KeyValuePair nameAndValue in metadataTable) { diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index c9b2b8fd43b..5fc96169dcf 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -834,7 +834,7 @@ public override bool Execute() this.StronglyTypedClassName = process.StronglyTypedClassName; // in case a default was chosen this.StronglyTypedFileName = process.StronglyTypedFilename; // in case a default was chosen _stronglyTypedResourceSuccessfullyCreated = process.StronglyTypedResourceSuccessfullyCreated; - if (null != process.UnsuccessfullyCreatedOutFiles) + if (process.UnsuccessfullyCreatedOutFiles != null) { foreach (string item in process.UnsuccessfullyCreatedOutFiles) { @@ -1067,7 +1067,7 @@ private bool ComputePathToResGen() { _resgenPath = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version35); - if (null == _resgenPath && ExecuteAsTool) + if (_resgenPath == null && ExecuteAsTool) { Log.LogErrorWithCodeFromResources("General.PlatformSDKFileNotFound", "resgen.exe", ToolLocationHelper.GetDotNetFrameworkSdkInstallKeyValue(TargetDotNetFrameworkVersion.Version35), @@ -1085,7 +1085,7 @@ private bool ComputePathToResGen() ExecuteAsTool); } - if (null == _resgenPath && !ExecuteAsTool) + if (_resgenPath == null && !ExecuteAsTool) { // if Resgen.exe is not installed, just use the filename _resgenPath = String.Empty; @@ -2356,7 +2356,7 @@ internal ArrayList UnsuccessfullyCreatedOutFiles { get { - if (null == _unsuccessfullyCreatedOutFiles) + if (_unsuccessfullyCreatedOutFiles == null) { _unsuccessfullyCreatedOutFiles = new ArrayList(); } diff --git a/src/Tasks/RCWForCurrentContext.cs b/src/Tasks/RCWForCurrentContext.cs index c8944fa05b1..0511c385cb1 100644 --- a/src/Tasks/RCWForCurrentContext.cs +++ b/src/Tasks/RCWForCurrentContext.cs @@ -79,7 +79,7 @@ public T RCW { get { - if (null == _rcwForCurrentCtx) + if (_rcwForCurrentCtx == null) { throw new ObjectDisposedException("RCWForCurrentCtx"); } @@ -108,7 +108,7 @@ private void CleanupComObject() { try { - if (null != _rcwForCurrentCtx && + if (_rcwForCurrentCtx != null && _shouldReleaseRCW && Marshal.IsComObject(_rcwForCurrentCtx)) { diff --git a/src/Tasks/ResolveComReference.cs b/src/Tasks/ResolveComReference.cs index 89ed55d4c40..2fd1310d355 100644 --- a/src/Tasks/ResolveComReference.cs +++ b/src/Tasks/ResolveComReference.cs @@ -490,7 +490,7 @@ private bool ComputePathToTlbImp() { _tlbimpPath = GetPathToSDKFileWithCurrentlyTargetedArchitecture("TlbImp.exe", TargetDotNetFrameworkVersion.Version35, VisualStudioVersion.VersionLatest); - if (null == _tlbimpPath && ExecuteAsTool) + if (_tlbimpPath == null && ExecuteAsTool) { Log.LogErrorWithCodeFromResources("General.PlatformSDKFileNotFound", "TlbImp.exe", ToolLocationHelper.GetDotNetFrameworkSdkInstallKeyValue(TargetDotNetFrameworkVersion.Version35, VisualStudioVersion.VersionLatest), @@ -502,7 +502,7 @@ private bool ComputePathToTlbImp() _tlbimpPath = SdkToolsPathUtility.GeneratePathToTool(SdkToolsPathUtility.FileInfoExists, TargetProcessorArchitecture, SdkToolsPath, "TlbImp.exe", Log, ExecuteAsTool); } - if (null == _tlbimpPath && !ExecuteAsTool) + if (_tlbimpPath == null && !ExecuteAsTool) { // if TlbImp.exe is not installed, just use the filename _tlbimpPath = "TlbImp.exe"; @@ -539,7 +539,7 @@ private bool ComputePathToAxImp() // We want to use the copy of AxImp corresponding to our targeted architecture if possible. _aximpPath = GetPathToSDKFileWithCurrentlyTargetedArchitecture("AxImp.exe", targetAxImpVersion, VisualStudioVersion.VersionLatest); - if (null == _aximpPath) + if (_aximpPath == null) { Log.LogErrorWithCodeFromResources("General.PlatformSDKFileNotFound", "AxImp.exe", ToolLocationHelper.GetDotNetFrameworkSdkInstallKeyValue(targetAxImpVersion, VisualStudioVersion.VersionLatest), diff --git a/src/Tasks/SdkToolsPathUtility.cs b/src/Tasks/SdkToolsPathUtility.cs index bac55b5daee..c9efaf7cde9 100644 --- a/src/Tasks/SdkToolsPathUtility.cs +++ b/src/Tasks/SdkToolsPathUtility.cs @@ -110,7 +110,7 @@ internal static string GeneratePathToTool(FileExists fileExists, string currentA // Fall back and see if we can find it with the toolsLocation helper methods. This is not optimal because // the location they are looking at is based on when the Microsoft.Build.Utilities.dll was compiled // but it is better than nothing. - if (null == pathToTool || !fileExists(pathToTool)) + if (pathToTool == null || !fileExists(pathToTool)) { pathToTool = FindSDKToolUsingToolsLocationHelper(toolName); diff --git a/src/Tasks/XamlTaskFactory/TaskParser.cs b/src/Tasks/XamlTaskFactory/TaskParser.cs index cb0e46abcb3..ad7d411177f 100644 --- a/src/Tasks/XamlTaskFactory/TaskParser.cs +++ b/src/Tasks/XamlTaskFactory/TaskParser.cs @@ -177,7 +177,7 @@ internal bool ParseXamlDocument(TextReader reader, string desiredRule) ErrorUtilities.VerifyThrowArgumentLength(desiredRule, nameof(desiredRule)); object rootObject = XamlServices.Load(reader); - if (null != rootObject) + if (rootObject != null) { XamlTypes.ProjectSchemaDefinitions schemas = rootObject as XamlTypes.ProjectSchemaDefinitions; if (schemas != null) diff --git a/src/Utilities.UnitTests/TaskLoggingHelper_Tests.cs b/src/Utilities.UnitTests/TaskLoggingHelper_Tests.cs index 9a2e54ae2bb..bf5eeb2a250 100644 --- a/src/Utilities.UnitTests/TaskLoggingHelper_Tests.cs +++ b/src/Utilities.UnitTests/TaskLoggingHelper_Tests.cs @@ -200,7 +200,7 @@ nor is this } finally { - if (null != file) File.Delete(file); + if (file != null) File.Delete(file); } } diff --git a/src/Utilities/ToolTask.cs b/src/Utilities/ToolTask.cs index 78311278ac0..93ec1767db9 100644 --- a/src/Utilities/ToolTask.cs +++ b/src/Utilities/ToolTask.cs @@ -607,7 +607,7 @@ string responseFileSwitch // Generally we won't set a working directory, and it will use the current directory string workingDirectory = GetWorkingDirectory(); - if (null != workingDirectory) + if (workingDirectory != null) { startInfo.WorkingDirectory = workingDirectory; } @@ -615,7 +615,7 @@ string responseFileSwitch // Old style environment overrides #pragma warning disable 0618 // obsolete Dictionary envOverrides = EnvironmentOverride; - if (null != envOverrides) + if (envOverrides != null) { foreach (KeyValuePair entry in envOverrides) { @@ -1453,7 +1453,7 @@ public override bool Execute() // Old style environment overrides #pragma warning disable 0618 // obsolete Dictionary envOverrides = EnvironmentOverride; - if (null != envOverrides) + if (envOverrides != null) { foreach (KeyValuePair entry in envOverrides) {