Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit 6f9bbb3

Browse files
committed
Add back in the file checks
Add back in the file existence checks @nslottow added. These were accidentally removed during a merge.
1 parent d0a07bf commit 6f9bbb3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Microsoft.DotNet.CodeFormatting/FormattingEngineImplementation.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ private async Task SaveChanges(Solution solution, Solution originalSolution, Can
112112

113113
private async Task<bool> ShouldBeProcessedAsync(Document document)
114114
{
115+
if (document.FilePath != null)
116+
{
117+
var fileInfo = new FileInfo(document.FilePath);
118+
if (!fileInfo.Exists || fileInfo.IsReadOnly)
119+
{
120+
Console.WriteLine("warning: skipping document '{0}' because it {1}.",
121+
document.FilePath,
122+
fileInfo.IsReadOnly ? "is read-only" : "does not exist");
123+
return false;
124+
}
125+
}
126+
115127
foreach (var filter in _filters)
116128
{
117129
var shouldBeProcessed = await filter.ShouldBeProcessedAsync(document);
@@ -177,7 +189,7 @@ private async Task<Solution> RunSyntaxPass(Solution originalSolution, IReadOnlyL
177189

178190
if (newRoot != syntaxRoot)
179191
{
180-
currentSolution = currentSolution.WithDocumentSyntaxRoot(document.Id, newRoot);
192+
currentSolution = currentSolution.WithDocumentSyntaxRoot(document.Id, newRoot);
181193
}
182194
}
183195

0 commit comments

Comments
 (0)