Exemplo n.º 1
0
        /// <summary>
        /// Calculate dignostics. this works differently than other ones such as todo comments or designer attribute scanner
        /// since in proc and out of proc runs quite differently due to concurrency and due to possible amount of data
        /// that needs to pass through between processes
        /// </summary>
        public Task CalculateDiagnosticsAsync(PinnedSolutionInfo solutionInfo, DiagnosticArguments arguments, string pipeName, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken))
                    using (arguments.IsHighPriority ? UserOperationBooster.Boost() : default)
                    {
                        var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                        var documentId = arguments.DocumentId;
                        var projectId = arguments.ProjectId;
                        var project = solution.GetProject(projectId);
                        var documentSpan = arguments.DocumentSpan;
                        var documentAnalysisKind = arguments.DocumentAnalysisKind;
                        var diagnosticComputer = new DiagnosticComputer(documentId, project, documentSpan, documentAnalysisKind, _analyzerInfoCache);

                        var result = await diagnosticComputer.GetDiagnosticsAsync(
                            arguments.AnalyzerIds,
                            reportSuppressedDiagnostics: arguments.ReportSuppressedDiagnostics,
                            logPerformanceInfo: arguments.LogPerformanceInfo,
                            getTelemetryInfo: arguments.GetTelemetryInfo,
                            cancellationToken).ConfigureAwait(false);

                        await RemoteEndPoint.WriteDataToNamedPipeAsync(pipeName, (result, documentAnalysisKind), (writer, data, cancellationToken) =>
                        {
                            var(diagnostics, telemetry) = DiagnosticResultSerializer.WriteDiagnosticAnalysisResults(writer, data.documentAnalysisKind, data.result, cancellationToken);

                            // save log for debugging
                            Log(TraceEventType.Information, $"diagnostics: {diagnostics}, telemetry: {telemetry}");

                            return Task.CompletedTask;
                        }, cancellationToken).ConfigureAwait(false);
                    }
            }, cancellationToken));
        }
        /// <summary>
        /// Calculate dignostics. this works differently than other ones such as todo comments or designer attribute scanner
        /// since in proc and out of proc runs quite differently due to concurrency and due to possible amount of data
        /// that needs to pass through between processes
        /// </summary>
        public Task CalculateDiagnosticsAsync(DiagnosticArguments arguments, string pipeName, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                // if this analysis is explicitly asked by user, boost priority of this request
                using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken))
                    using (arguments.ForcedAnalysis ? UserOperationBooster.Boost() : default)
                    {
                        // entry point for diagnostic service
                        var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                        var projectId = arguments.ProjectId;
                        var analyzers = RoslynServices.AssetService.GetGlobalAssetsOfType <AnalyzerReference>(cancellationToken);

                        var result = await new DiagnosticComputer(solution.GetProject(projectId)).GetDiagnosticsAsync(
                            analyzers, arguments.AnalyzerIds, arguments.ReportSuppressedDiagnostics, arguments.LogAnalyzerExecutionTime, cancellationToken).ConfigureAwait(false);

                        await RemoteEndPoint.WriteDataToNamedPipeAsync(pipeName, result, (writer, data, cancellationToken) =>
                        {
                            var(diagnostics, telemetry, exceptions) = DiagnosticResultSerializer.WriteDiagnosticAnalysisResults(writer, data, cancellationToken);

                            // save log for debugging
                            Log(TraceEventType.Information, $"diagnostics: {diagnostics}, telemetry: {telemetry}, exceptions: {exceptions}");

                            return Task.CompletedTask;
                        }, cancellationToken).ConfigureAwait(false);
                    }
            }, cancellationToken));
        }
Exemplo n.º 3
0
 public FindReferencesProgressCallback(Solution solution, RemoteEndPoint endPoint, CancellationToken cancellationToken)
 {
     _solution          = solution;
     _endPoint          = endPoint;
     _cancellationToken = cancellationToken;
     ProgressTracker    = this;
 }
        private ServiceHubRemoteHostClient(
            HostWorkspaceServices services,
            HubClient hubClient,
            HostGroup hostGroup,
            Stream stream)
        {
            _connectionPools = new ConnectionPools(
                connectionFactory: (serviceName, pool, cancellationToken) => CreateConnectionImplAsync(serviceName, callbackTarget: null, pool, cancellationToken),
                capacity: ConnectionPoolCapacity);

            // use the hub client logger for unexpected exceptions from devenv as well, so we have complete information in the log:
            services.GetService <IWorkspaceTelemetryService>()?.RegisterUnexpectedExceptionLogger(hubClient.Logger);

            _services  = services;
            _hubClient = hubClient;
            _hostGroup = hostGroup;

            _endPoint = new RemoteEndPoint(stream, hubClient.Logger, incomingCallTarget: this);
            _endPoint.Disconnected += OnDisconnected;
            _endPoint.UnexpectedExceptionThrown += OnUnexpectedExceptionThrown;
            _endPoint.StartListening();

            _assetStorage = services.GetRequiredService <ISolutionAssetStorageProvider>().AssetStorage;
            _serializer   = services.GetRequiredService <ISerializerService>();
        }
Exemplo n.º 5
0
        protected ServiceBase(IServiceProvider serviceProvider, Stream stream, IEnumerable <JsonConverter>?jsonConverters = null)
        {
            InstanceId = Interlocked.Add(ref s_instanceId, 1);

            // in unit test, service provider will return asset storage, otherwise, use the default one
            AssetStorage = (AssetStorage)serviceProvider.GetService(typeof(AssetStorage)) ?? AssetStorage.Default;

            Logger = (TraceSource)serviceProvider.GetService(typeof(TraceSource));
            Log(TraceEventType.Information, "Service instance created");

            // invoke all calls incoming over the stream on this service instance:
            EndPoint = new RemoteEndPoint(stream, Logger, incomingCallTarget: this, jsonConverters);
        }
Exemplo n.º 6
0
        public JsonRpcConnection(
            HostWorkspaceServices services,
            TraceSource logger,
            object?callbackTarget,
            Stream serviceStream,
            IPooledConnectionReclamation?poolReclamation)
        {
            _solutionAssetStorage = services.GetRequiredService <ISolutionAssetStorageProvider>().AssetStorage;
            _services             = services;

            _serviceEndPoint = new RemoteEndPoint(serviceStream, logger, callbackTarget);
            _serviceEndPoint.UnexpectedExceptionThrown += UnexpectedExceptionThrown;
            _serviceEndPoint.StartListening();

            _poolReclamation = poolReclamation;
#if DEBUG
            _creationCallStack = Environment.StackTrace;
#endif
        }
 public RemoteDesignerAttributeIncrementalAnalyzerProvider(RemoteEndPoint endPoint)
 {
     _endPoint = endPoint;
 }
Exemplo n.º 8
0
 public FindReferencesProgressCallback(RemoteEndPoint endPoint, CancellationToken cancellationToken)
 {
     _endPoint          = endPoint;
     _cancellationToken = cancellationToken;
 }
 public SymbolSearchService(RemoteEndPoint endPoint)
 {
     _endPoint = endPoint;
 }
 public RemoteTodoCommentsIncrementalAnalyzerProvider(RemoteEndPoint endPoint)
 {
     _endPoint = endPoint;
 }
 public RemoteDesignerAttributeIncrementalAnalyzer(Workspace workspace, RemoteEndPoint endPoint)
 {
     _endPoint       = endPoint;
     _storageService = workspace.Services.GetRequiredService <IPersistentStorageService>();
 }
 public FindLiteralReferencesProgressCallback(RemoteEndPoint endPoint, CancellationToken cancellationToken)
 {
     _endPoint          = endPoint;
     _cancellationToken = cancellationToken;
     ProgressTracker    = this;
 }
Exemplo n.º 13
0
 public RemoteProjectTelemetryIncrementalAnalyzer(RemoteEndPoint endPoint)
 => _endPoint = endPoint;
 public RemoteDesignerAttributeIncrementalAnalyzer(Workspace workspace, RemoteEndPoint endPoint)
     : base(workspace)
 {
     _endPoint = endPoint;
 }