From 5715e12a11f7cfd32a76af472e764753fda09b2d Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Mon, 9 Feb 2015 14:12:52 -0800 Subject: [PATCH 1/6] I'm just testing GitHub by adding a simple text file. (And I amended it after the fact) --- src/HelloGitHub.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/HelloGitHub.txt diff --git a/src/HelloGitHub.txt b/src/HelloGitHub.txt new file mode 100644 index 0000000000000..10b73d11b2ea2 --- /dev/null +++ b/src/HelloGitHub.txt @@ -0,0 +1 @@ +Hello, GitHub! \ No newline at end of file From 41971956795725fa29fd9a1c9d0fb00d5553dd7e Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Mon, 9 Feb 2015 14:42:31 -0800 Subject: [PATCH 2/6] Deleting the previous add. --- src/HelloGitHub.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/HelloGitHub.txt diff --git a/src/HelloGitHub.txt b/src/HelloGitHub.txt deleted file mode 100644 index 10b73d11b2ea2..0000000000000 --- a/src/HelloGitHub.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, GitHub! \ No newline at end of file From c9223ab1b4d94bff671a65f070eab9b0349e5feb Mon Sep 17 00:00:00 2001 From: Brett Forsgren Date: Mon, 9 Feb 2015 13:45:51 -0800 Subject: [PATCH 3/6] remove cancellation token from NavigateTo NavigateTo doesn't support cancellation when computing the display properties so the cancellation token is getting removed rather than having to manually handling OperationCanceledException. --- .../NavigableItemFactory.DeclaredSymbolNavigableItem.cs | 4 ++-- .../Core/Extensibility/Navigation/NavigableItemFactory.cs | 5 ++--- .../AbstractNavigateToSearchService.SearchResult.cs | 2 +- .../NavigateTo/AbstractNavigateToSearchService.cs | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs index 1e73a3c61403f..726cbcb50a23f 100644 --- a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs +++ b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs @@ -23,12 +23,12 @@ internal class DeclaredSymbolNavigableItem : INavigableItem private readonly Lazy _lazyDisplayName; private readonly Lazy _lazySymbol; - public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo, CancellationToken cancellationToken) + public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo) { Document = document; _declaredSymbolInfo = declaredSymbolInfo; - _lazySymbol = new Lazy(() => declaredSymbolInfo.GetSymbolAsync(document, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult()); + _lazySymbol = new Lazy(() => declaredSymbolInfo.GetSymbolAsync(document, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); _lazyDisplayName = new Lazy(() => { if (Symbol == null) diff --git a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs index 5ff90563df8c4..bdc896a169767 100644 --- a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs +++ b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.GeneratedCodeRecognition; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -17,9 +16,9 @@ public static INavigableItem GetItemFromSymbolLocation(Solution solution, ISymbo return new SymbolLocationNavigableItem(solution, symbol, location); } - public static INavigableItem GetItemFromDeclaredSymbolInfo(DeclaredSymbolInfo declaredSymbolInfo, Document document, CancellationToken cancellationToken) + public static INavigableItem GetItemFromDeclaredSymbolInfo(DeclaredSymbolInfo declaredSymbolInfo, Document document) { - return new DeclaredSymbolNavigableItem(document, declaredSymbolInfo, cancellationToken); + return new DeclaredSymbolNavigableItem(document, declaredSymbolInfo); } public static IEnumerable GetItemsfromPreferredSourceLocations(Solution solution, ISymbol symbol) diff --git a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs index 9fae74f4e6566..284084f354227 100644 --- a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs +++ b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs @@ -41,7 +41,7 @@ public SearchResult(Document document, DeclaredSymbolInfo declaredSymbolInfo, st var declaredNavigableItem = navigableItem as NavigableItemFactory.DeclaredSymbolNavigableItem; Debug.Assert(declaredNavigableItem != null); - _lazySummary = new Lazy(() => declaredNavigableItem.Symbol.GetDocumentationComment()?.SummaryText); + _lazySummary = new Lazy(() => declaredNavigableItem.Symbol?.GetDocumentationComment()?.SummaryText); _lazyAdditionalInfo = new Lazy(() => { switch (declaredSymbolInfo.Kind) diff --git a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs index 2a020127927f0..ef6bca88ccb3c 100644 --- a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs +++ b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs @@ -17,10 +17,10 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea public async Task> SearchProjectAsync(Project project, string searchPattern, CancellationToken cancellationToken) { var results = await NavigateToSymbolFinder.FindNavigableDeclaredSymbolInfos(project, searchPattern, cancellationToken).ConfigureAwait(false); - return results.Select(r => ConvertResult(r, cancellationToken)); + return results.Select(r => ConvertResult(r)); } - private INavigateToSearchResult ConvertResult(ValueTuple> result, CancellationToken cancellationToken) + private INavigateToSearchResult ConvertResult(ValueTuple> result) { var declaredSymbolInfo = result.Item1; var document = result.Item2; @@ -31,7 +31,7 @@ private INavigateToSearchResult ConvertResult(ValueTuple m.IsCaseSensitive); var kind = GetItemKind(declaredSymbolInfo); - var navigableItem = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document, cancellationToken); + var navigableItem = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document); return new SearchResult(document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem); } From a0c2d41baab39b13ce959a3da02e79ad8bc61659 Mon Sep 17 00:00:00 2001 From: Brett Forsgren Date: Mon, 9 Feb 2015 14:02:08 -0800 Subject: [PATCH 4/6] add comment explaining usage of CancellationToken.None --- .../NavigableItemFactory.DeclaredSymbolNavigableItem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs index 726cbcb50a23f..d03e168d4ce7b 100644 --- a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs +++ b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs @@ -28,6 +28,8 @@ public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declare Document = document; _declaredSymbolInfo = declaredSymbolInfo; + // Cancellation isn't supported when computing the various properties that depend on the symbol, hence + // CancellationToken.None. _lazySymbol = new Lazy(() => declaredSymbolInfo.GetSymbolAsync(document, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); _lazyDisplayName = new Lazy(() => { From 4de11f167c4899dcad377f7c5cb9a910daea2e46 Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Mon, 16 Feb 2015 10:50:06 -0800 Subject: [PATCH 5/6] PERF: Use the BinarySearch extension method for integer arrays instead of Array.BinarySearch --- .../Syntax/InternalSyntax/SyntaxList.WithLotsOfChildren.cs | 2 +- .../VisualBasic/Portable/Syntax/InternalSyntax/SyntaxList.vb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxList.WithLotsOfChildren.cs b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxList.WithLotsOfChildren.cs index 6f65f6bfc0641..b2c084dc326cb 100644 --- a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxList.WithLotsOfChildren.cs +++ b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxList.WithLotsOfChildren.cs @@ -52,7 +52,7 @@ public override int GetSlotOffset(int index) public override int FindSlotIndexContainingOffset(int offset) { Debug.Assert(offset >= 0 && offset < FullWidth); - int idx = Array.BinarySearch(_childOffsets, offset); + int idx = _childOffsets.BinarySearch(offset); return idx >= 0 ? idx : (~idx - 1); } diff --git a/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxList.vb b/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxList.vb index 1c05284d1370a..cccfb125a203d 100644 --- a/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxList.vb +++ b/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxList.vb @@ -466,7 +466,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax ''' Public Overrides Function FindSlotIndexContainingOffset(offset As Integer) As Integer Debug.Assert(offset >= 0 AndAlso offset < FullWidth) - Dim idx = Array.BinarySearch(_childOffsets, offset) + Dim idx = _childOffsets.BinarySearch(offset) Return If(idx >= 0, idx, (Not idx) - 1) End Function From 5f8470d8bdf65d89ec095f425d661df76a73c137 Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Mon, 16 Feb 2015 10:52:52 -0800 Subject: [PATCH 6/6] PERF: In LargeEncodedText, use the BinarySearch extension method for integer arrays in instead of Array.BinarySearch --- src/Compilers/Core/Desktop/LargeEncodedText.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Compilers/Core/Desktop/LargeEncodedText.cs b/src/Compilers/Core/Desktop/LargeEncodedText.cs index 89b1fc0c21a0e..a1daf50e4b54c 100644 --- a/src/Compilers/Core/Desktop/LargeEncodedText.cs +++ b/src/Compilers/Core/Desktop/LargeEncodedText.cs @@ -3,6 +3,7 @@ using System.IO; using System.Text; using System.Threading; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Text { @@ -109,7 +110,7 @@ private static bool IsBinary(char[] chunk) private int GetIndexFromPosition(int position) { // Binary search to find the chunk that contains the given position. - int idx = Array.BinarySearch(_chunkStartOffsets, position); + int idx = _chunkStartOffsets.BinarySearch(position); return idx >= 0 ? idx : (~idx - 1); }