Skip to content

Commit

Permalink
A little cleanup to ensure a project file base path (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Dec 18, 2023
1 parent 1b0c85b commit 4e44107
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.0.2

- Ensures paths being passed to Roslyn in Buildalyzer.Workspaces are absolute (#232, thanks @tjchester).

# 5.0.1

- Added support for additional files on `GetWorkspace()` (#231, thanks @Corniel).
Expand Down
7 changes: 4 additions & 3 deletions src/Buildalyzer.Workspaces/AnalyzerResultExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private static IEnumerable<DocumentInfo> GetAdditionalDocuments(IAnalyzerResult
{
string projectDirectory = Path.GetDirectoryName(analyzerResult.ProjectFilePath);
string[] additionalFiles = analyzerResult.AdditionalFiles ?? Array.Empty<string>();
return GetDocuments(additionalFiles.Select(x => Path.Combine(projectDirectory, x)), projectId);
return GetDocuments(additionalFiles.Select(x => Path.Combine(projectDirectory!, x)), projectId);
}

private static IEnumerable<MetadataReference> GetMetadataReferences(IAnalyzerResult analyzerResult) =>
Expand All @@ -300,8 +300,9 @@ private static IEnumerable<AnalyzerReference> GetAnalyzerReferences(IAnalyzerRes
{
IAnalyzerAssemblyLoader loader = workspace.Services.GetRequiredService<IAnalyzerService>().GetLoader();

return analyzerResult.AnalyzerReferences?.Where(x => File.Exists(Path.GetFullPath(x)))
.Select(x => new AnalyzerFileReference(Path.GetFullPath(x), loader))
string projectDirectory = Path.GetDirectoryName(analyzerResult.ProjectFilePath);
return analyzerResult.AnalyzerReferences?.Where(x => File.Exists(Path.GetFullPath(x, projectDirectory!)))
.Select(x => new AnalyzerFileReference(Path.GetFullPath(x, projectDirectory!), loader))
?? (IEnumerable<AnalyzerReference>)Array.Empty<AnalyzerReference>();
}

Expand Down

0 comments on commit 4e44107

Please sign in to comment.