Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming BuildCop to BuildCheck #9893

Merged
merged 3 commits into from
Mar 19, 2024
Merged
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
10 changes: 5 additions & 5 deletions src/Build.UnitTests/BackEnd/MockHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Build.BackEnd;
using Microsoft.Build.BackEnd.Logging;
using Microsoft.Build.BackEnd.SdkResolution;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.BuildCheck.Infrastructure;
using Microsoft.Build.Engine.UnitTests.BackEnd;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
Expand Down Expand Up @@ -62,7 +62,7 @@ internal sealed class MockHost : MockLoggingService, IBuildComponentHost, IBuild

private ISdkResolverService _sdkResolverService;

private IBuildCopManagerProvider _buildCopManagerProvider;
private IBuildCheckManagerProvider _buildCheckManagerProvider;

#region SystemParameterFields

Expand Down Expand Up @@ -130,8 +130,8 @@ public MockHost(BuildParameters buildParameters, ConfigCache overrideConfigCache
_sdkResolverService = new MockSdkResolverService();
((IBuildComponent)_sdkResolverService).InitializeComponent(this);

_buildCopManagerProvider = new NullBuildCopManagerProvider();
((IBuildComponent)_buildCopManagerProvider).InitializeComponent(this);
_buildCheckManagerProvider = new NullBuildCheckManagerProvider();
((IBuildComponent)_buildCheckManagerProvider).InitializeComponent(this);
}

/// <summary>
Expand Down Expand Up @@ -200,7 +200,7 @@ public IBuildComponent GetComponent(BuildComponentType type)
BuildComponentType.ResultsCache => (IBuildComponent)_resultsCache,
BuildComponentType.RequestBuilder => (IBuildComponent)_requestBuilder,
BuildComponentType.SdkResolverService => (IBuildComponent)_sdkResolverService,
BuildComponentType.BuildCop => (IBuildComponent)_buildCopManagerProvider,
BuildComponentType.BuildCheck => (IBuildComponent)_buildCheckManagerProvider,
_ => throw new ArgumentException("Unexpected type " + type),
};
}
Expand Down
16 changes: 8 additions & 8 deletions src/Build/BackEnd/BuildManager/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
using Microsoft.Build.BackEnd;
using Microsoft.Build.BackEnd.Logging;
using Microsoft.Build.BackEnd.SdkResolution;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.BuildCop.Logging;
using Microsoft.Build.BuildCheck.Infrastructure;
using Microsoft.Build.BuildCheck.Logging;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Eventing;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Experimental;
using Microsoft.Build.Experimental.BuildCop;
using Microsoft.Build.Experimental.BuildCheck;
using Microsoft.Build.Experimental.ProjectCache;
using Microsoft.Build.FileAccesses;
using Microsoft.Build.Framework;
Expand Down Expand Up @@ -2984,15 +2984,15 @@ private ILoggingService CreateLoggingService(
loggingService.WarningsNotAsErrors = warningsNotAsErrors;
loggingService.WarningsAsMessages = warningsAsMessages;

if (((IBuildComponentHost)this).BuildParameters.IsBuildCopEnabled)
if (((IBuildComponentHost)this).BuildParameters.IsBuildCheckEnabled)
{
var buildCopManagerProvider =
((IBuildComponentHost)this).GetComponent(BuildComponentType.BuildCop) as IBuildCopManagerProvider;
buildCopManagerProvider!.Instance.SetDataSource(BuildCopDataSource.EventArgs);
var buildCheckManagerProvider =
((IBuildComponentHost)this).GetComponent(BuildComponentType.BuildCheck) as IBuildCheckManagerProvider;
buildCheckManagerProvider!.Instance.SetDataSource(BuildCheckDataSource.EventArgs);

loggers = (loggers ?? Enumerable.Empty<ILogger>()).Concat(new[]
{
new BuildCopConnectorLogger(new AnalyzerLoggingContextFactory(loggingService), buildCopManagerProvider.Instance)
new BuildCheckConnectorLogger(new AnalyzerLoggingContextFactory(loggingService), buildCheckManagerProvider.Instance)
});
}

Expand Down
14 changes: 7 additions & 7 deletions src/Build/BackEnd/BuildManager/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.Build.Collections;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Experimental;
using Microsoft.Build.Experimental.BuildCop;
using Microsoft.Build.Experimental.BuildCheck;
using Microsoft.Build.Experimental.ProjectCache;
using Microsoft.Build.Framework;
using Microsoft.Build.Graph;
Expand Down Expand Up @@ -209,7 +209,7 @@ public class BuildParameters : ITranslatable

private bool _question;

private bool _isBuildCopEnabled;
private bool _isBuildCheckEnabled;

/// <summary>
/// The settings used to load the project under build
Expand Down Expand Up @@ -313,7 +313,7 @@ internal BuildParameters(BuildParameters other, bool resetEnvironment = false)
DiscardBuildResults = other.DiscardBuildResults;
LowPriority = other.LowPriority;
Question = other.Question;
IsBuildCopEnabled = other.IsBuildCopEnabled;
IsBuildCheckEnabled = other.IsBuildCheckEnabled;
ProjectCacheDescriptor = other.ProjectCacheDescriptor;
}

Expand Down Expand Up @@ -842,10 +842,10 @@ public bool Question
/// <summary>
/// Gets or sets an indication of build analysis enablement.
/// </summary>
public bool IsBuildCopEnabled
public bool IsBuildCheckEnabled
{
get => _isBuildCopEnabled;
set => _isBuildCopEnabled = value;
get => _isBuildCheckEnabled;
set => _isBuildCheckEnabled = value;
}

/// <summary>
Expand Down Expand Up @@ -912,7 +912,7 @@ void ITranslatable.Translate(ITranslator translator)
translator.TranslateEnum(ref _projectLoadSettings, (int)_projectLoadSettings);
translator.Translate(ref _interactive);
translator.Translate(ref _question);
translator.Translate(ref _isBuildCopEnabled);
translator.Translate(ref _isBuildCheckEnabled);
translator.TranslateEnum(ref _projectIsolationMode, (int)_projectIsolationMode);
translator.Translate(ref _reportFileAccesses);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;
using Microsoft.Build.BackEnd.Components.Caching;
using Microsoft.Build.BackEnd.SdkResolution;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.BuildCheck.Infrastructure;
using Microsoft.Build.FileAccesses;
using Microsoft.Build.Shared;

Expand Down Expand Up @@ -78,7 +78,7 @@ public void RegisterDefaultFactories()
_componentEntriesByType[BuildComponentType.LoggingService] = new BuildComponentEntry(BuildComponentType.LoggingService, null);
_componentEntriesByType[BuildComponentType.RequestBuilder] = new BuildComponentEntry(BuildComponentType.RequestBuilder, RequestBuilder.CreateComponent, CreationPattern.CreateAlways);
// This conditionally registers real or no-op implementation based on BuildParameters
_componentEntriesByType[BuildComponentType.BuildCop] = new BuildComponentEntry(BuildComponentType.BuildCop, BuildCopManagerProvider.CreateComponent, CreationPattern.Singleton);
_componentEntriesByType[BuildComponentType.BuildCheck] = new BuildComponentEntry(BuildComponentType.BuildCheck, BuildCheckManagerProvider.CreateComponent, CreationPattern.Singleton);
_componentEntriesByType[BuildComponentType.TargetBuilder] = new BuildComponentEntry(BuildComponentType.TargetBuilder, TargetBuilder.CreateComponent, CreationPattern.CreateAlways);
_componentEntriesByType[BuildComponentType.TaskBuilder] = new BuildComponentEntry(BuildComponentType.TaskBuilder, TaskBuilder.CreateComponent, CreationPattern.CreateAlways);
_componentEntriesByType[BuildComponentType.RegisteredTaskObjectCache] = new BuildComponentEntry(BuildComponentType.RegisteredTaskObjectCache, RegisteredTaskObjectCache.CreateComponent, CreationPattern.Singleton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Threading;
using System.Threading.Tasks.Dataflow;
using Microsoft.Build.BackEnd.Logging;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.BuildCheck.Infrastructure;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
Expand Down Expand Up @@ -283,8 +283,8 @@ public void CleanupForBuild()
throw new AggregateException(deactivateExceptions);
}

var buildCopManager = (_componentHost.GetComponent(BuildComponentType.BuildCop) as IBuildCopManagerProvider)!.Instance;
buildCopManager.FinalizeProcessing(_nodeLoggingContext);
var buildCheckManager = (_componentHost.GetComponent(BuildComponentType.BuildCheck) as IBuildCheckManagerProvider)!.Instance;
buildCheckManager.FinalizeProcessing(_nodeLoggingContext);
},
isLastTask: true);

Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/IBuildComponentHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ internal enum BuildComponentType
/// <summary>
/// The Build Analyzer Manager.
/// </summary>
BuildCop,
BuildCheck,
}

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions src/Build/BackEnd/Components/Logging/EventSourceSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.Experimental.BuildCop;
using Microsoft.Build.BuildCheck.Infrastructure;
using Microsoft.Build.Experimental.BuildCheck;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;

Expand Down Expand Up @@ -104,7 +104,7 @@ internal sealed class EventSourceSink :
/// <summary>
/// This event is raised to log build cop events.
/// </summary>
public event BuildCopEventHandler BuildCopEventRaised;
public event BuildCheckEventHandler BuildCheckEventRaised;
#endregion

#region Properties
Expand Down Expand Up @@ -270,8 +270,8 @@ public void Consume(BuildEventArgs buildEvent)
case TelemetryEventArgs telemetryEvent:
RaiseTelemetryEvent(null, telemetryEvent);
break;
case BuildCopEventArgs buildCopEvent:
RaiseBuildCopEvent(null, buildCopEvent);
case BuildCheckEventArgs buildCheckEvent:
RaiseBuildCheckEvent(null, buildCheckEvent);
break;

default:
Expand Down Expand Up @@ -859,13 +859,13 @@ private void RaiseStatusEvent(object sender, BuildStatusEventArgs buildEvent)
RaiseAnyEvent(sender, buildEvent);
}

private void RaiseBuildCopEvent(object sender, BuildCopEventArgs buildEvent)
private void RaiseBuildCheckEvent(object sender, BuildCheckEventArgs buildEvent)
{
if (BuildCopEventRaised != null)
if (BuildCheckEventRaised != null)
{
try
{
BuildCopEventRaised(sender, buildEvent);
BuildCheckEventRaised(sender, buildEvent);
}
catch (LoggerException)
{
Expand Down
26 changes: 13 additions & 13 deletions src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Build.BackEnd.Logging;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.BuildCheck.Infrastructure;
using Microsoft.Build.Collections;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Eventing;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Execution;
using Microsoft.Build.Experimental.BuildCop;
using Microsoft.Build.Experimental.BuildCheck;
using Microsoft.Build.Framework;
using Microsoft.Build.Internal;
using Microsoft.Build.Shared;
Expand Down Expand Up @@ -1118,10 +1118,10 @@ private void SetProjectCurrentDirectory()
/// </summary>
private async Task<BuildResult> BuildProject()
{
// We consider this the entrypoint for the project build for purposes of BuildCop processing
// We consider this the entrypoint for the project build for purposes of BuildCheck processing

var buildCopManager = (_componentHost.GetComponent(BuildComponentType.BuildCop) as IBuildCopManagerProvider)!.Instance;
buildCopManager.SetDataSource(BuildCopDataSource.BuildExecution);
var buildCheckManager = (_componentHost.GetComponent(BuildComponentType.BuildCheck) as IBuildCheckManagerProvider)!.Instance;
buildCheckManager.SetDataSource(BuildCheckDataSource.BuildExecution);

ErrorUtilities.VerifyThrow(_targetBuilder != null, "Target builder is null");

Expand All @@ -1137,8 +1137,8 @@ private async Task<BuildResult> BuildProject()
// Load the project
if (!_requestEntry.RequestConfiguration.IsLoaded)
{
buildCopManager.StartProjectEvaluation(
BuildCopDataSource.BuildExecution,
buildCheckManager.StartProjectEvaluation(
BuildCheckDataSource.BuildExecution,
_requestEntry.Request.ParentBuildEventContext,
_requestEntry.RequestConfiguration.ProjectFullPath);

Expand All @@ -1162,14 +1162,14 @@ private async Task<BuildResult> BuildProject()
}
finally
{
buildCopManager.EndProjectEvaluation(
BuildCopDataSource.BuildExecution,
buildCheckManager.EndProjectEvaluation(
BuildCheckDataSource.BuildExecution,
_requestEntry.Request.ParentBuildEventContext);
}

_projectLoggingContext = _nodeLoggingContext.LogProjectStarted(_requestEntry);
buildCopManager.StartProjectRequest(
BuildCopDataSource.BuildExecution,
buildCheckManager.StartProjectRequest(
BuildCheckDataSource.BuildExecution,
_requestEntry.Request.ParentBuildEventContext);

// Now that the project has started, parse a few known properties which indicate warning codes to treat as errors or messages
Expand Down Expand Up @@ -1223,8 +1223,8 @@ private async Task<BuildResult> BuildProject()
MSBuildEventSource.Log.BuildProjectStop(_requestEntry.RequestConfiguration.ProjectFullPath, string.Join(", ", allTargets));
}

buildCopManager.EndProjectRequest(
BuildCopDataSource.BuildExecution,
buildCheckManager.EndProjectRequest(
BuildCheckDataSource.BuildExecution,
_requestEntry.Request.ParentBuildEventContext);

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.Build.BuildCop.Infrastructure;
using Microsoft.Build.BuildCheck.Infrastructure;

namespace Microsoft.Build.Experimental.BuildCop;
namespace Microsoft.Build.Experimental.BuildCheck;

/// <summary>
/// Base class for build analyzers.
Expand Down Expand Up @@ -39,7 +39,7 @@ public abstract class BuildAnalyzer : IDisposable
///
/// </summary>
/// <param name="registrationContext"></param>
public abstract void RegisterActions(IBuildCopRegistrationContext registrationContext);
public abstract void RegisterActions(IBuildCheckRegistrationContext registrationContext);

public virtual void Dispose()
{ }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Build.Experimental.BuildCop;
namespace Microsoft.Build.Experimental.BuildCheck;

/// <summary>
/// Configuration for a build analyzer.
Expand All @@ -16,7 +16,7 @@ public class BuildAnalyzerConfiguration
// nor in the editorconfig configuration file.
public static BuildAnalyzerConfiguration Default { get; } = new()
{
EvaluationAnalysisScope = BuildCop.EvaluationAnalysisScope.AnalyzedProjectOnly,
EvaluationAnalysisScope = BuildCheck.EvaluationAnalysisScope.AnalyzedProjectOnly,
Severity = BuildAnalyzerResultSeverity.Info,
IsEnabled = false,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Build.Experimental.BuildCop;
namespace Microsoft.Build.Experimental.BuildCheck;

/// <summary>
/// The severity of reported result (or preconfigured or user configured severity for a rule).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Build.Experimental.BuildCop;
namespace Microsoft.Build.Experimental.BuildCheck;

/// <summary>
/// Represents a rule that is a unit of build analysis.
Expand Down Expand Up @@ -49,7 +49,7 @@ public BuildAnalyzerRule(string id, string title, string description, string cat
public string Category { get; }

/// <summary>
/// Message format that will be used by the actual reports (<see cref="BuildCopResult"/>) - those will just supply the actual arguments.
/// Message format that will be used by the actual reports (<see cref="BuildCheckResult"/>) - those will just supply the actual arguments.
/// </summary>
public string MessageFormat { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
using Microsoft.Build.Construction;
using Microsoft.Build.Framework;

namespace Microsoft.Build.Experimental.BuildCop;
namespace Microsoft.Build.Experimental.BuildCheck;

/// <summary>
/// Representation of a single report of a single finding from a BuildAnalyzer
/// Each rule has upfront known message format - so only the concrete arguments are added
/// Optionally a location is attached - in the near future we might need to support multiple locations
/// (for 2 cases - a) grouped result for multiple occurrences; b) a single report for a finding resulting from combination of multiple locations)
/// </summary>
public sealed class BuildCopResult : IBuildCopResult
public sealed class BuildCheckResult : IBuildCheckResult
{
public static BuildCopResult Create(BuildAnalyzerRule rule, ElementLocation location, params string[] messageArgs)
public static BuildCheckResult Create(BuildAnalyzerRule rule, ElementLocation location, params string[] messageArgs)
{
return new BuildCopResult(rule, location, messageArgs);
return new BuildCheckResult(rule, location, messageArgs);
}

public BuildCopResult(BuildAnalyzerRule buildAnalyzerRule, ElementLocation location, string[] messageArgs)
public BuildCheckResult(BuildAnalyzerRule buildAnalyzerRule, ElementLocation location, string[] messageArgs)
{
BuildAnalyzerRule = buildAnalyzerRule;
Location = location;
Expand All @@ -31,9 +31,9 @@ public BuildCopResult(BuildAnalyzerRule buildAnalyzerRule, ElementLocation locat
internal BuildEventArgs ToEventArgs(BuildAnalyzerResultSeverity severity)
=> severity switch
{
BuildAnalyzerResultSeverity.Info => new BuildCopResultMessage(this),
BuildAnalyzerResultSeverity.Warning => new BuildCopResultWarning(this),
BuildAnalyzerResultSeverity.Error => new BuildCopResultError(this),
BuildAnalyzerResultSeverity.Info => new BuildCheckResultMessage(this),
BuildAnalyzerResultSeverity.Warning => new BuildCheckResultWarning(this),
BuildAnalyzerResultSeverity.Error => new BuildCheckResultError(this),
_ => throw new ArgumentOutOfRangeException(nameof(severity), severity, null),
};

Expand Down
Loading