Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed symbol decoding from completion items #1670

Merged
merged 4 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All changes to the project will be documented in this file.

## [1.34.10] - not yet released
* Fixed a bug where completion items didn't decode symbols corectly (impacted, for example, object initializer completion quality) ([omnisharp-vscode#3465](https://github.com/OmniSharp/omnisharp-vscode/issues/3465), PR: [#1670](https://github.com/OmniSharp/omnisharp-roslyn/pull/1670))
* Updated to MsBuild 16.4.0 on Linux/MacOS (PR:[#1669](https://github.com/OmniSharp/omnisharp-roslyn/pull/1669))

## [1.34.9] - 2019-12-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ internal static class CompletionItemExtensions
private const string ParitalMethodCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.PartialMethodCompletionProvider";
private const string ProviderName = nameof(ProviderName);
private const string SymbolCompletionItem = "Microsoft.CodeAnalysis.Completion.Providers.SymbolCompletionItem";
private const string SymbolCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.SymbolCompletionProvider";
private const string SymbolKind = nameof(SymbolKind);
private const string SymbolName = nameof(SymbolName);
private const string Symbols = nameof(Symbols);
Expand Down Expand Up @@ -49,7 +48,9 @@ public static bool IsObjectCreationCompletionItem(this CompletionItem item)

public static async Task<IEnumerable<ISymbol>> GetCompletionSymbolsAsync(this CompletionItem completionItem, IEnumerable<ISymbol> recommendedSymbols, Document document)
{
if (completionItem.GetType() == _symbolCompletionItemType)
var properties = completionItem.Properties;

if (completionItem.GetType() == _symbolCompletionItemType || properties.ContainsKey(Symbols))
{
var decodedSymbolsTask = _getSymbolsAsync.InvokeStatic<Task<ImmutableArray<ISymbol>>>(new object[] { completionItem, document, default(CancellationToken) });
if (decodedSymbolsTask != null)
Expand All @@ -58,8 +59,6 @@ public static async Task<IEnumerable<ISymbol>> GetCompletionSymbolsAsync(this Co
}
}

var properties = completionItem.Properties;

// if the completion provider encoded symbols into Properties, we can return them
if (properties.ContainsKey(SymbolName) && properties.ContainsKey(SymbolKind))
{
Expand Down
1 change: 1 addition & 0 deletions tests/OmniSharp.Roslyn.CSharp.Tests/IntellisenseFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public MyClass2()

var completions = await FindCompletionsAsync(filename, source);
ContainsCompletions(completions.Select(c => c.CompletionText), "Foo");
ContainsCompletions(completions.Select(c => c.ReturnType), "string");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the changes from this PR, this assert fails (for example on current master). It would have prevented the regression too.

}

[Theory]
Expand Down