Пример #1
0
        private async Task <ProjectInfo> CreateProjectInfoAsync(Checksum projectChecksum)
        {
            var projectSnapshot = await _assetService.GetAssetAsync <ProjectStateChecksums>(projectChecksum, _cancellationToken).ConfigureAwait(false);

            var projectInfo = await _assetService.GetAssetAsync <ProjectInfo.ProjectAttributes>(projectSnapshot.Info, _cancellationToken).ConfigureAwait(false);

            if (!RemoteSupportedLanguages.IsSupported(projectInfo.Language))
            {
                // only add project our workspace supports.
                // workspace doesn't allow creating project with unknown languages
                return(null);
            }

            Contract.ThrowIfFalse(_baseSolution.Workspace.Services.IsSupported(projectInfo.Language));

            var compilationOptions = FixUpCompilationOptions(
                projectInfo,
                await _assetService.GetAssetAsync <CompilationOptions>(
                    projectSnapshot.CompilationOptions, _cancellationToken).ConfigureAwait(false));

            var parseOptions = await _assetService.GetAssetAsync <ParseOptions>(projectSnapshot.ParseOptions, _cancellationToken).ConfigureAwait(false);

            var p2p = await CreateCollectionAsync <ProjectReference>(projectSnapshot.ProjectReferences).ConfigureAwait(false);

            var metadata = await CreateCollectionAsync <MetadataReference>(projectSnapshot.MetadataReferences).ConfigureAwait(false);

            var analyzers = await CreateCollectionAsync <AnalyzerReference>(projectSnapshot.AnalyzerReferences).ConfigureAwait(false);

            var documents = new List <DocumentInfo>();

            foreach (var documentChecksum in projectSnapshot.Documents)
            {
                _cancellationToken.ThrowIfCancellationRequested();

                var documentInfo = await CreateDocumentInfoAsync(documentChecksum).ConfigureAwait(false);

                documents.Add(documentInfo);
            }

            var additionals = new List <DocumentInfo>();

            foreach (var documentChecksum in projectSnapshot.AdditionalDocuments)
            {
                _cancellationToken.ThrowIfCancellationRequested();

                var documentInfo = await CreateDocumentInfoAsync(documentChecksum).ConfigureAwait(false);

                additionals.Add(documentInfo);
            }

            return(ProjectInfo.Create(
                       projectInfo.Id, projectInfo.Version, projectInfo.Name, projectInfo.AssemblyName,
                       projectInfo.Language, projectInfo.FilePath, projectInfo.OutputFilePath,
                       compilationOptions, parseOptions,
                       documents, p2p, metadata, analyzers, additionals, projectInfo.IsSubmission)
                   .WithOutputRefFilePath(projectInfo.OutputRefFilePath)
                   .WithHasAllInformation(projectInfo.HasAllInformation)
                   .WithDefaultNamespace(projectInfo.DefaultNamespace));
        }
Пример #2
0
        public static Task <RemoteHostClient?> TryGetClientAsync(Project project, CancellationToken cancellationToken)
        {
            if (!RemoteSupportedLanguages.IsSupported(project.Language))
            {
                return(SpecializedTasks.Null <RemoteHostClient>());
            }

            return(TryGetClientAsync(project.Solution.Workspace, cancellationToken));
        }
        public async Task <ProjectInfo> CreateProjectInfoAsync(Checksum projectChecksum, CancellationToken cancellationToken)
        {
            var projectChecksums = await GetAssetAsync <ProjectStateChecksums>(projectChecksum, cancellationToken).ConfigureAwait(false);

            var projectInfo = await GetAssetAsync <ProjectInfo.ProjectAttributes>(projectChecksums.Info, cancellationToken).ConfigureAwait(false);

            if (!RemoteSupportedLanguages.IsSupported(projectInfo.Language))
            {
                // only add project our workspace supports.
                // workspace doesn't allow creating project with unknown languages
                return(null);
            }

            var compilationOptions = projectInfo.FixUpCompilationOptions(
                await GetAssetAsync <CompilationOptions>(projectChecksums.CompilationOptions, cancellationToken).ConfigureAwait(false));

            var parseOptions = await GetAssetAsync <ParseOptions>(projectChecksums.ParseOptions, cancellationToken).ConfigureAwait(false);

            var projectReferences = await CreateCollectionAsync <ProjectReference>(projectChecksums.ProjectReferences, cancellationToken).ConfigureAwait(false);

            var metadataReferences = await CreateCollectionAsync <MetadataReference>(projectChecksums.MetadataReferences, cancellationToken).ConfigureAwait(false);

            var analyzerReferences = await CreateCollectionAsync <AnalyzerReference>(projectChecksums.AnalyzerReferences, cancellationToken).ConfigureAwait(false);

            var documentInfos = await CreateDocumentInfosAsync(projectChecksums.Documents, cancellationToken).ConfigureAwait(false);

            var additionalDocumentInfos = await CreateDocumentInfosAsync(projectChecksums.AdditionalDocuments, cancellationToken).ConfigureAwait(false);

            var analyzerConfigDocumentInfos = await CreateDocumentInfosAsync(projectChecksums.AnalyzerConfigDocuments, cancellationToken).ConfigureAwait(false);

            return(ProjectInfo.Create(
                       projectInfo.Id,
                       projectInfo.Version,
                       projectInfo.Name,
                       projectInfo.AssemblyName,
                       projectInfo.Language,
                       projectInfo.FilePath,
                       projectInfo.OutputFilePath,
                       compilationOptions,
                       parseOptions,
                       documentInfos,
                       projectReferences,
                       metadataReferences,
                       analyzerReferences,
                       additionalDocumentInfos,
                       projectInfo.IsSubmission)
                   .WithOutputRefFilePath(projectInfo.OutputRefFilePath)
                   .WithCompilationOutputInfo(projectInfo.CompilationOutputInfo)
                   .WithHasAllInformation(projectInfo.HasAllInformation)
                   .WithRunAnalyzers(projectInfo.RunAnalyzers)
                   .WithDefaultNamespace(projectInfo.DefaultNamespace)
                   .WithAnalyzerConfigDocuments(analyzerConfigDocumentInfos)
                   .WithTelemetryId(projectInfo.TelemetryId));
        }