Skip to content

Commit

Permalink
Remove unused generalization of dependency diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
nguerrera committed Jan 11, 2018
1 parent 4fc6f5c commit b2333ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 84 deletions.
37 changes: 0 additions & 37 deletions src/Tasks/Common/DiagnosticsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,6 @@ public DiagnosticsHelper(ILog log)

public ITaskItem[] GetDiagnosticMessages() => _diagnosticMessages.ToArray();

public ITaskItem Add(string diagnosticCode, string message, string filePath, DiagnosticMessageSeverity severity)
=> Add(diagnosticCode, message, filePath, severity, startLine: 1, startColumn: 0);

public ITaskItem Add(string diagnosticCode, string message, string filePath, DiagnosticMessageSeverity severity, int startLine, int startColumn)
=> Add(
diagnosticCode,
message,
filePath,
severity,
startLine,
startColumn,
targetFrameworkMoniker: null,
packageId: null);

public ITaskItem Add(
string diagnosticCode,
string message,
string filePath,
DiagnosticMessageSeverity severity,
int startLine,
int startColumn,
string targetFrameworkMoniker,
string packageId,
bool logToMSBuild = true)
=> Add(
diagnosticCode,
message,
filePath,
severity,
startLine,
startColumn,
endLine: startLine,
endColumn: startColumn,
targetFrameworkMoniker: targetFrameworkMoniker,
packageId: packageId,
logToMSBuild: logToMSBuild);

public ITaskItem Add(
string diagnosticCode,
string message,
Expand Down
27 changes: 1 addition & 26 deletions src/Tasks/Common/TaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,8 @@ namespace Microsoft.NET.Build.Tasks
{
public abstract class TaskBase : Task
{
private readonly DiagnosticsHelper _diagnostics;

internal DiagnosticsHelper Diagnostics
{
get { return _diagnostics; }
}

[Output]
public ITaskItem[] DiagnosticMessages
{
get { return _diagnostics.GetDiagnosticMessages(); }
}

// no reason for outside classes to derive from this class.
internal TaskBase()
{
_diagnostics = new DiagnosticsHelper(new MSBuildLog(Log));
}

#region Test Support

internal TaskBase(ILog logger)
{
_diagnostics = new DiagnosticsHelper(logger ?? new MSBuildLog(Log));
}

#endregion
internal TaskBase() { }

public override bool Execute()
{
Expand Down
11 changes: 7 additions & 4 deletions src/Tasks/Microsoft.NET.Build.Tasks/ReportAssetsLogMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ namespace Microsoft.NET.Build.Tasks
public sealed class ReportAssetsLogMessages : TaskBase
{
private LockFile _lockFile;
private DiagnosticsHelper _diagnostics;

#region Outputs

// Only output is 'DiagnosticMessages' which is in the base class TaskBase
[Output]
public ITaskItem[] DiagnosticMessages => _diagnostics.GetDiagnosticMessages();

#endregion

Expand All @@ -38,14 +40,15 @@ public string ProjectAssetsFile

public ReportAssetsLogMessages()
{
_diagnostics = new DiagnosticsHelper(new MSBuildLog(Log));
}

#region Test Support

public ReportAssetsLogMessages(LockFile lockFile, ILog logger)
: base(logger)
internal ReportAssetsLogMessages(LockFile lockFile, ILog logger)
{
_lockFile = lockFile;
_diagnostics = new DiagnosticsHelper(logger);
}

#endregion
Expand Down Expand Up @@ -82,7 +85,7 @@ private void AddMessage(IAssetsLogMessage message)
{
var targetLib = message.LibraryId == null ? null : target?.GetTargetLibrary(message.LibraryId);

Diagnostics.Add(
_diagnostics.Add(
message.Code.ToString(),
message.Message,
message.FilePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</PrepareResourcesDependsOn>
</PropertyGroup>

<!-- List of targets that emit Dependency DiagnosticMessages items -->
<PropertyGroup>
<EmitsDependencyDiagnosticMessages>
RunResolvePackageDependencies;
$(EmitsDependencyDiagnosticMessages)
</EmitsDependencyDiagnosticMessages>
</PropertyGroup>

<!-- Common tokens used in preprocessed content files -->
<ItemGroup>
<PreprocessorValue Include="rootnamespace">
Expand Down Expand Up @@ -190,7 +182,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<Output TaskParameter="FileDefinitions" ItemName="FileDefinitions" />
<Output TaskParameter="PackageDependencies" ItemName="PackageDependencies" />
<Output TaskParameter="FileDependencies" ItemName="FileDependencies" />
<Output TaskParameter="DiagnosticMessages" ItemName="DiagnosticMessages" />
</ResolvePackageDependencies>

</Target>
Expand All @@ -209,7 +200,7 @@ Copyright (c) .NET Foundation. All rights reserved.

<Target Name="ResolvePackageDependenciesDesignTime"
Returns="@(_DependenciesDesignTime)"
DependsOnTargets="ResolveAssemblyReferencesDesignTime;$(EmitsDependencyDiagnosticMessages)">
DependsOnTargets="ResolveAssemblyReferencesDesignTime">

<PreprocessPackageDependenciesDesignTime
TargetDefinitions="@(TargetDefinitions)"
Expand Down Expand Up @@ -343,13 +334,6 @@ Copyright (c) .NET Foundation. All rights reserved.

</Target>

<PropertyGroup>
<EmitsDependencyDiagnosticMessages>
ReportAssetsLogMessages;
$(EmitsDependencyDiagnosticMessages)
</EmitsDependencyDiagnosticMessages>
</PropertyGroup>

<!--
============================================================
HELPERS: Get Package and File Dependencies matching active TFM and RID
Expand Down

0 comments on commit b2333ff

Please sign in to comment.