Skip to content

Commit d6b2109

Browse files
committed
Workaround the sanity check breaking.
1 parent 5e1ae3f commit d6b2109

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Shared/FileSystem/ManagedFileSystem.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ internal class ManagedFileSystem : IFileSystem
1717

1818
public static ManagedFileSystem Singleton() => ManagedFileSystem.Instance;
1919

20+
private static bool ShouldUseMicrosoftIO
21+
{
22+
get
23+
{
24+
#if !MICROSOFT_BUILD_ENGINE_OM_UNITTESTS
25+
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0);
26+
#else
27+
// We need to mock usage of ChangeWaves class,
28+
// because Microsoft.Build.Engine.OM.UnitTests should not have access to internals of Microsoft.Build.Framework.
29+
return true;
30+
#endif
31+
}
32+
}
33+
2034
protected ManagedFileSystem() { }
2135

2236
public TextReader ReadFile(string path)
@@ -69,7 +83,7 @@ Microsoft.IO.SearchOption searchOption
6983
public virtual IEnumerable<string> EnumerateFiles(string path, string searchPattern, SearchOption searchOption)
7084
{
7185
#if FEATURE_MSIOREDIST
72-
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
86+
return ShouldUseMicrosoftIO
7387
? HandleFileLoadException(
7488
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateFiles(path, searchPattern, searchOption),
7589
path,
@@ -85,7 +99,7 @@ public virtual IEnumerable<string> EnumerateFiles(string path, string searchPatt
8599
public virtual IEnumerable<string> EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
86100
{
87101
#if FEATURE_MSIOREDIST
88-
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
102+
return ShouldUseMicrosoftIO
89103
? HandleFileLoadException(
90104
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateDirectories(path, searchPattern, searchOption),
91105
path,
@@ -101,7 +115,7 @@ public virtual IEnumerable<string> EnumerateDirectories(string path, string sear
101115
public virtual IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
102116
{
103117
#if FEATURE_MSIOREDIST
104-
return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
118+
return ShouldUseMicrosoftIO
105119
? HandleFileLoadException(
106120
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateFileSystemEntries(path, searchPattern, searchOption),
107121
path,

0 commit comments

Comments
 (0)