diff --git a/src/Features/Core/Portable/DocumentSpan.cs b/src/Features/Core/Portable/DocumentSpan.cs index 83572635d15a21db2bc10b05d29c45d821c82664..66600136dd59f2804d18b37544586adf970757f3 100644 --- a/src/Features/Core/Portable/DocumentSpan.cs +++ b/src/Features/Core/Portable/DocumentSpan.cs @@ -22,31 +22,21 @@ public DocumentSpan(Document document, TextSpan sourceSpan) } public override bool Equals(object obj) - { - return Equals((DocumentSpan)obj); - } + => Equals((DocumentSpan)obj); public bool Equals(DocumentSpan obj) - { - return this.Document == obj.Document && this.SourceSpan == obj.SourceSpan; - } + => this.Document == obj.Document && this.SourceSpan == obj.SourceSpan; public static bool operator ==(DocumentSpan d1, DocumentSpan d2) - { - return d1.Equals(d2); - } + => d1.Equals(d2); public static bool operator !=(DocumentSpan d1, DocumentSpan d2) - { - return !(d1 == d2); - } + => !(d1 == d2); public override int GetHashCode() - { - return Hash.Combine( + => Hash.Combine( this.Document, this.SourceSpan.GetHashCode()); - } public bool CanNavigateTo() { @@ -57,9 +47,11 @@ public bool CanNavigateTo() public bool TryNavigateTo() { - var workspace = Document.Project.Solution.Workspace; + var solution = Document.Project.Solution; + var workspace = solution.Workspace; var service = workspace.Services.GetService(); - return service.TryNavigateToPosition(workspace, Document.Id, SourceSpan.Start); + return service.TryNavigateToPosition(workspace, Document.Id, SourceSpan.Start, + options: solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, true)); } } } \ No newline at end of file diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs index 876bd3ed5bfcb99ff29da2836fbe7d51e590c73e..c603847f4e3edfe17325ec1f2e064acfec89e3a7 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.FindUsages diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.SymbolDefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.SymbolDefinitionItem.cs index 48911343ffff2b4fc6cb3c807ec4523674866029..be317fbdad653b052fa11d340d2a7e789d1a8097 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.SymbolDefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.SymbolDefinitionItem.cs @@ -43,14 +43,13 @@ private sealed class MetadataDefinitionItem : DefinitionItem } public override bool CanNavigateTo() - { - return TryNavigateTo((symbol, project, service) => true); - } + => TryNavigateTo((symbol, project, service) => true); public override bool TryNavigateTo() { return TryNavigateTo((symbol, project, service) => - service.TryNavigateToSymbol(symbol, project)); + service.TryNavigateToSymbol( + symbol, project, project.Solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, true))); } private bool TryNavigateTo(Func action) @@ -61,8 +60,8 @@ private bool TryNavigateTo(Func? ResolveSymbolInCurrentSolution() + private (Project project, ISymbol symbol)? ResolveSymbolInCurrentSolution() { var project = _workspace.CurrentSolution .ProjectsWithReferenceToAssembly(_symbolAssemblyIdentity) @@ -90,7 +89,7 @@ private bool TryNavigateTo(Func(); - string filePath; - int lineNumber, charOffset; - if (!symbolNavigationService.WouldNavigateToSymbol(definition, solution, out filePath, out lineNumber, out charOffset)) + if (!symbolNavigationService.WouldNavigateToSymbol(definition, solution, out var filePath, out var lineNumber, out var charOffset)) { return null; } @@ -64,12 +63,9 @@ private string GetSourceLine(string filePath, int lineNumber) _serviceProvider, filePath, needsSave: false, needsUndoDisabled: false)) { var vsTextLines = invisibleEditor.VsTextLines; - int lineLength; - string lineText; - if (vsTextLines != null && - vsTextLines.GetLengthOfLine(lineNumber, out lineLength) == VSConstants.S_OK && - vsTextLines.GetLineText(lineNumber, 0, lineNumber, lineLength, out lineText) == VSConstants.S_OK) + vsTextLines.GetLengthOfLine(lineNumber, out var lineLength) == VSConstants.S_OK && + vsTextLines.GetLineText(lineNumber, 0, lineNumber, lineLength, out var lineText) == VSConstants.S_OK) { return lineText; } @@ -113,13 +109,9 @@ private bool TryOpenFile() { var shellOpenDocument = (IVsUIShellOpenDocument)_serviceProvider.GetService(typeof(SVsUIShellOpenDocument)); var textViewGuid = VSConstants.LOGVIEWID.TextView_guid; - - uint itemid; - IVsUIHierarchy hierarchy; - OLEServiceProvider oleServiceProvider; - IVsWindowFrame frame; if (shellOpenDocument.OpenDocumentViaProject( - _filePath, ref textViewGuid, out oleServiceProvider, out hierarchy, out itemid, out frame) == VSConstants.S_OK) + _filePath, ref textViewGuid, out var oleServiceProvider, + out var hierarchy, out var itemid, out var frame) == VSConstants.S_OK) { frame.Show(); return true; @@ -131,13 +123,8 @@ private bool TryOpenFile() private bool TryNavigateToPosition() { IVsRunningDocumentTable docTable = (IVsRunningDocumentTable)_serviceProvider.GetService(typeof(SVsRunningDocumentTable)); - - IntPtr bufferPtr; - IVsHierarchy hierarchy; - uint cookie; - uint itemid; - - if (docTable.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, _filePath, out hierarchy, out itemid, out bufferPtr, out cookie) != VSConstants.S_OK) + if (docTable.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, _filePath, + out var hierarchy, out var itemid, out var bufferPtr, out var cookie) != VSConstants.S_OK) { return false; }