internal async Task <ProjectInfo> LoadProject( MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.Project oldProject, ProjectCacheInfo cacheInfo, string framework) { var projectId = projectMap.GetOrCreateId(p, oldProject, framework); var config = await GetDotNetProjectConfiguration(p, framework).ConfigureAwait(false); MonoDevelop.Projects.DotNetCompilerParameters cp = config?.CompilationParameters; FilePath fileName = IdeApp.IsInitialized ? p.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration) : (FilePath)""; if (fileName.IsNullOrEmpty) { fileName = new FilePath(p.Name + ".dll"); } if (cacheInfo == null) { cacheInfo = await LoadProjectCacheInfo(p, config, framework, token).ConfigureAwait(false); if (token.IsCancellationRequested) { return(null); } if (config != null) { workspaceCache.Update(config, framework, p, projectMap, cacheInfo); } } if (token.IsCancellationRequested) { return(null); } var loader = workspace.Services.GetService <IAnalyzerService> ().GetLoader(); ProjectData projectData, oldProjectData; ProjectDocuments projectDocuments; try { await workspace.LoadLock.WaitAsync().ConfigureAwait(false); //when reloading e.g. after a save, preserve document IDs projectData = projectMap.ReplaceData(projectId, cacheInfo.References, out oldProjectData); projectDocuments = await CreateDocuments(projectData, p, token, cacheInfo, oldProjectData).ConfigureAwait(false); if (projectDocuments == null) { // Restore old document data if cancellation happens here. projectMap.ReplaceData(projectId, oldProjectData, out _); return(null); } } finally { workspace.LoadLock.Release(); } if (token.IsCancellationRequested) { return(null); } IEnumerable <DocumentInfo> documents = projectDocuments.Documents; var virtualDocuments = workspace.GetVirtualDocuments(projectId); if (virtualDocuments.Any()) { documents = documents.Concat(virtualDocuments); } // TODO: Pass in the WorkspaceMetadataFileReferenceResolver var info = ProjectInfo.Create( projectId, GetVersionStamp(p), GetProjectInfoName(p.Name, framework), fileName.FileNameWithoutExtension, (p as MonoDevelop.Projects.DotNetProject)?.RoslynLanguageName ?? LanguageNames.CSharp, p.FileName, fileName, null, // outputRefPath null, // defaultNamespace cp?.CreateCompilationOptions(), cp?.CreateParseOptions(config), documents, cacheInfo.ProjectReferences, cacheInfo.References.Select(x => x.CurrentSnapshot), analyzerReferences: cacheInfo.AnalyzerFiles.SelectAsArray(x => { var analyzer = new MonoDevelopAnalyzer(x, hostDiagnosticUpdateSource.Value, projectId, workspace, loader, LanguageNames.CSharp); analyzersToDispose.Add(analyzer); return(analyzer.GetReference()); }), analyzerConfigDocuments: projectDocuments.EditorConfigDocuments, additionalDocuments: projectDocuments.AdditionalDocuments, isSubmission: false, hostObjectType: null, hasAllInformation: true ); info = workspace.WithDynamicDocuments(p, info); return(info); }
internal async Task <ProjectInfo> LoadProject(MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.Project oldProject, ProjectCacheInfo cacheInfo) { var projectId = projectMap.GetOrCreateId(p, oldProject); var config = GetDotNetProjectConfiguration(p); MonoDevelop.Projects.DotNetCompilerParameters cp = config?.CompilationParameters; FilePath fileName = IdeApp.IsInitialized ? p.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration) : (FilePath)""; if (fileName.IsNullOrEmpty) { fileName = new FilePath(p.Name + ".dll"); } if (cacheInfo == null) { cacheInfo = await LoadProjectCacheInfo(p, config, token).ConfigureAwait(false); if (token.IsCancellationRequested) { return(null); } if (config != null) { workspaceCache.Update(config, p, projectMap, cacheInfo); } } if (token.IsCancellationRequested) { return(null); } var loader = workspace.Services.GetService <IAnalyzerService> ().GetLoader(); ProjectData projectData, oldProjectData; List <DocumentInfo> mainDocuments, additionalDocuments; try { await workspace.LoadLock.WaitAsync().ConfigureAwait(false); //when reloading e.g. after a save, preserve document IDs oldProjectData = projectMap.RemoveData(projectId); projectData = projectMap.CreateData(projectId, cacheInfo.References); var documents = await CreateDocuments(projectData, p, token, cacheInfo.SourceFiles, oldProjectData).ConfigureAwait(false); if (documents == null) { return(null); } mainDocuments = documents.Item1; additionalDocuments = documents.Item2; } finally { workspace.LoadLock.Release(); } // TODO: Pass in the WorkspaceMetadataFileReferenceResolver var info = ProjectInfo.Create( projectId, GetVersionStamp(p), p.Name, fileName.FileNameWithoutExtension, (p as MonoDevelop.Projects.DotNetProject)?.RoslynLanguageName ?? LanguageNames.CSharp, p.FileName, fileName, cp?.CreateCompilationOptions(), cp?.CreateParseOptions(config), mainDocuments, cacheInfo.ProjectReferences, cacheInfo.References.Select(x => x.CurrentSnapshot), analyzerReferences: cacheInfo.AnalyzerFiles.SelectAsArray(x => { var analyzer = new MonoDevelopAnalyzer(x, hostDiagnosticUpdateSource.Value, projectId, workspace, loader, LanguageNames.CSharp); analyzersToDispose.Add(analyzer); return(analyzer.GetReference()); }), additionalDocuments: additionalDocuments ); return(info); }