Skip to content

Commit

Permalink
Use NewestImportInput over MSBuildProjectFullPath
Browse files Browse the repository at this point in the history
Previously the FUTDC would check both the `MSBuildProjectFullPath` (i.e. the current `.csproj` file's path) and the first item of the `MSBuildAllProjects` property, which MSBuild sets to the newest of all imported project files.

As the FUTDC is only interested in the newest input, we only need to check that `MSBuildAllProjects` value and not the `MSBuildProjectFullPath` value. If the project file is newest, it will be covered by `MSBuildAllProjects`. If not, we don't need to check it.

This can save a little time by avoiding a file system check. It also reduces the log output a little.
  • Loading branch information
drewnoakes committed Jul 27, 2023
1 parent 31a2918 commit e0a2ef0
Show file tree
Hide file tree
Showing 17 changed files with 2 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,7 @@ bool CheckInputsAndOutputs(IEnumerable<(string Path, string? ItemType, bool IsRe

IEnumerable<(string Path, string? ItemType, bool IsRequired)> CollectDefaultInputs()
{
if (state.MSBuildProjectFullPath is not null)
{
log.Verbose(nameof(Resources.FUTD_AddingProjectFileInputs));
using (log.IndentScope())
{
log.VerboseLiteral(state.MSBuildProjectFullPath);
}
yield return (Path: state.MSBuildProjectFullPath, ItemType: null, IsRequired: true);
}

if (state.NewestImportInput is not null && !StringComparers.Paths.Equals(state.NewestImportInput, state.MSBuildProjectFullPath))
if (state.NewestImportInput is not null)
{
log.Verbose(nameof(Resources.FUTD_AddingNewestImportInput));
using (log.IndentScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static UpToDateCheckImplicitConfiguredInput CreateDisabled(ProjectConfigu
{
return new UpToDateCheckImplicitConfiguredInput(
projectConfiguration: projectConfiguration,
msBuildProjectFullPath: null,
msBuildProjectDirectory: null,
projectTargetPath: null,
copyUpToDateMarkerItem: null,
Expand Down Expand Up @@ -54,15 +53,6 @@ public static UpToDateCheckImplicitConfiguredInput CreateDisabled(ProjectConfigu
/// </remarks>
public ProjectConfiguration ProjectConfiguration { get; }

/// <summary>
/// Gets the full path to the project file.
/// </summary>
/// <remarks>
/// Comes from the <c>MSBuildProjectFullPath</c> MSBuild property.
/// For example, <c>C:\repos\MySolution\MyProject\MyProject.csproj</c>.
/// </remarks>
public string? MSBuildProjectFullPath { get; }

/// <summary>
/// Gets the full path to the project directory.
/// </summary>
Expand Down Expand Up @@ -248,7 +238,6 @@ private UpToDateCheckImplicitConfiguredInput(ProjectConfiguration projectConfigu

private UpToDateCheckImplicitConfiguredInput(
ProjectConfiguration projectConfiguration,
string? msBuildProjectFullPath,
string? msBuildProjectDirectory,
string? projectTargetPath,
string? copyUpToDateMarkerItem,
Expand All @@ -271,7 +260,6 @@ private UpToDateCheckImplicitConfiguredInput(
ProjectCopyData projectCopyData)
{
ProjectConfiguration = projectConfiguration;
MSBuildProjectFullPath = msBuildProjectFullPath;
MSBuildProjectDirectory = msBuildProjectDirectory;
ProjectTargetPath = projectTargetPath;
CopyUpToDateMarkerItem = copyUpToDateMarkerItem;
Expand Down Expand Up @@ -339,7 +327,7 @@ public UpToDateCheckImplicitConfiguredInput Update(
return CreateDisabled(ProjectConfiguration);
}

string? msBuildProjectFullPath = jointRuleUpdate.CurrentState.GetPropertyOrDefault(ConfigurationGeneral.SchemaName, ConfigurationGeneral.MSBuildProjectFullPathProperty, defaultValue: MSBuildProjectFullPath);
string? msBuildProjectFullPath = jointRuleUpdate.CurrentState.GetPropertyOrDefault(ConfigurationGeneral.SchemaName, ConfigurationGeneral.MSBuildProjectFullPathProperty, defaultValue: null);
string? msBuildProjectDirectory = jointRuleUpdate.CurrentState.GetPropertyOrDefault(ConfigurationGeneral.SchemaName, ConfigurationGeneral.MSBuildProjectDirectoryProperty, defaultValue: MSBuildProjectDirectory);
string? projectTargetPath = jointRuleUpdate.CurrentState.GetPropertyOrDefault(ConfigurationGeneral.SchemaName, ConfigurationGeneral.TargetPathProperty, defaultValue: "");
string? projectOutputPath = jointRuleUpdate.CurrentState.GetPropertyOrDefault(ConfigurationGeneral.SchemaName, ConfigurationGeneral.OutputPathProperty, defaultValue: OutputRelativeOrFullPath);
Expand Down Expand Up @@ -461,7 +449,6 @@ public UpToDateCheckImplicitConfiguredInput Update(

return new(
ProjectConfiguration,
msBuildProjectFullPath,
msBuildProjectDirectory,
projectTargetPath,
copyUpToDateMarkerItem: UpdateCopyUpToDateMarkerItem(),
Expand Down Expand Up @@ -713,7 +700,6 @@ internal UpToDateCheckImplicitConfiguredInput WithLastItemsChangedAtUtc(DateTime
{
return new(
ProjectConfiguration,
MSBuildProjectFullPath,
MSBuildProjectDirectory,
ProjectTargetPath,
CopyUpToDateMarkerItem,
Expand All @@ -740,7 +726,6 @@ public UpToDateCheckImplicitConfiguredInput WithRestoredState(int itemHash, Date
{
return new(
ProjectConfiguration,
MSBuildProjectFullPath,
MSBuildProjectDirectory,
ProjectTargetPath,
CopyUpToDateMarkerItem,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ This project was loaded using the wrong project type, likely as a result of rena
<value>In Set="{4}", no inputs are newer than earliest output '{0}' ({1}). Newest input is '{2}' ({3}).</value>
<comment>Do not translate 'Set' as this name is used in code. {0} and {2} are file paths. {1} and {2} are datetimes. {4} is the name of the set.</comment>
</data>
<data name="FUTD_AddingProjectFileInputs" xml:space="preserve">
<value>Adding project file inputs:</value>
</data>
<data name="FUTD_AddingNewestImportInput" xml:space="preserve">
<value>Adding newest import input:</value>
</data>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e0a2ef0

Please sign in to comment.