From 77df6b22429908ffe4293257951be1a253f59129 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 30 Dec 2021 10:33:44 +1000 Subject: [PATCH 1/8] CA1805 Do not initialize unnecessarily --- eng/CodeAnalysis.ruleset | 2 +- .../Helpers/ViewValidation.construction.cs | 2 +- .../ExporterMock.cs | 6 +- .../LinkedObjectsMap.cs | 4 +- src/Build.UnitTests/BackEnd/TaskHost_Tests.cs | 16 ++--- .../SolutionProjectGenerator_Tests.cs | 2 +- .../ToolsetConfigurationReaderTestHelper.cs | 4 +- .../ImportFromMSBuildExtensionsPath_Tests.cs | 2 +- src/Build.UnitTests/MockTask.cs | 70 +++++++++---------- .../BackEnd/BuildManager/BuildParameters.cs | 4 +- .../Communications/NodeProviderInProc.cs | 4 +- .../Logging/BuildEventArgTransportSink.cs | 2 +- .../Components/Logging/LoggingService.cs | 8 +-- .../Logging/LoggingServiceFactory.cs | 2 +- .../IntrinsicTasks/CallTarget.cs | 6 +- .../RequestBuilder/IntrinsicTasks/MSBuild.cs | 14 ++-- src/Framework.UnitTests/EventArgs_Tests.cs | 2 +- src/MSBuild/OutOfProcTaskHostNode.cs | 2 +- src/MSBuild/XMake.cs | 2 +- src/Shared/AssemblyNameExtension.cs | 6 +- src/Shared/CoreCLRAssemblyLoader.cs | 2 +- src/Shared/FileUtilities.cs | 2 +- src/Shared/LogMessagePacketBase.cs | 2 +- src/Shared/TaskEngineAssemblyResolver.cs | 6 +- src/Shared/TaskHostTaskComplete.cs | 4 +- src/Shared/TaskParameter.cs | 6 +- src/Shared/UnitTests/FileMatcher_Tests.cs | 6 +- src/Shared/UnitTests/MockEngine.cs | 2 +- .../SpanBasedStringBuilder_Benchmark.cs | 2 +- .../ResolveAssemblyReferenceTestFixture.cs | 6 +- 30 files changed, 99 insertions(+), 99 deletions(-) diff --git a/eng/CodeAnalysis.ruleset b/eng/CodeAnalysis.ruleset index 2078c42fe6c..989f3de33d1 100644 --- a/eng/CodeAnalysis.ruleset +++ b/eng/CodeAnalysis.ruleset @@ -83,7 +83,7 @@ - + diff --git a/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs b/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs index 8ebfe5804bb..a2a66e2e8d4 100644 --- a/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs +++ b/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs @@ -265,7 +265,7 @@ public static bool IsLinkedObject(object obj) return LinkedObjectsFactory.GetLink(obj) != null; } - private static bool dbgIgnoreLinked = false; + private static bool dbgIgnoreLinked; public static void VerifyNotLinked(object obj) { if (dbgIgnoreLinked) return; diff --git a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs index 95a409f777e..f0e3ed21453 100644 --- a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs +++ b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs @@ -143,9 +143,9 @@ internal interface IImportHolder /// internal class ProjectCollectionLinker : ExternalProjectsProvider { - internal static int _collecitonId = 0; + internal static int _collecitonId; - private bool importing = false; + private bool importing; private ExportedLinksMap exported = ExportedLinksMap.Create(); private Dictionary imported = new Dictionary(); @@ -214,7 +214,7 @@ private void ConnectTo (ProjectCollectionLinker other) } } - private static bool dbgValidateDuplicateViews = false; + private static bool dbgValidateDuplicateViews; internal void ValidateNoDuplicates() diff --git a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/LinkedObjectsMap.cs b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/LinkedObjectsMap.cs index b4a5223c125..e2bba4c5c8a 100644 --- a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/LinkedObjectsMap.cs +++ b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/LinkedObjectsMap.cs @@ -9,8 +9,8 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting internal class LinkedObjectsMap : IDisposable { private static object Lock { get; } = new object(); - private static UInt32 nextCollectionId = 0; - private UInt32 nextLocalId = 0; + private static UInt32 nextCollectionId; + private UInt32 nextLocalId; // internal fore debugging internal object GetLockForDebug => Lock; diff --git a/src/Build.UnitTests/BackEnd/TaskHost_Tests.cs b/src/Build.UnitTests/BackEnd/TaskHost_Tests.cs index e45add12e09..be7063d3061 100644 --- a/src/Build.UnitTests/BackEnd/TaskHost_Tests.cs +++ b/src/Build.UnitTests/BackEnd/TaskHost_Tests.cs @@ -1074,42 +1074,42 @@ internal class MyCustomLogger : ILogger /// /// Last error event the logger encountered /// - private BuildErrorEventArgs _lastError = null; + private BuildErrorEventArgs _lastError; /// /// Last warning event the logger encountered /// - private BuildWarningEventArgs _lastWarning = null; + private BuildWarningEventArgs _lastWarning; /// /// Last message event the logger encountered /// - private BuildMessageEventArgs _lastMessage = null; + private BuildMessageEventArgs _lastMessage; /// /// Last custom build event the logger encountered /// - private CustomBuildEventArgs _lastCustom = null; + private CustomBuildEventArgs _lastCustom; /// /// Number of errors /// - private int _numberOfError = 0; + private int _numberOfError; /// /// Number of warnings /// - private int _numberOfWarning = 0; + private int _numberOfWarning; /// /// Number of messages /// - private int _numberOfMessage = 0; + private int _numberOfMessage; /// /// Number of custom build events /// - private int _numberOfCustom = 0; + private int _numberOfCustom; /// /// Last error logged diff --git a/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs b/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs index a6649794529..9fb860f2fe0 100644 --- a/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs +++ b/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs @@ -36,7 +36,7 @@ public class SolutionProjectGenerator_Tests : IDisposable { private readonly ITestOutputHelper output; - private string _originalVisualStudioVersion = null; + private string _originalVisualStudioVersion; private static readonly BuildEventContext _buildEventContext = new BuildEventContext(0, 0, BuildEventContext.InvalidProjectContextId, 0); diff --git a/src/Build.UnitTests/Definition/ToolsetConfigurationReaderTestHelper.cs b/src/Build.UnitTests/Definition/ToolsetConfigurationReaderTestHelper.cs index 9299d5c6d87..2906641881f 100644 --- a/src/Build.UnitTests/Definition/ToolsetConfigurationReaderTestHelper.cs +++ b/src/Build.UnitTests/Definition/ToolsetConfigurationReaderTestHelper.cs @@ -16,8 +16,8 @@ namespace Microsoft.Build.UnitTests internal class ToolsetConfigurationReaderTestHelper { private static ExeConfigurationFileMap s_configFile; - private static string s_testFolderFullPath = null; - private static Exception s_exceptionToThrow = null; + private static string s_testFolderFullPath; + private static Exception s_exceptionToThrow; internal static string WriteConfigFile(string content) { diff --git a/src/Build.UnitTests/Evaluation/ImportFromMSBuildExtensionsPath_Tests.cs b/src/Build.UnitTests/Evaluation/ImportFromMSBuildExtensionsPath_Tests.cs index bfcf5685dc2..469a6f63eef 100644 --- a/src/Build.UnitTests/Evaluation/ImportFromMSBuildExtensionsPath_Tests.cs +++ b/src/Build.UnitTests/Evaluation/ImportFromMSBuildExtensionsPath_Tests.cs @@ -19,7 +19,7 @@ namespace Microsoft.Build.UnitTests.Evaluation /// public class ImportFromMSBuildExtensionsPathTests : IDisposable { - string toolsVersionToUse = null; + string toolsVersionToUse; public ImportFromMSBuildExtensionsPathTests() { diff --git a/src/Build.UnitTests/MockTask.cs b/src/Build.UnitTests/MockTask.cs index 929243a2859..8f5c0e248a2 100644 --- a/src/Build.UnitTests/MockTask.cs +++ b/src/Build.UnitTests/MockTask.cs @@ -12,43 +12,43 @@ namespace Microsoft.Build.UnitTests { internal class MockTaskBase { - private bool _myBoolParam = false; - private bool[] _myBoolArrayParam = null; - private int _myIntParam = 0; - private int[] _myIntArrayParam = null; - private string _myStringParam = null; - private string[] _myStringArrayParam = null; - private ITaskItem _myITaskItemParam = null; - private ITaskItem[] _myITaskItemArrayParam = null; - - private bool _myRequiredBoolParam = false; - private bool[] _myRequiredBoolArrayParam = null; - private int _myRequiredIntParam = 0; - private int[] _myRequiredIntArrayParam = null; - private string _myRequiredStringParam = null; - private string[] _myRequiredStringArrayParam = null; - private ITaskItem _myRequiredITaskItemParam = null; - private ITaskItem[] _myRequiredITaskItemArrayParam = null; - - internal bool myBoolParamWasSet = false; - internal bool myBoolArrayParamWasSet = false; - internal bool myIntParamWasSet = false; - internal bool myIntArrayParamWasSet = false; - internal bool myStringParamWasSet = false; - internal bool myStringArrayParamWasSet = false; - internal bool myITaskItemParamWasSet = false; - internal bool myITaskItemArrayParamWasSet = false; + private bool _myBoolParam; + private bool[] _myBoolArrayParam; + private int _myIntParam; + private int[] _myIntArrayParam; + private string _myStringParam; + private string[] _myStringArrayParam; + private ITaskItem _myITaskItemParam; + private ITaskItem[] _myITaskItemArrayParam; + + private bool _myRequiredBoolParam; + private bool[] _myRequiredBoolArrayParam; + private int _myRequiredIntParam; + private int[] _myRequiredIntArrayParam; + private string _myRequiredStringParam; + private string[] _myRequiredStringArrayParam; + private ITaskItem _myRequiredITaskItemParam; + private ITaskItem[] _myRequiredITaskItemArrayParam; + + internal bool myBoolParamWasSet; + internal bool myBoolArrayParamWasSet; + internal bool myIntParamWasSet; + internal bool myIntArrayParamWasSet; + internal bool myStringParamWasSet; + internal bool myStringArrayParamWasSet; + internal bool myITaskItemParamWasSet; + internal bool myITaskItemArrayParamWasSet; // disable csharp compiler warning #0414: field assigned unused value #pragma warning disable 0414 - internal bool myRequiredBoolParamWasSet = false; - internal bool myRequiredBoolArrayParamWasSet = false; - internal bool myRequiredIntParamWasSet = false; - internal bool myRequiredIntArrayParamWasSet = false; - internal bool myRequiredStringParamWasSet = false; - internal bool myRequiredStringArrayParamWasSet = false; - internal bool myRequiredITaskItemParamWasSet = false; - internal bool myRequiredITaskItemArrayParamWasSet = false; + internal bool myRequiredBoolParamWasSet; + internal bool myRequiredBoolArrayParamWasSet; + internal bool myRequiredIntParamWasSet; + internal bool myRequiredIntArrayParamWasSet; + internal bool myRequiredStringParamWasSet; + internal bool myRequiredStringArrayParamWasSet; + internal bool myRequiredITaskItemParamWasSet; + internal bool myRequiredITaskItemArrayParamWasSet; #pragma warning restore 0414 /// @@ -377,7 +377,7 @@ public TaskItem[] TaskItemArrayOutputParameter /// sealed internal class MockTask : MockTaskBase, ITask { - private IBuildEngine _e = null; + private IBuildEngine _e; /// /// Task constructor. diff --git a/src/Build/BackEnd/BuildManager/BuildParameters.cs b/src/Build/BackEnd/BuildManager/BuildParameters.cs index 93d21956172..5c7cf73fba9 100644 --- a/src/Build/BackEnd/BuildManager/BuildParameters.cs +++ b/src/Build/BackEnd/BuildManager/BuildParameters.cs @@ -327,7 +327,7 @@ public bool UseSynchronousLogging /// /// Indicates whether to emit a default error if a task returns false without logging an error. /// - public bool AllowFailureWithoutError { get; set; } = false; + public bool AllowFailureWithoutError { get; set; } /// /// Gets the environment variables which were set when this build was created. @@ -780,7 +780,7 @@ public string OutputResultsCacheFile /// /// Determines whether MSBuild will save the results of builds after EndBuild to speed up future builds. /// - public bool DiscardBuildResults { get; set; } = false; + public bool DiscardBuildResults { get; set; } /// /// Gets or sets a value indicating whether the build process should run as low priority. diff --git a/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs b/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs index 0081265b99c..15b6bc0946c 100644 --- a/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs +++ b/src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs @@ -27,7 +27,7 @@ internal class NodeProviderInProc : INodeProvider, INodePacketFactory, IDisposab /// /// Flag indicating we have disposed. /// - private bool _disposed = false; + private bool _disposed; /// /// Value used to ensure multiple in-proc nodes which save the operating environment are not created. @@ -72,7 +72,7 @@ internal class NodeProviderInProc : INodeProvider, INodePacketFactory, IDisposab /// /// Check to allow the inproc node to have exclusive ownership of the operating environment /// - private bool _exclusiveOperatingEnvironment = false; + private bool _exclusiveOperatingEnvironment; #endregion diff --git a/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs b/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs index 57c0e51523e..66d3bccd3ad 100644 --- a/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs +++ b/src/Build/BackEnd/Components/Logging/BuildEventArgTransportSink.cs @@ -112,7 +112,7 @@ public IDictionary> WarningsAsMessagesByProject /// /// This property is ignored by this event sink and relies on the receiver to keep track of whether or not any errors have been logged. /// - public ISet BuildSubmissionIdsThatHaveLoggedErrors { get; } = null; + public ISet BuildSubmissionIdsThatHaveLoggedErrors { get; } #endregion #region IBuildEventSink Methods diff --git a/src/Build/BackEnd/Components/Logging/LoggingService.cs b/src/Build/BackEnd/Components/Logging/LoggingService.cs index 117f5195448..314d427b5c1 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingService.cs @@ -145,7 +145,7 @@ internal partial class LoggingService : ILoggingService, INodePacketHandler, IBu /// What is the Id for the next logger registered with the logging service. /// This Id is unique for this instance of the loggingService. /// - private int _nextSinkId = 0; + private int _nextSinkId; /// /// The number of nodes in the system. Loggers may take different action depending on how many nodes are in the system. @@ -185,7 +185,7 @@ internal partial class LoggingService : ILoggingService, INodePacketHandler, IBu /// /// What node is this logging service running on /// - private int _nodeId = 0; + private int _nodeId; /// /// Whether to include evaluation metaprojects in events. @@ -477,7 +477,7 @@ public ISet WarningsAsErrors { get; set; - } = null; + } /// /// A list of warnings to treat as low importance messages. @@ -486,7 +486,7 @@ public ISet WarningsAsMessages { get; set; - } = null; + } /// /// Should evaluation events include generated metaprojects? diff --git a/src/Build/BackEnd/Components/Logging/LoggingServiceFactory.cs b/src/Build/BackEnd/Components/Logging/LoggingServiceFactory.cs index dcc4e2f8074..ed69b03a459 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingServiceFactory.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingServiceFactory.cs @@ -21,7 +21,7 @@ internal class LoggingServiceFactory /// /// What node is this logging service being created on. /// - private int _nodeId = 0; + private int _nodeId; #endregion #region Constructor diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/CallTarget.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/CallTarget.cs index cd25ccc91c4..e73090bfb1f 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/CallTarget.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/CallTarget.cs @@ -34,7 +34,7 @@ internal class CallTarget : ITask /// default targets, use the task and pass in Projects=$(MSBuildProjectFile). /// /// Array of target names. - public string[] Targets { get; set; } = null; + public string[] Targets { get; set; } /// /// Outputs of the targets built in each project. @@ -48,12 +48,12 @@ internal class CallTarget : ITask /// we would call the engine once per target (for each project). The benefit of this is that /// if one target fails, you can still continue with the remaining targets. /// - public bool RunEachTargetSeparately { get; set; } = false; + public bool RunEachTargetSeparately { get; set; } /// /// Deprecated. Does nothing. /// - public bool UseResultsCache { get; set; } = false; + public bool UseResultsCache { get; set; } #endregion diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs index 6e0ba6a0d5f..11138bcc8e7 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs @@ -90,7 +90,7 @@ private enum SkipNonexistentProjectsBehavior /// /// Gets or sets a semicolon-delimited list of global properties to remove. /// - public string RemoveProperties { get; set; } = null; + public string RemoveProperties { get; set; } /// /// The targets to build in each project specified by the property. @@ -116,25 +116,25 @@ private enum SkipNonexistentProjectsBehavior /// Indicates if the paths of target output items should be rebased relative to the calling project. /// /// true, if target output item paths should be rebased - public bool RebaseOutputs { get; set; } = false; + public bool RebaseOutputs { get; set; } /// /// Forces the task to stop building the remaining projects as soon as any of /// them fail. /// - public bool StopOnFirstFailure { get; set; } = false; + public bool StopOnFirstFailure { get; set; } /// /// When this is true, instead of calling the engine once to build all the targets (for each project), /// we would call the engine once per target (for each project). The benefit of this is that /// if one target fails, you can still continue with the remaining targets. /// - public bool RunEachTargetSeparately { get; set; } = false; + public bool RunEachTargetSeparately { get; set; } /// /// Value of ToolsVersion to use when building projects passed to this task. /// - public string ToolsVersion { get; set; } = null; + public string ToolsVersion { get; set; } /// /// When this is true we call the engine with all the projects at once instead of @@ -145,7 +145,7 @@ private enum SkipNonexistentProjectsBehavior /// /// If true the project will be unloaded once the operation is completed /// - public bool UnloadProjectsOnCompletion { get; set; } = false; + public bool UnloadProjectsOnCompletion { get; set; } /// /// Deprecated. Does nothing. @@ -200,7 +200,7 @@ public string SkipNonexistentProjects /// will be un-escaped before processing. e.g. %3B (an escaped ';') in the string for any of them will /// be treated as if it were an un-escaped ';' /// - public string[] TargetAndPropertyListSeparators { get; set; } = null; + public string[] TargetAndPropertyListSeparators { get; set; } /// /// If set, MSBuild will skip the targets specified in this build request if they are not defined in the diff --git a/src/Framework.UnitTests/EventArgs_Tests.cs b/src/Framework.UnitTests/EventArgs_Tests.cs index 69d90df50b3..f076d77a074 100644 --- a/src/Framework.UnitTests/EventArgs_Tests.cs +++ b/src/Framework.UnitTests/EventArgs_Tests.cs @@ -21,7 +21,7 @@ public class EventArgs_Tests /// Base instance of a BuildEventArgs some default data, this is used during the tests /// to verify the equals operators. /// - private static GenericBuildEventArgs s_baseGenericEvent = null; + private static GenericBuildEventArgs s_baseGenericEvent; /// /// Setup the test, this method is run ONCE for the entire test fixture diff --git a/src/MSBuild/OutOfProcTaskHostNode.cs b/src/MSBuild/OutOfProcTaskHostNode.cs index e747dbcc9a3..f8ffff3c833 100644 --- a/src/MSBuild/OutOfProcTaskHostNode.cs +++ b/src/MSBuild/OutOfProcTaskHostNode.cs @@ -267,7 +267,7 @@ public bool IsRunningMultipleNodes /// /// Enables or disables emitting a default error when a task fails without logging errors /// - public bool AllowFailureWithoutError { get; set; } = false; + public bool AllowFailureWithoutError { get; set; } #endregion #region IBuildEngine8 Implementation diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index ae95d608193..386669cbe3b 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -2037,7 +2037,7 @@ bool allowEmptyParameters /// /// Whether switches from the auto-response file are being used. /// - internal static bool usingSwitchesFromAutoResponseFile = false; + internal static bool usingSwitchesFromAutoResponseFile; /// /// Parses the auto-response file (assumes the "/noautoresponse" switch is not specified on the command line), and combines the diff --git a/src/Shared/AssemblyNameExtension.cs b/src/Shared/AssemblyNameExtension.cs index 99db41274e3..2a4bf7e261a 100644 --- a/src/Shared/AssemblyNameExtension.cs +++ b/src/Shared/AssemblyNameExtension.cs @@ -57,9 +57,9 @@ internal enum PartialComparisonFlags : int [Serializable] internal sealed class AssemblyNameExtension : ISerializable, IEquatable, ITranslatable { - private AssemblyName asAssemblyName = null; - private string asString = null; - private bool isSimpleName = false; + private AssemblyName asAssemblyName; + private string asString; + private bool isSimpleName; private bool hasProcessorArchitectureInFusionName; private bool immutable; diff --git a/src/Shared/CoreCLRAssemblyLoader.cs b/src/Shared/CoreCLRAssemblyLoader.cs index cd02dba6528..338d06d3984 100644 --- a/src/Shared/CoreCLRAssemblyLoader.cs +++ b/src/Shared/CoreCLRAssemblyLoader.cs @@ -22,7 +22,7 @@ internal sealed class CoreClrAssemblyLoader private readonly HashSet _dependencyPaths = new HashSet(StringComparer.OrdinalIgnoreCase); private readonly object _guard = new object(); - private bool _resolvingHandlerHookedUp = false; + private bool _resolvingHandlerHookedUp; private static readonly Version _currentAssemblyVersion = new Version(Microsoft.Build.Shared.MSBuildConstants.CurrentAssemblyVersion); diff --git a/src/Shared/FileUtilities.cs b/src/Shared/FileUtilities.cs index 940bcd46ce9..6067abbb117 100644 --- a/src/Shared/FileUtilities.cs +++ b/src/Shared/FileUtilities.cs @@ -41,7 +41,7 @@ internal static partial class FileUtilities /// /// The directory where MSBuild stores cache information used during the build. /// - internal static string cacheDirectory = null; + internal static string cacheDirectory; /// /// FOR UNIT TESTS ONLY diff --git a/src/Shared/LogMessagePacketBase.cs b/src/Shared/LogMessagePacketBase.cs index c398d3304a5..4815c1ff99e 100644 --- a/src/Shared/LogMessagePacketBase.cs +++ b/src/Shared/LogMessagePacketBase.cs @@ -187,7 +187,7 @@ private static int GetDefaultPacketVersion() /// /// Delegate for translating targetfinished events. /// - private TargetFinishedTranslator _targetFinishedTranslator = null; + private TargetFinishedTranslator _targetFinishedTranslator; #region Data diff --git a/src/Shared/TaskEngineAssemblyResolver.cs b/src/Shared/TaskEngineAssemblyResolver.cs index ddbc6dcc62c..705f97e8859 100644 --- a/src/Shared/TaskEngineAssemblyResolver.cs +++ b/src/Shared/TaskEngineAssemblyResolver.cs @@ -157,11 +157,11 @@ public override object InitializeLifetimeService() // we have to store the event handler instance in case we have to remove it - private ResolveEventHandler _eventHandler = null; + private ResolveEventHandler _eventHandler; #else - private Func _eventHandler = null; + private Func _eventHandler; #endif // path to the task assembly, but only if it's loaded using LoadFrom. If it's loaded with Load, this is null. - private string _taskAssemblyFile = null; + private string _taskAssemblyFile; } } diff --git a/src/Shared/TaskHostTaskComplete.cs b/src/Shared/TaskHostTaskComplete.cs index 11194395c49..ae4f7d4a3e7 100644 --- a/src/Shared/TaskHostTaskComplete.cs +++ b/src/Shared/TaskHostTaskComplete.cs @@ -73,12 +73,12 @@ internal class TaskHostTaskComplete : INodePacket /// /// The set of parameters / values from the task after it finishes execution. /// - private Dictionary _taskOutputParameters = null; + private Dictionary _taskOutputParameters; /// /// The process environment at the end of task execution. /// - private Dictionary _buildProcessEnvironment = null; + private Dictionary _buildProcessEnvironment; /// /// Constructor diff --git a/src/Shared/TaskParameter.cs b/src/Shared/TaskParameter.cs index 9dbd4f83802..e3e49bf3e99 100644 --- a/src/Shared/TaskParameter.cs +++ b/src/Shared/TaskParameter.cs @@ -502,17 +502,17 @@ private class TaskParameterTaskItem : /// /// The item spec /// - private string _escapedItemSpec = null; + private string _escapedItemSpec; /// /// The full path to the project that originally defined this item. /// - private string _escapedDefiningProject = null; + private string _escapedDefiningProject; /// /// The custom metadata /// - private Dictionary _customEscapedMetadata = null; + private Dictionary _customEscapedMetadata; /// /// Cache for fullpath metadata diff --git a/src/Shared/UnitTests/FileMatcher_Tests.cs b/src/Shared/UnitTests/FileMatcher_Tests.cs index b779aaa45ba..c1ed41d7163 100644 --- a/src/Shared/UnitTests/FileMatcher_Tests.cs +++ b/src/Shared/UnitTests/FileMatcher_Tests.cs @@ -1965,17 +1965,17 @@ internal class MockFileSystem /// /// Number of times a file from set 1 was requested. /// - private int _fileSet1Hits = 0; + private int _fileSet1Hits; /// /// Number of times a file from set 2 was requested. /// - private int _fileSet2Hits = 0; + private int _fileSet2Hits; /// /// Number of times a file from set 3 was requested. /// - private int _fileSet3Hits = 0; + private int _fileSet3Hits; /// /// Construct. diff --git a/src/Shared/UnitTests/MockEngine.cs b/src/Shared/UnitTests/MockEngine.cs index 431e8948cb0..bf02ec51ac7 100644 --- a/src/Shared/UnitTests/MockEngine.cs +++ b/src/Shared/UnitTests/MockEngine.cs @@ -51,7 +51,7 @@ internal MockEngine() : this(false) internal int Errors { get; set; } - public bool AllowFailureWithoutError { get; set; } = false; + public bool AllowFailureWithoutError { get; set; } public BuildErrorEventArgs[] ErrorEvents => _errorEvents.ToArray(); public BuildWarningEventArgs[] WarningEvents => _warningEvents.ToArray(); diff --git a/src/StringTools.Benchmark/SpanBasedStringBuilder_Benchmark.cs b/src/StringTools.Benchmark/SpanBasedStringBuilder_Benchmark.cs index 03fa15ccfc5..841fc3d51e8 100644 --- a/src/StringTools.Benchmark/SpanBasedStringBuilder_Benchmark.cs +++ b/src/StringTools.Benchmark/SpanBasedStringBuilder_Benchmark.cs @@ -20,7 +20,7 @@ public class SpanBasedStringBuilder_Benchmark private static SpanBasedStringBuilder _pooledSpanBasedStringBuilder = new SpanBasedStringBuilder(); private static StringBuilder _pooledStringBuilder = new StringBuilder(); - private static int _uniqueStringCounter = 0; + private static int _uniqueStringCounter; [GlobalSetup] public void GlobalSetup() diff --git a/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs b/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs index e64d7b07d8c..26c35c99ff0 100644 --- a/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs +++ b/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs @@ -41,10 +41,10 @@ public class ResolveAssemblyReferenceTestFixture : IDisposable internal static Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader = new Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader(ReadMachineTypeFromPEHeader); // Performance checks. - internal static Dictionary uniqueFileExists = null; - internal static Dictionary uniqueGetAssemblyName = null; + internal static Dictionary uniqueFileExists; + internal static Dictionary uniqueGetAssemblyName; - internal static bool useFrameworkFileExists = false; + internal static bool useFrameworkFileExists; internal const string REDISTLIST = @" From 5d2454f5b103257b57805586208b55c1a5e1f7c9 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 30 Dec 2021 11:03:15 +1000 Subject: [PATCH 2/8] Fixes typo --- .../RemoteProjectsProviderMock/ExporterMock.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs index f0e3ed21453..f25c3e4149e 100644 --- a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs +++ b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs @@ -143,7 +143,7 @@ internal interface IImportHolder /// internal class ProjectCollectionLinker : ExternalProjectsProvider { - internal static int _collecitonId; + internal static int _collectionId; private bool importing; private ExportedLinksMap exported = ExportedLinksMap.Create(); @@ -152,7 +152,7 @@ internal class ProjectCollectionLinker : ExternalProjectsProvider private ProjectCollectionLinker(ConnectedProjectCollections group) { this.LinkedCollections = group; - this.CollectionId = (UInt32) Interlocked.Increment(ref _collecitonId); + this.CollectionId = (UInt32) Interlocked.Increment(ref _collectionId); this.Collection = new ProjectCollection(); this.LinkFactory = LinkedObjectsFactory.Get(this.Collection); } From 99bb5c4aa73da21af76c257e7407b0684704b4d3 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 30 Dec 2021 11:16:03 +1000 Subject: [PATCH 3/8] Fixed missing CA1805 violations --- .../RequestBuilder/RequestBuilder.cs | 6 ++--- .../Components/RequestBuilder/TaskHost.cs | 6 ++--- .../BackEnd/Components/Scheduler/Scheduler.cs | 6 ++--- src/Build/Construction/ProjectRootElement.cs | 2 +- src/Build/Definition/Toolset.cs | 2 +- .../Definition/ToolsetConfigurationReader.cs | 4 ++-- .../Errors/InvalidProjectFileException.cs | 2 +- .../InvalidToolsetDefinitionException.cs | 2 +- .../MultipleComparisonExpressionNode.cs | 2 +- src/Build/Evaluation/Conditionals/Parser.cs | 4 ++-- src/Build/Evaluation/Conditionals/Scanner.cs | 6 ++--- .../Conditionals/StringExpressionNode.cs | 2 +- .../LazyItemEvaluator.UpdateOperation.cs | 6 ++--- src/Build/Evaluation/LazyItemEvaluator.cs | 2 +- src/Build/Instance/HostServices.cs | 4 ++-- .../TaskFactories/AssemblyTaskFactory.cs | 2 +- .../Instance/TaskFactories/TaskHostTask.cs | 4 ++-- src/Build/Logging/BaseConsoleLogger.cs | 22 +++++++++---------- .../BinaryLogger/BuildEventArgsReader.cs | 4 ++-- src/Build/Logging/ConsoleLogger.cs | 2 +- .../ConfigurableForwardingLogger.cs | 6 ++--- .../ParallelLogger/ParallelConsoleLogger.cs | 2 +- src/Build/Logging/ProfilerLogger.cs | 2 +- 23 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs index 7204146c1cd..95eefda8a53 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs @@ -96,12 +96,12 @@ internal class RequestBuilder : IRequestBuilder, IRequestBuilderCallback, IBuild /// /// Flag indicating we are in an MSBuild callback /// - private bool _inMSBuildCallback = false; + private bool _inMSBuildCallback; /// /// Flag indicating whether this request builder has been zombied by a cancellation request. /// - private bool _isZombie = false; + private bool _isZombie; /// /// Creates a new request builder. @@ -1382,7 +1382,7 @@ private ISet ParseWarningCodes(string warnings) private sealed class DedicatedThreadsTaskScheduler : TaskScheduler { private readonly BlockingCollection _tasks = new BlockingCollection(); - private int _availableThreads = 0; + private int _availableThreads; protected override void QueueTask(Task task) { diff --git a/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs b/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs index 0c07dae6d6f..46b3297ee7a 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs @@ -686,7 +686,7 @@ public IReadOnlyDictionary GetGlobalProperties() /// /// Enables or disables emitting a default error when a task fails without logging errors /// - public bool AllowFailureWithoutError { get; set; } = false; + public bool AllowFailureWithoutError { get; set; } #endregion @@ -756,12 +756,12 @@ public bool ShouldTreatWarningAsError(string warningCode) /// /// Additional cores granted to the task by the scheduler. Does not include the one implicit core automatically granted to all tasks. /// - private int _additionalAcquiredCores = 0; + private int _additionalAcquiredCores; /// /// True if the one implicit core has been allocated by , false otherwise. /// - private bool _isImplicitCoreUsed = false; + private bool _isImplicitCoreUsed; /// /// Total number of cores granted to the task, including the one implicit core. diff --git a/src/Build/BackEnd/Components/Scheduler/Scheduler.cs b/src/Build/BackEnd/Components/Scheduler/Scheduler.cs index baa4c5b1a44..8793cfbc1ba 100644 --- a/src/Build/BackEnd/Components/Scheduler/Scheduler.cs +++ b/src/Build/BackEnd/Components/Scheduler/Scheduler.cs @@ -94,13 +94,13 @@ internal class Scheduler : IScheduler /// The number of inproc nodes that can be created without hitting the /// node limit. /// - private int _currentInProcNodeCount = 0; + private int _currentInProcNodeCount; /// /// The number of out-of-proc nodes that can be created without hitting the /// node limit. /// - private int _currentOutOfProcNodeCount = 0; + private int _currentOutOfProcNodeCount; /// /// The collection of all requests currently known to the system. @@ -170,7 +170,7 @@ internal class Scheduler : IScheduler private NodeLoggingContext _inprocNodeContext; - private int _loggedWarningsForProxyBuildsOnOutOfProcNodes = 0; + private int _loggedWarningsForProxyBuildsOnOutOfProcNodes; /// /// Constructor. diff --git a/src/Build/Construction/ProjectRootElement.cs b/src/Build/Construction/ProjectRootElement.cs index cb08aee7b3e..7d69f53fdcd 100644 --- a/src/Build/Construction/ProjectRootElement.cs +++ b/src/Build/Construction/ProjectRootElement.cs @@ -620,7 +620,7 @@ public int Version /// public DateTime LastWriteTimeWhenRead => Link != null ? RootLink.LastWriteTimeWhenRead : _lastWriteTimeWhenReadUtc.ToLocalTime(); - internal DateTime? StreamTimeUtc = null; + internal DateTime? StreamTimeUtc; /// /// This does not allow conditions, so it should not be called. diff --git a/src/Build/Definition/Toolset.cs b/src/Build/Definition/Toolset.cs index b623fed7040..cbb229e6633 100644 --- a/src/Build/Definition/Toolset.cs +++ b/src/Build/Definition/Toolset.cs @@ -174,7 +174,7 @@ public class Toolset : ITranslatable /// /// Delegate to check to see if a directory exists /// - private DirectoryExists _directoryExists = null; + private DirectoryExists _directoryExists; /// /// Delegate for loading Xml. For unit testing only. diff --git a/src/Build/Definition/ToolsetConfigurationReader.cs b/src/Build/Definition/ToolsetConfigurationReader.cs index e2df26e70dd..938d44c09af 100644 --- a/src/Build/Definition/ToolsetConfigurationReader.cs +++ b/src/Build/Definition/ToolsetConfigurationReader.cs @@ -25,7 +25,7 @@ internal class ToolsetConfigurationReader : ToolsetReader /// /// A section of a toolset configuration /// - private ToolsetConfigurationSection _configurationSection = null; + private ToolsetConfigurationSection _configurationSection; /// /// Delegate used to read application configurations @@ -35,7 +35,7 @@ internal class ToolsetConfigurationReader : ToolsetReader /// /// Flag indicating that an attempt has been made to read the configuration /// - private bool _configurationReadAttempted = false; + private bool _configurationReadAttempted; /// /// Character used to separate search paths specified for MSBuildExtensionsPath* in diff --git a/src/Build/Errors/InvalidProjectFileException.cs b/src/Build/Errors/InvalidProjectFileException.cs index 6588acce0b8..c60f757eee9 100644 --- a/src/Build/Errors/InvalidProjectFileException.cs +++ b/src/Build/Errors/InvalidProjectFileException.cs @@ -370,6 +370,6 @@ internal set // the F1-help keyword for the host IDE private string helpKeyword; // Has this errors been sent to the loggers? - private bool hasBeenLogged = false; + private bool hasBeenLogged; } } diff --git a/src/Build/Errors/InvalidToolsetDefinitionException.cs b/src/Build/Errors/InvalidToolsetDefinitionException.cs index 79354ecd57d..eba95ecb488 100644 --- a/src/Build/Errors/InvalidToolsetDefinitionException.cs +++ b/src/Build/Errors/InvalidToolsetDefinitionException.cs @@ -20,7 +20,7 @@ public class InvalidToolsetDefinitionException : Exception /// /// The MSBuild error code corresponding with this exception. /// - private string errorCode = null; + private string errorCode; /// /// Basic constructor. diff --git a/src/Build/Evaluation/Conditionals/MultipleComparisonExpressionNode.cs b/src/Build/Evaluation/Conditionals/MultipleComparisonExpressionNode.cs index 18e1caad924..76b45b4be63 100644 --- a/src/Build/Evaluation/Conditionals/MultipleComparisonExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/MultipleComparisonExpressionNode.cs @@ -12,7 +12,7 @@ namespace Microsoft.Build.Evaluation /// internal abstract class MultipleComparisonNode : OperatorExpressionNode { - private bool _conditionedPropertiesUpdated = false; + private bool _conditionedPropertiesUpdated; /// /// Compare numbers diff --git a/src/Build/Evaluation/Conditionals/Parser.cs b/src/Build/Evaluation/Conditionals/Parser.cs index 292226a5ed8..41b447cc64e 100644 --- a/src/Build/Evaluation/Conditionals/Parser.cs +++ b/src/Build/Evaluation/Conditionals/Parser.cs @@ -43,11 +43,11 @@ internal sealed class Parser private Scanner _lexer; private ParserOptions _options; private ElementLocation _elementLocation; - internal int errorPosition = 0; // useful for unit tests + internal int errorPosition; // useful for unit tests #region REMOVE_COMPAT_WARNING - private bool _warnedForExpression = false; + private bool _warnedForExpression; private BuildEventContext _logBuildEventContext; /// diff --git a/src/Build/Evaluation/Conditionals/Scanner.cs b/src/Build/Evaluation/Conditionals/Scanner.cs index 04af6a1a016..0f27a965823 100644 --- a/src/Build/Evaluation/Conditionals/Scanner.cs +++ b/src/Build/Evaluation/Conditionals/Scanner.cs @@ -31,10 +31,10 @@ internal sealed class Scanner internal bool _errorState; private int _errorPosition; // What we found instead of what we were looking for - private string _unexpectedlyFound = null; + private string _unexpectedlyFound; private ParserOptions _options; - private string _errorResource = null; - private static string s_endOfInput = null; + private string _errorResource; + private static string s_endOfInput; /// /// Lazily format resource string to help avoid (in some perf critical cases) even loading diff --git a/src/Build/Evaluation/Conditionals/StringExpressionNode.cs b/src/Build/Evaluation/Conditionals/StringExpressionNode.cs index f87cd766ca5..96f724f1f7d 100644 --- a/src/Build/Evaluation/Conditionals/StringExpressionNode.cs +++ b/src/Build/Evaluation/Conditionals/StringExpressionNode.cs @@ -154,7 +154,7 @@ internal override void ResetState() _shouldBeTreatedAsVisualStudioVersion = null; } - private bool? _shouldBeTreatedAsVisualStudioVersion = null; + private bool? _shouldBeTreatedAsVisualStudioVersion; /// /// Should this node be treated as an expansion of VisualStudioVersion, rather than diff --git a/src/Build/Evaluation/LazyItemEvaluator.UpdateOperation.cs b/src/Build/Evaluation/LazyItemEvaluator.UpdateOperation.cs index 349a561c231..28191ba6056 100644 --- a/src/Build/Evaluation/LazyItemEvaluator.UpdateOperation.cs +++ b/src/Build/Evaluation/LazyItemEvaluator.UpdateOperation.cs @@ -16,9 +16,9 @@ internal partial class LazyItemEvaluator class UpdateOperation : LazyItemOperation { private readonly ImmutableList _metadata; - private ImmutableList.Builder _itemsToUpdate = null; - private ItemSpecMatchesItem _matchItemSpec = null; - private bool? _needToExpandMetadataForEachItem = null; + private ImmutableList.Builder _itemsToUpdate; + private ItemSpecMatchesItem _matchItemSpec; + private bool? _needToExpandMetadataForEachItem; public UpdateOperation(OperationBuilderWithMetadata builder, LazyItemEvaluator lazyEvaluator) : base(builder, lazyEvaluator) diff --git a/src/Build/Evaluation/LazyItemEvaluator.cs b/src/Build/Evaluation/LazyItemEvaluator.cs index 99dc789d996..791c42e9592 100644 --- a/src/Build/Evaluation/LazyItemEvaluator.cs +++ b/src/Build/Evaluation/LazyItemEvaluator.cs @@ -34,7 +34,7 @@ internal partial class LazyItemEvaluator private readonly LoggingContext _loggingContext; private readonly EvaluationProfiler _evaluationProfiler; - private int _nextElementOrder = 0; + private int _nextElementOrder; private Dictionary _itemLists = Traits.Instance.EscapeHatches.UseCaseSensitiveItemNames ? new Dictionary() : diff --git a/src/Build/Instance/HostServices.cs b/src/Build/Instance/HostServices.cs index a27e5787cfb..064ae4a50d7 100644 --- a/src/Build/Instance/HostServices.cs +++ b/src/Build/Instance/HostServices.cs @@ -384,8 +384,8 @@ internal class MonikerNameOrITaskHost { public ITaskHost TaskHost { get; } public string MonikerName { get; } - public bool IsTaskHost { get; } = false; - public bool IsMoniker { get; } = false; + public bool IsTaskHost { get; } + public bool IsMoniker { get; } public MonikerNameOrITaskHost(ITaskHost taskHost) { TaskHost = taskHost; diff --git a/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs b/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs index 4596be57f52..88265e4e242 100644 --- a/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs +++ b/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs @@ -31,7 +31,7 @@ internal class AssemblyTaskFactory : ITaskFactory2 /// /// Name of the task wrapped by the task factory /// - private string _taskName = null; + private string _taskName; /// /// The loaded type (type, assembly name / file) of the task wrapped by the factory diff --git a/src/Build/Instance/TaskFactories/TaskHostTask.cs b/src/Build/Instance/TaskFactories/TaskHostTask.cs index 99bc7663895..d489b8feaa4 100644 --- a/src/Build/Instance/TaskFactories/TaskHostTask.cs +++ b/src/Build/Instance/TaskFactories/TaskHostTask.cs @@ -91,7 +91,7 @@ internal class TaskHostTask : IGeneratedTask, ICancelableTask, INodePacketFactor /// /// True if currently connected to the task host; false otherwise. /// - private bool _connectedToTaskHost = false; + private bool _connectedToTaskHost; /// /// The provider for task host nodes. @@ -117,7 +117,7 @@ internal class TaskHostTask : IGeneratedTask, ICancelableTask, INodePacketFactor /// /// Did the task succeed? /// - private bool _taskExecutionSucceeded = false; + private bool _taskExecutionSucceeded; /// /// Constructor diff --git a/src/Build/Logging/BaseConsoleLogger.cs b/src/Build/Logging/BaseConsoleLogger.cs index 1f7480ffc0c..8ff3d28b728 100644 --- a/src/Build/Logging/BaseConsoleLogger.cs +++ b/src/Build/Logging/BaseConsoleLogger.cs @@ -75,14 +75,14 @@ internal static ConsoleColor BackgroundColor /// and warnings summary at the end of a build. /// /// null - public string Parameters { get; set; } = null; + public string Parameters { get; set; } /// /// Suppresses the display of project headers. Project headers are /// displayed by default unless this property is set. /// /// This is only needed by the IDE logger. - internal bool SkipProjectStartedText { get; set; } = false; + internal bool SkipProjectStartedText { get; set; } /// /// Suppresses the display of error and warnings summary. @@ -1148,12 +1148,12 @@ private bool ApplyVerbosityParameter(string parameterValue) /// /// Delegate used to change text color. /// - internal ColorSetter setColor = null; + internal ColorSetter setColor; /// /// Delegate used to reset text color /// - internal ColorResetter resetColor = null; + internal ColorResetter resetColor; /// /// Number of spaces that each level of indentation is worth @@ -1163,7 +1163,7 @@ private bool ApplyVerbosityParameter(string parameterValue) /// /// Keeps track of the current indentation level. /// - internal int currentIndentLevel = 0; + internal int currentIndentLevel; /// /// The kinds of newline breaks we expect. @@ -1190,7 +1190,7 @@ private bool ApplyVerbosityParameter(string parameterValue) /// /// When true, accumulate performance numbers. /// - internal bool showPerfSummary = false; + internal bool showPerfSummary; /// /// When true, show the list of item and property values at the start of each project @@ -1200,7 +1200,7 @@ private bool ApplyVerbosityParameter(string parameterValue) /// /// Should the target output items be displayed /// - internal bool showTargetOutputs = false; + internal bool showTargetOutputs; /// /// When true, suppresses all messages except for warnings. (And possibly errors, if showOnlyErrors is true.) @@ -1220,23 +1220,23 @@ private bool ApplyVerbosityParameter(string parameterValue) /// /// When true, indicates that the logger should tack the project file onto the end of errors and warnings. /// - protected bool showProjectFile = false; + protected bool showProjectFile; internal bool ignoreLoggerErrors = true; - internal bool runningWithCharacterFileType = false; + internal bool runningWithCharacterFileType; #region Per-build Members /// /// Number of errors encountered in this build /// - internal int errorCount = 0; + internal int errorCount; /// /// Number of warnings encountered in this build /// - internal int warningCount = 0; + internal int warningCount; /// /// A list of the errors that have occurred during this build. diff --git a/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs b/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs index c6be1d59db3..371df743324 100644 --- a/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs +++ b/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs @@ -22,7 +22,7 @@ public class BuildEventArgsReader : IDisposable { private readonly BinaryReader binaryReader; private readonly int fileFormatVersion; - private long recordNumber = 0; + private long recordNumber; /// /// A list of string records we've encountered so far. If it's a small string, it will be the string directly. @@ -1291,7 +1291,7 @@ public StringStorage() } } - private long totalAllocatedShortStrings = 0; + private long totalAllocatedShortStrings; public object Add(string text) { diff --git a/src/Build/Logging/ConsoleLogger.cs b/src/Build/Logging/ConsoleLogger.cs index c6358a9badb..d1f3409fe4b 100644 --- a/src/Build/Logging/ConsoleLogger.cs +++ b/src/Build/Logging/ConsoleLogger.cs @@ -50,7 +50,7 @@ public class ConsoleLogger : INodeLogger private ColorSetter _colorSet; private ColorResetter _colorReset; private string _parameters; - private bool _skipProjectStartedText = false; + private bool _skipProjectStartedText; private bool? _showSummary; #region Constructors diff --git a/src/Build/Logging/DistributedLoggers/ConfigurableForwardingLogger.cs b/src/Build/Logging/DistributedLoggers/ConfigurableForwardingLogger.cs index 83c2499aefa..9bddd0f5028 100644 --- a/src/Build/Logging/DistributedLoggers/ConfigurableForwardingLogger.cs +++ b/src/Build/Logging/DistributedLoggers/ConfigurableForwardingLogger.cs @@ -512,7 +512,7 @@ private bool IsVerbosityAtLeast(LoggerVerbosity checkVerbosity) /// /// Console logger parameters. /// - private string _loggerParameters = null; + private string _loggerParameters; /// /// Console logger parameters delimiters. @@ -572,12 +572,12 @@ private bool IsVerbosityAtLeast(LoggerVerbosity checkVerbosity) /// /// When true, accumulate performance numbers. /// - private bool _showPerfSummary = false; + private bool _showPerfSummary; /// /// When true the commandline message is sent /// - private bool _showCommandLine = false; + private bool _showCommandLine; /// /// Id of the node the logger is attached to diff --git a/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs b/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs index a68b477bfdc..598f8e5315e 100644 --- a/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs +++ b/src/Build/Logging/ParallelLogger/ParallelConsoleLogger.cs @@ -1769,7 +1769,7 @@ internal override void PrintCounterMessage(WriteLinePrettyFromResourceDelegate W private BuildEventContext _lastDisplayedBuildEventContext; private int _bufferWidth = -1; private readonly object _lockObject = new Object(); - private int _prefixWidth = 0; + private int _prefixWidth; private ProjectFullKey _lastProjectFullKey = new ProjectFullKey(-1, -1); private bool _alignMessages; private bool _forceNoAlign; diff --git a/src/Build/Logging/ProfilerLogger.cs b/src/Build/Logging/ProfilerLogger.cs index 5d0ed444b07..9c0542b3def 100644 --- a/src/Build/Logging/ProfilerLogger.cs +++ b/src/Build/Logging/ProfilerLogger.cs @@ -29,7 +29,7 @@ public sealed class ProfilerLogger : ILogger /// /// Aggregation of all profiled locations. Computed the first time is called. /// - private Dictionary _aggregatedLocations = null; + private Dictionary _aggregatedLocations; /// /// If null, no file is saved to disk From 7a16522ebb4c6d33cc935b5e5ddf53b6da44e31a Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 30 Dec 2021 11:39:57 +1000 Subject: [PATCH 4/8] Wrap debug variables instead of not assigning them --- .../Helpers/ViewValidation.construction.cs | 4 +++- .../RemoteProjectsProviderMock/ExporterMock.cs | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs b/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs index a2a66e2e8d4..92b2b07e215 100644 --- a/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs +++ b/src/Build.OM.UnitTests/ObjectModelRemoting/Helpers/ViewValidation.construction.cs @@ -265,7 +265,9 @@ public static bool IsLinkedObject(object obj) return LinkedObjectsFactory.GetLink(obj) != null; } - private static bool dbgIgnoreLinked; +#pragma warning disable CA1805 // Do not initialize unnecessarily + private static bool dbgIgnoreLinked = false; +#pragma warning restore CA1805 // Do not initialize unnecessarily public static void VerifyNotLinked(object obj) { if (dbgIgnoreLinked) return; diff --git a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs index f25c3e4149e..ba98efe7e64 100644 --- a/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs +++ b/src/Build.OM.UnitTests/ObjectModelRemoting/RemoteProjectsProviderMock/ExporterMock.cs @@ -1,5 +1,4 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting { @@ -214,10 +213,11 @@ private void ConnectTo (ProjectCollectionLinker other) } } - private static bool dbgValidateDuplicateViews; +#pragma warning disable CA1805 // Do not initialize unnecessarily + private static bool dbgValidateDuplicateViews = false; +#pragma warning restore CA1805 // Do not initialize unnecessarily - - internal void ValidateNoDuplicates() + internal void ValidateNoDuplicates() { foreach (var r in imported) { From 4456c622716f62c90e0f0ebc4915ef60ab870826 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 30 Dec 2021 11:46:15 +1000 Subject: [PATCH 5/8] Fix CS0649 warning --- .../AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs b/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs index 26c35c99ff0..428b4705511 100644 --- a/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs +++ b/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs @@ -44,7 +44,7 @@ public class ResolveAssemblyReferenceTestFixture : IDisposable internal static Dictionary uniqueFileExists; internal static Dictionary uniqueGetAssemblyName; - internal static bool useFrameworkFileExists; + internal static bool useFrameworkFileExists { get; set; } internal const string REDISTLIST = @" From d01f99bd7c834863fbdb93dba0c61956da176c8b Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Sat, 8 Jan 2022 10:20:39 +1000 Subject: [PATCH 6/8] Revert CodeAnalysis.ruleset --- eng/CodeAnalysis.ruleset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/CodeAnalysis.ruleset b/eng/CodeAnalysis.ruleset index 989f3de33d1..2078c42fe6c 100644 --- a/eng/CodeAnalysis.ruleset +++ b/eng/CodeAnalysis.ruleset @@ -83,7 +83,7 @@ - + From 8bc5f6741c5e9f29142eb15184c28441174a38b1 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Sat, 8 Jan 2022 10:21:17 +1000 Subject: [PATCH 7/8] enable warning on CA1805 --- eng/Common.globalconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig index fd878420d57..a15b89db538 100644 --- a/eng/Common.globalconfig +++ b/eng/Common.globalconfig @@ -248,7 +248,7 @@ dotnet_diagnostic.CA1801.severity = none dotnet_diagnostic.CA1802.severity = suggestion # Do not initialize unnecessarily -dotnet_diagnostic.CA1805.severity = suggestion +dotnet_diagnostic.CA1805.severity = warning dotnet_diagnostic.CA1806.severity = none From 1804a8a8a295375ecbd55a2b24183e99fe5c2d1f Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Sat, 8 Jan 2022 12:43:16 +1000 Subject: [PATCH 8/8] Fix remaining occurrences of CA1805 violations --- .../Definition/ToolsetReader_Tests.cs | 8 ++-- .../Definition/ToolsetRegistryReader_Tests.cs | 6 +-- .../Evaluation/Evaluator_Tests.cs | 2 +- src/Build/Definition/Toolset.cs | 2 +- src/Build/Utilities/RegistryKeyWrapper.cs | 2 +- src/Framework/BuildEnvironmentState.cs | 4 +- src/Framework/TaskPropertyInfo.cs | 2 +- src/Framework/TestInfo.cs | 2 +- src/Framework/Traits.cs | 2 +- .../LanguageParser/CSharptokenEnumerator.cs | 2 +- src/Shared/LanguageParser/CSharptokenizer.cs | 4 +- .../LanguageParser/StreamMappedString.cs | 10 ++--- .../VisualBasictokenEnumerator.cs | 2 +- .../LanguageParser/VisualBasictokenizer.cs | 2 +- src/Shared/LanguageParser/token.cs | 4 +- src/Shared/LanguageParser/tokenEnumerator.cs | 2 +- .../GlobalAssemblyCacheTests.cs | 2 +- .../SdkToolsPathUtility_Tests.cs | 8 ++-- src/Tasks.UnitTests/XamlTestHelpers.cs | 2 +- src/Tasks/AssemblyDependency/Reference.cs | 20 ++++----- .../ResolveAssemblyReference.cs | 26 ++++++------ src/Tasks/AssignProjectConfiguration.cs | 4 +- src/Tasks/AxTlbBaseTask.cs | 2 +- src/Tasks/BootstrapperUtil/BuildSettings.cs | 2 +- src/Tasks/CallTarget.cs | 2 +- src/Tasks/CodeTaskFactory.cs | 2 +- .../CombineTargetFrameworkInfoProperties.cs | 2 +- src/Tasks/CreateItem.cs | 2 +- src/Tasks/CreateManifestResourceName.cs | 2 +- src/Tasks/Delete.cs | 2 +- src/Tasks/DependencyFile.cs | 2 +- src/Tasks/GenerateDeploymentManifest.cs | 4 +- src/Tasks/GenerateManifestBase.cs | 4 +- src/Tasks/GenerateResource.cs | 42 +++++++++---------- src/Tasks/ManifestUtil/AssemblyReference.cs | 6 +-- src/Tasks/ManifestUtil/mansign2.cs | 34 +++++++-------- src/Tasks/ResolveKeySource.cs | 4 +- src/Tasks/ResolveManifestFiles.cs | 6 +-- src/Tasks/System.Design.cs | 4 +- src/Tasks/XamlTaskFactory/XamlTaskFactory.cs | 2 +- src/Utilities/ToolLocationHelper.cs | 2 +- src/Utilities/ToolTask.cs | 6 +-- 42 files changed, 125 insertions(+), 125 deletions(-) diff --git a/src/Build.UnitTests/Definition/ToolsetReader_Tests.cs b/src/Build.UnitTests/Definition/ToolsetReader_Tests.cs index e1c99c40e33..bd422f2ed49 100644 --- a/src/Build.UnitTests/Definition/ToolsetReader_Tests.cs +++ b/src/Build.UnitTests/Definition/ToolsetReader_Tests.cs @@ -34,11 +34,11 @@ namespace Microsoft.Build.UnitTests.Definition public class ToolsetReaderTests : IDisposable { // The registry key that is passed as the baseKey parameter to the ToolsetRegistryReader class - private RegistryKey _testRegistryKey = null; + private RegistryKey _testRegistryKey; // Subkey "4.0" - private RegistryKey _currentVersionRegistryKey = null; + private RegistryKey _currentVersionRegistryKey; // Subkey "ToolsVersions" - private RegistryKey _toolsVersionsRegistryKey = null; + private RegistryKey _toolsVersionsRegistryKey; // Path to the registry key under HKCU // Note that this is a test registry key created solely for unit testing. @@ -2868,7 +2868,7 @@ public enum WhereToThrow } private WhereToThrow _whereToThrow = WhereToThrow.None; - private string _subKeyThatDoesNotExist = null; + private string _subKeyThatDoesNotExist; /// /// Construct the mock key with a specified key diff --git a/src/Build.UnitTests/Definition/ToolsetRegistryReader_Tests.cs b/src/Build.UnitTests/Definition/ToolsetRegistryReader_Tests.cs index 38a7a917f76..8b682854959 100644 --- a/src/Build.UnitTests/Definition/ToolsetRegistryReader_Tests.cs +++ b/src/Build.UnitTests/Definition/ToolsetRegistryReader_Tests.cs @@ -27,11 +27,11 @@ namespace Microsoft.Build.UnitTests.Definition public class ToolsetRegistryReader_Tests : IDisposable { // The registry key that is passed as the baseKey parameter to the ToolsetRegistryReader class - private RegistryKey _testRegistryKey = null; + private RegistryKey _testRegistryKey; // Subkey "3.5" - private RegistryKey _currentVersionRegistryKey = null; + private RegistryKey _currentVersionRegistryKey; // Subkey "ToolsVersions" - private RegistryKey _toolsVersionsRegistryKey = null; + private RegistryKey _toolsVersionsRegistryKey; // Path to the registry key under HKCU // Note that this is a test registry key created solely for unit testing. diff --git a/src/Build.UnitTests/Evaluation/Evaluator_Tests.cs b/src/Build.UnitTests/Evaluation/Evaluator_Tests.cs index 0ac654bcb3a..c95ec9b89ff 100644 --- a/src/Build.UnitTests/Evaluation/Evaluator_Tests.cs +++ b/src/Build.UnitTests/Evaluation/Evaluator_Tests.cs @@ -4234,7 +4234,7 @@ public void VerifyDTDProcessingIsDisabled() } #if FEATURE_HTTP_LISTENER - private Exception _httpListenerThreadException = null; + private Exception _httpListenerThreadException; /// /// Verify that DTD processing is disabled when loading a project diff --git a/src/Build/Definition/Toolset.cs b/src/Build/Definition/Toolset.cs index 6cf6dfeaef7..02c5cfdb530 100644 --- a/src/Build/Definition/Toolset.cs +++ b/src/Build/Definition/Toolset.cs @@ -110,7 +110,7 @@ public class Toolset : ITranslatable /// Null if it hasn't been figured out yet; true if (some variation of) Visual Studio 2010 is installed on /// the current machine, false otherwise. /// - private static bool? s_dev10IsInstalled = null; + private static bool? s_dev10IsInstalled; #endif // FEATURE_WIN32_REGISTRY /// diff --git a/src/Build/Utilities/RegistryKeyWrapper.cs b/src/Build/Utilities/RegistryKeyWrapper.cs index 3257b6eb229..f77d484629b 100644 --- a/src/Build/Utilities/RegistryKeyWrapper.cs +++ b/src/Build/Utilities/RegistryKeyWrapper.cs @@ -25,7 +25,7 @@ internal class RegistryKeyWrapper : IDisposable // The hive this registry key lives under private RegistryKey _registryHive; // This field will be set to true when we try to open the registry key - private bool _attemptedToOpenRegistryKey = false; + private bool _attemptedToOpenRegistryKey; /// /// Has the object been disposed yet. diff --git a/src/Framework/BuildEnvironmentState.cs b/src/Framework/BuildEnvironmentState.cs index 9743b2a5eab..2746ce3c9f0 100644 --- a/src/Framework/BuildEnvironmentState.cs +++ b/src/Framework/BuildEnvironmentState.cs @@ -13,7 +13,7 @@ namespace Microsoft.Build.Framework /// internal static class BuildEnvironmentState { - internal static bool s_runningInVisualStudio = false; - internal static bool s_runningTests = false; + internal static bool s_runningInVisualStudio; + internal static bool s_runningTests; } } diff --git a/src/Framework/TaskPropertyInfo.cs b/src/Framework/TaskPropertyInfo.cs index 449354b5e43..b52537cd4a4 100644 --- a/src/Framework/TaskPropertyInfo.cs +++ b/src/Framework/TaskPropertyInfo.cs @@ -61,6 +61,6 @@ public TaskPropertyInfo(string name, Type typeOfParameter, bool output, bool req /// /// Whether the Log and LogItemMetadata properties have been assigned already. /// - internal bool Initialized = false; + internal bool Initialized; } } diff --git a/src/Framework/TestInfo.cs b/src/Framework/TestInfo.cs index 48c47b52296..a9fe09de258 100644 --- a/src/Framework/TestInfo.cs +++ b/src/Framework/TestInfo.cs @@ -12,6 +12,6 @@ namespace Microsoft.Build.Framework // which are compiled into multiple projects. internal static class TestInfo { - public static bool s_runningTests = false; + public static bool s_runningTests; } } diff --git a/src/Framework/Traits.cs b/src/Framework/Traits.cs index ddcb8ade1ed..c38188ec71e 100644 --- a/src/Framework/Traits.cs +++ b/src/Framework/Traits.cs @@ -195,7 +195,7 @@ public bool LogTaskInputs } private bool? _logPropertiesAndItemsAfterEvaluation; - private bool _logPropertiesAndItemsAfterEvaluationInitialized = false; + private bool _logPropertiesAndItemsAfterEvaluationInitialized; public bool? LogPropertiesAndItemsAfterEvaluation { get diff --git a/src/Shared/LanguageParser/CSharptokenEnumerator.cs b/src/Shared/LanguageParser/CSharptokenEnumerator.cs index 6cd1204c112..ab1c7152418 100644 --- a/src/Shared/LanguageParser/CSharptokenEnumerator.cs +++ b/src/Shared/LanguageParser/CSharptokenEnumerator.cs @@ -18,7 +18,7 @@ namespace Microsoft.Build.Shared.LanguageParser sealed internal class CSharpTokenEnumerator : TokenEnumerator { // Reader over the sources. - private CSharpTokenCharReader _reader = null; + private CSharpTokenCharReader _reader; /* * Method: TokenEnumerator diff --git a/src/Shared/LanguageParser/CSharptokenizer.cs b/src/Shared/LanguageParser/CSharptokenizer.cs index eedeedd05a8..b947bbb38f3 100644 --- a/src/Shared/LanguageParser/CSharptokenizer.cs +++ b/src/Shared/LanguageParser/CSharptokenizer.cs @@ -33,10 +33,10 @@ internal class OpenScopeToken : OperatorOrPunctuatorToken { } // i.e. "{" internal class CloseScopeToken : OperatorOrPunctuatorToken { } // i.e. "}" // The source lines - private Stream _binaryStream = null; + private Stream _binaryStream; // Whether to force ANSI or not. - private bool _forceANSI = false; + private bool _forceANSI; /// /// Construct. diff --git a/src/Shared/LanguageParser/StreamMappedString.cs b/src/Shared/LanguageParser/StreamMappedString.cs index f8fda805458..80abe309153 100644 --- a/src/Shared/LanguageParser/StreamMappedString.cs +++ b/src/Shared/LanguageParser/StreamMappedString.cs @@ -43,27 +43,27 @@ sealed internal class StreamMappedString /// /// The number of characters read into currentPage. /// - private int _charactersRead = 0; + private int _charactersRead; /// /// The page before currentPage. /// - private char[] _priorPage = null; + private char[] _priorPage; /// /// The most recently read page. /// - private char[] _currentPage = null; + private char[] _currentPage; /// /// Count of the total number of pages allocated. /// - private int _pagesAllocated = 0; + private int _pagesAllocated; /// /// Size of pages to use for reading from source file. /// - private int _pageSize = 0; + private int _pageSize; /// /// Construct. diff --git a/src/Shared/LanguageParser/VisualBasictokenEnumerator.cs b/src/Shared/LanguageParser/VisualBasictokenEnumerator.cs index 3fbc3b0ed4b..7d65256e2f6 100644 --- a/src/Shared/LanguageParser/VisualBasictokenEnumerator.cs +++ b/src/Shared/LanguageParser/VisualBasictokenEnumerator.cs @@ -17,7 +17,7 @@ namespace Microsoft.Build.Shared.LanguageParser sealed internal class VisualBasicTokenEnumerator : TokenEnumerator { // Reader over the sources. - private VisualBasicTokenCharReader _reader = null; + private VisualBasicTokenCharReader _reader; /* * Method: TokenEnumerator diff --git a/src/Shared/LanguageParser/VisualBasictokenizer.cs b/src/Shared/LanguageParser/VisualBasictokenizer.cs index 3dfff889a24..262e764fd83 100644 --- a/src/Shared/LanguageParser/VisualBasictokenizer.cs +++ b/src/Shared/LanguageParser/VisualBasictokenizer.cs @@ -31,7 +31,7 @@ internal class OctalIntegerLiteralToken : IntegerLiteralToken { } internal class ExpectedValidOctalDigitToken : SyntaxErrorToken { } // The source lines - private Stream _binaryStream = null; + private Stream _binaryStream; // Whether or not to force ANSI reading. private bool _forceANSI; diff --git a/src/Shared/LanguageParser/token.cs b/src/Shared/LanguageParser/token.cs index 2322048c796..e079a6a9dd5 100644 --- a/src/Shared/LanguageParser/token.cs +++ b/src/Shared/LanguageParser/token.cs @@ -16,9 +16,9 @@ namespace Microsoft.Build.Shared.LanguageParser internal abstract class Token { // The text from the originating source file that caused this token. - private string _innerText = null; + private string _innerText; // The line number that the token fell on. - private int _line = 0; + private int _line; /* * Method: InnerText diff --git a/src/Shared/LanguageParser/tokenEnumerator.cs b/src/Shared/LanguageParser/tokenEnumerator.cs index 8c691dcb8b8..9c10b46cc18 100644 --- a/src/Shared/LanguageParser/tokenEnumerator.cs +++ b/src/Shared/LanguageParser/tokenEnumerator.cs @@ -17,7 +17,7 @@ namespace Microsoft.Build.Shared.LanguageParser internal abstract class TokenEnumerator : IEnumerator { // The current token that was found. - protected Token current = null; + protected Token current; // Return the token char reader. abstract internal TokenCharReader Reader { get; } diff --git a/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs b/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs index 276cb4ed9f6..d2e5cbf9a70 100644 --- a/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs +++ b/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs @@ -958,7 +958,7 @@ private static IEnumerable MockAssemblyCacheEnumerator(st internal class MockEnumerator : IEnumerable { - private List _assembliesToEnumerate = null; + private List _assembliesToEnumerate; private List.Enumerator _enumerator; public MockEnumerator(List assembliesToEnumerate) diff --git a/src/Tasks.UnitTests/SdkToolsPathUtility_Tests.cs b/src/Tasks.UnitTests/SdkToolsPathUtility_Tests.cs index 454e37ac408..0ad7fb36181 100644 --- a/src/Tasks.UnitTests/SdkToolsPathUtility_Tests.cs +++ b/src/Tasks.UnitTests/SdkToolsPathUtility_Tests.cs @@ -15,10 +15,10 @@ namespace Microsoft.Build.UnitTests sealed public class SdkToolsPathUtility_Tests { private string _defaultSdkToolsPath = NativeMethodsShared.IsWindows ? "C:\\ProgramFiles\\WIndowsSDK\\bin" : "/ProgramFiles/WindowsSDK/bin"; - private TaskLoggingHelper _log = null; + private TaskLoggingHelper _log; private string _toolName = "MyTool.exe"; - private MockEngine _mockEngine = null; - private MockFileExists _mockExists = null; + private MockEngine _mockEngine; + private MockFileExists _mockExists; public SdkToolsPathUtility_Tests() { @@ -236,7 +236,7 @@ internal class MockFileExists /// /// Path to the x86 sdk tools location /// - private string _sdkToolsPath = null; + private string _sdkToolsPath; #endregion #region Constructor diff --git a/src/Tasks.UnitTests/XamlTestHelpers.cs b/src/Tasks.UnitTests/XamlTestHelpers.cs index 052fe764616..d4d6d734f0a 100644 --- a/src/Tasks.UnitTests/XamlTestHelpers.cs +++ b/src/Tasks.UnitTests/XamlTestHelpers.cs @@ -87,7 +87,7 @@ internal static class XamlTestHelpers "; - private static string s_pathToMSBuildBinaries = null; + private static string s_pathToMSBuildBinaries; /// /// Returns the path to the MSBuild binaries diff --git a/src/Tasks/AssemblyDependency/Reference.cs b/src/Tasks/AssemblyDependency/Reference.cs index 015ff467546..60990c3011d 100644 --- a/src/Tasks/AssemblyDependency/Reference.cs +++ b/src/Tasks/AssemblyDependency/Reference.cs @@ -318,18 +318,18 @@ internal string[] GetExecutableExtensions(string[] allowedAssemblyExtensions) /// Whether types need to be embedded into the target assembly /// /// - internal bool EmbedInteropTypes { get; set; } = false; + internal bool EmbedInteropTypes { get; set; } /// /// This will be true if the user requested a specific file. We know this when the file was resolved /// by hintpath or if it was resolve as a raw file name for example. /// - internal bool UserRequestedSpecificFile { get; set; } = false; + internal bool UserRequestedSpecificFile { get; set; } /// /// The version number of this reference /// - internal Version ReferenceVersion { get; set; } = null; + internal Version ReferenceVersion { get; set; } /// /// True if the assembly was found to be in the GAC. @@ -589,22 +589,22 @@ internal string FullPathWithoutExtension /// through the reference resolution process. /// /// 'true' if this reference is a primary assembly. - internal bool IsPrimary { get; private set; } = false; + internal bool IsPrimary { get; private set; } /// /// Whether or not this reference will be installed on the target machine. /// - internal bool IsPrerequisite { set; get; } = false; + internal bool IsPrerequisite { set; get; } /// /// Whether or not this reference is a redist root. /// - internal bool? IsRedistRoot { set; get; } = null; + internal bool? IsRedistRoot { set; get; } /// /// The redist name for this reference (if any) /// - internal string RedistName { set; get; } = null; + internal string RedistName { set; get; } /// /// The original source item, as passed into the task that is directly associated @@ -628,7 +628,7 @@ internal ITaskItem PrimarySourceItem /// This item shouldn't be passed to compilers and so forth. /// /// 'true' if this reference points to a bad image. - internal bool IsBadImage { get; private set; } = false; + internal bool IsBadImage { get; private set; } /// /// If true, then this item conflicted with another item and lost. @@ -660,7 +660,7 @@ internal List GetConflictVictims() /// /// The name of the assembly that won over this reference. /// - internal AssemblyNameExtension ConflictVictorName { get; set; } = null; + internal AssemblyNameExtension ConflictVictorName { get; set; } /// /// The reason why this reference lost to another reference. @@ -799,7 +799,7 @@ internal bool IsUnresolvable /// /// Whether or not we still need to find dependencies for this reference. /// - internal bool DependenciesFound { get; set; } = false; + internal bool DependenciesFound { get; set; } /// /// If the reference has an SDK name metadata this will contain that string. diff --git a/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs b/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs index 470d064f9ce..589ce02dbb6 100644 --- a/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs +++ b/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs @@ -51,7 +51,7 @@ public class ResolveAssemblyReference : TaskExtension /// /// Cache of system state information, used to optimize performance. /// - internal SystemState _cache = null; + internal SystemState _cache; /// /// Construct @@ -103,7 +103,7 @@ private static class Strings public static string UnifiedDependency; public static string UnifiedPrimaryReference; - private static bool initialized = false; + private static bool initialized; internal static void Initialize(TaskLoggingHelper log) { @@ -163,18 +163,18 @@ internal static void Initialize(TaskLoggingHelper log) private ITaskItem[] _installedAssemblySubsetTables = Array.Empty(); private ITaskItem[] _fullFrameworkAssemblyTables = Array.Empty(); private ITaskItem[] _resolvedSDKReferences = Array.Empty(); - private bool _ignoreDefaultInstalledAssemblyTables = false; - private bool _ignoreDefaultInstalledAssemblySubsetTables = false; + private bool _ignoreDefaultInstalledAssemblyTables; + private bool _ignoreDefaultInstalledAssemblySubsetTables; private string[] _candidateAssemblyFiles = Array.Empty(); private string[] _targetFrameworkDirectories = Array.Empty(); private string[] _searchPaths = Array.Empty(); private string[] _allowedAssemblyExtensions = new string[] { ".winmd", ".dll", ".exe" }; private string[] _relatedFileExtensions = new string[] { ".pdb", ".xml", ".pri" }; - private string _appConfigFile = null; + private string _appConfigFile; private bool _supportsBindingRedirectGeneration; - private bool _autoUnify = false; - private bool _ignoreVersionForFrameworkReferences = false; - private bool _ignoreTargetFrameworkAttributeVersionMismatch = false; + private bool _autoUnify; + private bool _ignoreVersionForFrameworkReferences; + private bool _ignoreTargetFrameworkAttributeVersionMismatch; private ITaskItem[] _resolvedFiles = Array.Empty(); private ITaskItem[] _resolvedDependencyFiles = Array.Empty(); private ITaskItem[] _relatedFiles = Array.Empty(); @@ -192,22 +192,22 @@ internal static void Initialize(TaskLoggingHelper log) private bool _findSatellites = true; private bool _findSerializationAssemblies = true; private bool _findRelatedFiles = true; - private bool _silent = false; + private bool _silent; private string _projectTargetFrameworkAsString = String.Empty; private string _targetedRuntimeVersionRawValue = String.Empty; private Version _projectTargetFramework; - private string _stateFile = null; - private string _targetProcessorArchitecture = null; + private string _stateFile; + private string _targetProcessorArchitecture; private string _profileName = String.Empty; private string[] _fullFrameworkFolders = Array.Empty(); private string[] _latestTargetFrameworkDirectories = Array.Empty(); private bool _copyLocalDependenciesWhenParentReferenceInGac = true; private Dictionary _showAssemblyFoldersExLocations = new Dictionary(StringComparer.OrdinalIgnoreCase); - private bool _logVerboseSearchResults = false; + private bool _logVerboseSearchResults; private WarnOrErrorOnTargetArchitectureMismatchBehavior _warnOrErrorOnTargetArchitectureMismatch = WarnOrErrorOnTargetArchitectureMismatchBehavior.Warning; - private bool _unresolveFrameworkAssembliesFromHigherFrameworks = false; + private bool _unresolveFrameworkAssembliesFromHigherFrameworks; /// /// If set to true, it forces to unresolve framework assemblies with versions higher or equal the version of the target framework, regardless of the target framework diff --git a/src/Tasks/AssignProjectConfiguration.cs b/src/Tasks/AssignProjectConfiguration.cs index 1f93054af17..639d5094a0b 100644 --- a/src/Tasks/AssignProjectConfiguration.cs +++ b/src/Tasks/AssignProjectConfiguration.cs @@ -112,7 +112,7 @@ public string VcxToDefaultPlatformMapping /// /// Should we build references even if they were disabled in the project configuration /// - public bool OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration { get; set; } = false; + public bool OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration { get; set; } // Whether to set the project reference's GlobalPropertiesToRemove metadata to contain // Configuration and Platform. @@ -122,7 +122,7 @@ public string VcxToDefaultPlatformMapping /// on an MSBuild call, the Configuration and Platform metadata will be unset, allowing the /// child project to build in its default configuration / platform. /// - public bool ShouldUnsetParentConfigurationAndPlatform { get; set; } = false; + public bool ShouldUnsetParentConfigurationAndPlatform { get; set; } /// /// The output type for the project diff --git a/src/Tasks/AxTlbBaseTask.cs b/src/Tasks/AxTlbBaseTask.cs index a6bde0f4930..f533386777d 100644 --- a/src/Tasks/AxTlbBaseTask.cs +++ b/src/Tasks/AxTlbBaseTask.cs @@ -71,7 +71,7 @@ public string SdkToolsPath /// executable, so return null for the ToolName -- And make sure that /// Execute() logs an error! /// - protected override string ToolName { get; } = null; + protected override string ToolName { get; } /// /// Invokes the ToolTask with the given parameters diff --git a/src/Tasks/BootstrapperUtil/BuildSettings.cs b/src/Tasks/BootstrapperUtil/BuildSettings.cs index 1bbc9f6185a..db48a858d32 100644 --- a/src/Tasks/BootstrapperUtil/BuildSettings.cs +++ b/src/Tasks/BootstrapperUtil/BuildSettings.cs @@ -66,7 +66,7 @@ public BuildSettings() /// /// The file location to copy output files to /// - public string OutputPath { get; set; } = null; + public string OutputPath { get; set; } /// /// The product builders to use for generating the bootstrapper diff --git a/src/Tasks/CallTarget.cs b/src/Tasks/CallTarget.cs index 3ce6ae1b3b0..be5ad2c2fe2 100644 --- a/src/Tasks/CallTarget.cs +++ b/src/Tasks/CallTarget.cs @@ -49,7 +49,7 @@ public class CallTarget : TaskExtension /// /// Deprecated. Does nothing. /// - public bool UseResultsCache { get; set; } = false; + public bool UseResultsCache { get; set; } #endregion diff --git a/src/Tasks/CodeTaskFactory.cs b/src/Tasks/CodeTaskFactory.cs index 77c8c929879..1f2cbf657ac 100644 --- a/src/Tasks/CodeTaskFactory.cs +++ b/src/Tasks/CodeTaskFactory.cs @@ -1045,7 +1045,7 @@ public sealed class CodeTaskFactory : ITaskFactory { public string FactoryName => "Code Task Factory"; - public Type TaskType { get; } = null; + public Type TaskType { get; } public bool Initialize(string taskName, IDictionary parameterGroup, string taskBody, IBuildEngine taskFactoryLoggingHost) { diff --git a/src/Tasks/CombineTargetFrameworkInfoProperties.cs b/src/Tasks/CombineTargetFrameworkInfoProperties.cs index 4108feb5246..45ab4f3befb 100644 --- a/src/Tasks/CombineTargetFrameworkInfoProperties.cs +++ b/src/Tasks/CombineTargetFrameworkInfoProperties.cs @@ -27,7 +27,7 @@ public class CombineTargetFrameworkInfoProperties : TaskExtension /// /// Opts into or out of using the new schema with Property Name=... rather than just specifying the RootElementName. /// - public bool UseAttributeForTargetFrameworkInfoPropertyNames { get; set; } = false; + public bool UseAttributeForTargetFrameworkInfoPropertyNames { get; set; } /// /// The generated XML representation of the properties and values. diff --git a/src/Tasks/CreateItem.cs b/src/Tasks/CreateItem.cs index f386549f525..6257dd3c57f 100644 --- a/src/Tasks/CreateItem.cs +++ b/src/Tasks/CreateItem.cs @@ -26,7 +26,7 @@ public class CreateItem : TaskExtension /// /// Only apply the additional metadata is none already exists /// - public bool PreserveExistingMetadata { get; set; } = false; + public bool PreserveExistingMetadata { get; set; } /// /// A list of metadata name/value pairs to apply to the output items. diff --git a/src/Tasks/CreateManifestResourceName.cs b/src/Tasks/CreateManifestResourceName.cs index 49d1b38bd52..495bdb26aad 100644 --- a/src/Tasks/CreateManifestResourceName.cs +++ b/src/Tasks/CreateManifestResourceName.cs @@ -59,7 +59,7 @@ public ITaskItem[] ResourceFiles /// /// Rootnamespace to use for naming. /// - public string RootNamespace { get; set; } = null; + public string RootNamespace { get; set; } /// /// The resulting manifest names. diff --git a/src/Tasks/Delete.cs b/src/Tasks/Delete.cs index 92dd730eca9..f9d49572d1e 100644 --- a/src/Tasks/Delete.cs +++ b/src/Tasks/Delete.cs @@ -38,7 +38,7 @@ public ITaskItem[] Files /// /// When true, errors will be logged as warnings. /// - public bool TreatErrorsAsWarnings { get; set; } = false; + public bool TreatErrorsAsWarnings { get; set; } [Output] public ITaskItem[] DeletedFiles { get; set; } diff --git a/src/Tasks/DependencyFile.cs b/src/Tasks/DependencyFile.cs index c3d4ab2f05a..84e6fcc3789 100644 --- a/src/Tasks/DependencyFile.cs +++ b/src/Tasks/DependencyFile.cs @@ -26,7 +26,7 @@ internal class DependencyFile internal DateTime lastModified; // Whether the file exists or not. - internal bool exists = false; + internal bool exists; /// /// The name of the file. diff --git a/src/Tasks/GenerateDeploymentManifest.cs b/src/Tasks/GenerateDeploymentManifest.cs index d4ff40421a4..38bc1a91a2b 100644 --- a/src/Tasks/GenerateDeploymentManifest.cs +++ b/src/Tasks/GenerateDeploymentManifest.cs @@ -72,7 +72,7 @@ public bool Install set => _install = value; } - public string MinimumRequiredVersion { get; set; } = null; + public string MinimumRequiredVersion { get; set; } public bool MapFileExtensions { @@ -97,7 +97,7 @@ public string SuiteName set => _suiteName = value; } - public string SupportUrl { get; set; } = null; + public string SupportUrl { get; set; } public bool TrustUrlParameters { diff --git a/src/Tasks/GenerateManifestBase.cs b/src/Tasks/GenerateManifestBase.cs index 026cdfb8da1..2d276b2e0da 100644 --- a/src/Tasks/GenerateManifestBase.cs +++ b/src/Tasks/GenerateManifestBase.cs @@ -51,9 +51,9 @@ protected GenerateManifestBase() : base(AssemblyResources.PrimaryResources, "MSB [Output] public ITaskItem OutputManifest { get; set; } - public string Platform { get; set; } = null; + public string Platform { get; set; } - public string TargetCulture { get; set; } = null; + public string TargetCulture { get; set; } public string TargetFrameworkVersion { diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 4dabaed7f16..163432c8cdc 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -58,23 +58,23 @@ public sealed partial class GenerateResource : TaskExtension private ResGenDependencies _cache; // This is where we store the list of input files/sources - private ITaskItem[] _sources = null; + private ITaskItem[] _sources; // Indicates whether the resource reader should use the source file's // directory to resolve relative file paths. - private bool _useSourcePath = false; + private bool _useSourcePath; // This is needed for the actual items from the project - private ITaskItem[] _references = null; + private ITaskItem[] _references; // Any additional inputs to dependency checking. - private ITaskItem[] _additionalInputs = null; + private ITaskItem[] _additionalInputs; // This is the path/name of the dependency cache file - private ITaskItem _stateFile = null; + private ITaskItem _stateFile; // This list is all of the resource file(s) generated by the task - private ITaskItem[] _outputResources = null; + private ITaskItem[] _outputResources; // List of those output resources that were not actually created, due to an error private ArrayList _unsuccessfullyCreatedOutFiles = new ArrayList(); @@ -83,28 +83,28 @@ public sealed partial class GenerateResource : TaskExtension private ArrayList _filesWritten = new ArrayList(); // StronglyTypedLanguage - private string _stronglyTypedLanguage = null; + private string _stronglyTypedLanguage; // StronglyTypedNamespace - private string _stronglyTypedNamespace = null; + private string _stronglyTypedNamespace; // StronglyTypedManifestPrefix - private string _stronglyTypedManifestPrefix = null; + private string _stronglyTypedManifestPrefix; // StronglyTypedClassName - private string _stronglyTypedClassName = null; + private string _stronglyTypedClassName; // StronglyTypedFileName - private string _stronglyTypedFileName = null; + private string _stronglyTypedFileName; // Whether the STR class should have public members; default is false - private bool _publicClass = false; + private bool _publicClass; // Did the CodeDOM succeed when creating any Strongly Typed Resource class? - private bool _stronglyTypedResourceSuccessfullyCreated = false; + private bool _stronglyTypedResourceSuccessfullyCreated; // When true, a separate AppDomain is always created. - private bool _neverLockTypeAssemblies = false; + private bool _neverLockTypeAssemblies; // Newest uncorrelated input, // or null if not yet determined @@ -200,7 +200,7 @@ public ITaskItem[] References /// format. .NET Core-targeted assemblies should use this; it's the only way to support /// non-string resources with MSBuild running on .NET Core. /// - public bool UsePreserializedResources { get; set; } = false; + public bool UsePreserializedResources { get; set; } /// /// Additional inputs to the dependency checking done by this task. For example, @@ -937,7 +937,7 @@ public override bool Execute() private const uint ZoneUntrusted = 4; - private static IInternetSecurityManager internetSecurityManager = null; + private static IInternetSecurityManager internetSecurityManager; // Resources can have arbitrarily serialized objects in them which can execute arbitrary code // so check to see if we should trust them before analyzing them @@ -2236,7 +2236,7 @@ internal sealed class ProcessResourceFiles /// /// Logger for any messages or errors /// - private TaskLoggingHelper _logger = null; + private TaskLoggingHelper _logger; /// /// Language for the strongly typed resources. @@ -2289,7 +2289,7 @@ internal string StronglyTypedClassName /// Class that gets called by the ResxResourceReader to resolve references /// to assemblies within the .RESX. /// - private AssemblyNamesTypeResolutionService _typeResolver = null; + private AssemblyNamesTypeResolutionService _typeResolver; /// /// Handles assembly resolution events. @@ -2384,15 +2384,15 @@ internal bool StronglyTypedResourceSuccessfullyCreated return _stronglyTypedResourceSuccessfullyCreated; } } - private bool _stronglyTypedResourceSuccessfullyCreated = false; + private bool _stronglyTypedResourceSuccessfullyCreated; /// /// Indicates whether the resource reader should use the source file's /// directory to resolve relative file paths. /// - private bool _useSourcePath = false; + private bool _useSourcePath; -#endregion + #endregion /// /// Process all files. diff --git a/src/Tasks/ManifestUtil/AssemblyReference.cs b/src/Tasks/ManifestUtil/AssemblyReference.cs index 702790b55d4..dcf11495771 100644 --- a/src/Tasks/ManifestUtil/AssemblyReference.cs +++ b/src/Tasks/ManifestUtil/AssemblyReference.cs @@ -40,10 +40,10 @@ public enum AssemblyReferenceType [ComVisible(false)] public sealed class AssemblyReference : BaseReference { - private AssemblyIdentity _assemblyIdentity = null; - private bool _isPrerequisite = false; + private AssemblyIdentity _assemblyIdentity; + private bool _isPrerequisite; private AssemblyReferenceType _referenceType = AssemblyReferenceType.Unspecified; - private bool _isPrimary = false; + private bool _isPrimary; /// /// Initializes a new instance of the AssemblyReference class. diff --git a/src/Tasks/ManifestUtil/mansign2.cs b/src/Tasks/ManifestUtil/mansign2.cs index 2923d63cddb..c008f9b49c6 100644 --- a/src/Tasks/ManifestUtil/mansign2.cs +++ b/src/Tasks/ManifestUtil/mansign2.cs @@ -240,7 +240,7 @@ [In] [MarshalAs(UnmanagedType.LPStr)] string pszHashId, internal class ManifestSignedXml2 : SignedXml { - private bool _verify = false; + private bool _verify; private const string Sha256SignatureMethodUri = @"http://www.w3.org/2000/09/xmldsig#rsa-sha256"; private const string Sha256DigestMethod = @"http://www.w3.org/2000/09/xmldsig#sha256"; @@ -310,9 +310,9 @@ public override XmlElement GetIdElement(XmlDocument document, string idValue) internal class SignedCmiManifest2 { - private XmlDocument _manifestDom = null; - private CmiStrongNameSignerInfo _strongNameSignerInfo = null; - private CmiAuthenticodeSignerInfo _authenticodeSignerInfo = null; + private XmlDocument _manifestDom; + private CmiStrongNameSignerInfo _strongNameSignerInfo; + private CmiAuthenticodeSignerInfo _authenticodeSignerInfo; private bool _useSha256; private const string Sha256SignatureMethodUri = @"http://www.w3.org/2000/09/xmldsig#rsa-sha256"; @@ -1163,9 +1163,9 @@ internal CmiManifestSignerFlag Flag internal class CmiStrongNameSignerInfo { - private int _error = 0; - private string _publicKeyToken = null; - private AsymmetricAlgorithm _snKey = null; + private int _error; + private string _publicKeyToken; + private AsymmetricAlgorithm _snKey; internal CmiStrongNameSignerInfo() { } @@ -1217,13 +1217,13 @@ internal AsymmetricAlgorithm PublicKey internal class CmiAuthenticodeSignerInfo { - private int _error = 0; - private X509Chain _signerChain = null; - private uint _algHash = 0; - private string _hash = null; - private string _description = null; - private string _descriptionUrl = null; - private CmiAuthenticodeTimestamperInfo _timestamperInfo = null; + private int _error; + private X509Chain _signerChain; + private uint _algHash; + private string _hash; + private string _description; + private string _descriptionUrl; + private CmiAuthenticodeTimestamperInfo _timestamperInfo; internal CmiAuthenticodeSignerInfo() { } @@ -1343,10 +1343,10 @@ internal X509Chain SignerChain internal class CmiAuthenticodeTimestamperInfo { - private int _error = 0; - private X509Chain _timestamperChain = null; + private int _error; + private X509Chain _timestamperChain; private DateTime _timestampTime; - private uint _algHash = 0; + private uint _algHash; private CmiAuthenticodeTimestamperInfo() { } diff --git a/src/Tasks/ResolveKeySource.cs b/src/Tasks/ResolveKeySource.cs index 676d5a4d249..96509cdf875 100644 --- a/src/Tasks/ResolveKeySource.cs +++ b/src/Tasks/ResolveKeySource.cs @@ -34,9 +34,9 @@ public class ResolveKeySource : TaskExtension public string CertificateFile { get; set; } - public bool SuppressAutoClosePasswordPrompt { get; set; } = false; + public bool SuppressAutoClosePasswordPrompt { get; set; } - public bool ShowImportDialogDespitePreviousFailures { get; set; } = false; + public bool ShowImportDialogDespitePreviousFailures { get; set; } public int AutoClosePasswordPromptTimeout { get; set; } = 20; diff --git a/src/Tasks/ResolveManifestFiles.cs b/src/Tasks/ResolveManifestFiles.cs index 62bd9251366..8cb3770eda6 100644 --- a/src/Tasks/ResolveManifestFiles.cs +++ b/src/Tasks/ResolveManifestFiles.cs @@ -92,10 +92,10 @@ public ITaskItem[] NativeAssemblies public ITaskItem[] RuntimePackAssets { get; set; } // True if deployment mode during publish is set to self-contained mode - public bool IsSelfContainedPublish { get; set; } = false; + public bool IsSelfContainedPublish { get; set; } // True if single file publish is on - public bool IsSingleFilePublish { get; set; } = false; + public bool IsSingleFilePublish { get; set; } [Output] public ITaskItem[] OutputAssemblies { get; set; } @@ -127,7 +127,7 @@ public ITaskItem[] SatelliteAssemblies public string AssemblyName { get; set; } - public bool LauncherBasedDeployment {get; set; } = false; + public bool LauncherBasedDeployment {get; set; } public string TargetFrameworkVersion { diff --git a/src/Tasks/System.Design.cs b/src/Tasks/System.Design.cs index 0ab4947d7b6..f0e8ba1e3d1 100644 --- a/src/Tasks/System.Design.cs +++ b/src/Tasks/System.Design.cs @@ -16,7 +16,7 @@ namespace Microsoft.Build.Tasks [AttributeUsage(AttributeTargets.All)] internal sealed class SRDescriptionAttribute : DescriptionAttribute { - private bool _replaced = false; + private bool _replaced; /// /// Constructs a new sys description. @@ -81,7 +81,7 @@ internal sealed class SR internal const string MismatchedResourceName = "MismatchedResourceName"; internal const string InvalidIdentifier = "InvalidIdentifier"; - private static SR s_loader = null; + private static SR s_loader; private MainAssemblyFallbackResourceManager _resources; /// diff --git a/src/Tasks/XamlTaskFactory/XamlTaskFactory.cs b/src/Tasks/XamlTaskFactory/XamlTaskFactory.cs index a9195d3f89d..24a43538d99 100644 --- a/src/Tasks/XamlTaskFactory/XamlTaskFactory.cs +++ b/src/Tasks/XamlTaskFactory/XamlTaskFactory.cs @@ -246,7 +246,7 @@ public sealed class XamlTaskFactory : ITaskFactory { public string FactoryName => "XamlTaskFactory"; - public Type TaskType { get; } = null; + public Type TaskType { get; } public bool Initialize(string taskName, IDictionary parameterGroup, string taskBody, IBuildEngine taskFactoryLoggingHost) { diff --git a/src/Utilities/ToolLocationHelper.cs b/src/Utilities/ToolLocationHelper.cs index 28d03e97be8..7e831e8f0d5 100644 --- a/src/Utilities/ToolLocationHelper.cs +++ b/src/Utilities/ToolLocationHelper.cs @@ -257,7 +257,7 @@ public static class ToolLocationHelper /// /// Cache the list of supported frameworks /// - private static List s_targetFrameworkMonikers = null; + private static List s_targetFrameworkMonikers; /// /// Cache the VS Install folders for particular range of VS versions diff --git a/src/Utilities/ToolTask.cs b/src/Utilities/ToolTask.cs index 6eb42bff3ff..2af0fe9fda5 100644 --- a/src/Utilities/ToolTask.cs +++ b/src/Utilities/ToolTask.cs @@ -263,18 +263,18 @@ public virtual string ToolExe /// Task Parameter: Importance with which to log text from the /// standard out stream. /// - public string StandardOutputImportance { get; set; } = null; + public string StandardOutputImportance { get; set; } /// /// Task Parameter: Importance with which to log text from the /// standard error stream. /// - public string StandardErrorImportance { get; set; } = null; + public string StandardErrorImportance { get; set; } /// /// Should ALL messages received on the standard error stream be logged as errors. /// - public bool LogStandardErrorAsError { get; set; } = false; + public bool LogStandardErrorAsError { get; set; } /// /// Importance with which to log text from in the