Skip to content

Commit

Permalink
Workaround the sanity check breaking. Revert this commit when changewave
Browse files Browse the repository at this point in the history
17_0 is deleted.
  • Loading branch information
AR-May committed Oct 13, 2021
1 parent 5e1ae3f commit d94c76b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\Shared\FileSystemSources.proj" />
<Import Project="..\Shared\FileSystemSourcesBase.proj" />
<Import Project="..\Shared\DebuggingSources.proj" />

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// This file is a workaround from PR https://github.com/dotnet/msbuild/pull/6771.
// We need to avoid using ChangeWaves.cs in Microsoft.Build.Engine.OM.UnitTests.
// It mocks ManagedFileSystemChangeWavesExtension.cs.
// We are mocking the call ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0) as true.
// After deleting changewave 17_0 delete this file as well.

#if FEATURE_MSIOREDIST
namespace Microsoft.Build.Shared.FileSystem
{
/// <summary>
/// Implementation of file system operations directly over the dot net managed layer
/// </summary>

internal partial class ManagedFileSystem : IFileSystem
{
private bool ShouldUseMicrosoftIO = true;
}
}
#endif
8 changes: 4 additions & 4 deletions src/Shared/FileSystem/ManagedFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Build.Shared.FileSystem
/// <summary>
/// Implementation of file system operations directly over the dot net managed layer
/// </summary>
internal class ManagedFileSystem : IFileSystem
internal partial class ManagedFileSystem : IFileSystem
{
private static readonly ManagedFileSystem Instance = new ManagedFileSystem();

Expand Down Expand Up @@ -69,7 +69,7 @@ Microsoft.IO.SearchOption searchOption
public virtual IEnumerable<string> EnumerateFiles(string path, string searchPattern, SearchOption searchOption)
{
#if FEATURE_MSIOREDIST
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
return ShouldUseMicrosoftIO
? HandleFileLoadException(
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateFiles(path, searchPattern, searchOption),
path,
Expand All @@ -85,7 +85,7 @@ public virtual IEnumerable<string> EnumerateFiles(string path, string searchPatt
public virtual IEnumerable<string> EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
{
#if FEATURE_MSIOREDIST
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
return ShouldUseMicrosoftIO
? HandleFileLoadException(
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateDirectories(path, searchPattern, searchOption),
path,
Expand All @@ -101,7 +101,7 @@ public virtual IEnumerable<string> EnumerateDirectories(string path, string sear
public virtual IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
{
#if FEATURE_MSIOREDIST
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
return ShouldUseMicrosoftIO
? HandleFileLoadException(
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateFileSystemEntries(path, searchPattern, searchOption),
path,
Expand Down
8 changes: 5 additions & 3 deletions src/Shared/FileSystemSources.proj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project>
<Import Project="FileSystemSourcesBase.proj" />

<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)FileSystem\*.cs">
<Link>FileSystem\%(Filename).cs</Link>
<Compile Include="$(MSBuildThisFileDirectory)ManagedFileSystemChangeWavesExtension.cs">
<Link>FileSystem\ManagedFileSystemChangeWavesExtension.cs</Link>
</Compile>
</ItemGroup>
</Project>
</Project>
7 changes: 7 additions & 0 deletions src/Shared/FileSystemSourcesBase.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)FileSystem\*.cs">
<Link>FileSystem\%(Filename).cs</Link>
</Compile>
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions src/Shared/ManagedFileSystemChangeWavesExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// This file is a workaround from PR https://github.com/dotnet/msbuild/pull/6771.
// We need to avoid using ChangeWaves.cs in Microsoft.Build.Engine.OM.UnitTests.
// Usage of ChangeWaves class in ManagedFileSystem is done in this separate file.
// In Microsoft.Build.Engine.OM.UnitTests this part is mocked (see MockManagedFileSystemChangeWavesExtension.cs).
// After deleting changewave 17_0 delete this file as well.

#if FEATURE_MSIOREDIST
using Microsoft.Build.Utilities;

namespace Microsoft.Build.Shared.FileSystem
{
/// <summary>
/// Implementation of file system operations directly over the dot net managed layer
/// </summary>
internal partial class ManagedFileSystem : IFileSystem
{
private bool ShouldUseMicrosoftIO = ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0);
}
}
#endif

0 comments on commit d94c76b

Please sign in to comment.