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

Cleanup: Delete Pair of TKey, TValue #9265

Merged
merged 1 commit into from
Sep 26, 2023
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
4 changes: 2 additions & 2 deletions src/Build/Definition/ProjectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,11 @@ public ProjectItem CreateItem(string evaluatedIncludeEscaped, string evaluatedIn
/// <summary>
/// Applies the supplied metadata to the destination item.
/// </summary>
public void SetMetadata(IEnumerable<Pair<ProjectMetadataElement, string>> metadata, IEnumerable<ProjectItem> destinationItems)
public void SetMetadata(IEnumerable<KeyValuePair<ProjectMetadataElement, string>> metadata, IEnumerable<ProjectItem> destinationItems)
{
foreach (IItem<ProjectMetadata> item in destinationItems)
{
foreach (Pair<ProjectMetadataElement, string> metadatum in metadata)
foreach (KeyValuePair<ProjectMetadataElement, string> metadatum in metadata)
{
item.SetMetadata(metadatum.Key, metadatum.Value);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Build/Evaluation/Evaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal class Evaluator<P, I, M, D>
/// Key is the directory of the file importing the usingTask, which is needed
/// to handle any relative paths in the usingTask.
/// </summary>
private readonly List<Pair<string, ProjectUsingTaskElement>> _usingTaskElements;
private readonly List<KeyValuePair<string, ProjectUsingTaskElement>> _usingTaskElements;

/// <summary>
/// List of ProjectTargetElement's traversing into imports.
Expand Down Expand Up @@ -249,7 +249,7 @@ private Evaluator(
_data = data;
_itemGroupElements = new List<ProjectItemGroupElement>();
_itemDefinitionGroupElements = new List<ProjectItemDefinitionGroupElement>();
_usingTaskElements = new List<Pair<string, ProjectUsingTaskElement>>();
_usingTaskElements = new List<KeyValuePair<string, ProjectUsingTaskElement>>();
_targetElements = new List<ProjectTargetElement>();
_importsSeen = new Dictionary<string, ProjectImportElement>(StringComparer.OrdinalIgnoreCase);
_initialTargetsList = new List<string>();
Expand Down Expand Up @@ -913,7 +913,7 @@ private void PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
EvaluateImportGroupElement(currentProjectOrImport.DirectoryPath, importGroup);
break;
case ProjectUsingTaskElement usingTask:
_usingTaskElements.Add(new Pair<string, ProjectUsingTaskElement>(currentProjectOrImport.DirectoryPath, usingTask));
_usingTaskElements.Add(new KeyValuePair<string, ProjectUsingTaskElement>(currentProjectOrImport.DirectoryPath, usingTask));
break;
case ProjectChooseElement choose:
EvaluateChooseElement(choose);
Expand Down
153 changes: 74 additions & 79 deletions src/Build/Evaluation/Expander.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Build/Evaluation/IItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ ProjectItemElement ItemElement
/// <summary>
/// Applies the supplied metadata to the destination items.
/// </summary>
void SetMetadata(IEnumerable<Pair<ProjectMetadataElement, string>> metadata, IEnumerable<T> destinationItems);
void SetMetadata(IEnumerable<KeyValuePair<ProjectMetadataElement, string>> metadata, IEnumerable<T> destinationItems);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public I CreateItem(string include, I baseItem, string definingProject)
return _wrappedItemFactory.CreateItem(include, baseItem, definingProject);
}

public void SetMetadata(IEnumerable<Pair<ProjectMetadataElement, string>> metadata, IEnumerable<I> destinationItems)
public void SetMetadata(IEnumerable<KeyValuePair<ProjectMetadataElement, string>> metadata, IEnumerable<I> destinationItems)
{
SetItemElement();
_wrappedItemFactory.SetMetadata(metadata, destinationItems);
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Evaluation/LazyItemEvaluator.LazyItemOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected void DecorateItemsWithMetadata(IEnumerable<ItemBatchingContext> itemBa
_expander.Metadata = metadataTable;

// Also keep a list of everything so we can get the predecessor objects correct.
List<Pair<ProjectMetadataElement, string>> metadataList = new(metadata.Length);
List<KeyValuePair<ProjectMetadataElement, string>> metadataList = new(metadata.Length);

foreach (var metadataElement in metadata)
{
Expand All @@ -252,7 +252,7 @@ protected void DecorateItemsWithMetadata(IEnumerable<ItemBatchingContext> itemBa
evaluatedValue = FileUtilities.MaybeAdjustFilePath(evaluatedValue, metadataElement.ContainingProject.DirectoryPath);

metadataTable.SetValue(metadataElement, evaluatedValue);
metadataList.Add(new Pair<ProjectMetadataElement, string>(metadataElement, evaluatedValue));
metadataList.Add(new KeyValuePair<ProjectMetadataElement, string>(metadataElement, evaluatedValue));
}

// Apply those metadata to each item
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Instance/ProjectItemInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ public ProjectItemInstance CreateItem(string evaluatedInclude, string evaluatedI
/// <summary>
/// Applies the supplied metadata to the destination item.
/// </summary>
public void SetMetadata(IEnumerable<Pair<ProjectMetadataElement, string>> metadataList, IEnumerable<ProjectItemInstance> destinationItems)
public void SetMetadata(IEnumerable<KeyValuePair<ProjectMetadataElement, string>> metadataList, IEnumerable<ProjectItemInstance> destinationItems)
{
// Set up a single dictionary that can be applied to all the items
CopyOnWritePropertyDictionary<ProjectMetadataInstance> metadata = new CopyOnWritePropertyDictionary<ProjectMetadataInstance>();
Expand Down Expand Up @@ -2172,7 +2172,7 @@ public TaskItem CreateItem(string includeEscaped, string includeBeforeWildcardEx
/// <summary>
/// Applies the supplied metadata to the destination item.
/// </summary>
public void SetMetadata(IEnumerable<Pair<ProjectMetadataElement, string>> metadata, IEnumerable<TaskItem> destinationItems)
public void SetMetadata(IEnumerable<KeyValuePair<ProjectMetadataElement, string>> metadata, IEnumerable<TaskItem> destinationItems)
{
// Not difficult to implement, but we do not expect to go here.
ErrorUtilities.ThrowInternalErrorUnreachable();
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Logging/ProfilerLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private static Dictionary<EvaluationLocation, ProfiledLocation> PruneSmallItems(

// Let's build an index of profiled locations by id, to speed up subsequent queries
var idTable = aggregatedLocations.ToDictionary(pair => pair.Key.Id,
pair => new Pair<EvaluationLocation, ProfiledLocation>(pair.Key, pair.Value));
pair => new KeyValuePair<EvaluationLocation, ProfiledLocation>(pair.Key, pair.Value));

// We want to keep all evaluation pass entries plus the big enough regular entries
foreach (var prunedPair in aggregatedLocations.Where(pair =>
Expand All @@ -237,7 +237,7 @@ private static Dictionary<EvaluationLocation, ProfiledLocation> PruneSmallItems(
/// <summary>
/// Finds the first ancestor of parentId (which could be itself) that is either an evaluation pass location or a big enough profiled data.
/// </summary>
private static long? FindBigEnoughParentId(IDictionary<long, Pair<EvaluationLocation, ProfiledLocation>> idTable,
private static long? FindBigEnoughParentId(IDictionary<long, KeyValuePair<EvaluationLocation, ProfiledLocation>> idTable,
long? parentId)
{
// The parent id is null, which means the item was pointing to an evaluation pass item. So we keep it as is.
Expand Down
3 changes: 0 additions & 3 deletions src/Build/Microsoft.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
<Compile Include="..\Shared\NGen.cs">
<Link>SharedUtilities\NGen.cs</Link>
</Compile>
<Compile Include="..\Shared\Pair.cs">
<Link>SharedUtilities\Pair.cs</Link>
</Compile>
<Compile Include="..\Shared\PropertyParser.cs">
<Link>BackEnd\Components\RequestBuilder\IntrinsicTasks\PropertyParser.cs</Link>
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
Expand Down
60 changes: 0 additions & 60 deletions src/Shared/Pair.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Shared/Tracing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ internal static void List<T>(IEnumerable<T> items)
/// Dump all the named counters, if any
/// </summary>
[Conditional("DEBUG")]
[SuppressMessage("Microsoft.MSInternal", "CA908:AvoidTypesThatRequireJitCompilationInPrecompiledAssemblies", Justification = "Debug only")]
internal static void Dump()
{
if (s_counts.Count > 0)
Expand Down