Skip to content

Commit

Permalink
Merge pull request #10705 from rainersigwald/mio-redist-in-main
Browse files Browse the repository at this point in the history
Use Microsoft.IO.Redist in XMake.cs
  • Loading branch information
rainersigwald authored Oct 9, 2024
2 parents f3c6b67 + 4fe03ac commit 94941d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.
19 changes: 6 additions & 13 deletions src/Build/Logging/ProfilerLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,12 @@ private void GenerateProfilerReport()

Console.WriteLine(ResourceUtilities.GetResourceString("WritingProfilerReportDone"));
}
catch (DirectoryNotFoundException ex)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
}
catch (IOException ex)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
}
catch (UnauthorizedAccessException ex)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
}
catch (SecurityException ex)
catch (Exception ex) when (ex is
DirectoryNotFoundException or
IOException or
UnauthorizedAccessException or
SecurityException or
ArgumentException)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
}
Expand Down
19 changes: 0 additions & 19 deletions src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,25 +1531,6 @@ public void ProcessInvalidTargetSwitch()
#endif
}

/// <summary>
/// Verifies that when the /profileevaluation switch is used with invalid filenames an error is shown.
/// </summary>
[MemberData(nameof(GetInvalidFilenames))]
[WindowsFullFrameworkOnlyTheory(additionalMessage: ".NET Core 2.1+ no longer validates paths: https://github.com/dotnet/corefx/issues/27779#issuecomment-371253486.")]
public void ProcessProfileEvaluationInvalidFilename(string filename)
{
bool enableProfiler = false;
Should.Throw(
() => MSBuildApp.ProcessProfileEvaluationSwitch(new[] { filename }, new List<ILogger>(), out enableProfiler),
typeof(CommandLineSwitchException));
}

public static IEnumerable<object[]> GetInvalidFilenames()
{
yield return new object[] { $"a_file_with${Path.GetInvalidFileNameChars().First()}invalid_chars" };
yield return new object[] { $"C:\\a_path\\with{Path.GetInvalidPathChars().First()}invalid\\chars" };
}

/// <summary>
/// Verifies that help messages are correctly formed with the right width and leading spaces.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/MSBuild/XMake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
using SimpleErrorLogger = Microsoft.Build.Logging.SimpleErrorLogger.SimpleErrorLogger;
using TerminalLogger = Microsoft.Build.Logging.TerminalLogger.TerminalLogger;

#if NETFRAMEWORK
// Use I/O operations from Microsoft.IO.Redist which is generally higher perf
// and also works around https://github.com/dotnet/msbuild/issues/10540.
// Unnecessary on .NET 6+ because the perf improvements are in-box there.
using Microsoft.IO;
using Directory = Microsoft.IO.Directory;
using File = Microsoft.IO.File;
using FileInfo = Microsoft.IO.FileInfo;
using Path = Microsoft.IO.Path;
#endif

#nullable disable

namespace Microsoft.Build.CommandLine
Expand Down

0 comments on commit 94941d9

Please sign in to comment.