提交 955d08a2 编写于 作者: C Cyrus Najmabadi

Use var

上级 7f421eeb
...@@ -23,7 +23,7 @@ public VSCommanding.CommandState GetCommandState(TabKeyCommandArgs args, Func<VS ...@@ -23,7 +23,7 @@ public VSCommanding.CommandState GetCommandState(TabKeyCommandArgs args, Func<VS
public void ExecuteCommand(TabKeyCommandArgs args, Action nextHandler, CommandExecutionContext context) public void ExecuteCommand(TabKeyCommandArgs args, Action nextHandler, CommandExecutionContext context)
{ {
// If the Dashboard is focused, just navigate through its UI. // If the Dashboard is focused, just navigate through its UI.
Dashboard dashboard = GetDashboard(args.TextView); var dashboard = GetDashboard(args.TextView);
if (dashboard != null && dashboard.ShouldReceiveKeyboardNavigation) if (dashboard != null && dashboard.ShouldReceiveKeyboardNavigation)
{ {
dashboard.FocusNextElement(); dashboard.FocusNextElement();
...@@ -36,11 +36,11 @@ public void ExecuteCommand(TabKeyCommandArgs args, Action nextHandler, CommandEx ...@@ -36,11 +36,11 @@ public void ExecuteCommand(TabKeyCommandArgs args, Action nextHandler, CommandEx
_renameService.ActiveSession.GetBufferManager(args.SubjectBuffer) _renameService.ActiveSession.GetBufferManager(args.SubjectBuffer)
.GetEditableSpansForSnapshot(args.SubjectBuffer.CurrentSnapshot)); .GetEditableSpansForSnapshot(args.SubjectBuffer.CurrentSnapshot));
for (int i = 0; i < spans.Count; i++) for (var i = 0; i < spans.Count; i++)
{ {
if (span == spans[i]) if (span == spans[i])
{ {
int selectNext = i < spans.Count - 1 ? i + 1 : 0; var selectNext = i < spans.Count - 1 ? i + 1 : 0;
var newSelection = spans[selectNext]; var newSelection = spans[selectNext];
args.TextView.TryMoveCaretToAndEnsureVisible(newSelection.Start); args.TextView.TryMoveCaretToAndEnsureVisible(newSelection.Start);
args.TextView.SetSelection(newSelection); args.TextView.SetSelection(newSelection);
......
...@@ -24,7 +24,7 @@ public bool ExecuteCommand(UndoCommandArgs args, CommandExecutionContext context ...@@ -24,7 +24,7 @@ public bool ExecuteCommand(UndoCommandArgs args, CommandExecutionContext context
{ {
if (_renameService.ActiveSession != null) if (_renameService.ActiveSession != null)
{ {
for (int i = 0; i < args.Count && _renameService.ActiveSession != null; i++) for (var i = 0; i < args.Count && _renameService.ActiveSession != null; i++)
{ {
_renameService.ActiveSession.UndoManager.Undo(args.SubjectBuffer); _renameService.ActiveSession.UndoManager.Undo(args.SubjectBuffer);
} }
...@@ -39,7 +39,7 @@ public bool ExecuteCommand(RedoCommandArgs args, CommandExecutionContext context ...@@ -39,7 +39,7 @@ public bool ExecuteCommand(RedoCommandArgs args, CommandExecutionContext context
{ {
if (_renameService.ActiveSession != null) if (_renameService.ActiveSession != null)
{ {
for (int i = 0; i < args.Count && _renameService.ActiveSession != null; i++) for (var i = 0; i < args.Count && _renameService.ActiveSession != null; i++)
{ {
_renameService.ActiveSession.UndoManager.Redo(args.SubjectBuffer); _renameService.ActiveSession.UndoManager.Redo(args.SubjectBuffer);
} }
......
...@@ -185,7 +185,7 @@ private void ConnectToPresentationSource(PresentationSource presentationSource) ...@@ -185,7 +185,7 @@ private void ConnectToPresentationSource(PresentationSource presentationSource)
if (_rootDependencyObject != null && _rootInputElement != null) if (_rootDependencyObject != null && _rootInputElement != null)
{ {
foreach (string accessKey in _renameAccessKeys) foreach (var accessKey in _renameAccessKeys)
{ {
AccessKeyManager.Register(accessKey, _rootInputElement); AccessKeyManager.Register(accessKey, _rootInputElement);
} }
...@@ -196,7 +196,7 @@ private void ConnectToPresentationSource(PresentationSource presentationSource) ...@@ -196,7 +196,7 @@ private void ConnectToPresentationSource(PresentationSource presentationSource)
private void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs args) private void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs args)
{ {
foreach (string accessKey in _renameAccessKeys) foreach (var accessKey in _renameAccessKeys)
{ {
if (string.Compare(accessKey, args.Key, StringComparison.OrdinalIgnoreCase) == 0) if (string.Compare(accessKey, args.Key, StringComparison.OrdinalIgnoreCase) == 0)
{ {
...@@ -243,7 +243,7 @@ private void DisconnectFromPresentationSource() ...@@ -243,7 +243,7 @@ private void DisconnectFromPresentationSource()
{ {
if (_rootInputElement != null) if (_rootInputElement != null)
{ {
foreach (string registeredKey in _renameAccessKeys) foreach (var registeredKey in _renameAccessKeys)
{ {
AccessKeyManager.Unregister(registeredKey, _rootInputElement); AccessKeyManager.Unregister(registeredKey, _rootInputElement);
} }
......
...@@ -52,8 +52,8 @@ public DashboardViewModel(InlineRenameSession session) ...@@ -52,8 +52,8 @@ public DashboardViewModel(InlineRenameSession session)
private void OnReferenceLocationsChanged(object sender, ImmutableArray<InlineRenameLocation> renameLocations) private void OnReferenceLocationsChanged(object sender, ImmutableArray<InlineRenameLocation> renameLocations)
{ {
int totalFilesCount = renameLocations.GroupBy(s => s.Document).Count(); var totalFilesCount = renameLocations.GroupBy(s => s.Document).Count();
int totalSpansCount = renameLocations.Length; var totalSpansCount = renameLocations.Length;
UpdateSearchText(totalSpansCount, totalFilesCount); UpdateSearchText(totalSpansCount, totalFilesCount);
} }
......
...@@ -27,7 +27,7 @@ static RenameShortcutKey() ...@@ -27,7 +27,7 @@ static RenameShortcutKey()
/// </summary> /// </summary>
private static string ExtractAccessKey(string localizedLabel, string defaultValue) private static string ExtractAccessKey(string localizedLabel, string defaultValue)
{ {
int underscoreIndex = localizedLabel.IndexOf('_'); var underscoreIndex = localizedLabel.IndexOf('_');
if (underscoreIndex >= 0 && underscoreIndex < localizedLabel.Length - 1) if (underscoreIndex >= 0 && underscoreIndex < localizedLabel.Length - 1)
{ {
......
...@@ -541,7 +541,7 @@ internal void ApplyConflictResolutionEdits(IInlineRenameReplacementInfo conflict ...@@ -541,7 +541,7 @@ internal void ApplyConflictResolutionEdits(IInlineRenameReplacementInfo conflict
private static string GetWithoutAttributeSuffix(string text, bool isCaseSensitive) private static string GetWithoutAttributeSuffix(string text, bool isCaseSensitive)
{ {
if (!text.TryGetWithoutAttributeSuffix(isCaseSensitive, out string replaceText)) if (!text.TryGetWithoutAttributeSuffix(isCaseSensitive, out var replaceText))
{ {
replaceText = text; replaceText = text;
} }
...@@ -566,8 +566,8 @@ private static async Task<IEnumerable<TextChange>> GetTextChangesFromTextDiffere ...@@ -566,8 +566,8 @@ private static async Task<IEnumerable<TextChange>> GetTextChangesFromTextDiffere
throw new ArgumentException(WorkspacesResources.The_specified_document_is_not_a_version_of_this_document); throw new ArgumentException(WorkspacesResources.The_specified_document_is_not_a_version_of_this_document);
} }
SourceText oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
SourceText newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
if (oldText == newText) if (oldText == newText)
{ {
......
...@@ -183,7 +183,7 @@ private void InitializeOpenBuffers(SnapshotSpan triggerSpan) ...@@ -183,7 +183,7 @@ private void InitializeOpenBuffers(SnapshotSpan triggerSpan)
{ {
using (Logger.LogBlock(FunctionId.Rename_CreateOpenTextBufferManagerForAllOpenDocs, CancellationToken.None)) using (Logger.LogBlock(FunctionId.Rename_CreateOpenTextBufferManagerForAllOpenDocs, CancellationToken.None))
{ {
HashSet<ITextBuffer> openBuffers = new HashSet<ITextBuffer>(); var openBuffers = new HashSet<ITextBuffer>();
foreach (var d in _workspace.GetOpenDocumentIds()) foreach (var d in _workspace.GetOpenDocumentIds())
{ {
var document = _baseSolution.GetDocument(d); var document = _baseSolution.GetDocument(d);
...@@ -669,7 +669,7 @@ private void CommitCore(IWaitContext waitContext, bool previewChanges) ...@@ -669,7 +669,7 @@ private void CommitCore(IWaitContext waitContext, bool previewChanges)
_conflictResolutionTask.Wait(waitContext.CancellationToken); _conflictResolutionTask.Wait(waitContext.CancellationToken);
waitContext.AllowCancel = false; waitContext.AllowCancel = false;
Solution newSolution = _conflictResolutionTask.Result.NewSolution; var newSolution = _conflictResolutionTask.Result.NewSolution;
if (previewChanges) if (previewChanges)
{ {
var previewService = _workspace.Services.GetService<IPreviewDialogService>(); var previewService = _workspace.Services.GetService<IPreviewDialogService>();
......
...@@ -64,7 +64,7 @@ public string CommandLine ...@@ -64,7 +64,7 @@ public string CommandLine
public Task<ExecutionResult> Execute(IInteractiveWindow window, string arguments) public Task<ExecutionResult> 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); ReportInvalidArguments(window);
return ExecutionResult.Failed; return ExecutionResult.Failed;
...@@ -77,8 +77,8 @@ public Task<ExecutionResult> Execute(IInteractiveWindow window, string arguments ...@@ -77,8 +77,8 @@ public Task<ExecutionResult> Execute(IInteractiveWindow window, string arguments
public IEnumerable<ClassificationSpan> ClassifyArguments(ITextSnapshot snapshot, Span argumentsSpan, Span spanToClassify) public IEnumerable<ClassificationSpan> ClassifyArguments(ITextSnapshot snapshot, Span argumentsSpan, Span spanToClassify)
{ {
string arguments = snapshot.GetText(argumentsSpan); var arguments = snapshot.GetText(argumentsSpan);
int argumentsStart = argumentsSpan.Start; var argumentsStart = argumentsSpan.Start;
foreach (var pos in GetNoConfigPositions(arguments)) foreach (var pos in GetNoConfigPositions(arguments))
{ {
var snapshotSpan = new SnapshotSpan(snapshot, new Span(argumentsStart + pos, s_noConfigParameterNameLength)); var snapshotSpan = new SnapshotSpan(snapshot, new Span(argumentsStart + pos, s_noConfigParameterNameLength));
...@@ -90,10 +90,10 @@ public IEnumerable<ClassificationSpan> ClassifyArguments(ITextSnapshot snapshot, ...@@ -90,10 +90,10 @@ public IEnumerable<ClassificationSpan> ClassifyArguments(ITextSnapshot snapshot,
/// </remarks> /// </remarks>
internal static IEnumerable<int> GetNoConfigPositions(string arguments) internal static IEnumerable<int> GetNoConfigPositions(string arguments)
{ {
int startIndex = 0; var startIndex = 0;
while (true) 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) yield break;
if ((index == 0 || char.IsWhiteSpace(arguments[index - 1])) && if ((index == 0 || char.IsWhiteSpace(arguments[index - 1])) &&
......
...@@ -61,7 +61,7 @@ bool VSCommanding.ICommandHandler<ExecuteInInteractiveCommandArgs>.ExecuteComman ...@@ -61,7 +61,7 @@ bool VSCommanding.ICommandHandler<ExecuteInInteractiveCommandArgs>.ExecuteComman
var window = OpenInteractiveWindow(focus: false); var window = OpenInteractiveWindow(focus: false);
using (context.OperationContext.AddScope(allowCancellation: true, InteractiveEditorFeaturesResources.Executing_selection_in_Interactive_Window)) 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)) if (!String.IsNullOrWhiteSpace(submission))
{ {
window.SubmitAsync(new string[] { submission }); window.SubmitAsync(new string[] { submission });
......
...@@ -53,7 +53,7 @@ public IWorkspaceGlobalUndoTransaction OpenGlobalUndoTransaction(Workspace works ...@@ -53,7 +53,7 @@ public IWorkspaceGlobalUndoTransaction OpenGlobalUndoTransaction(Workspace works
throw new ArgumentException(EditorFeaturesResources.Given_Workspace_doesn_t_support_Undo); throw new ArgumentException(EditorFeaturesResources.Given_Workspace_doesn_t_support_Undo);
} }
ITextUndoHistory textUndoHistory = GetHistory(workspace); var textUndoHistory = GetHistory(workspace);
var transaction = textUndoHistory.CreateTransaction(description); var transaction = textUndoHistory.CreateTransaction(description);
......
...@@ -89,8 +89,8 @@ private void PasteInteractiveFormat(ITextView textView) ...@@ -89,8 +89,8 @@ private void PasteInteractiveFormat(ITextView textView)
var data = RoslynClipboard.GetDataObject(); var data = RoslynClipboard.GetDataObject();
Debug.Assert(data != null); Debug.Assert(data != null);
bool dataHasLineCutCopyTag = false; var dataHasLineCutCopyTag = false;
bool dataHasBoxCutCopyTag = false; var dataHasBoxCutCopyTag = false;
dataHasLineCutCopyTag = data.GetDataPresent(ClipboardLineBasedCutCopyTag); dataHasLineCutCopyTag = data.GetDataPresent(ClipboardLineBasedCutCopyTag);
dataHasBoxCutCopyTag = data.GetDataPresent(BoxSelectionCutCopyTag); dataHasBoxCutCopyTag = data.GetDataPresent(BoxSelectionCutCopyTag);
...@@ -140,9 +140,9 @@ private void PasteInteractiveFormat(ITextView textView) ...@@ -140,9 +140,9 @@ private void PasteInteractiveFormat(ITextView textView)
private static bool HasNonWhiteSpaceCharacter(ITextSnapshotLine line) private static bool HasNonWhiteSpaceCharacter(ITextSnapshotLine line)
{ {
var snapshot = line.Snapshot; var snapshot = line.Snapshot;
int start = line.Start.Position; var start = line.Start.Position;
int count = line.Length; var count = line.Length;
for (int i = 0; i < count; i++) for (var i = 0; i < count; i++)
{ {
if (!char.IsWhiteSpace(snapshot[start + i])) if (!char.IsWhiteSpace(snapshot[start + i]))
{ {
......
...@@ -23,7 +23,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context) ...@@ -23,7 +23,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
// the provider might be invoked in non-interactive context: // the provider might be invoked in non-interactive context:
Workspace ws; 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 (Workspace.TryGetWorkspace(sourceText.Container, out ws))
{ {
if (ws is InteractiveWorkspace workspace) if (ws is InteractiveWorkspace workspace)
...@@ -33,14 +33,14 @@ public override async Task ProvideCompletionsAsync(CompletionContext context) ...@@ -33,14 +33,14 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
if (await ShouldDisplayCommandCompletionsAsync(tree, position, cancellationToken).ConfigureAwait(false)) if (await ShouldDisplayCommandCompletionsAsync(tree, position, cancellationToken).ConfigureAwait(false))
{ {
IInteractiveWindowCommands commands = window.GetInteractiveCommands(); var commands = window.GetInteractiveCommands();
if (commands != null) if (commands != null)
{ {
foreach (var command in commands.GetCommands()) foreach (var command in commands.GetCommands())
{ {
foreach (var commandName in command.Names) foreach (var commandName in command.Names)
{ {
string completion = GetCompletionString(commandName); var completion = GetCompletionString(commandName);
context.AddItem(CommonCompletionItem.Create( context.AddItem(CommonCompletionItem.Create(
completion, displayTextSuffix: "", CompletionItemRules.Default, description: command.Description.ToSymbolDisplayParts(), glyph: Glyph.Intrinsic)); completion, displayTextSuffix: "", CompletionItemRules.Default, description: command.Description.ToSymbolDisplayParts(), glyph: Glyph.Intrinsic));
} }
......
...@@ -39,7 +39,7 @@ internal ResetInteractive(IEditorOptionsFactoryService editorOptionsFactoryServi ...@@ -39,7 +39,7 @@ internal ResetInteractive(IEditorOptionsFactoryService editorOptionsFactoryServi
internal Task Execute(IInteractiveWindow interactiveWindow, string title) 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 // 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. // indicator so the user knows something is happening, and also so they cancel.
...@@ -114,7 +114,7 @@ internal Task Execute(IInteractiveWindow interactiveWindow, string title) ...@@ -114,7 +114,7 @@ internal Task Execute(IInteractiveWindow interactiveWindow, string title)
// Project's default namespace might be different from namespace used within project. // Project's default namespace might be different from namespace used within project.
// Filter out namespace imports that do not exist in interactive compilation. // Filter out namespace imports that do not exist in interactive compilation.
IEnumerable<string> namespacesToImport = await GetNamespacesToImportAsync(projectNamespaces, interactiveWindow).ConfigureAwait(true); var namespacesToImport = await GetNamespacesToImportAsync(projectNamespaces, interactiveWindow).ConfigureAwait(true);
var importNamespacesCommand = namespacesToImport.Select(_createImport).Join(editorOptions.GetNewLineCharacter()); var importNamespacesCommand = namespacesToImport.Select(_createImport).Join(editorOptions.GetNewLineCharacter());
if (!string.IsNullOrWhiteSpace(importNamespacesCommand)) if (!string.IsNullOrWhiteSpace(importNamespacesCommand))
......
...@@ -32,7 +32,7 @@ internal abstract class AbstractSendToInteractiveSubmissionProvider : ISendToInt ...@@ -32,7 +32,7 @@ internal abstract class AbstractSendToInteractiveSubmissionProvider : ISendToInt
string ISendToInteractiveSubmissionProvider.GetSelectedText(IEditorOptions editorOptions, EditorCommandArgs args, CancellationToken cancellationToken) string ISendToInteractiveSubmissionProvider.GetSelectedText(IEditorOptions editorOptions, EditorCommandArgs args, CancellationToken cancellationToken)
{ {
IEnumerable<SnapshotSpan> selectedSpans = args.TextView.Selection.IsEmpty var selectedSpans = args.TextView.Selection.IsEmpty
? GetExpandedLineAsync(editorOptions, args, cancellationToken).WaitAndGetResult(cancellationToken) ? GetExpandedLineAsync(editorOptions, args, cancellationToken).WaitAndGetResult(cancellationToken)
: args.TextView.Selection.GetSnapshotSpansOnBuffer(args.SubjectBuffer).Where(ss => ss.Length > 0); : args.TextView.Selection.GetSnapshotSpansOnBuffer(args.SubjectBuffer).Where(ss => ss.Length > 0);
...@@ -42,7 +42,7 @@ string ISendToInteractiveSubmissionProvider.GetSelectedText(IEditorOptions edito ...@@ -42,7 +42,7 @@ string ISendToInteractiveSubmissionProvider.GetSelectedText(IEditorOptions edito
/// <summary>Returns the span for the selected line. Extends it if it is a part of a multi line statement or declaration.</summary> /// <summary>Returns the span for the selected line. Extends it if it is a part of a multi line statement or declaration.</summary>
private Task<IEnumerable<SnapshotSpan>> GetExpandedLineAsync(IEditorOptions editorOptions, EditorCommandArgs args, CancellationToken cancellationToken) private Task<IEnumerable<SnapshotSpan>> GetExpandedLineAsync(IEditorOptions editorOptions, EditorCommandArgs args, CancellationToken cancellationToken)
{ {
IEnumerable<SnapshotSpan> selectedSpans = GetSelectedLine(args.TextView); var selectedSpans = GetSelectedLine(args.TextView);
var candidateSubmission = GetSubmissionFromSelectedSpans(editorOptions, selectedSpans); var candidateSubmission = GetSubmissionFromSelectedSpans(editorOptions, selectedSpans);
return CanParseSubmission(candidateSubmission) return CanParseSubmission(candidateSubmission)
? Task.FromResult(selectedSpans) ? Task.FromResult(selectedSpans)
...@@ -52,8 +52,8 @@ private Task<IEnumerable<SnapshotSpan>> GetExpandedLineAsync(IEditorOptions edit ...@@ -52,8 +52,8 @@ private Task<IEnumerable<SnapshotSpan>> GetExpandedLineAsync(IEditorOptions edit
/// <summary>Returns the span for the currently selected line.</summary> /// <summary>Returns the span for the currently selected line.</summary>
private static IEnumerable<SnapshotSpan> GetSelectedLine(ITextView textView) private static IEnumerable<SnapshotSpan> GetSelectedLine(ITextView textView)
{ {
ITextSnapshotLine snapshotLine = textView.Caret.Position.VirtualBufferPosition.Position.GetContainingLine(); var snapshotLine = textView.Caret.Position.VirtualBufferPosition.Position.GetContainingLine();
SnapshotSpan span = new SnapshotSpan(snapshotLine.Start, snapshotLine.LengthIncludingLineBreak); var span = new SnapshotSpan(snapshotLine.Start, snapshotLine.LengthIncludingLineBreak);
return new NormalizedSnapshotSpanCollection(span); return new NormalizedSnapshotSpanCollection(span);
} }
...@@ -63,7 +63,7 @@ private static IEnumerable<SnapshotSpan> GetSelectedLine(ITextView textView) ...@@ -63,7 +63,7 @@ private static IEnumerable<SnapshotSpan> GetSelectedLine(ITextView textView)
ITextSnapshot snapshot, ITextSnapshot snapshot,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
Document doc = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); var doc = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
var semanticDocument = await SemanticDocument.CreateAsync(doc, cancellationToken).ConfigureAwait(false); var semanticDocument = await SemanticDocument.CreateAsync(doc, cancellationToken).ConfigureAwait(false);
var root = semanticDocument.Root; var root = semanticDocument.Root;
...@@ -75,9 +75,9 @@ private async Task<IEnumerable<SnapshotSpan>> ExpandSelectionAsync(IEnumerable<S ...@@ -75,9 +75,9 @@ private async Task<IEnumerable<SnapshotSpan>> ExpandSelectionAsync(IEnumerable<S
{ {
var selectedSpansStart = selectedSpans.Min(span => span.Start); var selectedSpansStart = selectedSpans.Min(span => span.Start);
var selectedSpansEnd = selectedSpans.Max(span => span.End); var selectedSpansEnd = selectedSpans.Max(span => span.End);
ITextSnapshot snapshot = args.TextView.TextSnapshot; var snapshot = args.TextView.TextSnapshot;
IEnumerable<SnapshotSpan> newSpans = await GetExecutableSyntaxTreeNodeSelectionAsync( var newSpans = await GetExecutableSyntaxTreeNodeSelectionAsync(
TextSpan.FromBounds(selectedSpansStart, selectedSpansEnd), TextSpan.FromBounds(selectedSpansStart, selectedSpansEnd),
args, args,
snapshot, snapshot,
......
...@@ -92,7 +92,7 @@ public StringConvertingDictionary(IReadOnlyDictionary<string, object> underlying ...@@ -92,7 +92,7 @@ public StringConvertingDictionary(IReadOnlyDictionary<string, object> underlying
public bool TryGetValue(string key, out string value) 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(); value = objectValue?.ToString();
return true; return true;
......
...@@ -180,7 +180,7 @@ private void CreateLogProperties(Dictionary<string, object> map) ...@@ -180,7 +180,7 @@ private void CreateLogProperties(Dictionary<string, object> map)
map[FixAllLogger.FixAllScope] = fixSome.FixAllState.Scope.ToString(); map[FixAllLogger.FixAllScope] = fixSome.FixAllState.Scope.ToString();
} }
if (TryGetTelemetryId(out Guid telemetryId)) if (TryGetTelemetryId(out var telemetryId))
{ {
// Lightbulb correlation info // Lightbulb correlation info
map["TelemetryId"] = telemetryId.ToString(); map["TelemetryId"] = telemetryId.ToString();
......
...@@ -65,8 +65,8 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes) ...@@ -65,8 +65,8 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes)
fixed (byte* pSourceBuf = sourceBytes) fixed (byte* pSourceBuf = sourceBytes)
fixed (byte* pPatchBuf = patchBytes) fixed (byte* pPatchBuf = patchBytes)
{ {
DeltaInput ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true); var ds = new DeltaInput(pSourceBuf, sourceBytes.Length, true);
DeltaInput dp = new DeltaInput(pPatchBuf, patchBytes.Length, true); var dp = new DeltaInput(pPatchBuf, patchBytes.Length, true);
if (!ApplyDeltaB(DeltaApplyFlag.None, if (!ApplyDeltaB(DeltaApplyFlag.None,
ds, ds,
dp, dp,
...@@ -75,7 +75,7 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes) ...@@ -75,7 +75,7 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes)
throw new Win32Exception(); 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); Marshal.Copy(output.pBuf, targetBytes, 0, targetBytes.Length);
DeltaFree(output.pBuf); DeltaFree(output.pBuf);
return targetBytes; return targetBytes;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册