-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2604eec
commit a3ad3db
Showing
9 changed files
with
140 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Build.Framework; | ||
|
||
internal struct TaskOrTargetTelemetryKey : IEquatable<TaskOrTargetTelemetryKey> | ||
{ | ||
public TaskOrTargetTelemetryKey(string name, bool isCustom, bool isFromNugetCache, bool isFromMetaProject) | ||
{ | ||
Name = name; | ||
IsCustom = isCustom; | ||
IsFromNugetCache = isFromNugetCache; | ||
IsFromMetaProject = isFromMetaProject; | ||
} | ||
|
||
public TaskOrTargetTelemetryKey(string name, bool isCustom, bool isFromNugetCache) | ||
{ | ||
Name = name; | ||
IsCustom = isCustom; | ||
IsFromNugetCache = isFromNugetCache; | ||
} | ||
|
||
public TaskOrTargetTelemetryKey(string name) => Name = name; | ||
|
||
public static explicit operator TaskOrTargetTelemetryKey(string key) => new(key); | ||
|
||
public string Name { get; } | ||
// Indicate custom targets/task - those must be hashed. | ||
public bool IsCustom { get; } | ||
// Indicate targets/tasks sourced from nuget cache - those can be custom or MSFT provided ones. | ||
public bool IsFromNugetCache { get; } | ||
// Indicate targets/tasks generated during build - those must be hashed (as they contain paths). | ||
public bool IsFromMetaProject { get; } | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
if (obj is TaskOrTargetTelemetryKey other) | ||
{ | ||
return Equals(other); | ||
} | ||
return false; | ||
} | ||
|
||
public bool Equals(TaskOrTargetTelemetryKey other) | ||
=> string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase) && | ||
IsCustom == other.IsCustom && | ||
IsFromNugetCache == other.IsFromNugetCache && | ||
IsFromMetaProject == other.IsFromMetaProject; | ||
|
||
// We need hash code and equals - so that we can stuff data into dictionaries | ||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
var hashCode = Name.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ IsCustom.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ IsFromNugetCache.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ IsFromMetaProject.GetHashCode(); | ||
return hashCode; | ||
} | ||
} | ||
|
||
public override string ToString() => $"{Name},Custom:{IsCustom},IsFromNugetCache:{IsFromNugetCache},IsFromMetaProject:{IsFromMetaProject}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters