public static void LogPreviewChangesResult(FixAllKind fixAllKind, int?correlationId, bool applied, bool allChangesApplied = true) { string value; if (applied) { value = allChangesApplied ? AllChangesApplied : SubsetOfChangesApplied; } else { value = Cancelled; } var functionId = fixAllKind switch { FixAllKind.CodeFix => FunctionId.CodeFixes_FixAllOccurrencesPreviewChanges, FixAllKind.Refactoring => FunctionId.Refactoring_FixAllOccurrencesPreviewChanges, _ => throw ExceptionUtilities.UnexpectedValue(fixAllKind) }; Logger.Log(functionId, KeyValueLogMessage.Create(m => { // we might not have this info for suppression if (correlationId.HasValue) { m[CorrelationId] = correlationId; } m[Result] = value; })); }
public static void LogComputationResult(FixAllKind fixAllKind, int correlationId, bool completed, bool timedOut = false) { Contract.ThrowIfTrue(completed && timedOut); string value; if (completed) { value = Completed; } else if (timedOut) { value = TimedOut; } else { value = Cancelled; } var functionId = fixAllKind switch { FixAllKind.CodeFix => FunctionId.CodeFixes_FixAllOccurrencesComputation, FixAllKind.Refactoring => FunctionId.Refactoring_FixAllOccurrencesComputation, _ => throw ExceptionUtilities.UnexpectedValue(fixAllKind) }; Logger.Log(functionId, KeyValueLogMessage.Create(m => { m[CorrelationId] = correlationId; m[Result] = value; })); }
internal static Solution PreviewChanges( Solution currentSolution, Solution newSolution, string fixAllPreviewChangesTitle, string fixAllTopLevelHeader, FixAllKind fixAllKind, string languageOpt, Workspace workspace, int?correlationId = null, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); var functionId = fixAllKind switch { FixAllKind.CodeFix => FunctionId.CodeFixes_FixAllOccurrencesPreviewChanges, FixAllKind.Refactoring => FunctionId.Refactoring_FixAllOccurrencesPreviewChanges, _ => throw ExceptionUtilities.UnexpectedValue(fixAllKind) }; using (Logger.LogBlock( functionId, KeyValueLogMessage.Create(LogType.UserAction, m => { // only set when correlation id is given // we might not have this info for suppression if (correlationId.HasValue) { m[FixAllLogger.CorrelationId] = correlationId; } }), cancellationToken)) { var glyph = languageOpt == null ? Glyph.Assembly : languageOpt == LanguageNames.CSharp ? Glyph.CSharpProject : Glyph.BasicProject; #if COCOA var previewService = workspace.Services.GetService <IPreviewDialogService>(); // Until IPreviewDialogService is implemented, just execute all changes without user ability to pick and choose if (previewService == null) { return(newSolution); } #else var previewService = workspace.Services.GetRequiredService <IPreviewDialogService>(); #endif var changedSolution = previewService.PreviewChanges( string.Format(EditorFeaturesResources.Preview_Changes_0, fixAllPreviewChangesTitle), "vs.codefix.fixall", fixAllTopLevelHeader, fixAllPreviewChangesTitle, glyph, newSolution, currentSolution); if (changedSolution == null) { // User clicked cancel. FixAllLogger.LogPreviewChangesResult(fixAllKind, correlationId, applied: false); return(null); } FixAllLogger.LogPreviewChangesResult(fixAllKind, correlationId, applied: true, allChangesApplied: changedSolution == newSolution); return(changedSolution); } }