exclude emitted source gen files from workspace
This commit is contained in:
@@ -965,7 +965,7 @@ public class RoslynAnalysis(ILogger<RoslynAnalysis> logger, BuildService buildSe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddDocument(SharpIdeFile fileModel, string content)
|
public async Task<bool> AddDocument(SharpIdeFile fileModel, string content)
|
||||||
{
|
{
|
||||||
using var _ = SharpIdeOtel.Source.StartActivity($"{nameof(RoslynAnalysis)}.{nameof(AddDocument)}");
|
using var _ = SharpIdeOtel.Source.StartActivity($"{nameof(RoslynAnalysis)}.{nameof(AddDocument)}");
|
||||||
await _solutionLoadedTcs.Task;
|
await _solutionLoadedTcs.Task;
|
||||||
@@ -977,6 +977,12 @@ public class RoslynAnalysis(ILogger<RoslynAnalysis> logger, BuildService buildSe
|
|||||||
// This file probably belongs to this project, but we need to check its path against the globs for the project to make sure
|
// This file probably belongs to this project, but we need to check its path against the globs for the project to make sure
|
||||||
var projectFileInfo = _projectFileInfoMap.GetValueOrDefault(probableProject.Id);
|
var projectFileInfo = _projectFileInfoMap.GetValueOrDefault(probableProject.Id);
|
||||||
Guard.Against.Null(projectFileInfo);
|
Guard.Against.Null(projectFileInfo);
|
||||||
|
|
||||||
|
var generatedFilesOutputDirectory = projectFileInfo.GeneratedFilesOutputDirectory;
|
||||||
|
if (generatedFilesOutputDirectory is not null && fileModel.Path.StartsWith(generatedFilesOutputDirectory, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var matchers = projectFileInfo.FileGlobs.Select(glob =>
|
var matchers = projectFileInfo.FileGlobs.Select(glob =>
|
||||||
{
|
{
|
||||||
var matcher = new Matcher();
|
var matcher = new Matcher();
|
||||||
@@ -1005,7 +1011,7 @@ public class RoslynAnalysis(ILogger<RoslynAnalysis> logger, BuildService buildSe
|
|||||||
|
|
||||||
if (belongsToProject is false)
|
if (belongsToProject is false)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var existingDocumentIdsWithFilePath = _workspace!.CurrentSolution.GetDocumentIdsWithFilePath(fileModel.Path);
|
var existingDocumentIdsWithFilePath = _workspace!.CurrentSolution.GetDocumentIdsWithFilePath(fileModel.Path);
|
||||||
@@ -1026,6 +1032,7 @@ public class RoslynAnalysis(ILogger<RoslynAnalysis> logger, BuildService buildSe
|
|||||||
};
|
};
|
||||||
return newSolution;
|
return newSolution;
|
||||||
}, WorkspaceChangeKind.DocumentAdded, documentId: documentId);
|
}, WorkspaceChangeKind.DocumentAdded, documentId: documentId);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> RemoveDocument(SharpIdeFile fileModel)
|
public async Task<bool> RemoveDocument(SharpIdeFile fileModel)
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ public class FileChangedService
|
|||||||
|
|
||||||
private async Task HandleWorkspaceFileAdded(SharpIdeFile file, string contents)
|
private async Task HandleWorkspaceFileAdded(SharpIdeFile file, string contents)
|
||||||
{
|
{
|
||||||
await _roslynAnalysis.AddDocument(file, contents);
|
var success = await _roslynAnalysis.AddDocument(file, contents);
|
||||||
|
if (success is false) return;
|
||||||
GlobalEvents.Instance.SolutionAltered.InvokeParallelFireAndForget();
|
GlobalEvents.Instance.SolutionAltered.InvokeParallelFireAndForget();
|
||||||
_updateSolutionDiagnosticsQueue.AddWork();
|
_updateSolutionDiagnosticsQueue.AddWork();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user