/// <summary> /// Enhances references with the assemblies they bring into the compilation and their dependency hierarchy. /// </summary> public static async Task <ImmutableArray <ReferenceInfo> > ReadReferencesAsync( ImmutableArray <ReferenceInfo> projectReferences, string projectAssetsFilePath) { var doesProjectAssetsFileExist = IOUtilities.PerformIO(() => File.Exists(projectAssetsFilePath)); if (!doesProjectAssetsFileExist) { return(ImmutableArray <ReferenceInfo> .Empty); } var projectAssetsFileContents = await IOUtilities.PerformIOAsync(async() => { using var fileStream = File.OpenRead(projectAssetsFilePath); using var reader = new StreamReader(fileStream); return(await reader.ReadToEndAsync().ConfigureAwait(false)); }).ConfigureAwait(false); if (projectAssetsFileContents is null) { return(ImmutableArray <ReferenceInfo> .Empty); } try { var projectAssets = JsonConvert.DeserializeObject <ProjectAssetsFile>(projectAssetsFileContents); return(ProjectAssetsReader.AddDependencyHierarchies(projectReferences, projectAssets)); } catch { return(ImmutableArray <ReferenceInfo> .Empty); } }