Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ public void AbsolutePathShouldHandleUriLikeRelativePathsOnUnix()

/// <summary>
/// Test to verify that the fix for issue #1769 works by directly testing
/// FileUtilities.FixFilePath integration in AbsolutePath.
/// FrameworkFileUtilities.FixFilePath integration in AbsolutePath.
/// This test simulates scenarios where intermediate path processing might
/// leave backslashes in the AbsolutePath on Unix systems.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/Evaluation/Expander_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3455,7 +3455,7 @@ public void PropertyFunctionStaticMethodDirectoryNameOfFileAbove()

string result = expander.ExpandIntoStringAndUnescape(@"$([MSBuild]::GetDirectoryNameOfFileAbove($(StartingDirectory), $(FileToFind)))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance);

Assert.Equal(Microsoft.Build.Shared.FileUtilities.EnsureTrailingSlash(tempPath), Microsoft.Build.Shared.FileUtilities.EnsureTrailingSlash(result));
Assert.Equal(FrameworkFileUtilities.EnsureTrailingSlash(tempPath), FrameworkFileUtilities.EnsureTrailingSlash(result));

result = expander.ExpandIntoStringAndUnescape(@"$([MSBuild]::GetDirectoryNameOfFileAbove($(StartingDirectory), Hobbits))", ExpanderOptions.ExpandProperties, MockElementLocation.Instance);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Build.BackEnd;
using Microsoft.Build.Execution;
using Microsoft.Build.Experimental.FileAccess;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.Shared.FileSystem;

Expand Down Expand Up @@ -44,7 +45,7 @@ public void InitializeComponent(IBuildComponentHost host)
{
_scheduler = host.GetComponent(BuildComponentType.Scheduler) as IScheduler;
_configCache = host.GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
_tempDirectory = FileUtilities.EnsureNoTrailingSlash(FileUtilities.TempFileDirectory);
_tempDirectory = FrameworkFileUtilities.EnsureNoTrailingSlash(FileUtilities.TempFileDirectory);
}

public void ShutdownComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ internal static bool IsAnyOutOfDate<T>(out DependencyAnalysisLogDetail dependenc
// possibly the outputs list isn't actually the shortest list. However it always is the shortest
// in the cases I've seen, and adding this optimization would make the code hard to read.

string oldestOutput = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(outputs[0].ToString()));
string oldestOutput = EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(outputs[0].ToString()));
ErrorUtilities.ThrowIfTypeDoesNotImplementToString(outputs[0]);

DateTime oldestOutputFileTime = DateTime.MinValue;
Expand All @@ -996,15 +996,15 @@ internal static bool IsAnyOutOfDate<T>(out DependencyAnalysisLogDetail dependenc
if (oldestOutputFileTime == DateTime.MinValue)
{
// First output is missing: we must build the target
string arbitraryInput = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(inputs[0].ToString()));
string arbitraryInput = EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(inputs[0].ToString()));
ErrorUtilities.ThrowIfTypeDoesNotImplementToString(inputs[0]);
dependencyAnalysisDetailEntry = new DependencyAnalysisLogDetail(arbitraryInput, oldestOutput, null, null, OutofdateReason.MissingOutput);
return true;
}

for (int i = 1; i < outputs.Count; i++)
{
string candidateOutput = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(outputs[i].ToString()));
string candidateOutput = EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(outputs[i].ToString()));
ErrorUtilities.ThrowIfTypeDoesNotImplementToString(outputs[i]);
DateTime candidateOutputFileTime = DateTime.MinValue;
try
Expand All @@ -1022,7 +1022,7 @@ internal static bool IsAnyOutOfDate<T>(out DependencyAnalysisLogDetail dependenc
{
// An output is missing: we must build the target
string arbitraryInput =
EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(inputs[0].ToString()));
EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(inputs[0].ToString()));
ErrorUtilities.ThrowIfTypeDoesNotImplementToString(inputs[0]);
dependencyAnalysisDetailEntry = new DependencyAnalysisLogDetail(arbitraryInput, candidateOutput, null, null, OutofdateReason.MissingOutput);
return true;
Expand All @@ -1039,7 +1039,7 @@ internal static bool IsAnyOutOfDate<T>(out DependencyAnalysisLogDetail dependenc
// Now compare the oldest output with each input and break out if we find one newer.
foreach (T input in inputs)
{
string unescapedInput = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(input.ToString()));
string unescapedInput = EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(input.ToString()));
ErrorUtilities.ThrowIfTypeDoesNotImplementToString(input);
DateTime inputFileTime = DateTime.MaxValue;
try
Expand Down Expand Up @@ -1127,8 +1127,8 @@ private void RecordUniqueInputsAndOutputs<T>(IList<T> inputs, IList<T> outputs)
/// <returns>true, if "input" is newer than "output"</returns>
private bool IsOutOfDate(string input, string output, string inputItemName, string outputItemName)
{
input = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(input));
output = EscapingUtilities.UnescapeAll(FileUtilities.FixFilePath(output));
input = EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(input));
output = EscapingUtilities.UnescapeAll(FrameworkFileUtilities.FixFilePath(output));
ProjectErrorUtilities.VerifyThrowInvalidProject(input.AsSpan().IndexOfAny(MSBuildConstants.InvalidPathChars) < 0, _project.ProjectFileLocation, "IllegalCharactersInFileOrDirectory", input, inputItemName);
ProjectErrorUtilities.VerifyThrowInvalidProject(output.AsSpan().IndexOfAny(MSBuildConstants.InvalidPathChars) < 0, _project.ProjectFileLocation, "IllegalCharactersInFileOrDirectory", output, outputItemName);
bool outOfDate = (CompareLastWriteTimes(input, output, out bool inputDoesNotExist, out bool outputDoesNotExist) == 1) || inputDoesNotExist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;

#nullable disable
Expand Down Expand Up @@ -79,7 +80,7 @@ internal static SdkResolverManifest Load(string filePath, string manifestFolder)
{
SdkResolverManifest manifest = ParseSdkResolverElement(reader, filePath);

manifest.Path = FileUtilities.FixFilePath(manifest.Path);
manifest.Path = FrameworkFileUtilities.FixFilePath(manifest.Path);
if (!System.IO.Path.IsPathRooted(manifest.Path))
{
manifest.Path = System.IO.Path.Combine(manifestFolder, manifest.Path);
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/ProjectImportElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal ProjectImportElement(XmlElementWithLocation xmlElement, ProjectRootElem
/// </summary>
public string Project
{
get => FileUtilities.FixFilePath(GetAttributeValue(XMakeAttributes.project));
get => FrameworkFileUtilities.FixFilePath(GetAttributeValue(XMakeAttributes.project));
set
{
ErrorUtilities.VerifyThrowArgumentLength(value, XMakeAttributes.project);
Expand All @@ -71,7 +71,7 @@ public string Project
/// </summary>
public string Sdk
{
get => FileUtilities.FixFilePath(GetAttributeValue(XMakeAttributes.sdk));
get => FrameworkFileUtilities.FixFilePath(GetAttributeValue(XMakeAttributes.sdk));
set
{
ErrorUtilities.VerifyThrowArgumentLength(value, XMakeAttributes.sdk);
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/ProjectRootElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ public ProjectTargetElement AddTarget(string name)
/// </summary>
public ProjectUsingTaskElement AddUsingTask(string name, string assemblyFile, string assemblyName)
{
ProjectUsingTaskElement usingTask = CreateUsingTaskElement(name, FileUtilities.FixFilePath(assemblyFile), assemblyName);
ProjectUsingTaskElement usingTask = CreateUsingTaskElement(name, FrameworkFileUtilities.FixFilePath(assemblyFile), assemblyName);
AppendChild(usingTask);

return usingTask;
Expand Down
8 changes: 4 additions & 4 deletions src/Build/Construction/ProjectUsingTaskElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Diagnostics;

using Microsoft.Build.Framework;
using Microsoft.Build.ObjectModelRemoting;
using Microsoft.Build.Shared;

Expand Down Expand Up @@ -48,14 +48,14 @@ private ProjectUsingTaskElement(XmlElementWithLocation xmlElement, ProjectRootEl
/// </summary>
public string AssemblyFile
{
get => FileUtilities.FixFilePath(
get => FrameworkFileUtilities.FixFilePath(
GetAttributeValue(XMakeAttributes.assemblyFile));

set
{
ErrorUtilities.VerifyThrowArgumentLength(value, XMakeAttributes.assemblyName);
ErrorUtilities.VerifyThrowInvalidOperation(String.IsNullOrEmpty(AssemblyName), "OM_EitherAttributeButNotBoth", ElementName, XMakeAttributes.assemblyFile, XMakeAttributes.assemblyName);
value = FileUtilities.FixFilePath(value);
value = FrameworkFileUtilities.FixFilePath(value);
SetOrRemoveAttribute(XMakeAttributes.assemblyFile, value, "Set usingtask AssemblyFile {0}", value);
}
}
Expand Down Expand Up @@ -249,7 +249,7 @@ internal static ProjectUsingTaskElement CreateDisconnected(string taskName, stri

if (!String.IsNullOrEmpty(assemblyFile))
{
usingTask.AssemblyFile = FileUtilities.FixFilePath(assemblyFile);
usingTask.AssemblyFile = FrameworkFileUtilities.FixFilePath(assemblyFile);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ private string GetMetaprojectName(ProjectInSolution project)
baseName = project.ProjectName;
}

baseName = FileUtilities.EnsureNoTrailingSlash(baseName);
baseName = FrameworkFileUtilities.EnsureNoTrailingSlash(baseName);

return GetMetaprojectName(baseName);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Build/Definition/Toolset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
using Microsoft.Build.Collections;
using Microsoft.Build.Construction;
using Microsoft.Build.Execution;
#if NET
using Microsoft.Build.Framework;
#endif

using Microsoft.Build.Internal;
using Microsoft.Build.Shared;
using Microsoft.Build.Shared.FileSystem;
Expand Down Expand Up @@ -367,7 +366,7 @@ private set
// technically hurt anything, but it doesn't look nice.)
string toolsPathToUse = value;

if (FileUtilities.EndsWithSlash(toolsPathToUse))
if (FrameworkFileUtilities.EndsWithSlash(toolsPathToUse))
{
string rootPath = Path.GetPathRoot(Path.GetFullPath(toolsPathToUse));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;

using TaskItem = Microsoft.Build.Execution.ProjectItemInstance.TaskItem;
Expand Down Expand Up @@ -119,7 +120,7 @@ private static string ExpandArgumentForScalarParameter(string function, GenericE
// Fix path before expansion
if (isFilePath)
{
argument = FileUtilities.FixFilePath(argument);
argument = FrameworkFileUtilities.FixFilePath(argument);
}

IList<TaskItem> items = state.ExpandIntoTaskItems(argument);
Expand Down Expand Up @@ -153,7 +154,7 @@ private List<string> ExpandArgumentAsFileList(GenericExpressionNode argumentNode
// Fix path before expansion
if (isFilePath)
{
argument = FileUtilities.FixFilePath(argument);
argument = FrameworkFileUtilities.FixFilePath(argument);
}

IList<TaskItem> expanded = state.ExpandIntoTaskItems(argument);
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Evaluation/Expander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ private static object ExpandMSBuildThisFileProperty(string propertyName, IElemen
}
else if (String.Equals(propertyName, ReservedPropertyNames.thisFileDirectory, StringComparison.OrdinalIgnoreCase))
{
value = FileUtilities.EnsureTrailingSlash(Path.GetDirectoryName(elementLocation.File));
value = FrameworkFileUtilities.EnsureTrailingSlash(Path.GetDirectoryName(elementLocation.File));
}
else if (String.Equals(propertyName, ReservedPropertyNames.thisFileDirectoryNoRoot, StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -4004,7 +4004,7 @@ internal object Execute(object objectInstance, IPropertyProvider<T> properties,
if (_receiverType == typeof(File) || _receiverType == typeof(Directory)
|| _receiverType == typeof(Path))
{
argumentValue = FileUtilities.FixFilePath(argumentValue);
argumentValue = FrameworkFileUtilities.FixFilePath(argumentValue);
}

args[n] = EscapingUtilities.UnescapeAll(argumentValue);
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Evaluation/IntrinsicFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ internal static bool DoesTaskHostExist(string runtime, string architecture)
/// <returns>The specified path with a trailing slash.</returns>
internal static string EnsureTrailingSlash(string path)
{
return FileUtilities.EnsureTrailingSlash(path);
return FrameworkFileUtilities.EnsureTrailingSlash(path);
}

/// <summary>
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 @@ -865,8 +865,8 @@ internal TaskItem(
ErrorUtilities.VerifyThrowArgumentLength(includeEscaped);
ErrorUtilities.VerifyThrowArgumentLength(includeBeforeWildcardExpansionEscaped);

_includeEscaped = FileUtilities.FixFilePath(includeEscaped);
_includeBeforeWildcardExpansionEscaped = FileUtilities.FixFilePath(includeBeforeWildcardExpansionEscaped);
_includeEscaped = FrameworkFileUtilities.FixFilePath(includeEscaped);
_includeBeforeWildcardExpansionEscaped = FrameworkFileUtilities.FixFilePath(includeBeforeWildcardExpansionEscaped);
_directMetadata = (directMetadata == null || directMetadata.Count == 0) ? null : directMetadata; // If the metadata was all removed, toss the dictionary
_itemDefinitions = itemDefinitions;
_projectDirectory = projectDirectory;
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Instance/TaskRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private static void RegisterTasksFromUsingTaskElement
// don't want paths from imported projects being interpreted relative to the main project file.
try
{
assemblyFile = FileUtilities.FixFilePath(assemblyFile);
assemblyFile = FrameworkFileUtilities.FixFilePath(assemblyFile);

if (assemblyFile != null && !Path.IsPathRooted(assemblyFile))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Logging/FileLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private void ApplyFileLoggerParameter(string parameterName, string parameterValu
switch (parameterName.ToUpperInvariant())
{
case "LOGFILE":
_logFileName = FileUtilities.FixFilePath(parameterValue);
_logFileName = FrameworkFileUtilities.FixFilePath(parameterValue);
break;
case "APPEND":
_append = true;
Expand Down
3 changes: 2 additions & 1 deletion src/Build/Utilities/FileSpecMatchTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;

#nullable disable
Expand Down Expand Up @@ -131,7 +132,7 @@ private static void CreateRegexOrFilenamePattern(string unescapedFileSpec, strin
? Directory.GetCurrentDirectory()
: FileUtilities.GetFullPathNoThrow(absoluteFixedDirPart);

normalizedFixedDirPart = FileUtilities.EnsureTrailingSlash(normalizedFixedDirPart);
normalizedFixedDirPart = FrameworkFileUtilities.EnsureTrailingSlash(normalizedFixedDirPart);

var recombinedFileSpec = string.Concat(normalizedFixedDirPart, wildcardDirectoryPart, filenamePart);

Expand Down
2 changes: 1 addition & 1 deletion src/Framework/ErrorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Build.Framework
// because some of the errors there will use localized resources from different assemblies,
// which won't be referenceable in Framework.

internal class FrameworkErrorUtilities
internal static class FrameworkErrorUtilities
{
/// <summary>
/// This method should be used in places where one would normally put
Expand Down
Loading
Loading