public string Connect(string host, string serializedSession) { _primaryInstance = InstanceId; var existing = Interlocked.CompareExchange(ref _host, host, null); SetGlobalContext(serializedSession); if (existing != null && existing != host) { LogError($"{host} is given for {existing}"); } // log telemetry that service hub started RoslynLogger.Log(FunctionId.RemoteHost_Connect, KeyValueLogMessage.Create(SetSessionInfo)); return(_host); }
protected override async Task ExecuteAsync() { // wait for global operation such as build await GlobalOperationTask.ConfigureAwait(false); using (var pooledObject = SharedPools.Default <List <ExpensiveAnalyzerInfo> >().GetPooledObject()) using (RoslynLogger.LogBlock(FunctionId.Diagnostics_GeneratePerformaceReport, CancellationToken)) { _diagnosticAnalyzerPerformanceTracker.GenerateReport(pooledObject.Object); foreach (var analyzerInfo in pooledObject.Object) { var newAnalyzer = _reported.Add(analyzerInfo.AnalyzerId); var isInternalUser = _telemetrySession.IsUserMicrosoftInternal; // we only report same analyzer once unless it is internal user if (isInternalUser || newAnalyzer) { // this will report telemetry under VS. this will let us see how accurate our performance tracking is RoslynLogger.Log(FunctionId.Diagnostics_BadAnalyzer, KeyValueLogMessage.Create(m => { // since it is telemetry, we hash analyzer name if it is not builtin analyzer m[nameof(analyzerInfo.AnalyzerId)] = isInternalUser ? analyzerInfo.AnalyzerId : analyzerInfo.PIISafeAnalyzerId; m[nameof(analyzerInfo.LocalOutlierFactor)] = analyzerInfo.LocalOutlierFactor; m[nameof(analyzerInfo.Average)] = analyzerInfo.Average; m[nameof(analyzerInfo.AdjustedStandardDeviation)] = analyzerInfo.AdjustedStandardDeviation; })); } // for logging, we only log once. we log here so that we can ask users to provide this log to us // when we want to find out VS performance issue that could be caused by analyzer if (newAnalyzer) { _logger.TraceEvent(TraceEventType.Warning, 0, $"Analyzer perf indicators exceeded threshold for '{analyzerInfo.AnalyzerId}' ({analyzerInfo.AnalyzerIdHash}): " + $"LOF: {analyzerInfo.LocalOutlierFactor}, Avg: {analyzerInfo.Average}, Stddev: {analyzerInfo.AdjustedStandardDeviation}"); } } } }
public string Connect(string host, int uiCultureLCID, int cultureLCID, string?serializedSession, CancellationToken cancellationToken) { return(RunService(() => { cancellationToken.ThrowIfCancellationRequested(); // initialize global assert storage AssetStorage.Initialize(this); _primaryInstance = InstanceId; var existing = Interlocked.CompareExchange(ref _host, host, null); // serializedSession may be null for testing if (serializedSession != null) { SetGlobalContext(uiCultureLCID, cultureLCID, serializedSession); } if (existing != null && existing != host) { Log(TraceEventType.Error, $"{host} is given for {existing}"); } // log telemetry that service hub started RoslynLogger.Log(FunctionId.RemoteHost_Connect, KeyValueLogMessage.Create(SetSessionInfo)); if (serializedSession != null) { // Set this process's priority BelowNormal. // this should let us to freely try to use all resources possible without worrying about affecting // host's work such as responsiveness or build. Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal; } return _host; }, cancellationToken)); }
// TO-DO: More LSP.CompletionTriggerKind mappings are required to properly map to Roslyn CompletionTriggerKinds. // https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1178726 public static Completion.CompletionTrigger LSPToRoslynCompletionTrigger(LSP.CompletionContext?context) { if (context == null) { // Some LSP clients don't support sending extra context, so all we can do is invoke return(Completion.CompletionTrigger.Invoke); } else if (context.TriggerKind == LSP.CompletionTriggerKind.Invoked) { return(Completion.CompletionTrigger.Invoke); } else if (context.TriggerKind == LSP.CompletionTriggerKind.TriggerCharacter) { Contract.ThrowIfNull(context.TriggerCharacter); return(Completion.CompletionTrigger.CreateInsertionTrigger(char.Parse(context.TriggerCharacter))); } else { // LSP added a TriggerKind that we need to support. Logger.Log(FunctionId.LSPCompletion_MissingLSPCompletionTriggerKind); return(Completion.CompletionTrigger.Invoke); } }