Exemplo n.º 1
0
 private static void SetRoslynLogger <T>(List <string> loggerTypes, Func <T> creator) where T : ILogger
 {
     if (loggerTypes.Contains(typeof(T).Name))
     {
         RoslynLogger.SetLogger(AggregateLogger.AddOrReplace(creator(), RoslynLogger.GetLogger(), l => l is T));
     }
     else
     {
         RoslynLogger.SetLogger(AggregateLogger.Remove(RoslynLogger.GetLogger(), l => l is T));
     }
 }
Exemplo n.º 2
0
        private void SetGlobalContext(int uiCultureLCID, int cultureLCID, string?serializedSession)
        {
            // set global telemetry session
            var session = GetTelemetrySession(serializedSession);

            if (session == null)
            {
                return;
            }

            EnsureCulture(uiCultureLCID, cultureLCID);

            // set roslyn loggers
            RoslynServices.SetTelemetrySession(session);

            RoslynLogger.SetLogger(AggregateLogger.Create(new VSTelemetryLogger(session), RoslynLogger.GetLogger()));

            // set both handler as NFW
            FatalError.Handler         = ex => WatsonReporter.Report(ex, WatsonSeverity.Critical);
            FatalError.NonFatalHandler = ex => WatsonReporter.Report(ex);

            // start performance reporter
            var diagnosticAnalyzerPerformanceTracker = SolutionService.PrimaryWorkspace.Services.GetService <IPerformanceTrackerService>();

            if (diagnosticAnalyzerPerformanceTracker != null)
            {
                var globalOperationNotificationService = SolutionService.PrimaryWorkspace.Services.GetService <IGlobalOperationNotificationService>();
                _performanceReporter = new PerformanceReporter(Logger, diagnosticAnalyzerPerformanceTracker, globalOperationNotificationService, s_reportInterval, _shutdownCancellationSource.Token);
            }
        }
Exemplo n.º 3
0
        private static void SetGlobalContext(string serializedSession)
        {
            // set global telemetry session
            var session = GetTelemetrySession(serializedSession);

            if (session == null)
            {
                return;
            }

            // set roslyn loggers
            WatsonReporter.SetTelemetrySession(session);

            RoslynLogger.SetLogger(AggregateLogger.Create(new VSTelemetryLogger(session), RoslynLogger.GetLogger()));

            // set both handler as NFW
            FatalError.Handler         = WatsonReporter.Report;
            FatalError.NonFatalHandler = WatsonReporter.Report;
        }
Exemplo n.º 4
0
        private void SetGlobalContext(int uiCultureLCID, int cultureLCID, string serializedSession)
        {
            var session = new TelemetrySession(serializedSession);

            session.Start();

            EnsureCulture(uiCultureLCID, cultureLCID);

            WatsonReporter.InitializeFatalErrorHandlers(session);
            WatsonReporter.InitializeLogger(Logger);

            // set roslyn loggers
            RoslynServices.SetTelemetrySession(session);

            RoslynLogger.SetLogger(AggregateLogger.Create(new VSTelemetryLogger(session), RoslynLogger.GetLogger()));

            // start performance reporter
            var diagnosticAnalyzerPerformanceTracker = SolutionService.PrimaryWorkspace.Services.GetService <IPerformanceTrackerService>();

            if (diagnosticAnalyzerPerformanceTracker != null)
            {
                var globalOperationNotificationService = SolutionService.PrimaryWorkspace.Services.GetService <IGlobalOperationNotificationService>();
                _performanceReporter = new PerformanceReporter(Logger, diagnosticAnalyzerPerformanceTracker, globalOperationNotificationService, s_reportInterval, _shutdownCancellationSource.Token);
            }
        }