diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs index ddabf21013b..a07d1e40557 100644 --- a/src/Build/BackEnd/BuildManager/BuildManager.cs +++ b/src/Build/BackEnd/BuildManager/BuildManager.cs @@ -20,7 +20,6 @@ using Microsoft.Build.BackEnd.Logging; using Microsoft.Build.BackEnd.SdkResolution; using Microsoft.Build.Collections; -using Microsoft.Build.Construction; using Microsoft.Build.Evaluation; using Microsoft.Build.Eventing; using Microsoft.Build.Exceptions; @@ -31,7 +30,6 @@ using Microsoft.Build.Logging; using Microsoft.Build.Shared; using Microsoft.Build.Shared.Debugging; -using Microsoft.Build.Shared.FileSystem; using Microsoft.Build.Utilities; using ForwardingLoggerRecord = Microsoft.Build.Logging.ForwardingLoggerRecord; using LoggerDescription = Microsoft.Build.Logging.LoggerDescription; diff --git a/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs b/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs index 4e6e5be0145..57c0e51523e 100644 --- a/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs +++ b/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs @@ -121,7 +121,7 @@ public IDictionary> WarningsAsMessagesByProject /// public void Consume(BuildEventArgs buildEvent) { - ErrorUtilities.VerifyThrow(false, "Do not use this method for the transport sink"); + ErrorUtilities.ThrowInternalError("Do not use this method for the transport sink"); } /// diff --git a/src/Build/BackEnd/Components/Logging/EventSourceSink.cs b/src/Build/BackEnd/Components/Logging/EventSourceSink.cs index 97b7512d14e..a393d6c36a8 100644 --- a/src/Build/BackEnd/Components/Logging/EventSourceSink.cs +++ b/src/Build/BackEnd/Components/Logging/EventSourceSink.cs @@ -280,7 +280,7 @@ public void Consume(BuildEventArgs buildEvent) } else { - ErrorUtilities.VerifyThrow(false, "Unknown event args type."); + ErrorUtilities.ThrowInternalError("Unknown event args type."); } } diff --git a/src/Build/BackEnd/Components/Logging/LoggingService.cs b/src/Build/BackEnd/Components/Logging/LoggingService.cs index 19ed313b922..117f5195448 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingService.cs @@ -1417,7 +1417,7 @@ private void RouteBuildEvent(object loggingEvent) } else { - ErrorUtilities.VerifyThrow(false, "Unknown logging item in queue:" + loggingEvent.GetType().FullName); + ErrorUtilities.ThrowInternalError("Unknown logging item in queue:" + loggingEvent.GetType().FullName); } if (buildEventArgs is BuildWarningEventArgs warningEvent) diff --git a/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs b/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs index 3e676950ea5..3fde04be279 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/BatchingEngine.cs @@ -156,8 +156,7 @@ ElementLocation elementLocation // to really loop here... it's just that the foreach is the only way I can // figure out how to get data out of the hashtable without knowing any of the // keys! - ProjectErrorUtilities.VerifyThrowInvalidProject(false, - elementLocation, "CannotReferenceItemMetadataWithoutItemName", unqualifiedMetadataName); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "CannotReferenceItemMetadataWithoutItemName", unqualifiedMetadataName); } } else @@ -410,7 +409,7 @@ ElementLocation elementLocation } catch (InvalidOperationException e) { - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "CannotEvaluateItemMetadata", metadataName, e.Message); } } diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs index f96e90a2822..165b1f2b427 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs @@ -583,7 +583,7 @@ private List FindItemsMatchingMetadataSpecification( ItemSpec itemSpec = new ItemSpec(child.Remove, expander, child.RemoveLocation, Project.Directory, true); ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile( itemSpec.Fragments.All(f => f is ItemSpec.ItemExpressionFragment), - new BuildEventFileInfo(string.Empty), + BuildEventFileInfo.Empty, "OM_MatchOnMetadataIsRestrictedToReferencedItems", child.RemoveLocation, child.Remove); diff --git a/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs index 5fdd1a3e145..276c7d04e66 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs @@ -709,7 +709,7 @@ private void UpdateContinueOnError(ItemBucket bucket, TaskHost taskHost) catch (ArgumentException e) { // handle errors in string-->bool conversion - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _taskNode.ContinueOnErrorLocation, "InvalidContinueOnErrorAttribute", _taskNode.Name, e.Message); + ProjectErrorUtilities.ThrowInvalidProject(_taskNode.ContinueOnErrorLocation, "InvalidContinueOnErrorAttribute", _taskNode.Name, e.Message); } } @@ -740,7 +740,7 @@ private async Task ExecuteInstantiatedTask(ITaskExecutionHost ta if (!taskExecutionHost.SetTaskParameters(_taskNode.ParametersForBuild)) { // The task cannot be initialized. - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _targetChildInstance.Location, "TaskParametersError", _taskNode.Name, String.Empty); + ProjectErrorUtilities.ThrowInvalidProject(_targetChildInstance.Location, "TaskParametersError", _taskNode.Name, String.Empty); } else { diff --git a/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs b/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs index f6a291d929c..77497354b7b 100644 --- a/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs +++ b/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs @@ -12,7 +12,6 @@ #endif using System.Text; using System.Threading; -using System.Threading.Tasks; using Microsoft.Build.BackEnd.Logging; using Microsoft.Build.Construction; @@ -442,9 +441,8 @@ bool ITaskExecutionHost.GatherTaskOutputs(string parameterName, ElementLocation } else { - ProjectErrorUtilities.VerifyThrowInvalidProject + ProjectErrorUtilities.ThrowInvalidProject ( - false, parameterLocation, "UnsupportedTaskParameterTypeError", parameter.PropertyType.FullName, @@ -482,9 +480,8 @@ bool ITaskExecutionHost.GatherTaskOutputs(string parameterName, ElementLocation // We do not recover from a task exception while getting outputs, // so do not merely set gatheredGeneratedOutputsSuccessfully = false; here - ProjectErrorUtilities.VerifyThrowInvalidProject + ProjectErrorUtilities.ThrowInvalidProject ( - false, parameterLocation, "FailedToRetrieveTaskOutputs", _taskName, @@ -500,9 +497,8 @@ bool ITaskExecutionHost.GatherTaskOutputs(string parameterName, ElementLocation throw; } - ProjectErrorUtilities.VerifyThrowInvalidProject + ProjectErrorUtilities.ThrowInvalidProject ( - false, parameterLocation, "FailedToRetrieveTaskOutputs", _taskName, @@ -1183,11 +1179,9 @@ out bool taskParameterSet { // We only allow a single item to be passed into a parameter of ITaskItem. - // Some of the computation (expansion) here is expensive, so don't make the above - // "if" statement directly part of the first param to VerifyThrowInvalidProject. - ProjectErrorUtilities.VerifyThrowInvalidProject + // Some of the computation (expansion) here is expensive, so don't switch to VerifyThrowInvalidProject. + ProjectErrorUtilities.ThrowInvalidProject ( - false, parameterLocation, "CannotPassMultipleItemsIntoScalarParameter", _batchBucket.Expander.ExpandIntoStringAndUnescape(parameterValue, ExpanderOptions.ExpandAll, parameterLocation), diff --git a/src/Build/Construction/Solution/ProjectInSolution.cs b/src/Build/Construction/Solution/ProjectInSolution.cs index 80d7bdaad22..c1e3f8efe62 100644 --- a/src/Build/Construction/Solution/ProjectInSolution.cs +++ b/src/Build/Construction/Solution/ProjectInSolution.cs @@ -8,7 +8,9 @@ using System.Security; using System.Text; using System.Xml; +#if !NETFRAMEWORK || MONO using Microsoft.Build.Shared; +#endif using XMakeAttributes = Microsoft.Build.Shared.XMakeAttributes; using ProjectFileErrorUtilities = Microsoft.Build.Shared.ProjectFileErrorUtilities; diff --git a/src/Build/Construction/Solution/SolutionProjectGenerator.cs b/src/Build/Construction/Solution/SolutionProjectGenerator.cs index 625352ba374..43318152844 100644 --- a/src/Build/Construction/Solution/SolutionProjectGenerator.cs +++ b/src/Build/Construction/Solution/SolutionProjectGenerator.cs @@ -1133,9 +1133,8 @@ private bool CanBuildDirectly(ProjectInstance traversalProject, ProjectInSolutio { if (!_solutionFile.ProjectsByGuid.TryGetValue(dependencyProjectGuid, out ProjectInSolution dependencyProject)) { - ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile + ProjectFileErrorUtilities.ThrowInvalidProjectFile ( - false, "SubCategoryForSolutionParsingErrors", new BuildEventFileInfo(traversalProject.FullPath), "SolutionParseProjectDepNotFoundError", @@ -1206,9 +1205,8 @@ private ProjectInstance CreateMetaproject(ProjectInstance traversalProject, Proj if (project.ProjectType == SolutionProjectType.WebProject) { #if !FEATURE_ASPNET_COMPILER - ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile + ProjectFileErrorUtilities.ThrowInvalidProjectFile ( - false, "SubCategoryForSolutionParsingErrors", new BuildEventFileInfo(_solutionFile.FullPath), "AspNetCompiler.UnsupportedMSBuildVersion", @@ -1295,9 +1293,8 @@ private void AddMetaprojectReferenceItems(ProjectInstance traversalProject, Proj { if (!_solutionFile.ProjectsByGuid.TryGetValue(dependencyProjectGuid, out ProjectInSolution dependencyProject)) { - ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile + ProjectFileErrorUtilities.ThrowInvalidProjectFile ( - false, "SubCategoryForSolutionParsingErrors", new BuildEventFileInfo(traversalProject.FullPath), "SolutionParseProjectDepNotFoundError", @@ -1557,9 +1554,8 @@ private void ValidateTargetFrameworkForWebProject(ProjectInSolution project) } if (!isDotNetFramework) { - ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile + ProjectFileErrorUtilities.ThrowInvalidProjectFile ( - false, "SubCategoryForSolutionParsingErrors", new BuildEventFileInfo(_solutionFile.FullPath), "AspNetCompiler.InvalidTargetFrameworkMonikerNotDotNET", diff --git a/src/Build/Definition/Toolset.cs b/src/Build/Definition/Toolset.cs index 77d32963bf6..8193377caeb 100644 --- a/src/Build/Definition/Toolset.cs +++ b/src/Build/Definition/Toolset.cs @@ -1087,7 +1087,7 @@ private void LoadAndRegisterFromTasksFile(string[] defaultTaskFiles, ILoggingSer catch (XmlException e) { // handle XML errors in the default tasks file - ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(false, new BuildEventFileInfo(defaultTasksFile, e), taskFileError, e.Message); + ProjectFileErrorUtilities.ThrowInvalidProjectFile(new BuildEventFileInfo(defaultTasksFile, e), taskFileError, e.Message); } catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e)) { diff --git a/src/Build/Errors/InternalLoggerException.cs b/src/Build/Errors/InternalLoggerException.cs index 7a1e0aa25ad..56016a76d82 100644 --- a/src/Build/Errors/InternalLoggerException.cs +++ b/src/Build/Errors/InternalLoggerException.cs @@ -33,7 +33,7 @@ public sealed class InternalLoggerException : Exception /// public InternalLoggerException() { - ErrorUtilities.VerifyThrowInvalidOperation(false, "InternalLoggerExceptionOnlyThrownByEngine"); + ErrorUtilities.ThrowInvalidOperation("InternalLoggerExceptionOnlyThrownByEngine"); } /// @@ -47,7 +47,7 @@ public InternalLoggerException() public InternalLoggerException(string message) : base(message) { - ErrorUtilities.VerifyThrowInvalidOperation(false, "InternalLoggerExceptionOnlyThrownByEngine"); + ErrorUtilities.ThrowInvalidOperation("InternalLoggerExceptionOnlyThrownByEngine"); } /// @@ -62,7 +62,7 @@ public InternalLoggerException(string message) public InternalLoggerException(string message, Exception innerException) : base(message, innerException) { - ErrorUtilities.VerifyThrowInvalidOperation(false, "InternalLoggerExceptionOnlyThrownByEngine"); + ErrorUtilities.ThrowInvalidOperation("InternalLoggerExceptionOnlyThrownByEngine"); } #endregion diff --git a/src/Build/Evaluation/Conditionals/AndExpressionNode.cs b/src/Build/Evaluation/Conditionals/AndExpressionNode.cs index 31d790c5b3a..69df786fb83 100644 --- a/src/Build/Evaluation/Conditionals/AndExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/AndExpressionNode.cs @@ -18,13 +18,15 @@ internal sealed class AndExpressionNode : OperatorExpressionNode /// internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState state) { - ProjectErrorUtilities.VerifyThrowInvalidProject - (LeftChild.TryBoolEvaluate(state, out bool leftBool), + if (!LeftChild.TryBoolEvaluate(state, out bool leftBool)) + { + ProjectErrorUtilities.ThrowInvalidProject( state.ElementLocation, "ExpressionDoesNotEvaluateToBoolean", LeftChild.GetUnexpandedValue(state), LeftChild.GetExpandedValue(state), state.Condition); + } if (!leftBool) { @@ -33,13 +35,15 @@ internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState } else { - ProjectErrorUtilities.VerifyThrowInvalidProject - (RightChild.TryBoolEvaluate(state, out bool rightBool), - state.ElementLocation, - "ExpressionDoesNotEvaluateToBoolean", - RightChild.GetUnexpandedValue(state), - RightChild.GetExpandedValue(state), - state.Condition); + if (!RightChild.TryBoolEvaluate(state, out bool rightBool)) + { + ProjectErrorUtilities.ThrowInvalidProject( + state.ElementLocation, + "ExpressionDoesNotEvaluateToBoolean", + RightChild.GetUnexpandedValue(state), + RightChild.GetExpandedValue(state), + state.Condition); + } return rightBool; } diff --git a/src/Build/Evaluation/Conditionals/FunctionCallExpressionNode.cs b/src/Build/Evaluation/Conditionals/FunctionCallExpressionNode.cs index 12547eaa3ae..d1ffa2a8248 100644 --- a/src/Build/Evaluation/Conditionals/FunctionCallExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/FunctionCallExpressionNode.cs @@ -90,8 +90,7 @@ internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState // We haven't implemented any other "functions" else { - ProjectErrorUtilities.VerifyThrowInvalidProject( - false, + ProjectErrorUtilities.ThrowInvalidProject( state.ElementLocation, "UndefinedFunctionCall", state.Condition, diff --git a/src/Build/Evaluation/Conditionals/GenericExpressionNode.cs b/src/Build/Evaluation/Conditionals/GenericExpressionNode.cs index 5963a4a61e7..c85b95e088d 100644 --- a/src/Build/Evaluation/Conditionals/GenericExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/GenericExpressionNode.cs @@ -53,12 +53,14 @@ internal virtual bool EvaluatesToEmpty(ConditionEvaluator.IConditionEvaluationSt /// internal bool Evaluate(ConditionEvaluator.IConditionEvaluationState state) { - ProjectErrorUtilities.VerifyThrowInvalidProject( - TryBoolEvaluate(state, out bool boolValue), - state.ElementLocation, - "ConditionNotBooleanDetail", - state.Condition, - GetExpandedValue(state)); + if (!TryBoolEvaluate(state, out bool boolValue)) + { + ProjectErrorUtilities.ThrowInvalidProject( + state.ElementLocation, + "ConditionNotBooleanDetail", + state.Condition, + GetExpandedValue(state)); + } return boolValue; } diff --git a/src/Build/Evaluation/Conditionals/NotExpressionNode.cs b/src/Build/Evaluation/Conditionals/NotExpressionNode.cs index de73b72e736..2f5dd07d112 100644 --- a/src/Build/Evaluation/Conditionals/NotExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/NotExpressionNode.cs @@ -18,13 +18,16 @@ internal sealed class NotExpressionNode : OperatorExpressionNode /// internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState state) { - ProjectErrorUtilities.VerifyThrowInvalidProject - (LeftChild.TryBoolEvaluate(state, out bool boolValue), - state.ElementLocation, - "ExpressionDoesNotEvaluateToBoolean", - LeftChild.GetUnexpandedValue(state), - LeftChild.GetExpandedValue(state), - state.Condition); + if (!LeftChild.TryBoolEvaluate(state, out bool boolValue)) + { + ProjectErrorUtilities.ThrowInvalidProject( + state.ElementLocation, + "ExpressionDoesNotEvaluateToBoolean", + LeftChild.GetUnexpandedValue(state), + LeftChild.GetExpandedValue(state), + state.Condition); + } + return !boolValue; } diff --git a/src/Build/Evaluation/Conditionals/NumericComparisonExpressionNode.cs b/src/Build/Evaluation/Conditionals/NumericComparisonExpressionNode.cs index dec7c6e2fe2..a86a3031bb3 100644 --- a/src/Build/Evaluation/Conditionals/NumericComparisonExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/NumericComparisonExpressionNode.cs @@ -43,14 +43,16 @@ internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState bool isRightNum = RightChild.TryNumericEvaluate(state, out double rightNum); bool isRightVersion = RightChild.TryVersionEvaluate(state, out Version rightVersion); - ProjectErrorUtilities.VerifyThrowInvalidProject - ((isLeftNum || isLeftVersion) && (isRightNum || isRightVersion), - state.ElementLocation, - "ComparisonOnNonNumericExpression", - state.Condition, - /* helpfully display unexpanded token and expanded result in error message */ - isLeftNum ? RightChild.GetUnexpandedValue(state) : LeftChild.GetUnexpandedValue(state), - isLeftNum ? RightChild.GetExpandedValue(state) : LeftChild.GetExpandedValue(state)); + if ((!isLeftNum && !isLeftVersion) || (!isRightNum && !isRightVersion)) + { + ProjectErrorUtilities.ThrowInvalidProject( + state.ElementLocation, + "ComparisonOnNonNumericExpression", + state.Condition, + /* helpfully display unexpanded token and expanded result in error message */ + isLeftNum ? RightChild.GetUnexpandedValue(state) : LeftChild.GetUnexpandedValue(state), + isLeftNum ? RightChild.GetExpandedValue(state) : LeftChild.GetExpandedValue(state)); + } return (isLeftNum, isLeftVersion, isRightNum, isRightVersion) switch { diff --git a/src/Build/Evaluation/Conditionals/OperatorExpressionNode.cs b/src/Build/Evaluation/Conditionals/OperatorExpressionNode.cs index d5520e01bd7..92609fd763e 100644 --- a/src/Build/Evaluation/Conditionals/OperatorExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/OperatorExpressionNode.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using Microsoft.Build.Shared; namespace Microsoft.Build.Evaluation { diff --git a/src/Build/Evaluation/Conditionals/OrExpressionNode.cs b/src/Build/Evaluation/Conditionals/OrExpressionNode.cs index 73a91600f9b..1ac1713a5aa 100644 --- a/src/Build/Evaluation/Conditionals/OrExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/OrExpressionNode.cs @@ -18,13 +18,15 @@ internal sealed class OrExpressionNode : OperatorExpressionNode /// internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState state) { - ProjectErrorUtilities.VerifyThrowInvalidProject - (LeftChild.TryBoolEvaluate(state, out bool leftBool), - state.ElementLocation, - "ExpressionDoesNotEvaluateToBoolean", - LeftChild.GetUnexpandedValue(state), - LeftChild.GetExpandedValue(state), - state.Condition); + if (!LeftChild.TryBoolEvaluate(state, out bool leftBool)) + { + ProjectErrorUtilities.ThrowInvalidProject( + state.ElementLocation, + "ExpressionDoesNotEvaluateToBoolean", + LeftChild.GetUnexpandedValue(state), + LeftChild.GetExpandedValue(state), + state.Condition); + } if (leftBool) { @@ -33,13 +35,15 @@ internal override bool BoolEvaluate(ConditionEvaluator.IConditionEvaluationState } else { - ProjectErrorUtilities.VerifyThrowInvalidProject - (RightChild.TryBoolEvaluate(state, out bool rightBool), - state.ElementLocation, - "ExpressionDoesNotEvaluateToBoolean", - RightChild.GetUnexpandedValue(state), - RightChild.GetExpandedValue(state), - state.Condition); + if (!RightChild.TryBoolEvaluate(state, out bool rightBool)) + { + ProjectErrorUtilities.ThrowInvalidProject( + state.ElementLocation, + "ExpressionDoesNotEvaluateToBoolean", + RightChild.GetUnexpandedValue(state), + RightChild.GetExpandedValue(state), + state.Condition); + } return rightBool; } diff --git a/src/Build/Evaluation/Conditionals/Parser.cs b/src/Build/Evaluation/Conditionals/Parser.cs index ac231b18964..292226a5ed8 100644 --- a/src/Build/Evaluation/Conditionals/Parser.cs +++ b/src/Build/Evaluation/Conditionals/Parser.cs @@ -107,13 +107,13 @@ internal GenericExpressionNode Parse(string expression, ParserOptions optionSett if (!_lexer.Advance()) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, _lexer.GetErrorResource(), expression, errorPosition, _lexer.UnexpectedlyFound); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, _lexer.GetErrorResource(), expression, errorPosition, _lexer.UnexpectedlyFound); } GenericExpressionNode node = Expr(expression); if (!_lexer.IsNext(Token.TokenType.EndOfInput)) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } return node; } @@ -177,7 +177,7 @@ private GenericExpressionNode BooleanTerm(string expression) if (node == null) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } if (!_lexer.IsNext(Token.TokenType.EndOfInput)) @@ -199,7 +199,7 @@ private GenericExpressionNode BooleanTermPrime(string expression, GenericExpress if (rhs == null) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } OperatorExpressionNode andNode = new AndExpressionNode(); @@ -221,7 +221,7 @@ private GenericExpressionNode RelationalExpr(string expression) if (lhs == null) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } OperatorExpressionNode node = RelationalOperation(expression); @@ -284,7 +284,7 @@ private GenericExpressionNode Factor(string expression) if (!Same(expression, Token.TokenType.LeftParenthesis)) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", _lexer.IsNextString(), errorPosition); return null; } var arglist = new List(); @@ -292,7 +292,7 @@ private GenericExpressionNode Factor(string expression) if (!Same(expression, Token.TokenType.RightParenthesis)) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); return null; } return new FunctionCallExpressionNode(current.String, arglist); @@ -305,7 +305,7 @@ private GenericExpressionNode Factor(string expression) else { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } } else if (Same(expression, Token.TokenType.Not)) @@ -315,7 +315,7 @@ private GenericExpressionNode Factor(string expression) if (expr == null) { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } notNode.LeftChild = expr; return notNode; @@ -323,7 +323,7 @@ private GenericExpressionNode Factor(string expression) else { errorPosition = _lexer.GetErrorPosition(); - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, "UnexpectedTokenInCondition", expression, _lexer.IsNextString(), errorPosition); } return null; } @@ -384,11 +384,11 @@ private bool Same(string expression, Token.TokenType token) errorPosition = _lexer.GetErrorPosition(); if (_lexer.UnexpectedlyFound != null) { - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, _lexer.GetErrorResource(), expression, errorPosition, _lexer.UnexpectedlyFound); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, _lexer.GetErrorResource(), expression, errorPosition, _lexer.UnexpectedlyFound); } else { - ProjectErrorUtilities.VerifyThrowInvalidProject(false, _elementLocation, _lexer.GetErrorResource(), expression, errorPosition); + ProjectErrorUtilities.ThrowInvalidProject(_elementLocation, _lexer.GetErrorResource(), expression, errorPosition); } } return true; diff --git a/src/Build/Evaluation/ProjectParser.cs b/src/Build/Evaluation/ProjectParser.cs index 761ef477d6f..186ed1ddf4c 100644 --- a/src/Build/Evaluation/ProjectParser.cs +++ b/src/Build/Evaluation/ProjectParser.cs @@ -127,7 +127,10 @@ private void Parse() // XML guarantees exactly one root element XmlElementWithLocation element = _document.DocumentElement as XmlElementWithLocation; - ProjectErrorUtilities.VerifyThrowInvalidProject(element != null, ElementLocation.Create(_document.FullPath), "NoRootProjectElement", XMakeElements.project); + if (element is null) + { + ProjectErrorUtilities.ThrowInvalidProject(ElementLocation.Create(_document.FullPath), "NoRootProjectElement", XMakeElements.project); + } ProjectErrorUtilities.VerifyThrowInvalidProject(element.Name != XMakeElements.visualStudioProject, element.Location, "ProjectUpgradeNeeded", _project.FullPath); ProjectErrorUtilities.VerifyThrowInvalidProject(element.LocalName == XMakeElements.project, element.Location, "UnrecognizedElement", element.Name); diff --git a/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs b/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs index 802539f6077..6237ac280ed 100644 --- a/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs +++ b/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs @@ -282,7 +282,7 @@ string taskProjectFile { // Exception thrown by the called code itself // Log the stack, so the task vendor can fix their code - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, Environment.NewLine + e.InnerException.ToString()); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, Environment.NewLine + e.InnerException.ToString()); } catch (ReflectionTypeLoadException e) { @@ -295,12 +295,12 @@ string taskProjectFile } } - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, e.Message); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, e.Message); } catch (ArgumentNullException e) { // taskName may be null - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, e.Message); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, e.Message); } catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception. { @@ -309,7 +309,7 @@ string taskProjectFile throw; } - ProjectErrorUtilities.VerifyThrowInvalidProject(false, elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, e.Message); + ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "TaskLoadFailure", taskName, loadInfo.AssemblyLocation, e.Message); } return _loadedType; diff --git a/src/Build/Logging/BaseConsoleLogger.cs b/src/Build/Logging/BaseConsoleLogger.cs index 167a67e396e..28f1d0d9d5f 100644 --- a/src/Build/Logging/BaseConsoleLogger.cs +++ b/src/Build/Logging/BaseConsoleLogger.cs @@ -352,7 +352,7 @@ internal static LoggerVerbosity ImportanceToMinimumVerbosity(MessageImportance i return LoggerVerbosity.Detailed; default: - ErrorUtilities.VerifyThrow(false, "Impossible"); + ErrorUtilities.ThrowInternalError("Impossible"); lightenText = false; return LoggerVerbosity.Detailed; } diff --git a/src/Build/Logging/DistributedLoggers/DistributedFileLogger.cs b/src/Build/Logging/DistributedLoggers/DistributedFileLogger.cs index c64e5f2fd85..72f225241d3 100644 --- a/src/Build/Logging/DistributedLoggers/DistributedFileLogger.cs +++ b/src/Build/Logging/DistributedLoggers/DistributedFileLogger.cs @@ -183,7 +183,7 @@ public LoggerVerbosity Verbosity { get { - ErrorUtilities.VerifyThrow(false, "Should not be getting verbosity from distributed file logger"); + ErrorUtilities.ThrowInternalError("Should not be getting verbosity from distributed file logger"); return LoggerVerbosity.Detailed; } set diff --git a/src/Build/Logging/NullCentralLogger.cs b/src/Build/Logging/NullCentralLogger.cs index b2101e63bc6..de64da650a1 100644 --- a/src/Build/Logging/NullCentralLogger.cs +++ b/src/Build/Logging/NullCentralLogger.cs @@ -53,7 +53,7 @@ public void AnyEventRaisedHandler(object sender, BuildEventArgs e) { if (!(e is BuildStartedEventArgs) && !(e is BuildFinishedEventArgs)) { - ErrorUtilities.VerifyThrowInvalidOperation(false, "Should not receive any events other than build started or finished"); + ErrorUtilities.ThrowInvalidOperation("Should not receive any events other than build started or finished"); } } diff --git a/src/Build/Logging/SerialConsoleLogger.cs b/src/Build/Logging/SerialConsoleLogger.cs index 9deedd88b0e..4784c183001 100644 --- a/src/Build/Logging/SerialConsoleLogger.cs +++ b/src/Build/Logging/SerialConsoleLogger.cs @@ -702,7 +702,7 @@ private string GetCurrentlyBuildingProjectFile() } else { - ErrorUtilities.VerifyThrow(false, "Unexpected frame type."); + ErrorUtilities.ThrowInternalError("Unexpected frame type."); return null; } } @@ -752,7 +752,7 @@ private void ShowDeferredMessages() break; default: - ErrorUtilities.VerifyThrow(false, "Unexpected frame type."); + ErrorUtilities.ThrowInternalError("Unexpected frame type."); break; } } diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index c4408477cfa..ae95d608193 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -1551,7 +1551,7 @@ private static void VerifyThrowSupportedOS() { // If we're running on any of the unsupported OS's, fail immediately. This way, // we don't run into some obscure error down the line, totally confusing the user. - InitializationException.VerifyThrow(false, "UnsupportedOS"); + InitializationException.Throw("UnsupportedOS", null, null, false); } #endif } @@ -2843,7 +2843,7 @@ DirectoryGetFiles getFiles // If there is more than one solution file in the current directory we have no idea which one to use else if (actualSolutionFiles.Count > 1) { - InitializationException.VerifyThrow(false, projectDirectory == null ? "AmbiguousProjectError" : "AmbiguousProjectDirectoryError", null, projectDirectory); + InitializationException.VerifyThrow(false, projectDirectory == null ? "AmbiguousProjectError" : "AmbiguousProjectDirectoryError", null, projectDirectory, false); } // If there is more than one project file in the current directory we may be able to figure it out else if (actualProjectFiles.Count > 1) @@ -2883,7 +2883,7 @@ DirectoryGetFiles getFiles actualSolutionFiles.Count== 0 && solutionFilterFiles.Count == 0) { - InitializationException.VerifyThrow(false, "MissingProjectError"); + InitializationException.Throw("MissingProjectError", null, null, false); } else { diff --git a/src/Shared/ConversionUtilities.cs b/src/Shared/ConversionUtilities.cs index c2e424e322e..a6febc5c973 100644 --- a/src/Shared/ConversionUtilities.cs +++ b/src/Shared/ConversionUtilities.cs @@ -4,7 +4,7 @@ using System; using System.Globalization; using System.Text; -using error = Microsoft.Build.Shared.ErrorUtilities; +using Error = Microsoft.Build.Shared.ErrorUtilities; namespace Microsoft.Build.Shared { @@ -33,7 +33,7 @@ internal static bool ConvertStringToBool(string parameterValue) else { // Unsupported boolean representation. - error.VerifyThrowArgument(false, "Shared.CannotConvertStringToBool", parameterValue); + Error.ThrowArgument("Shared.CannotConvertStringToBool", parameterValue); return false; } } @@ -142,7 +142,7 @@ internal static double ConvertDecimalOrHexToDouble(string number) { return result; } - ErrorUtilities.VerifyThrow(false, "Cannot numeric evaluate"); + Error.ThrowInternalError("Cannot numeric evaluate"); return 0.0D; } diff --git a/src/Shared/ErrorUtilities.cs b/src/Shared/ErrorUtilities.cs index 9bb3502596b..05dcb114de3 100644 --- a/src/Shared/ErrorUtilities.cs +++ b/src/Shared/ErrorUtilities.cs @@ -488,7 +488,7 @@ params object[] args /// Can be null. /// /// - private static void ThrowArgument + internal static void ThrowArgument ( Exception innerException, string resourceName, diff --git a/src/Shared/FileMatcher.cs b/src/Shared/FileMatcher.cs index 22a9572fc82..cca9caee3b3 100644 --- a/src/Shared/FileMatcher.cs +++ b/src/Shared/FileMatcher.cs @@ -246,7 +246,7 @@ private static IReadOnlyList GetAccessibleFileSystemEntries(IFileSystem case FileSystemEntity.Directories: return GetAccessibleDirectories(fileSystem, path, pattern); case FileSystemEntity.FilesAndDirectories: return GetAccessibleFilesAndDirectories(fileSystem, path, pattern); default: - ErrorUtilities.VerifyThrow(false, "Unexpected filesystem entity type."); + ErrorUtilities.ThrowInternalError("Unexpected filesystem entity type."); break; } return Array.Empty(); diff --git a/src/Shared/Modifiers.cs b/src/Shared/Modifiers.cs index 1ad37579cb6..bfb564d884b 100644 --- a/src/Shared/Modifiers.cs +++ b/src/Shared/Modifiers.cs @@ -599,7 +599,7 @@ internal static string GetItemSpecModifier(string currentDirectory, string itemS } catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e)) { - ErrorUtilities.VerifyThrowInvalidOperation(false, "Shared.InvalidFilespecForTransform", modifier, itemSpec, e.Message); + ErrorUtilities.ThrowInvalidOperation("Shared.InvalidFilespecForTransform", modifier, itemSpec, e.Message); } return modifiedItemSpec; diff --git a/src/Shared/ProjectErrorUtilities.cs b/src/Shared/ProjectErrorUtilities.cs index 540b26f71d1..b02ed0ef6c3 100644 --- a/src/Shared/ProjectErrorUtilities.cs +++ b/src/Shared/ProjectErrorUtilities.cs @@ -57,7 +57,7 @@ internal static void ThrowInvalidProject T1 arg0 ) { - VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0); + ThrowInvalidProject(null, elementLocation, resourceName, arg0); } /// @@ -93,7 +93,7 @@ internal static void ThrowInvalidProject T2 arg1 ) { - VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0, arg1); + ThrowInvalidProject(null, elementLocation, resourceName, arg0, arg1); } /// @@ -113,7 +113,7 @@ internal static void ThrowInvalidProject T3 arg2 ) { - VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0, arg1, arg2); + ThrowInvalidProject(null, elementLocation, resourceName, arg0, arg1, arg2); } /// @@ -135,7 +135,7 @@ internal static void ThrowInvalidProject T4 arg3 ) { - VerifyThrowInvalidProject(false, null, elementLocation, resourceName, arg0, arg1, arg2, arg3); + ThrowInvalidProject(null, elementLocation, resourceName, arg0, arg1, arg2, arg3); } /// @@ -396,16 +396,9 @@ params object[] args ResourceUtilities.VerifyResourceStringExists(resourceName); #endif - string errorSubCategory = null; + string errorSubCategory = errorSubCategoryResourceName is null ? null : AssemblyResources.GetString(errorSubCategoryResourceName); - if (errorSubCategoryResourceName != null) - { - errorSubCategory = AssemblyResources.GetString(errorSubCategoryResourceName); - } - - string errorCode; - string helpKeyword; - string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword(out errorCode, out helpKeyword, resourceName, args); + string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword(out string errorCode, out string helpKeyword, resourceName, args); throw new InvalidProjectFileException(elementLocation.File, elementLocation.Line, elementLocation.Column, 0 /* Unknown end line */, 0 /* Unknown end column */, message, errorSubCategory, errorCode, helpKeyword); } diff --git a/src/Shared/ProjectFileErrorUtilities.cs b/src/Shared/ProjectFileErrorUtilities.cs index d672e250e5f..bcc433204d0 100644 --- a/src/Shared/ProjectFileErrorUtilities.cs +++ b/src/Shared/ProjectFileErrorUtilities.cs @@ -29,7 +29,7 @@ internal static void ThrowInvalidProjectFile params object[] args ) { - VerifyThrowInvalidProjectFile(false, null, projectFile, resourceName, args); + ThrowInvalidProjectFile(null, projectFile, resourceName, args); } /// @@ -157,16 +157,8 @@ params object[] args #endif if (!condition) { - string errorSubCategory = null; - - if (errorSubCategoryResourceName != null) - { - errorSubCategory = AssemblyResources.GetString(errorSubCategoryResourceName); - } - - string errorCode; - string helpKeyword; - string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword(out errorCode, out helpKeyword, resourceName, args); + string errorSubCategory = errorSubCategoryResourceName is null ? null : AssemblyResources.GetString(errorSubCategoryResourceName); + string message = ResourceUtilities.FormatResourceStringStripCodeAndKeyword(out string errorCode, out string helpKeyword, resourceName, args); throw new InvalidProjectFileException(projectFile.File, projectFile.Line, projectFile.Column, projectFile.EndLine, projectFile.EndColumn, message, errorSubCategory, errorCode, helpKeyword, innerException); } diff --git a/src/Shared/TaskLoggingHelper.cs b/src/Shared/TaskLoggingHelper.cs index 4ee21110651..7de1b7c8ab1 100644 --- a/src/Shared/TaskLoggingHelper.cs +++ b/src/Shared/TaskLoggingHelper.cs @@ -1435,7 +1435,7 @@ public bool LogMessageFromText(string lineOfText, MessageImportance messageImpor } default: - ErrorUtilities.VerifyThrow(false, "Impossible canonical part."); + ErrorUtilities.ThrowInternalError("Impossible canonical part."); break; } } diff --git a/src/Tasks/AppConfig/BindingRedirect.cs b/src/Tasks/AppConfig/BindingRedirect.cs index 5e5404af394..8a226ede9c5 100644 --- a/src/Tasks/AppConfig/BindingRedirect.cs +++ b/src/Tasks/AppConfig/BindingRedirect.cs @@ -61,7 +61,7 @@ internal void Read(XmlReader reader) throw; } - ErrorUtilities.VerifyThrowArgument(false, e, "AppConfig.InvalidOldVersionAttribute", e.Message); + ErrorUtilities.ThrowArgument(e, "AppConfig.InvalidOldVersionAttribute", e.Message); } string newVersionAttribute = reader.GetAttribute("newVersion"); @@ -80,7 +80,7 @@ internal void Read(XmlReader reader) throw; } - ErrorUtilities.VerifyThrowArgument(false, e, "AppConfig.InvalidNewVersionAttribute", e.Message); + ErrorUtilities.ThrowArgument(e, "AppConfig.InvalidNewVersionAttribute", e.Message); } } } diff --git a/src/Tasks/AppConfig/DependentAssembly.cs b/src/Tasks/AppConfig/DependentAssembly.cs index 2337cafd376..2bbbc37e39a 100644 --- a/src/Tasks/AppConfig/DependentAssembly.cs +++ b/src/Tasks/AppConfig/DependentAssembly.cs @@ -96,7 +96,7 @@ internal void Read(XmlReader reader) catch (System.IO.FileLoadException e) { // A badly formed assembly name. - ErrorUtilities.VerifyThrowArgument(false, e, "AppConfig.InvalidAssemblyIdentityFields"); + ErrorUtilities.ThrowArgument(e, "AppConfig.InvalidAssemblyIdentityFields"); } } diff --git a/src/Tasks/AssemblyFolder.cs b/src/Tasks/AssemblyFolder.cs index d6d3e0ae209..dfc0c4632c7 100644 --- a/src/Tasks/AssemblyFolder.cs +++ b/src/Tasks/AssemblyFolder.cs @@ -54,7 +54,7 @@ Dictionary directories } else { - ErrorUtilities.VerifyThrow(false, "AssemblyFolder.AddFoldersFromRegistryKey expected a known hive."); + ErrorUtilities.ThrowInternalError("AssemblyFolder.AddFoldersFromRegistryKey expected a known hive."); } if (baseKey != null) diff --git a/src/Tasks/Copy.cs b/src/Tasks/Copy.cs index 6c91abeaab3..1575b55d11b 100644 --- a/src/Tasks/Copy.cs +++ b/src/Tasks/Copy.cs @@ -588,8 +588,7 @@ private bool CopyParallel( if (!partitionAccepted) { // Retail assert... - ErrorUtilities.VerifyThrow(false, - "Failed posting a file copy to an ActionBlock. Should not happen with block at max int capacity."); + ErrorUtilities.ThrowInternalError("Failed posting a file copy to an ActionBlock. Should not happen with block at max int capacity."); } } diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 26967ca64e7..54d5b149d96 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -4146,7 +4146,7 @@ public Type GetType(string name, bool throwOnError, bool ignoreCase) if (result == null && throwOnError) { - ErrorUtilities.VerifyThrowArgument(false, "GenerateResource.CouldNotLoadType", name); + ErrorUtilities.ThrowArgument("GenerateResource.CouldNotLoadType", name); } _cachedTypes[name] = result; diff --git a/src/Tasks/ResolveComReference.cs b/src/Tasks/ResolveComReference.cs index a8cf11d7a56..e64e155ca4b 100644 --- a/src/Tasks/ResolveComReference.cs +++ b/src/Tasks/ResolveComReference.cs @@ -1040,7 +1040,7 @@ internal bool ResolveComClassicReference(ComReferenceInfo referenceInfo, string } else { - ErrorUtilities.VerifyThrow(false, "Unknown wrapper type!"); + ErrorUtilities.ThrowInternalError("Unknown wrapper type!"); } referenceInfo.resolvedWrapper = wrapperInfo; diff --git a/src/Tasks/XamlTaskFactory/CommandLineGenerator.cs b/src/Tasks/XamlTaskFactory/CommandLineGenerator.cs index 41d74bb1934..96fc22b7388 100644 --- a/src/Tasks/XamlTaskFactory/CommandLineGenerator.cs +++ b/src/Tasks/XamlTaskFactory/CommandLineGenerator.cs @@ -256,7 +256,7 @@ internal void GenerateCommandsAccordingToType(CommandLineBuilder clb, CommandLin break; default: // should never reach this point - if it does, there's a bug somewhere. - ErrorUtilities.VerifyThrow(false, "InternalError"); + ErrorUtilities.ThrowInternalError("InternalError"); break; } } diff --git a/src/Utilities/ToolTask.cs b/src/Utilities/ToolTask.cs index e7766038d11..0818aec23b2 100644 --- a/src/Utilities/ToolTask.cs +++ b/src/Utilities/ToolTask.cs @@ -902,7 +902,7 @@ private void HandleToolNotifications(Process proc) break; default: - ErrorUtilities.VerifyThrow(false, "Unknown tool notification."); + ErrorUtilities.ThrowInternalError("Unknown tool notification."); break; } } diff --git a/src/Utilities/TrackedDependencies/FileTracker.cs b/src/Utilities/TrackedDependencies/FileTracker.cs index ec2d396bfc5..423083dbd1b 100644 --- a/src/Utilities/TrackedDependencies/FileTracker.cs +++ b/src/Utilities/TrackedDependencies/FileTracker.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if FEATURE_FILE_TRACKER + using System; using System.Collections.Generic; @@ -13,8 +15,6 @@ using Microsoft.Build.Shared; using Microsoft.Build.Shared.FileSystem; -#if FEATURE_FILE_TRACKER - namespace Microsoft.Build.Utilities { /// @@ -58,7 +58,7 @@ public enum ExecutableType /// public static class FileTracker { - #region Static Member Data +#region Static Member Data // The default path to temp, used to create explicitly short and long paths private static readonly string s_tempPath = Path.GetTempPath(); @@ -101,9 +101,9 @@ public static class FileTracker // Static cache of the path separator character in an array for use in String.Split. private static readonly string pathSeparator = Path.PathSeparator.ToString(); - #endregion +#endregion - #region Static constructor +#region Static constructor static FileTracker() { @@ -128,9 +128,9 @@ static FileTracker() } } - #endregion +#endregion - #region Native method wrappers +#region Native method wrappers /// /// Stops tracking file accesses. @@ -195,9 +195,9 @@ public static void StartTrackingContextWithRoot(string intermediateDirectory, st [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TLogs", Justification = "Has now shipped as public API; plus it's unclear whether 'Tlog' or 'TLog' is the preferred casing")] public static void WriteContextTLogs(string intermediateDirectory, string taskName) => InprocTrackingNativeMethods.WriteContextTLogs(intermediateDirectory, taskName); - #endregion // Native method wrappers +#endregion // Native method wrappers - #region Methods +#region Methods /// /// Test to see if the specified file is excluded from tracked dependencies @@ -627,7 +627,7 @@ public static string TrackerArguments(string command, string arguments, string d public static string TrackerArguments(string command, string arguments, string dllName, string intermediateDirectory, string rootFiles, string cancelEventName) => TrackerResponseFileArguments(dllName, intermediateDirectory, rootFiles, cancelEventName) + TrackerCommandArguments(command, arguments); - #region StartProcess methods +#region StartProcess methods /// /// Start the process; tracking the command. @@ -694,7 +694,7 @@ public static Process StartProcess(string command, string arguments, ExecutableT public static Process StartProcess(string command, string arguments, ExecutableType toolType) => StartProcess(command, arguments, toolType, null, null, null, null); - #endregion // StartProcess methods +#endregion // StartProcess methods /// /// Logs a message of the given importance using the specified resource string. To the specified Log. @@ -744,7 +744,7 @@ internal static void LogWarningWithCodeFromResources(TaskLoggingHelper Log, stri Log?.LogWarningWithCodeFromResources(messageResourceName, messageArgs); } - #endregion +#endregion } ///