diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs index 460cd072bd9599a9c58055143e4ce7aef5243cc7..bdbdaa735d0b301e854d258cd6b1b727031d3f16 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs @@ -1,5 +1,6 @@ // 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; using System.Linq; using System.Threading; @@ -215,7 +216,7 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService // We'll take those results, massage them, and forward them along to the // FindUsagesContext instance we were given. await SymbolFinder.FindLiteralReferencesAsync( - tokenValue, solution, progressAdapter, cancellationToken).ConfigureAwait(false); + tokenValue, Type.GetTypeCode(tokenValue.GetType()), solution, progressAdapter, cancellationToken).ConfigureAwait(false); return true; } diff --git a/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs index 00043271eae2ef536841201f6646c43e371c3a79..9d808d4451d8b0e4f5cbd93d6fda740582dd15d3 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs @@ -1,5 +1,6 @@ // 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; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Remote; @@ -9,7 +10,7 @@ namespace Microsoft.CodeAnalysis.FindSymbols internal interface IRemoteSymbolFinder { Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndProjectIdArg, DocumentId[] documentArgs); - Task FindLiteralReferencesAsync(object value); + Task FindLiteralReferencesAsync(object value, TypeCode typeCode); Task> FindAllDeclarationsWithNormalQueryAsync( ProjectId projectId, string name, SearchKind searchKind, SymbolFilter criteria); diff --git a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindLiteralReferences.cs b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindLiteralReferences.cs index 5d79810426179f1f1d163e2243b21051967cc879..9402ab8f51c2b7c12e59175124f8813298dbcf91 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindLiteralReferences.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindLiteralReferences.cs @@ -1,12 +1,9 @@ // 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.Collections.Immutable; -using System.Linq; +using System; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.FindSymbols.Finders; using Microsoft.CodeAnalysis.Internal.Log; -using Microsoft.CodeAnalysis.Remote; namespace Microsoft.CodeAnalysis.FindSymbols { @@ -14,6 +11,7 @@ public static partial class SymbolFinder { internal static async Task FindLiteralReferencesAsync( object value, + TypeCode typeCode, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) @@ -21,7 +19,7 @@ public static partial class SymbolFinder using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var handled = await TryFindLiteralReferencesInServiceProcessAsync( - value, solution, progress, cancellationToken).ConfigureAwait(false); + value, typeCode, solution, progress, cancellationToken).ConfigureAwait(false); if (handled) { return; @@ -44,6 +42,7 @@ public static partial class SymbolFinder private static async Task TryFindLiteralReferencesInServiceProcessAsync( object value, + TypeCode typeCode, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) @@ -63,7 +62,7 @@ public static partial class SymbolFinder await session.InvokeAsync( nameof(IRemoteSymbolFinder.FindLiteralReferencesAsync), - value).ConfigureAwait(false); + value, typeCode).ConfigureAwait(false); return true; } diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs index e4ec2c390589420f8ac991844ffd3e305c863d09..5ae035ef7eb78eaee4b57297002b3f41e2bde049 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs @@ -1,5 +1,6 @@ // 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; using System.Linq; using System.Threading.Tasks; @@ -35,13 +36,14 @@ public async Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndPr progressCallback, documents, CancellationToken).ConfigureAwait(false); } - public async Task FindLiteralReferencesAsync(object value) + public async Task FindLiteralReferencesAsync(object value, TypeCode typeCode) { + var convertedType = System.Convert.ChangeType(value, typeCode); var solution = await GetSolutionAsync().ConfigureAwait(false); var progressCallback = new FindLiteralReferencesProgressCallback(this); await SymbolFinder.FindLiteralReferencesInCurrentProcessAsync( - value, solution, progressCallback, CancellationToken).ConfigureAwait(false); + convertedType, solution, progressCallback, CancellationToken).ConfigureAwait(false); } public async Task> FindAllDeclarationsWithNormalQueryAsync(