Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Common.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ public static bool IsLinkedObject(object obj)
return LinkedObjectsFactory.GetLink(obj) != null;
}

private static bool dbgIgnoreLinked = false;
#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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

#nullable disable

Expand Down Expand Up @@ -145,16 +144,16 @@ internal interface IImportHolder
/// </summary>
internal class ProjectCollectionLinker : ExternalProjectsProvider
{
internal static int _collecitonId = 0;
internal static int _collectionId;

private bool importing = false;
private bool importing;
private ExportedLinksMap exported = ExportedLinksMap.Create();
private Dictionary<UInt32, ExternalConnection> imported = new Dictionary<UInt32, ExternalConnection>();

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);
}
Expand Down Expand Up @@ -216,10 +215,11 @@ private void ConnectTo (ProjectCollectionLinker other)
}
}

#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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
internal class LinkedObjectsMap<KeyType> : 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;
Expand Down
16 changes: 8 additions & 8 deletions src/Build.UnitTests/BackEnd/TaskHost_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,42 +1076,42 @@ internal class MyCustomLogger : ILogger
/// <summary>
/// Last error event the logger encountered
/// </summary>
private BuildErrorEventArgs _lastError = null;
private BuildErrorEventArgs _lastError;

/// <summary>
/// Last warning event the logger encountered
/// </summary>
private BuildWarningEventArgs _lastWarning = null;
private BuildWarningEventArgs _lastWarning;

/// <summary>
/// Last message event the logger encountered
/// </summary>
private BuildMessageEventArgs _lastMessage = null;
private BuildMessageEventArgs _lastMessage;

/// <summary>
/// Last custom build event the logger encountered
/// </summary>
private CustomBuildEventArgs _lastCustom = null;
private CustomBuildEventArgs _lastCustom;

/// <summary>
/// Number of errors
/// </summary>
private int _numberOfError = 0;
private int _numberOfError;

/// <summary>
/// Number of warnings
/// </summary>
private int _numberOfWarning = 0;
private int _numberOfWarning;

/// <summary>
/// Number of messages
/// </summary>
private int _numberOfMessage = 0;
private int _numberOfMessage;

/// <summary>
/// Number of custom build events
/// </summary>
private int _numberOfCustom = 0;
private int _numberOfCustom;

/// <summary>
/// Last error logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Build.UnitTests/Definition/ToolsetReader_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -2868,7 +2868,7 @@ public enum WhereToThrow
}

private WhereToThrow _whereToThrow = WhereToThrow.None;
private string _subKeyThatDoesNotExist = null;
private string _subKeyThatDoesNotExist;

/// <summary>
/// Construct the mock key with a specified key
Expand Down
6 changes: 3 additions & 3 deletions src/Build.UnitTests/Definition/ToolsetRegistryReader_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/Evaluation/Evaluator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4234,7 +4234,7 @@ public void VerifyDTDProcessingIsDisabled()
}

#if FEATURE_HTTP_LISTENER
private Exception _httpListenerThreadException = null;
private Exception _httpListenerThreadException;

/// <summary>
/// Verify that DTD processing is disabled when loading a project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.Build.UnitTests.Evaluation
/// </summary>
public class ImportFromMSBuildExtensionsPathTests : IDisposable
{
string toolsVersionToUse = null;
string toolsVersionToUse;

public ImportFromMSBuildExtensionsPathTests()
{
Expand Down
70 changes: 35 additions & 35 deletions src/Build.UnitTests/MockTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,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

/// <summary>
Expand Down Expand Up @@ -379,7 +379,7 @@ public TaskItem[] TaskItemArrayOutputParameter
/// </summary>
sealed internal class MockTask : MockTaskBase, ITask
{
private IBuildEngine _e = null;
private IBuildEngine _e;

/// <summary>
/// Task constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/Build/BackEnd/BuildManager/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public bool UseSynchronousLogging
/// <summary>
/// Indicates whether to emit a default error if a task returns false without logging an error.
/// </summary>
public bool AllowFailureWithoutError { get; set; } = false;
public bool AllowFailureWithoutError { get; set; }

/// <summary>
/// Gets the environment variables which were set when this build was created.
Expand Down Expand Up @@ -782,7 +782,7 @@ public string OutputResultsCacheFile
/// <summary>
/// Determines whether MSBuild will save the results of builds after EndBuild to speed up future builds.
/// </summary>
public bool DiscardBuildResults { get; set; } = false;
public bool DiscardBuildResults { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the build process should run as low priority.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class NodeProviderInProc : INodeProvider, INodePacketFactory, IDisposab
/// <summary>
/// Flag indicating we have disposed.
/// </summary>
private bool _disposed = false;
private bool _disposed;

/// <summary>
/// Value used to ensure multiple in-proc nodes which save the operating environment are not created.
Expand Down Expand Up @@ -74,7 +74,7 @@ internal class NodeProviderInProc : INodeProvider, INodePacketFactory, IDisposab
/// <summary>
/// Check to allow the inproc node to have exclusive ownership of the operating environment
/// </summary>
private bool _exclusiveOperatingEnvironment = false;
private bool _exclusiveOperatingEnvironment;

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public IDictionary<int, ISet<string>> WarningsAsMessagesByProject
/// <summary>
/// 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.
/// </summary>
public ISet<int> BuildSubmissionIdsThatHaveLoggedErrors { get; } = null;
public ISet<int> BuildSubmissionIdsThatHaveLoggedErrors { get; }
#endregion
#region IBuildEventSink Methods

Expand Down
8 changes: 4 additions & 4 deletions src/Build/BackEnd/Components/Logging/LoggingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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.
/// </summary>
private int _nextSinkId = 0;
private int _nextSinkId;

/// <summary>
/// The number of nodes in the system. Loggers may take different action depending on how many nodes are in the system.
Expand Down Expand Up @@ -187,7 +187,7 @@ internal partial class LoggingService : ILoggingService, INodePacketHandler, IBu
/// <summary>
/// What node is this logging service running on
/// </summary>
private int _nodeId = 0;
private int _nodeId;

/// <summary>
/// Whether to include evaluation metaprojects in events.
Expand Down Expand Up @@ -479,7 +479,7 @@ public ISet<string> WarningsAsErrors
{
get;
set;
} = null;
}

/// <summary>
/// A list of warnings to treat as low importance messages.
Expand All @@ -488,7 +488,7 @@ public ISet<string> WarningsAsMessages
{
get;
set;
} = null;
}

/// <summary>
/// Should evaluation events include generated metaprojects?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class LoggingServiceFactory
/// <summary>
/// What node is this logging service being created on.
/// </summary>
private int _nodeId = 0;
private int _nodeId;
#endregion

#region Constructor
Expand Down
Loading