diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler_TabHandler.cs b/src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler_TabHandler.cs index f39144e42d6a586fe4ed4163d8a9fe8d28ee3aeb..3ba31e5e1b77cec1d960cf8d2d0cd6c2542e273b 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler_TabHandler.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler_TabHandler.cs @@ -23,7 +23,7 @@ public VSCommanding.CommandState GetCommandState(TabKeyCommandArgs args, Func renameLocations) { - int totalFilesCount = renameLocations.GroupBy(s => s.Document).Count(); - int totalSpansCount = renameLocations.Length; + var totalFilesCount = renameLocations.GroupBy(s => s.Document).Count(); + var totalSpansCount = renameLocations.Length; UpdateSearchText(totalSpansCount, totalFilesCount); } diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/RenameShortcutKeys.cs b/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/RenameShortcutKeys.cs index e329d1f1b7ae3735387a1b7d9881bf7547849891..2c43eb7bc4a3f75a9fe1eaa6eae08bf0135f757c 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/RenameShortcutKeys.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/RenameShortcutKeys.cs @@ -27,7 +27,7 @@ static RenameShortcutKey() /// private static string ExtractAccessKey(string localizedLabel, string defaultValue) { - int underscoreIndex = localizedLabel.IndexOf('_'); + var underscoreIndex = localizedLabel.IndexOf('_'); if (underscoreIndex >= 0 && underscoreIndex < localizedLabel.Length - 1) { diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.OpenTextBufferManager.cs b/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.OpenTextBufferManager.cs index 2e39761c7e31c8cf1b82e2733a7bbe0c42aba77b..8ceba7f6648f9f33ff4cbda3e7629bfe0fdca1c7 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.OpenTextBufferManager.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.OpenTextBufferManager.cs @@ -541,7 +541,7 @@ internal void ApplyConflictResolutionEdits(IInlineRenameReplacementInfo conflict private static string GetWithoutAttributeSuffix(string text, bool isCaseSensitive) { - if (!text.TryGetWithoutAttributeSuffix(isCaseSensitive, out string replaceText)) + if (!text.TryGetWithoutAttributeSuffix(isCaseSensitive, out var replaceText)) { replaceText = text; } @@ -566,8 +566,8 @@ private static async Task> GetTextChangesFromTextDiffere throw new ArgumentException(WorkspacesResources.The_specified_document_is_not_a_version_of_this_document); } - SourceText oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); - SourceText newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); + var oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); + var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); if (oldText == newText) { diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs b/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs index 0b26470e7bfb2620314ee2971c2160ab636e0ed2..eb1159e53ae6a3e5d8303f36d349bbb65592483a 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs @@ -183,7 +183,7 @@ private void InitializeOpenBuffers(SnapshotSpan triggerSpan) { using (Logger.LogBlock(FunctionId.Rename_CreateOpenTextBufferManagerForAllOpenDocs, CancellationToken.None)) { - HashSet openBuffers = new HashSet(); + var openBuffers = new HashSet(); foreach (var d in _workspace.GetOpenDocumentIds()) { var document = _baseSolution.GetDocument(d); @@ -669,7 +669,7 @@ private void CommitCore(IWaitContext waitContext, bool previewChanges) _conflictResolutionTask.Wait(waitContext.CancellationToken); waitContext.AllowCancel = false; - Solution newSolution = _conflictResolutionTask.Result.NewSolution; + var newSolution = _conflictResolutionTask.Result.NewSolution; if (previewChanges) { var previewService = _workspace.Services.GetService(); diff --git a/src/EditorFeatures/Core.Wpf/Interactive/CSharpVBResetCommand.cs b/src/EditorFeatures/Core.Wpf/Interactive/CSharpVBResetCommand.cs index 48e93b0cacfed828d8ad538bbd7dd1f6ea6756e6..f536c87dee584baf2f929319e6c4ad47985440eb 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/CSharpVBResetCommand.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/CSharpVBResetCommand.cs @@ -64,7 +64,7 @@ public string CommandLine public Task Execute(IInteractiveWindow window, string arguments) { - if (!TryParseArguments(arguments, out bool initialize, out bool? is64bit)) + if (!TryParseArguments(arguments, out var initialize, out var is64bit)) { ReportInvalidArguments(window); return ExecutionResult.Failed; @@ -77,8 +77,8 @@ public Task Execute(IInteractiveWindow window, string arguments public IEnumerable ClassifyArguments(ITextSnapshot snapshot, Span argumentsSpan, Span spanToClassify) { - string arguments = snapshot.GetText(argumentsSpan); - int argumentsStart = argumentsSpan.Start; + var arguments = snapshot.GetText(argumentsSpan); + var argumentsStart = argumentsSpan.Start; foreach (var pos in GetNoConfigPositions(arguments)) { var snapshotSpan = new SnapshotSpan(snapshot, new Span(argumentsStart + pos, s_noConfigParameterNameLength)); @@ -90,10 +90,10 @@ public IEnumerable ClassifyArguments(ITextSnapshot snapshot, /// internal static IEnumerable GetNoConfigPositions(string arguments) { - int startIndex = 0; + var startIndex = 0; while (true) { - int index = arguments.IndexOf(NoConfigParameterName, startIndex, StringComparison.Ordinal); + var index = arguments.IndexOf(NoConfigParameterName, startIndex, StringComparison.Ordinal); if (index < 0) yield break; if ((index == 0 || char.IsWhiteSpace(arguments[index - 1])) && diff --git a/src/EditorFeatures/Core.Wpf/Interactive/InteractiveCommandHandler.cs b/src/EditorFeatures/Core.Wpf/Interactive/InteractiveCommandHandler.cs index 2a34fd873a8e18ab4b0a52b81ede5d9896c10938..7f8fce0d5ad3f0cc954e5965900bd65a8f7ea32a 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/InteractiveCommandHandler.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/InteractiveCommandHandler.cs @@ -61,7 +61,7 @@ bool VSCommanding.ICommandHandler.ExecuteComman var window = OpenInteractiveWindow(focus: false); using (context.OperationContext.AddScope(allowCancellation: true, InteractiveEditorFeaturesResources.Executing_selection_in_Interactive_Window)) { - string submission = GetSelectedText(args, context.OperationContext.UserCancellationToken); + var submission = GetSelectedText(args, context.OperationContext.UserCancellationToken); if (!String.IsNullOrWhiteSpace(submission)) { window.SubmitAsync(new string[] { submission }); diff --git a/src/EditorFeatures/Core.Wpf/Interactive/InteractiveGlobalUndoServiceFactory.cs b/src/EditorFeatures/Core.Wpf/Interactive/InteractiveGlobalUndoServiceFactory.cs index 3ebd2894f4f42e73bf188f46862e29ecb44bd364..f5ce640dbed892ce6aab8152e27c5dc531c2f373 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/InteractiveGlobalUndoServiceFactory.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/InteractiveGlobalUndoServiceFactory.cs @@ -53,7 +53,7 @@ public IWorkspaceGlobalUndoTransaction OpenGlobalUndoTransaction(Workspace works throw new ArgumentException(EditorFeaturesResources.Given_Workspace_doesn_t_support_Undo); } - ITextUndoHistory textUndoHistory = GetHistory(workspace); + var textUndoHistory = GetHistory(workspace); var transaction = textUndoHistory.CreateTransaction(description); diff --git a/src/EditorFeatures/Core.Wpf/Interactive/InteractivePasteCommandHandler.cs b/src/EditorFeatures/Core.Wpf/Interactive/InteractivePasteCommandHandler.cs index 82403110cfce9a36aafb184a16da40f4c8c99743..bf85474af024654544162a40f9db3f8d563d9d24 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/InteractivePasteCommandHandler.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/InteractivePasteCommandHandler.cs @@ -89,8 +89,8 @@ private void PasteInteractiveFormat(ITextView textView) var data = RoslynClipboard.GetDataObject(); Debug.Assert(data != null); - bool dataHasLineCutCopyTag = false; - bool dataHasBoxCutCopyTag = false; + var dataHasLineCutCopyTag = false; + var dataHasBoxCutCopyTag = false; dataHasLineCutCopyTag = data.GetDataPresent(ClipboardLineBasedCutCopyTag); dataHasBoxCutCopyTag = data.GetDataPresent(BoxSelectionCutCopyTag); @@ -140,9 +140,9 @@ private void PasteInteractiveFormat(ITextView textView) private static bool HasNonWhiteSpaceCharacter(ITextSnapshotLine line) { var snapshot = line.Snapshot; - int start = line.Start.Position; - int count = line.Length; - for (int i = 0; i < count; i++) + var start = line.Start.Position; + var count = line.Length; + for (var i = 0; i < count; i++) { if (!char.IsWhiteSpace(snapshot[start + i])) { diff --git a/src/EditorFeatures/Core.Wpf/Interactive/ReplCommandCompletionProvider.cs b/src/EditorFeatures/Core.Wpf/Interactive/ReplCommandCompletionProvider.cs index ed383c0d9e6d6c2352bde7fde86652b261020169..c41904f3a9de672b7c6dc3b095d929218f41dfee 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/ReplCommandCompletionProvider.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/ReplCommandCompletionProvider.cs @@ -23,7 +23,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context) // the provider might be invoked in non-interactive context: Workspace ws; - SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); + var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); if (Workspace.TryGetWorkspace(sourceText.Container, out ws)) { if (ws is InteractiveWorkspace workspace) @@ -33,14 +33,14 @@ public override async Task ProvideCompletionsAsync(CompletionContext context) if (await ShouldDisplayCommandCompletionsAsync(tree, position, cancellationToken).ConfigureAwait(false)) { - IInteractiveWindowCommands commands = window.GetInteractiveCommands(); + var commands = window.GetInteractiveCommands(); if (commands != null) { foreach (var command in commands.GetCommands()) { foreach (var commandName in command.Names) { - string completion = GetCompletionString(commandName); + var completion = GetCompletionString(commandName); context.AddItem(CommonCompletionItem.Create( completion, displayTextSuffix: "", CompletionItemRules.Default, description: command.Description.ToSymbolDisplayParts(), glyph: Glyph.Intrinsic)); } diff --git a/src/EditorFeatures/Core.Wpf/Interactive/ResetInteractive.cs b/src/EditorFeatures/Core.Wpf/Interactive/ResetInteractive.cs index 05e54fdd8456e2163440060a3b7c527e4a769322..76f6d6a58bef8baeca643d37277a675da4342a05 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/ResetInteractive.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/ResetInteractive.cs @@ -39,7 +39,7 @@ internal ResetInteractive(IEditorOptionsFactoryService editorOptionsFactoryServi internal Task Execute(IInteractiveWindow interactiveWindow, string title) { - if (GetProjectProperties(out var references, out var referenceSearchPaths, out var sourceSearchPaths, out var projectNamespaces, out var projectDirectory, out bool? is64Bit)) + if (GetProjectProperties(out var references, out var referenceSearchPaths, out var sourceSearchPaths, out var projectNamespaces, out var projectDirectory, out var is64Bit)) { // Now, we're going to do a bunch of async operations. So create a wait // indicator so the user knows something is happening, and also so they cancel. @@ -114,7 +114,7 @@ internal Task Execute(IInteractiveWindow interactiveWindow, string title) // Project's default namespace might be different from namespace used within project. // Filter out namespace imports that do not exist in interactive compilation. - IEnumerable namespacesToImport = await GetNamespacesToImportAsync(projectNamespaces, interactiveWindow).ConfigureAwait(true); + var namespacesToImport = await GetNamespacesToImportAsync(projectNamespaces, interactiveWindow).ConfigureAwait(true); var importNamespacesCommand = namespacesToImport.Select(_createImport).Join(editorOptions.GetNewLineCharacter()); if (!string.IsNullOrWhiteSpace(importNamespacesCommand)) diff --git a/src/EditorFeatures/Core.Wpf/Interactive/SendToInteractiveSubmissionProvider.cs b/src/EditorFeatures/Core.Wpf/Interactive/SendToInteractiveSubmissionProvider.cs index 1ff7b957e1b0499d4986391fcee1fb15813d0b5f..c7e61ee983995cc8bffa610038225c162c9f24da 100644 --- a/src/EditorFeatures/Core.Wpf/Interactive/SendToInteractiveSubmissionProvider.cs +++ b/src/EditorFeatures/Core.Wpf/Interactive/SendToInteractiveSubmissionProvider.cs @@ -32,7 +32,7 @@ internal abstract class AbstractSendToInteractiveSubmissionProvider : ISendToInt string ISendToInteractiveSubmissionProvider.GetSelectedText(IEditorOptions editorOptions, EditorCommandArgs args, CancellationToken cancellationToken) { - IEnumerable selectedSpans = args.TextView.Selection.IsEmpty + var selectedSpans = args.TextView.Selection.IsEmpty ? GetExpandedLineAsync(editorOptions, args, cancellationToken).WaitAndGetResult(cancellationToken) : args.TextView.Selection.GetSnapshotSpansOnBuffer(args.SubjectBuffer).Where(ss => ss.Length > 0); @@ -42,7 +42,7 @@ string ISendToInteractiveSubmissionProvider.GetSelectedText(IEditorOptions edito /// Returns the span for the selected line. Extends it if it is a part of a multi line statement or declaration. private Task> GetExpandedLineAsync(IEditorOptions editorOptions, EditorCommandArgs args, CancellationToken cancellationToken) { - IEnumerable selectedSpans = GetSelectedLine(args.TextView); + var selectedSpans = GetSelectedLine(args.TextView); var candidateSubmission = GetSubmissionFromSelectedSpans(editorOptions, selectedSpans); return CanParseSubmission(candidateSubmission) ? Task.FromResult(selectedSpans) @@ -52,8 +52,8 @@ private Task> GetExpandedLineAsync(IEditorOptions edit /// Returns the span for the currently selected line. private static IEnumerable GetSelectedLine(ITextView textView) { - ITextSnapshotLine snapshotLine = textView.Caret.Position.VirtualBufferPosition.Position.GetContainingLine(); - SnapshotSpan span = new SnapshotSpan(snapshotLine.Start, snapshotLine.LengthIncludingLineBreak); + var snapshotLine = textView.Caret.Position.VirtualBufferPosition.Position.GetContainingLine(); + var span = new SnapshotSpan(snapshotLine.Start, snapshotLine.LengthIncludingLineBreak); return new NormalizedSnapshotSpanCollection(span); } @@ -63,7 +63,7 @@ private static IEnumerable GetSelectedLine(ITextView textView) ITextSnapshot snapshot, CancellationToken cancellationToken) { - Document doc = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); + var doc = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); var semanticDocument = await SemanticDocument.CreateAsync(doc, cancellationToken).ConfigureAwait(false); var root = semanticDocument.Root; @@ -75,9 +75,9 @@ private async Task> ExpandSelectionAsync(IEnumerable span.Start); var selectedSpansEnd = selectedSpans.Max(span => span.End); - ITextSnapshot snapshot = args.TextView.TextSnapshot; + var snapshot = args.TextView.TextSnapshot; - IEnumerable newSpans = await GetExecutableSyntaxTreeNodeSelectionAsync( + var newSpans = await GetExecutableSyntaxTreeNodeSelectionAsync( TextSpan.FromBounds(selectedSpansStart, selectedSpansEnd), args, snapshot, diff --git a/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs b/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs index f5778e412d66bce5a467b2a277f8098ffcfa542d..ec284bef62be6637e615d41531d96ed3509e7e4f 100644 --- a/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs +++ b/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs @@ -92,7 +92,7 @@ public StringConvertingDictionary(IReadOnlyDictionary underlying public bool TryGetValue(string key, out string value) { - if (_underlyingDictionary.TryGetValue(key, out object objectValue)) + if (_underlyingDictionary.TryGetValue(key, out var objectValue)) { value = objectValue?.ToString(); return true; diff --git a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActions/SuggestedAction.cs b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActions/SuggestedAction.cs index f293990d1cc0bd0f7e925d72d0ecb976838d5057..406fb3c9e01bfc1ccdd150d3c1e1e26714946965 100644 --- a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActions/SuggestedAction.cs +++ b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActions/SuggestedAction.cs @@ -180,7 +180,7 @@ private void CreateLogProperties(Dictionary map) map[FixAllLogger.FixAllScope] = fixSome.FixAllState.Scope.ToString(); } - if (TryGetTelemetryId(out Guid telemetryId)) + if (TryGetTelemetryId(out var telemetryId)) { // Lightbulb correlation info map["TelemetryId"] = telemetryId.ToString(); diff --git a/src/EditorFeatures/Core.Wpf/SymbolSearch/Patching/Delta.cs b/src/EditorFeatures/Core.Wpf/SymbolSearch/Patching/Delta.cs index 1ca0bfa7d90d128aa5c4a9753a092b9f88117e0b..d73c99a678563beb24120e4e7478472a908fb687 100644 --- a/src/EditorFeatures/Core.Wpf/SymbolSearch/Patching/Delta.cs +++ b/src/EditorFeatures/Core.Wpf/SymbolSearch/Patching/Delta.cs @@ -65,8 +65,8 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes) fixed (byte* pSourceBuf = sourceBytes) fixed (byte* pPatchBuf = patchBytes) { - DeltaInput ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true); - DeltaInput dp = new DeltaInput(pPatchBuf, patchBytes.Length, true); + var ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true); + var dp = new DeltaInput(pPatchBuf, patchBytes.Length, true); if (!ApplyDeltaB(DeltaApplyFlag.None, ds, dp, @@ -75,7 +75,7 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes) throw new Win32Exception(); } - byte[] targetBytes = new byte[output.cbBuf.ToInt32()]; + var targetBytes = new byte[output.cbBuf.ToInt32()]; Marshal.Copy(output.pBuf, targetBytes, 0, targetBytes.Length); DeltaFree(output.pBuf); return targetBytes;