NavigateToTests.cs 46.2 KB
Newer Older
S
Sam Harwell 已提交
1
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
2

3
using System;
4 5
using System.Collections.Generic;
using System.Linq;
C
Cyrus Najmabadi 已提交
6
using System.Threading.Tasks;
7
using Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo;
8
using Microsoft.CodeAnalysis.Editor.UnitTests;
9
using Microsoft.CodeAnalysis.Editor.UnitTests.NavigateTo;
10 11
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Shared.TestHooks;
12
using Microsoft.CodeAnalysis.Test.Utilities;
13
using Microsoft.VisualStudio.Composition;
14
using Microsoft.VisualStudio.Language.NavigateTo.Interfaces;
15
using Microsoft.VisualStudio.Text.PatternMatching;
16 17 18 19
using Roslyn.Test.EditorUtilities.NavigateTo;
using Roslyn.Test.Utilities;
using Xunit;

20
#pragma warning disable CS0618 // MatchKind is obsolete
21 22
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.NavigateTo
{
23
    public class NavigateToTests : AbstractNavigateToTests
24
    {
25
        protected override string Language => "csharp";
26

C
CyrusNajmabadi 已提交
27
        protected override TestWorkspace CreateWorkspace(string content, ExportProvider exportProvider)
C
CyrusNajmabadi 已提交
28
            => TestWorkspace.CreateCSharp(content, exportProvider: exportProvider);
29

30 31 32
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task NoItemsForEmptyFile(Type trackingServiceType)
33
        {
34
            await TestAsync("", async w =>
35
            {
36
                Assert.Empty(await _aggregator.GetItemsAsync("Hello"));
37
            }, trackingServiceType);
38 39
        }

40 41 42
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindClass(Type trackingServiceType)
43
        {
C
CyrusNajmabadi 已提交
44
            await TestAsync(
45
@"class Goo
C
CyrusNajmabadi 已提交
46 47
{
}", async w =>
48
            {
49
                var item = (await _aggregator.GetItemsAsync("Goo")).Single(x => x.Kind != "Method");
50
                VerifyNavigateToResultItem(item, "Goo", "[|Goo|]", PatternMatchKind.Exact, NavigateToItemKind.Class, Glyph.ClassInternal);
51
            }, trackingServiceType);
52 53
        }

54 55 56
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindVerbatimClass(Type trackingServiceType)
57
        {
C
CyrusNajmabadi 已提交
58 59 60 61
            await TestAsync(
@"class @static
{
}", async w =>
62
            {
63
                var item = (await _aggregator.GetItemsAsync("static")).Single(x => x.Kind != "Method");
64
                VerifyNavigateToResultItem(item, "static", "[|static|]", PatternMatchKind.Exact, NavigateToItemKind.Class, Glyph.ClassInternal);
65 66

                // Check searching for @static too
67
                item = (await _aggregator.GetItemsAsync("@static")).Single(x => x.Kind != "Method");
68
                VerifyNavigateToResultItem(item, "static", "[|static|]", PatternMatchKind.Exact, NavigateToItemKind.Class, Glyph.ClassInternal);
69
            }, trackingServiceType);
70 71
        }

72 73 74
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindNestedClass(Type trackingServiceType)
75
        {
C
CyrusNajmabadi 已提交
76
            await TestAsync(
77
@"class Goo
C
CyrusNajmabadi 已提交
78 79 80 81 82 83 84 85
{
    class Bar
    {
        internal class DogBed
        {
        }
    }
}", async w =>
86
            {
87
                var item = (await _aggregator.GetItemsAsync("DogBed")).Single(x => x.Kind != "Method");
88
                VerifyNavigateToResultItem(item, "DogBed", "[|DogBed|]", PatternMatchKind.Exact, NavigateToItemKind.Class, Glyph.ClassInternal);
89
            }, trackingServiceType);
90 91
        }

92 93 94
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindMemberInANestedClass(Type trackingServiceType)
95
        {
C
CyrusNajmabadi 已提交
96
            await TestAsync(
97
@"class Goo
C
CyrusNajmabadi 已提交
98
{
99
    class Bar 
C
CyrusNajmabadi 已提交
100 101 102 103 104 105 106 107 108
    {
        class DogBed
        {
            public void Method()
            {
            }
        }
    }
}", async w =>
109
            {
110
                var item = (await _aggregator.GetItemsAsync("Method")).Single();
111
                VerifyNavigateToResultItem(item, "Method", "[|Method|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPublic, string.Format(FeaturesResources.in_0_project_1, "Goo.Bar.DogBed", "Test"));
112
            }, trackingServiceType);
113 114
        }

115 116 117
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindGenericClassWithConstraints(Type trackingServiceType)
118
        {
C
CyrusNajmabadi 已提交
119 120 121
            await TestAsync(
@"using System.Collections;

122
class Goo<T> where T : IEnumerable
C
CyrusNajmabadi 已提交
123 124
{
}", async w =>
125
            {
126
                var item = (await _aggregator.GetItemsAsync("Goo")).Single(x => x.Kind != "Method");
127
                VerifyNavigateToResultItem(item, "Goo", "[|Goo|]<T>", PatternMatchKind.Exact, NavigateToItemKind.Class, Glyph.ClassInternal);
128
            }, trackingServiceType);
129 130
        }

131 132 133
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindGenericMethodWithConstraints(Type trackingServiceType)
134
        {
C
CyrusNajmabadi 已提交
135 136 137
            await TestAsync(
@"using System;

138
class Goo<U>
C
CyrusNajmabadi 已提交
139 140 141 142 143
{
    public void Bar<T>(T item) where T : IComparable<T>
    {
    }
}", async w =>
144
            {
145
                var item = (await _aggregator.GetItemsAsync("Bar")).Single();
146
                VerifyNavigateToResultItem(item, "Bar", "[|Bar|]<T>(T)", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPublic, string.Format(FeaturesResources.in_0_project_1, "Goo<U>", "Test"));
147
            }, trackingServiceType);
148 149
        }

150 151 152
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindPartialClass(Type trackingServiceType)
153
        {
C
CyrusNajmabadi 已提交
154
            await TestAsync(
155
@"public partial class Goo
C
CyrusNajmabadi 已提交
156 157 158 159
{
    int a;
}

160
partial class Goo
C
CyrusNajmabadi 已提交
161 162 163
{
    int b;
}", async w =>
164
            {
165
                var expecteditem1 = new NavigateToItem("Goo", NavigateToItemKind.Class, "csharp", null, null, s_emptyExactPatternMatch, null);
166 167
                var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 };

168
                var items = await _aggregator.GetItemsAsync("Goo");
169 170

                VerifyNavigateToResultItems(expecteditems, items);
171
            }, trackingServiceType);
172 173
        }

174 175 176
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindTypesInMetadata(Type trackingServiceType)
177
        {
C
CyrusNajmabadi 已提交
178 179 180 181
            await TestAsync(
@"using System;

Class Program { FileStyleUriParser f; }", async w =>
182
            {
183
                var items = await _aggregator.GetItemsAsync("FileStyleUriParser");
184
                Assert.Equal(items.Count(), 0);
185
            }, trackingServiceType);
186 187
        }

188 189 190
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindClassInNamespace(Type trackingServiceType)
191
        {
C
CyrusNajmabadi 已提交
192 193 194
            await TestAsync(
@"namespace Bar
{
195
    class Goo
C
CyrusNajmabadi 已提交
196 197 198
    {
    }
}", async w =>
199
            {
200
                var item = (await _aggregator.GetItemsAsync("Goo")).Single(x => x.Kind != "Method");
201
                VerifyNavigateToResultItem(item, "Goo", "[|Goo|]", PatternMatchKind.Exact, NavigateToItemKind.Class, Glyph.ClassInternal);
202
            }, trackingServiceType);
203 204
        }

205 206 207
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindStruct(Type trackingServiceType)
208
        {
C
CyrusNajmabadi 已提交
209 210 211 212
            await TestAsync(
@"struct Bar
{
}", async w =>
213
            {
214
                var item = (await _aggregator.GetItemsAsync("B")).Single(x => x.Kind != "Method");
215
                VerifyNavigateToResultItem(item, "Bar", "[|B|]ar", PatternMatchKind.Prefix, NavigateToItemKind.Structure, Glyph.StructureInternal);
216
            }, trackingServiceType);
217 218
        }

219 220 221
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindEnum(Type trackingServiceType)
222
        {
C
CyrusNajmabadi 已提交
223 224 225 226 227 228 229
            await TestAsync(
@"enum Colors
{
    Red,
    Green,
    Blue
}", async w =>
230
            {
231
                var item = (await _aggregator.GetItemsAsync("Colors")).Single(x => x.Kind != "Method");
232
                VerifyNavigateToResultItem(item, "Colors", "[|Colors|]", PatternMatchKind.Exact, NavigateToItemKind.Enum, Glyph.EnumInternal);
233
            }, trackingServiceType);
234 235
        }

236 237 238
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindEnumMember(Type trackingServiceType)
239
        {
C
CyrusNajmabadi 已提交
240 241 242 243 244 245 246
            await TestAsync(
@"enum Colors
{
    Red,
    Green,
    Blue
}", async w =>
247
            {
248
                var item = (await _aggregator.GetItemsAsync("R")).Single();
249
                VerifyNavigateToResultItem(item, "Red", "[|R|]ed", PatternMatchKind.Prefix, NavigateToItemKind.EnumItem, Glyph.EnumMemberPublic);
250
            }, trackingServiceType);
251 252
        }

253 254 255
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindField1(Type trackingServiceType)
256
        {
C
CyrusNajmabadi 已提交
257
            await TestAsync(
258
@"class Goo
C
CyrusNajmabadi 已提交
259 260 261
{
    int bar;
}", async w =>
262
            {
263
                var item = (await _aggregator.GetItemsAsync("b")).Single();
264
                VerifyNavigateToResultItem(item, "bar", "[|b|]ar", PatternMatchKind.Prefix, NavigateToItemKind.Field, Glyph.FieldPrivate, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
265
            }, trackingServiceType);
266 267
        }

268 269 270
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindField2(Type trackingServiceType)
271
        {
C
CyrusNajmabadi 已提交
272
            await TestAsync(
273
@"class Goo
C
CyrusNajmabadi 已提交
274 275 276
{
    int bar;
}", async w =>
277
            {
278
                var item = (await _aggregator.GetItemsAsync("ba")).Single();
279
                VerifyNavigateToResultItem(item, "bar", "[|ba|]r", PatternMatchKind.Prefix, NavigateToItemKind.Field, Glyph.FieldPrivate, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
280
            }, trackingServiceType);
281 282
        }

283 284 285
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindField3(Type trackingServiceType)
286
        {
C
CyrusNajmabadi 已提交
287
            await TestAsync(
288
@"class Goo
C
CyrusNajmabadi 已提交
289 290 291
{
    int bar;
}", async w =>
292
            {
293
                Assert.Empty(await _aggregator.GetItemsAsync("ar"));
294
            }, trackingServiceType);
295 296
        }

297 298 299
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindVerbatimField(Type trackingServiceType)
300
        {
C
CyrusNajmabadi 已提交
301
            await TestAsync(
302
@"class Goo
C
CyrusNajmabadi 已提交
303 304 305
{
    int @string;
}", async w =>
306
            {
307
                var item = (await _aggregator.GetItemsAsync("string")).Single();
308
                VerifyNavigateToResultItem(item, "string", "[|string|]", PatternMatchKind.Exact, NavigateToItemKind.Field, Glyph.FieldPrivate, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
309 310

                // Check searching for@string too
311
                item = (await _aggregator.GetItemsAsync("@string")).Single();
312
                VerifyNavigateToResultItem(item, "string", "[|string|]", PatternMatchKind.Exact, NavigateToItemKind.Field, Glyph.FieldPrivate, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
313
            }, trackingServiceType);
314 315
        }

316 317 318
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindPtrField1(Type trackingServiceType)
319
        {
C
CyrusNajmabadi 已提交
320
            await TestAsync(
321
@"class Goo
C
CyrusNajmabadi 已提交
322 323 324
{
    int* bar;
}", async w =>
325
            {
326
                Assert.Empty(await _aggregator.GetItemsAsync("ar"));
327
            }, trackingServiceType);
328 329
        }

330 331 332
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindPtrField2(Type trackingServiceType)
333
        {
C
CyrusNajmabadi 已提交
334
            await TestAsync(
335
@"class Goo
C
CyrusNajmabadi 已提交
336 337 338
{
    int* bar;
}", async w =>
339
            {
340
                var item = (await _aggregator.GetItemsAsync("b")).Single();
341
                VerifyNavigateToResultItem(item, "bar", "[|b|]ar", PatternMatchKind.Prefix, NavigateToItemKind.Field, Glyph.FieldPrivate);
342
            }, trackingServiceType);
343 344
        }

345 346 347
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindConstField(Type trackingServiceType)
348
        {
C
CyrusNajmabadi 已提交
349
            await TestAsync(
350
@"class Goo
C
CyrusNajmabadi 已提交
351 352 353
{
    const int bar = 7;
}", async w =>
354
            {
355
                var item = (await _aggregator.GetItemsAsync("ba")).Single();
356
                VerifyNavigateToResultItem(item, "bar", "[|ba|]r", PatternMatchKind.Prefix, NavigateToItemKind.Constant, Glyph.ConstantPrivate);
357
            }, trackingServiceType);
358 359
        }

360 361 362
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindIndexer(Type trackingServiceType)
363
        {
364
            var program = @"class Goo { int[] arr; public int this[int i] { get { return arr[i]; } set { arr[i] = value; } } }";
365
            await TestAsync(program, async w =>
366
            {
367
                var item = (await _aggregator.GetItemsAsync("this")).Single();
368
                VerifyNavigateToResultItem(item, "this", "[|this|][int]", PatternMatchKind.Exact, NavigateToItemKind.Property, Glyph.PropertyPublic, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
369
            }, trackingServiceType);
370 371
        }

372 373 374
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindEvent(Type trackingServiceType)
375
        {
376
            var program = "class Goo { public event EventHandler ChangedEventHandler; }";
377
            await TestAsync(program, async w =>
378
            {
379
                var item = (await _aggregator.GetItemsAsync("CEH")).Single();
380
                VerifyNavigateToResultItem(item, "ChangedEventHandler", "[|C|]hanged[|E|]vent[|H|]andler", PatternMatchKind.CamelCaseExact, NavigateToItemKind.Event, Glyph.EventPublic, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
381
            }, trackingServiceType);
382 383
        }

384 385 386
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindAutoProperty(Type trackingServiceType)
387
        {
C
CyrusNajmabadi 已提交
388
            await TestAsync(
389
@"class Goo
C
CyrusNajmabadi 已提交
390 391 392
{
    int Bar { get; set; }
}", async w =>
393
            {
394
                var item = (await _aggregator.GetItemsAsync("B")).Single();
395
                VerifyNavigateToResultItem(item, "Bar", "[|B|]ar", PatternMatchKind.Prefix, NavigateToItemKind.Property, Glyph.PropertyPrivate, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
396
            }, trackingServiceType);
397 398
        }

399 400 401
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindMethod(Type trackingServiceType)
402
        {
C
CyrusNajmabadi 已提交
403
            await TestAsync(
404
@"class Goo
C
CyrusNajmabadi 已提交
405 406 407
{
    void DoSomething();
}", async w =>
408
            {
409
                var item = (await _aggregator.GetItemsAsync("DS")).Single();
410
                VerifyNavigateToResultItem(item, "DoSomething", "[|D|]o[|S|]omething()", PatternMatchKind.CamelCaseExact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
411
            }, trackingServiceType);
412 413
        }

414 415 416
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindVerbatimMethod(Type trackingServiceType)
417
        {
C
CyrusNajmabadi 已提交
418
            await TestAsync(
419
@"class Goo
C
CyrusNajmabadi 已提交
420 421 422
{
    void @static();
}", async w =>
423
            {
424
                var item = (await _aggregator.GetItemsAsync("static")).Single();
425
                VerifyNavigateToResultItem(item, "static", "[|static|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
426 427

                // Verify if we search for @static too
428
                item = (await _aggregator.GetItemsAsync("@static")).Single();
429
                VerifyNavigateToResultItem(item, "static", "[|static|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
430
            }, trackingServiceType);
431 432
        }

433 434 435
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindParameterizedMethod(Type trackingServiceType)
436
        {
C
CyrusNajmabadi 已提交
437
            await TestAsync(
438
@"class Goo
C
CyrusNajmabadi 已提交
439 440 441 442 443
{
    void DoSomething(int a, string b)
    {
    }
}", async w =>
444
            {
445
                var item = (await _aggregator.GetItemsAsync("DS")).Single();
446
                VerifyNavigateToResultItem(item, "DoSomething", "[|D|]o[|S|]omething(int, string)", PatternMatchKind.CamelCaseExact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
447
            }, trackingServiceType);
448 449
        }

450 451 452
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindConstructor(Type trackingServiceType)
453
        {
C
CyrusNajmabadi 已提交
454
            await TestAsync(
455
@"class Goo
C
CyrusNajmabadi 已提交
456
{
457
    public Goo()
C
CyrusNajmabadi 已提交
458 459 460
    {
    }
}", async w =>
461
            {
462
                var item = (await _aggregator.GetItemsAsync("Goo")).Single(t => t.Kind == NavigateToItemKind.Method);
463
                VerifyNavigateToResultItem(item, "Goo", "[|Goo|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPublic, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
464
            }, trackingServiceType);
465 466
        }

467 468 469
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindParameterizedConstructor(Type trackingServiceType)
470
        {
C
CyrusNajmabadi 已提交
471
            await TestAsync(
472
@"class Goo
C
CyrusNajmabadi 已提交
473
{
474
    public Goo(int i)
C
CyrusNajmabadi 已提交
475 476 477
    {
    }
}", async w =>
478
            {
479
                var item = (await _aggregator.GetItemsAsync("Goo")).Single(t => t.Kind == NavigateToItemKind.Method);
480
                VerifyNavigateToResultItem(item, "Goo", "[|Goo|](int)", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPublic, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
481
            }, trackingServiceType);
482 483
        }

484 485 486
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindStaticConstructor(Type trackingServiceType)
487
        {
C
CyrusNajmabadi 已提交
488
            await TestAsync(
489
@"class Goo
C
CyrusNajmabadi 已提交
490
{
491
    static Goo()
C
CyrusNajmabadi 已提交
492 493 494
    {
    }
}", async w =>
495
            {
496
                var item = (await _aggregator.GetItemsAsync("Goo")).Single(t => t.Kind == NavigateToItemKind.Method && t.Name != ".ctor");
497
                VerifyNavigateToResultItem(item, "Goo", "[|Goo|].static Goo()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
498
            }, trackingServiceType);
499 500
        }

501 502 503
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindPartialMethods(Type trackingServiceType)
504
        {
505
            await TestAsync("partial class Goo { partial void Bar(); } partial class Goo { partial void Bar() { Console.Write(\"hello\"); } }", async w =>
506
            {
507
                var expecteditem1 = new NavigateToItem("Bar", NavigateToItemKind.Method, "csharp", null, null, s_emptyExactPatternMatch, null);
508 509
                var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 };

510
                var items = await _aggregator.GetItemsAsync("Bar");
511 512

                VerifyNavigateToResultItems(expecteditems, items);
513
            }, trackingServiceType);
514 515
        }

516 517 518
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindPartialMethodDefinitionOnly(Type trackingServiceType)
519
        {
C
CyrusNajmabadi 已提交
520
            await TestAsync(
521
@"partial class Goo
C
CyrusNajmabadi 已提交
522 523 524
{
    partial void Bar();
}", async w =>
525
            {
526
                var item = (await _aggregator.GetItemsAsync("Bar")).Single();
527
                VerifyNavigateToResultItem(item, "Bar", "[|Bar|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
528
            }, trackingServiceType);
529 530
        }

531 532 533
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindPartialMethodImplementationOnly(Type trackingServiceType)
534
        {
C
CyrusNajmabadi 已提交
535
            await TestAsync(
536
@"partial class Goo
C
CyrusNajmabadi 已提交
537 538 539 540 541
{
    partial void Bar()
    {
    }
}", async w =>
542
            {
543
                var item = (await _aggregator.GetItemsAsync("Bar")).Single();
544
                VerifyNavigateToResultItem(item, "Bar", "[|Bar|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
545
            }, trackingServiceType);
546 547
        }

548 549 550
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindOverriddenMembers(Type trackingServiceType)
551
        {
552
            var program = "class Goo { public virtual string Name { get; set; } } class DogBed : Goo { public override string Name { get { return base.Name; } set {} } }";
553
            await TestAsync(program, async w =>
554
            {
555
                var expecteditem1 = new NavigateToItem("Name", NavigateToItemKind.Property, "csharp", null, null, s_emptyExactPatternMatch, null);
556 557
                var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 };

558
                var items = await _aggregator.GetItemsAsync("Name");
559 560 561 562 563 564 565 566

                VerifyNavigateToResultItems(expecteditems, items);

                var item = items.ElementAt(0);
                var itemDisplay = item.DisplayFactory.CreateItemDisplay(item);
                var unused = itemDisplay.Glyph;

                Assert.Equal("Name", itemDisplay.Name);
C
CyrusNajmabadi 已提交
567
                Assert.Equal(string.Format(FeaturesResources.in_0_project_1, "DogBed", "Test"), itemDisplay.AdditionalInformation);
568 569 570 571 572 573

                item = items.ElementAt(1);
                itemDisplay = item.DisplayFactory.CreateItemDisplay(item);
                unused = itemDisplay.Glyph;

                Assert.Equal("Name", itemDisplay.Name);
574
                Assert.Equal(string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"), itemDisplay.AdditionalInformation);
575
            }, trackingServiceType);
576 577
        }

578 579 580
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindInterface(Type trackingServiceType)
581
        {
C
CyrusNajmabadi 已提交
582
            await TestAsync(
583
@"public interface IGoo
C
CyrusNajmabadi 已提交
584 585
{
}", async w =>
586
            {
587
                var item = (await _aggregator.GetItemsAsync("IG")).Single();
588
                VerifyNavigateToResultItem(item, "IGoo", "[|IG|]oo", PatternMatchKind.Prefix, NavigateToItemKind.Interface, Glyph.InterfacePublic);
589
            }, trackingServiceType);
590 591
        }

592 593 594
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindDelegateInNamespace(Type trackingServiceType)
595
        {
C
CyrusNajmabadi 已提交
596
            await TestAsync(
597
@"namespace Goo
C
CyrusNajmabadi 已提交
598 599 600
{
    delegate void DoStuff();
}", async w =>
601
            {
602
                var item = (await _aggregator.GetItemsAsync("DoStuff")).Single(x => x.Kind != "Method");
603
                VerifyNavigateToResultItem(item, "DoStuff", "[|DoStuff|]", PatternMatchKind.Exact, NavigateToItemKind.Delegate, Glyph.DelegateInternal);
604
            }, trackingServiceType);
605 606
        }

607 608 609
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindLambdaExpression(Type trackingServiceType)
610
        {
C
CyrusNajmabadi 已提交
611 612 613
            await TestAsync(
@"using System;

614
class Goo
C
CyrusNajmabadi 已提交
615 616 617
{
    Func<int, int> sqr = x => x * x;
}", async w =>
618
            {
619
                var item = (await _aggregator.GetItemsAsync("sqr")).Single();
620
                VerifyNavigateToResultItem(item, "sqr", "[|sqr|]", PatternMatchKind.Exact, NavigateToItemKind.Field, Glyph.FieldPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
621
            }, trackingServiceType);
622 623
        }

624 625 626
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindArray(Type trackingServiceType)
627
        {
C
CyrusNajmabadi 已提交
628
            await TestAsync(
629
@"class Goo
C
CyrusNajmabadi 已提交
630 631 632
{
    object[] itemArray;
}", async w =>
633
            {
634
                var item = (await _aggregator.GetItemsAsync("itemArray")).Single();
635
                VerifyNavigateToResultItem(item, "itemArray", "[|itemArray|]", PatternMatchKind.Exact, NavigateToItemKind.Field, Glyph.FieldPrivate, string.Format(FeaturesResources.in_0_project_1, "Goo", "Test"));
636
            }, trackingServiceType);
637 638
        }

639 640 641
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindClassAndMethodWithSameName(Type trackingServiceType)
642
        {
C
CyrusNajmabadi 已提交
643
            await TestAsync(
644
@"class Goo
C
CyrusNajmabadi 已提交
645 646 647 648 649
{
}

class Test
{
650
    void Goo()
C
CyrusNajmabadi 已提交
651 652 653
    {
    }
}", async w =>
654 655 656
            {
                var expectedItems = new List<NavigateToItem>
                {
657 658
                    new NavigateToItem("Goo", NavigateToItemKind.Method, "csharp", "Goo", null, s_emptyExactPatternMatch, null),
                    new NavigateToItem("Goo", NavigateToItemKind.Class, "csharp", "Goo", null, s_emptyExactPatternMatch, null)
659
                };
660
                var items = await _aggregator.GetItemsAsync("Goo");
661
                VerifyNavigateToResultItems(expectedItems, items);
662
            }, trackingServiceType);
663 664
        }

665 666 667
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindMethodNestedInGenericTypes(Type trackingServiceType)
668
        {
C
CyrusNajmabadi 已提交
669 670 671 672 673 674 675 676 677 678 679 680 681
            await TestAsync(
@"class A<T>
{
    class B
    {
        struct C<U>
        {
            void M()
            {
            }
        }
    }
}", async w =>
682
            {
683
                var item = (await _aggregator.GetItemsAsync("M")).Single();
684
                VerifyNavigateToResultItem(item, "M", "[|M|]()", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate, additionalInfo: string.Format(FeaturesResources.in_0_project_1, "A<T>.B.C<U>", "Test"));
685
            }, trackingServiceType);
686 687
        }

688 689 690
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task OrderingOfConstructorsAndTypes(Type trackingServiceType)
691
        {
C
CyrusNajmabadi 已提交
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
            await TestAsync(
@"class C1
{
    C1(int i)
    {
    }
}

class C2
{
    C2(float f)
    {
    }

    static C2()
    {
    }
}", async w =>
710 711 712
            {
                var expecteditems = new List<NavigateToItem>
                {
713 714 715 716 717
                    new NavigateToItem("C1", NavigateToItemKind.Class, "csharp", "C1", null, s_emptyPrefixPatternMatch, null),
                    new NavigateToItem("C1", NavigateToItemKind.Method, "csharp", "C1", null, s_emptyPrefixPatternMatch, null),
                    new NavigateToItem("C2", NavigateToItemKind.Class, "csharp", "C2", null, s_emptyPrefixPatternMatch, null),
                    new NavigateToItem("C2", NavigateToItemKind.Method, "csharp", "C2", null, s_emptyPrefixPatternMatch, null), // this is the static ctor
                    new NavigateToItem("C2", NavigateToItemKind.Method, "csharp", "C2", null, s_emptyPrefixPatternMatch, null),
718
                };
719
                var items = (await _aggregator.GetItemsAsync("C")).ToList();
720 721
                items.Sort(CompareNavigateToItems);
                VerifyNavigateToResultItems(expecteditems, items);
722
            }, trackingServiceType);
723 724
        }

725 726 727
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task NavigateToMethodWithNullableParameter(Type trackingServiceType)
728
        {
C
CyrusNajmabadi 已提交
729 730 731 732 733 734 735
            await TestAsync(
@"class C
{
    void M(object? o)
    {
    }
}", async w =>
736
            {
737
                var item = (await _aggregator.GetItemsAsync("M")).Single();
738
                VerifyNavigateToResultItem(item, "M", "[|M|](object?)", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPrivate);
739
            }, trackingServiceType);
740 741
        }

742 743 744
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task StartStopSanity(Type trackingServiceType)
745 746
        {
            // Verify that multiple calls to start/stop and dispose don't blow up
C
CyrusNajmabadi 已提交
747
            await TestAsync(
748
@"public class Goo
C
CyrusNajmabadi 已提交
749 750
{
}", async w =>
751 752
            {
                // Do one set of queries
753
                Assert.Single((await _aggregator.GetItemsAsync("Goo")).Where(x => x.Kind != "Method"));
754 755 756
                _provider.StopSearch();

                // Do the same query again, make sure nothing was left over
757
                Assert.Single((await _aggregator.GetItemsAsync("Goo")).Where(x => x.Kind != "Method"));
758 759 760 761
                _provider.StopSearch();

                // Dispose the provider
                _provider.Dispose();
762
            }, trackingServiceType);
763 764
        }

765 766 767
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DescriptionItems(Type trackingServiceType)
768
        {
769
            await TestAsync("public\r\nclass\r\nGoo\r\n{ }", async w =>
770
            {
771
                var item = (await _aggregator.GetItemsAsync("G")).Single(x => x.Kind != "Method");
772 773 774 775
                var itemDisplay = item.DisplayFactory.CreateItemDisplay(item);

                var descriptionItems = itemDisplay.DescriptionItems;

C
CyrusNajmabadi 已提交
776
                void assertDescription(string label, string value)
777 778 779
                {
                    var descriptionItem = descriptionItems.Single(i => i.Category.Single().Text == label);
                    Assert.Equal(value, descriptionItem.Details.Single().Text);
C
CyrusNajmabadi 已提交
780
                }
781

782
                assertDescription("File:", w.Documents.Single().Name);
783 784
                assertDescription("Line:", "3"); // one based line number
                assertDescription("Project:", "Test");
785
            }, trackingServiceType);
786 787
        }

788 789 790
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest1(Type trackingServiceType)
791 792
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
793
            await TestAsync(source, async w =>
794
            {
795 796 797
                var expecteditem1 = new NavigateToItem("get_keyword", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseNonContiguousPrefixPatternMatch_NotCaseSensitive, null);
                var expecteditem2 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseNonContiguousPrefixPatternMatch_NotCaseSensitive, null);
                var expecteditem3 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCasePrefixPatternMatch, null);
798 799
                var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem2, expecteditem3 };

800
                var items = await _aggregator.GetItemsAsync("GK");
801 802 803 804

                Assert.Equal(expecteditems.Count(), items.Count());

                VerifyNavigateToResultItems(expecteditems, items);
805
            }, trackingServiceType);
806 807
        }

808 809 810
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest2(Type trackingServiceType)
811 812
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
813
            await TestAsync(source, async w =>
814
            {
815 816
                var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseNonContiguousPrefixPatternMatch_NotCaseSensitive, null);
                var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseExactPatternMatch, null);
817 818
                var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem2 };

819
                var items = await _aggregator.GetItemsAsync("GKW");
820 821

                VerifyNavigateToResultItems(expecteditems, items);
822
            }, trackingServiceType);
823 824
        }

825 826 827
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest3(Type trackingServiceType)
828 829
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
830
            await TestAsync(source, async w =>
831
            {
832 833
                var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseSubstringPatternMatch_NotCaseSensitive, null);
                var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptySubstringPatternMatch, null);
834 835
                var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem2 };

836
                var items = await _aggregator.GetItemsAsync("K W");
837 838

                VerifyNavigateToResultItems(expecteditems, items);
839
            }, trackingServiceType);
840 841
        }

842 843 844
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest4(Type trackingServiceType)
845 846
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
847
            await TestAsync(source, async w =>
848
            {
849
                var items = await _aggregator.GetItemsAsync("WKG");
850
                Assert.Empty(items);
851
            }, trackingServiceType);
852 853
        }

854 855 856
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest5(Type trackingServiceType)
857 858
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
859
            await TestAsync(source, async w =>
860
            {
861
                var item = (await _aggregator.GetItemsAsync("G_K_W")).Single();
862
                VerifyNavigateToResultItem(item, "get_key_word", "[|g|]et[|_k|]ey[|_w|]ord", PatternMatchKind.CamelCaseExact, NavigateToItemKind.Field, Glyph.FieldPrivate);
863
            }, trackingServiceType);
864 865
        }

866 867 868
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest6(Type trackingServiceType)
869 870
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
871
            await TestAsync(source, async w =>
872 873 874
            {
                var expecteditems = new List<NavigateToItem>
                {
875 876
                    new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null,s_emptyPrefixPatternMatch, null),
                    new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptyPrefixPatternMatch_NotCaseSensitive, null)
877 878
                };

879
                var items = await _aggregator.GetItemsAsync("get word");
880 881

                VerifyNavigateToResultItems(expecteditems, items);
882
            }, trackingServiceType);
883 884
        }

885 886 887
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TermSplittingTest7(Type trackingServiceType)
888 889
        {
            var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}";
890
            await TestAsync(source, async w =>
891
            {
892
                var items = await _aggregator.GetItemsAsync("GTW");
893
                Assert.Empty(items);
894
            }, trackingServiceType);
895 896
        }

897 898 899
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task TestIndexer1(Type trackingServiceType)
900 901 902 903 904 905 906 907 908
        {
            var source =
@"class C
{
    public int this[int y] { get { } }
}

class D
{
909
    void Goo()
910 911 912 913 914
    {
        var q = new C();
        var b = q[4];
    }
}";
915
            await TestAsync(source, async w =>
916 917 918
            {
                var expecteditems = new List<NavigateToItem>
                {
919
                    new NavigateToItem("this", NavigateToItemKind.Property, "csharp", null, null, s_emptyExactPatternMatch, null),
920 921
                };

922
                var items = await _aggregator.GetItemsAsync("this");
923 924

                VerifyNavigateToResultItems(expecteditems, items);
925
            }, trackingServiceType);
926 927
        }

928 929 930
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern1(Type trackingServiceType)
931
        {
932
            var source = "namespace Goo { namespace Bar { class Baz { void Quux() { } } } }";
933
            await TestAsync(source, async w =>
934 935 936
            {
                var expecteditems = new List<NavigateToItem>
                {
937
                    new NavigateToItem("Quux", NavigateToItemKind.Method, "csharp", null, null, s_emptyPrefixPatternMatch, null)
938 939
                };

940
                var items = await _aggregator.GetItemsAsync("B.Q");
941 942

                VerifyNavigateToResultItems(expecteditems, items);
943
            }, trackingServiceType);
944 945
        }

946 947 948
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern2(Type trackingServiceType)
949
        {
950
            var source = "namespace Goo { namespace Bar { class Baz { void Quux() { } } } }";
951
            await TestAsync(source, async w =>
952 953 954 955 956
            {
                var expecteditems = new List<NavigateToItem>
                {
                };

957
                var items = await _aggregator.GetItemsAsync("C.Q");
958 959

                VerifyNavigateToResultItems(expecteditems, items);
960
            }, trackingServiceType);
961 962
        }

963 964 965
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern3(Type trackingServiceType)
966
        {
967
            var source = "namespace Goo { namespace Bar { class Baz { void Quux() { } } } }";
968
            await TestAsync(source, async w =>
969 970 971
            {
                var expecteditems = new List<NavigateToItem>
                {
972
                    new NavigateToItem("Quux", NavigateToItemKind.Method, "csharp", null, null, s_emptyPrefixPatternMatch, null)
973 974
                };

975
                var items = await _aggregator.GetItemsAsync("B.B.Q");
976 977

                VerifyNavigateToResultItems(expecteditems, items);
978
            }, trackingServiceType);
979 980
        }

981 982 983
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern4(Type trackingServiceType)
984
        {
985
            var source = "namespace Goo { namespace Bar { class Baz { void Quux() { } } } }";
986
            await TestAsync(source, async w =>
987 988 989
            {
                var expecteditems = new List<NavigateToItem>
                {
990
                    new NavigateToItem("Quux", NavigateToItemKind.Method, "csharp", null, null, s_emptyExactPatternMatch, null)
991 992
                };

993
                var items = await _aggregator.GetItemsAsync("Baz.Quux");
994 995

                VerifyNavigateToResultItems(expecteditems, items);
996
            }, trackingServiceType);
997 998
        }

999 1000 1001
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern5(Type trackingServiceType)
1002
        {
1003
            var source = "namespace Goo { namespace Bar { class Baz { void Quux() { } } } }";
1004
            await TestAsync(source, async w =>
1005 1006 1007
            {
                var expecteditems = new List<NavigateToItem>
                {
1008
                    new NavigateToItem("Quux", NavigateToItemKind.Method, "csharp", null, null, s_emptyExactPatternMatch, null)
1009 1010
                };

1011
                var items = await _aggregator.GetItemsAsync("G.B.B.Quux");
1012 1013

                VerifyNavigateToResultItems(expecteditems, items);
1014
            }, trackingServiceType);
1015 1016
        }

1017 1018 1019
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern6(Type trackingServiceType)
1020
        {
1021
            var source = "namespace Goo { namespace Bar { class Baz { void Quux() { } } } }";
1022
            await TestAsync(source, async w =>
1023 1024 1025 1026 1027
            {
                var expecteditems = new List<NavigateToItem>
                {
                };

1028
                var items = await _aggregator.GetItemsAsync("F.F.B.B.Quux");
1029 1030

                VerifyNavigateToResultItems(expecteditems, items);
1031
            }, trackingServiceType);
1032 1033
        }

1034
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
1035
        [WorkItem(7855, "https://github.com/dotnet/Roslyn/issues/7855")]
1036 1037
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task DottedPattern7(Type trackingServiceType)
1038
        {
1039
            var source = "namespace Goo { namespace Bar { class Baz<X,Y,Z> { void Quux() { } } } }";
1040
            await TestAsync(source, async w =>
1041 1042 1043
            {
                var expecteditems = new List<NavigateToItem>
                {
1044
                    new NavigateToItem("Quux", NavigateToItemKind.Method, "csharp", null, null, s_emptyPrefixPatternMatch, null)
1045 1046
                };

1047
                var items = await _aggregator.GetItemsAsync("Baz.Q");
1048 1049

                VerifyNavigateToResultItems(expecteditems, items);
1050
            }, trackingServiceType);
1051 1052
        }

J
Jared Parsons 已提交
1053
        [WorkItem(1174255, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1174255")]
1054
        [WorkItem(8009, "https://github.com/dotnet/roslyn/issues/8009")]
1055
        [WpfFact, Trait(Traits.Feature, Traits.Features.NavigateTo)]
1056
        public async Task NavigateToGeneratedFiles()
1057
        {
C
CyrusNajmabadi 已提交
1058
            using (var workspace = TestWorkspace.Create(@"
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
<Workspace>
    <Project Language=""C#"" CommonReferences=""true"">
        <Document FilePath=""File1.cs"">
            namespace N
            {
                public partial class C
                {
                    public void VisibleMethod() { }
                }
            }
        </Document>
        <Document FilePath=""File1.g.cs"">
            namespace N
            {
                public partial class C
                {
1075
                    public void VisibleMethod_Generated() { }
1076 1077 1078 1079 1080
                }
            }
        </Document>
    </Project>
</Workspace>
1081
", exportProvider: TestExportProvider.ExportProviderWithCSharpAndVisualBasic))
1082
            {
1083
                _provider = new NavigateToItemProvider(workspace, AsynchronousOperationListenerProvider.NullListener);
1084 1085
                _aggregator = new NavigateToTestAggregator(_provider);

1086
                var items = await _aggregator.GetItemsAsync("VisibleMethod");
1087 1088
                var expectedItems = new List<NavigateToItem>()
                {
1089 1090
                    new NavigateToItem("VisibleMethod", NavigateToItemKind.Method, "csharp", null, null, s_emptyExactPatternMatch, null),
                    new NavigateToItem("VisibleMethod_Generated", NavigateToItemKind.Method, "csharp", null, null, s_emptyPrefixPatternMatch, null)
1091 1092 1093 1094 1095 1096 1097 1098
                };

                // The pattern matcher should match 'VisibleMethod' to both 'VisibleMethod' and 'VisibleMethod_Not', except that
                // the _Not method is declared in a generated file.
                VerifyNavigateToResultItems(expectedItems, items);
            }
        }

1099
        [WorkItem(11474, "https://github.com/dotnet/roslyn/pull/11474")]
1100 1101 1102
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task FindFuzzy1(Type trackingServiceType)
1103
        {
C
CyrusNajmabadi 已提交
1104 1105 1106 1107 1108 1109 1110
            await TestAsync(
@"class C
{
    public void ToError()
    {
    }
}", async w =>
1111
            {
1112
                var item = (await _aggregator.GetItemsAsync("ToEror")).Single();
1113
                VerifyNavigateToResultItem(item, "ToError", "ToError()", PatternMatchKind.Fuzzy, NavigateToItemKind.Method, Glyph.MethodPublic);
1114
            }, trackingServiceType);
1115
        }
1116 1117

        [WorkItem(18843, "https://github.com/dotnet/roslyn/issues/18843")]
1118 1119 1120
        [WpfTheory, Trait(Traits.Feature, Traits.Features.NavigateTo)]
        [MemberData(nameof(TrackingServiceTypes))]
        public async Task Test__arglist(Type trackingServiceType)
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
        {
            await TestAsync(
@"class C
{
    public void ToError(__arglist)
    {
    }
}", async w =>
{
    var item = (await _aggregator.GetItemsAsync("ToError")).Single();
1131
    VerifyNavigateToResultItem(item, "ToError", "[|ToError|](__arglist)", PatternMatchKind.Exact, NavigateToItemKind.Method, Glyph.MethodPublic);
1132
}, trackingServiceType);
1133
        }
1134
    }
S
Sam Harwell 已提交
1135
}
1136
#pragma warning restore CS0618 // MatchKind is obsolete