forked from dotnet/msbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dotnet#5546 from cdmihai/iSystemData
- Made IFileSystem public as MSBuildFileSystemBase. This interface will also be passed to the future project cache interface so that caches can reuse IO from evaluation and between themselves. - EvaluationContext can take an MSBuildFileSystemBase. This enables QuickBuild and VisualStudio to share their file system caches with msbuild evaluations.
- Loading branch information
Showing
30 changed files
with
664 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Microsoft.Build.Shared.FileSystem; | ||
|
||
namespace Microsoft.Build.FileSystem | ||
{ | ||
internal class MSBuildFileSystemAdapter : IFileSystem | ||
{ | ||
private readonly MSBuildFileSystemBase _msbuildFileSystem; | ||
public MSBuildFileSystemAdapter(MSBuildFileSystemBase msbuildFileSystem) | ||
{ | ||
_msbuildFileSystem = msbuildFileSystem; | ||
} | ||
public TextReader ReadFile(string path) => _msbuildFileSystem.ReadFile(path); | ||
|
||
public Stream GetFileStream(string path, FileMode mode, FileAccess access, FileShare share) => _msbuildFileSystem.GetFileStream(path, mode, access, share); | ||
|
||
public string ReadFileAllText(string path) => _msbuildFileSystem.ReadFileAllText(path); | ||
|
||
public byte[] ReadFileAllBytes(string path) => _msbuildFileSystem.ReadFileAllBytes(path); | ||
|
||
public IEnumerable<string> EnumerateFiles(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly) | ||
{ | ||
return _msbuildFileSystem.EnumerateFiles(path, searchPattern, searchOption); | ||
} | ||
|
||
public IEnumerable<string> EnumerateDirectories(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly) | ||
{ | ||
return _msbuildFileSystem.EnumerateDirectories(path, searchPattern, searchOption); | ||
} | ||
|
||
public IEnumerable<string> EnumerateFileSystemEntries( | ||
string path, | ||
string searchPattern = "*", | ||
SearchOption searchOption = SearchOption.TopDirectoryOnly) | ||
{ | ||
return _msbuildFileSystem.EnumerateFileSystemEntries(path, searchPattern, searchOption); | ||
} | ||
|
||
public FileAttributes GetAttributes(string path) => _msbuildFileSystem.GetAttributes(path); | ||
|
||
public DateTime GetLastWriteTimeUtc(string path) => _msbuildFileSystem.GetLastWriteTimeUtc(path); | ||
|
||
public bool DirectoryExists(string path) => _msbuildFileSystem.DirectoryExists(path); | ||
|
||
public bool FileExists(string path) => _msbuildFileSystem.FileExists(path); | ||
|
||
public bool DirectoryEntryExists(string path) => _msbuildFileSystem.FileOrDirectoryExists(path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Microsoft.Build.FileSystem | ||
{ | ||
/// <summary> | ||
/// Abstracts away some file system operations. | ||
/// | ||
/// Implementations: | ||
/// - must be thread safe | ||
/// - may cache some or all the calls. | ||
/// </summary> | ||
public abstract class MSBuildFileSystemBase | ||
{ | ||
/// <summary> | ||
/// Use this for var sr = new StreamReader(path) | ||
/// </summary> | ||
public abstract TextReader ReadFile(string path); | ||
|
||
/// <summary> | ||
/// Use this for new FileStream(path, mode, access, share) | ||
/// </summary> | ||
public abstract Stream GetFileStream(string path, FileMode mode, FileAccess access, FileShare share); | ||
|
||
/// <summary> | ||
/// Use this for File.ReadAllText(path) | ||
/// </summary> | ||
public abstract string ReadFileAllText(string path); | ||
|
||
/// <summary> | ||
/// Use this for File.ReadAllBytes(path) | ||
/// </summary> | ||
public abstract byte[] ReadFileAllBytes(string path); | ||
|
||
/// <summary> | ||
/// Use this for Directory.EnumerateFiles(path, pattern, option) | ||
/// </summary> | ||
public abstract IEnumerable<string> EnumerateFiles(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly); | ||
|
||
/// <summary> | ||
/// Use this for Directory.EnumerateFolders(path, pattern, option) | ||
/// </summary> | ||
public abstract IEnumerable<string> EnumerateDirectories(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly); | ||
|
||
/// <summary> | ||
/// Use this for Directory.EnumerateFileSystemEntries(path, pattern, option) | ||
/// </summary> | ||
public abstract IEnumerable<string> EnumerateFileSystemEntries(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly); | ||
|
||
/// <summary> | ||
/// Use this for File.GetAttributes() | ||
/// </summary> | ||
public abstract FileAttributes GetAttributes(string path); | ||
|
||
/// <summary> | ||
/// Use this for File.GetLastWriteTimeUtc(path) | ||
/// </summary> | ||
public abstract DateTime GetLastWriteTimeUtc(string path); | ||
|
||
/// <summary> | ||
/// Use this for Directory.Exists(path) | ||
/// </summary> | ||
public abstract bool DirectoryExists(string path); | ||
|
||
/// <summary> | ||
/// Use this for File.Exists(path) | ||
/// </summary> | ||
public abstract bool FileExists(string path); | ||
|
||
/// <summary> | ||
/// Use this for File.Exists(path) || Directory.Exists(path) | ||
/// </summary> | ||
public abstract bool FileOrDirectoryExists(string path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.