Skip to content

Commit 3d5b936

Browse files
committed
Convert value tuple to record
1 parent 82f5a54 commit 3d5b936

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/BuildUpToDateCheck.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,12 +1054,11 @@ private async Task<bool> IsUpToDateInternalAsync(
10541054

10551055
// We may have an incomplete set of copy items.
10561056
// We check timestamps of whatever items we can find, but only perform acceleration when the full set is available.
1057-
(IEnumerable<(string Path, ImmutableArray<CopyItem> CopyItems)> copyItemsByProject, bool isCopyItemsComplete, bool allReferencesProduceReferenceAssemblies)
1058-
= _copyItemAggregator.TryGatherCopyItemsForProject(implicitState.ProjectTargetPath, logger);
1057+
CopyItemsResult copyInfo = _copyItemAggregator.TryGatherCopyItemsForProject(implicitState.ProjectTargetPath, logger);
10591058

1060-
bool? isBuildAccelerationEnabled = IsBuildAccelerationEnabled(isCopyItemsComplete, implicitState);
1059+
bool? isBuildAccelerationEnabled = IsBuildAccelerationEnabled(copyInfo.IsComplete, implicitState);
10611060

1062-
var configuredFileSystemOperations = new ConfiguredFileSystemOperationAggregator(fileSystemOperations, isBuildAccelerationEnabled, allReferencesProduceReferenceAssemblies);
1061+
var configuredFileSystemOperations = new ConfiguredFileSystemOperationAggregator(fileSystemOperations, isBuildAccelerationEnabled, copyInfo.AllReferencesProduceReferenceAssemblies);
10631062

10641063
string outputFullPath = Path.Combine(implicitState.MSBuildProjectDirectory, implicitState.OutputRelativeOrFullPath);
10651064

@@ -1069,7 +1068,7 @@ private async Task<bool> IsUpToDateInternalAsync(
10691068
!CheckInputsAndOutputs(logger, lastSuccessfulBuildStartTimeUtc, timestampCache, implicitState, ignoreKinds, token) ||
10701069
!CheckBuiltFromInputFiles(logger, timestampCache, implicitState, token) ||
10711070
!CheckMarkers(logger, timestampCache, implicitState, isBuildAccelerationEnabled, fileSystemOperations) ||
1072-
!CheckCopyToOutputDirectoryItems(logger, implicitState, copyItemsByProject, configuredFileSystemOperations, isBuildAccelerationEnabled, token))
1071+
!CheckCopyToOutputDirectoryItems(logger, implicitState, copyInfo.ItemsByProject, configuredFileSystemOperations, isBuildAccelerationEnabled, token))
10731072
{
10741073
return (false, checkedConfigurations);
10751074
}

src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/CopyItemAggregator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void SetProjectData(ProjectCopyData projectCopyData)
2020
}
2121
}
2222

23-
public (IEnumerable<(string Path, ImmutableArray<CopyItem> CopyItems)> ItemsByProject, bool IsComplete, bool AllReferencesProduceReferenceAssemblies) TryGatherCopyItemsForProject(string targetPath, BuildUpToDateCheck.Log logger)
23+
public CopyItemsResult TryGatherCopyItemsForProject(string targetPath, BuildUpToDateCheck.Log logger)
2424
{
2525
// Keep track of all projects we've visited to avoid infinite recursion or duplicated results.
2626
HashSet<string> explored = new(StringComparers.Paths);
@@ -83,7 +83,7 @@ public void SetProjectData(ProjectCopyData projectCopyData)
8383
}
8484
}
8585

86-
return (GenerateCopyItems(), isComplete, allReferencesProduceReferenceAssemblies);
86+
return new(GenerateCopyItems(), isComplete, allReferencesProduceReferenceAssemblies);
8787

8888
IEnumerable<(string Path, ImmutableArray<CopyItem> CopyItems)> GenerateCopyItems()
8989
{

src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/ICopyItemAggregator.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,22 @@ internal interface ICopyItemAggregator
2525
/// </remarks>
2626
/// <param name="targetPath">The target path of the project to query from.</param>
2727
/// <param name="logger">An object for writing log messages.</param>
28-
/// <returns>
29-
/// A tuple comprising:
30-
/// <list type="number">
31-
/// <item><c>Items</c> a sequence of items by project, that are reachable from the current project.</item>
32-
/// <item><c>IsComplete</c> indicating whether we have items from all reachable projects.</item>
33-
/// <item><c>AllReferencesProduceReferenceAssemblies</c> indicating whether all referenced projects produce reference assemblies.</item>
34-
/// </list>
35-
/// </returns>
36-
(IEnumerable<(string Path, ImmutableArray<CopyItem> CopyItems)> ItemsByProject, bool IsComplete, bool AllReferencesProduceReferenceAssemblies) TryGatherCopyItemsForProject(string targetPath, BuildUpToDateCheck.Log logger);
28+
/// <returns>A structure containing the results of the operation.</returns>
29+
CopyItemsResult TryGatherCopyItemsForProject(string targetPath, BuildUpToDateCheck.Log logger);
3730
}
3831

32+
/// <summary>
33+
/// Results of gathering the items that must be copied as part of a project's build
34+
/// by <see cref="ICopyItemAggregator.TryGatherCopyItemsForProject(string, BuildUpToDateCheck.Log)"/>.
35+
/// </summary>
36+
/// <param name="ItemsByProject">A sequence of items by project, that are reachable from the current project</param>
37+
/// <param name="IsComplete">Indicates whether we have items from all reachable projects.</param>
38+
/// <param name="AllReferencesProduceReferenceAssemblies">Indicates whether all referenced projects produce reference assemblies.</param>
39+
internal record struct CopyItemsResult(
40+
IEnumerable<(string Path, ImmutableArray<CopyItem> CopyItems)> ItemsByProject,
41+
bool IsComplete,
42+
bool AllReferencesProduceReferenceAssemblies);
43+
3944
/// <summary>
4045
/// Models the set of copy items a project produces, along with some details about the project.
4146
/// </summary>

tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/UpToDate/BuildUpToDateCheckTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public BuildUpToDateCheckTests(ITestOutputHelper output)
9999
var upToDateCheckHost = new Mock<IUpToDateCheckHost>(MockBehavior.Strict);
100100

101101
var copyItemAggregator = new Mock<ICopyItemAggregator>(MockBehavior.Strict);
102-
copyItemAggregator.Setup(o => o.TryGatherCopyItemsForProject(It.IsAny<string>(), It.IsAny<BuildUpToDateCheck.Log>())).Returns(() => (_copyItems, _isCopyItemsComplete, _allReferencesProduceReferenceAssemblies));
102+
copyItemAggregator.Setup(o => o.TryGatherCopyItemsForProject(It.IsAny<string>(), It.IsAny<BuildUpToDateCheck.Log>())).Returns(() => new CopyItemsResult(_copyItems, _isCopyItemsComplete, _allReferencesProduceReferenceAssemblies));
103103

104104
_currentSolutionBuildContext = new SolutionBuildContext(_fileSystem);
105105

0 commit comments

Comments
 (0)