SemanticQuickInfoSourceTests.cs 130.5 KB
Newer Older
1 2 3 4 5 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.Linq;
using System.Security;
using System.Threading;
C
Cyrus Najmabadi 已提交
7
using System.Threading.Tasks;
8
using System.Xml.Linq;
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Editor.CSharp.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.QuickInfo;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.QuickInfo
{
    public class SemanticQuickInfoSourceTests : AbstractSemanticQuickInfoSourceTests
    {
C
Cyrus Najmabadi 已提交
27
        private async Task TestWithOptionsAsync(CSharpParseOptions options, string markup, params Action<object>[] expectedResults)
28
        {
C
Cyrus Najmabadi 已提交
29
            using (var workspace = await CSharpWorkspaceFactory.CreateWorkspaceFromFileAsync(markup, options))
30
            {
31
                await TestWithOptionsAsync(workspace, expectedResults);
32 33
            }
        }
34

35
        private async Task TestWithOptionsAsync(TestWorkspace workspace, params Action<object>[] expectedResults)
36 37 38 39 40
        {
            var testDocument = workspace.DocumentWithCursor;
            var position = testDocument.CursorPosition.GetValueOrDefault();
            var documentId = workspace.GetDocumentId(testDocument);
            var document = workspace.CurrentSolution.GetDocument(documentId);
41

42 43 44 45 46 47 48 49
            var provider = new SemanticQuickInfoProvider(
                workspace.GetService<ITextBufferFactoryService>(),
                workspace.GetService<IContentTypeRegistryService>(),
                workspace.GetService<IProjectionBufferFactoryService>(),
                workspace.GetService<IEditorOptionsFactoryService>(),
                workspace.GetService<ITextEditorFactoryService>(),
                workspace.GetService<IGlyphService>(),
                workspace.GetService<ClassificationTypeMap>());
50

51
            await TestWithOptionsAsync(document, provider, position, expectedResults);
52 53

            // speculative semantic model
54
            if (await CanUseSpeculativeSemanticModelAsync(document, position))
55 56 57 58 59 60 61
            {
                var buffer = testDocument.TextBuffer;
                using (var edit = buffer.CreateEdit())
                {
                    var currentSnapshot = buffer.CurrentSnapshot;
                    edit.Replace(0, currentSnapshot.Length, currentSnapshot.GetText());
                    edit.Apply();
62
                }
63

64
                await TestWithOptionsAsync(document, provider, position, expectedResults);
65 66 67
            }
        }

68
        private async Task TestWithOptionsAsync(Document document, SemanticQuickInfoProvider provider, int position, Action<object>[] expectedResults)
69
        {
C
Cyrus Najmabadi 已提交
70
            var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
            if (state != null)
            {
                WaitForDocumentationComment(state.Content);
            }

            if (expectedResults.Length == 0)
            {
                Assert.Null(state);
            }
            else
            {
                Assert.NotNull(state);

                foreach (var expected in expectedResults)
                {
                    expected(state.Content);
                }
            }
        }

C
Cyrus Najmabadi 已提交
91
        private async Task VerifyWithMscorlib45Async(string markup, Action<object>[] expectedResults)
92 93 94 95 96 97 98 99 100 101
        {
            var xmlString = string.Format(@"
<Workspace>
    <Project Language=""C#"" CommonReferencesNet45=""true"">
        <Document FilePath=""SourceDocument"">
{0}
        </Document>
    </Project>
</Workspace>", SecurityElement.Escape(markup));

C
Cyrus Najmabadi 已提交
102
            using (var workspace = await TestWorkspaceFactory.CreateWorkspaceAsync(xmlString))
103 104 105 106 107 108 109 110 111 112 113 114 115 116
            {
                var position = workspace.Documents.Single(d => d.Name == "SourceDocument").CursorPosition.Value;
                var documentId = workspace.Documents.Where(d => d.Name == "SourceDocument").Single().Id;
                var document = workspace.CurrentSolution.GetDocument(documentId);

                var provider = new SemanticQuickInfoProvider(
                        workspace.GetService<ITextBufferFactoryService>(),
                        workspace.GetService<IContentTypeRegistryService>(),
                        workspace.GetService<IProjectionBufferFactoryService>(),
                        workspace.GetService<IEditorOptionsFactoryService>(),
                        workspace.GetService<ITextEditorFactoryService>(),
                        workspace.GetService<IGlyphService>(),
                        workspace.GetService<ClassificationTypeMap>());

C
Cyrus Najmabadi 已提交
117
                var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
                if (state != null)
                {
                    WaitForDocumentationComment(state.Content);
                }

                if (expectedResults.Length == 0)
                {
                    Assert.Null(state);
                }
                else
                {
                    Assert.NotNull(state);

                    foreach (var expected in expectedResults)
                    {
                        expected(state.Content);
                    }
                }
            }
        }

C
Cyrus Najmabadi 已提交
139
        protected override async Task TestAsync(string markup, params Action<object>[] expectedResults)
140
        {
C
Cyrus Najmabadi 已提交
141 142
            await TestWithOptionsAsync(Options.Regular, markup, expectedResults);
            await TestWithOptionsAsync(Options.Script, markup, expectedResults);
143 144
        }

C
Cyrus Najmabadi 已提交
145
        protected async Task TestWithUsingsAsync(string markup, params Action<object>[] expectedResults)
146 147 148 149 150 151 152
        {
            var markupWithUsings =
@"using System;
using System.Collections.Generic;
using System.Linq;
" + markup;

C
Cyrus Najmabadi 已提交
153
            await TestAsync(markupWithUsings, expectedResults);
154 155
        }

C
Cyrus Najmabadi 已提交
156
        protected Task TestInClassAsync(string markup, params Action<object>[] expectedResults)
157 158
        {
            var markupInClass = "class C { " + markup + " }";
C
Cyrus Najmabadi 已提交
159
            return TestWithUsingsAsync(markupInClass, expectedResults);
160 161
        }

C
Cyrus Najmabadi 已提交
162
        protected Task TestInMethodAsync(string markup, params Action<object>[] expectedResults)
163 164
        {
            var markupInMethod = "class C { void M() { " + markup + " } }";
C
Cyrus Najmabadi 已提交
165
            return TestWithUsingsAsync(markupInMethod, expectedResults);
166 167
        }

C
Cyrus Najmabadi 已提交
168
        private async Task TestWithReferenceAsync(string sourceCode,
169 170 171 172 173
            string referencedCode,
            string sourceLanguage,
            string referencedLanguage,
            params Action<object>[] expectedResults)
        {
C
Cyrus Najmabadi 已提交
174 175
            await TestWithMetadataReferenceHelperAsync(sourceCode, referencedCode, sourceLanguage, referencedLanguage, expectedResults);
            await TestWithProjectReferenceHelperAsync(sourceCode, referencedCode, sourceLanguage, referencedLanguage, expectedResults);
176 177 178 179

            // Multi-language projects are not supported.
            if (sourceLanguage == referencedLanguage)
            {
C
Cyrus Najmabadi 已提交
180
                await TestInSameProjectHelperAsync(sourceCode, referencedCode, sourceLanguage, expectedResults);
181 182 183
            }
        }

C
Cyrus Najmabadi 已提交
184
        private async Task TestWithMetadataReferenceHelperAsync(
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
            string sourceCode,
            string referencedCode,
            string sourceLanguage,
            string referencedLanguage,
            params Action<object>[] expectedResults)
        {
            var xmlString = string.Format(@"
<Workspace>
    <Project Language=""{0}"" CommonReferences=""true"">
        <Document FilePath=""SourceDocument"">
{1}
        </Document>
        <MetadataReferenceFromSource Language=""{2}"" CommonReferences=""true"" IncludeXmlDocComments=""true"">
            <Document FilePath=""ReferencedDocument"">
{3}
            </Document>
        </MetadataReferenceFromSource>
    </Project>
</Workspace>", sourceLanguage, SecurityElement.Escape(sourceCode),
               referencedLanguage, SecurityElement.Escape(referencedCode));

C
Cyrus Najmabadi 已提交
206
            await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
207 208
        }

C
Cyrus Najmabadi 已提交
209
        private async Task TestWithProjectReferenceHelperAsync(
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
            string sourceCode,
            string referencedCode,
            string sourceLanguage,
            string referencedLanguage,
            params Action<object>[] expectedResults)
        {
            var xmlString = string.Format(@"
<Workspace>
    <Project Language=""{0}"" CommonReferences=""true"">
        <ProjectReference>ReferencedProject</ProjectReference>
        <Document FilePath=""SourceDocument"">
{1}
        </Document>
    </Project>
    <Project Language=""{2}"" CommonReferences=""true"" AssemblyName=""ReferencedProject"">
        <Document FilePath=""ReferencedDocument"">
{3}
        </Document>
    </Project>
    
</Workspace>", sourceLanguage, SecurityElement.Escape(sourceCode),
               referencedLanguage, SecurityElement.Escape(referencedCode));

C
Cyrus Najmabadi 已提交
233
            await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
234 235
        }

C
Cyrus Najmabadi 已提交
236
        private async Task TestInSameProjectHelperAsync(
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
            string sourceCode,
            string referencedCode,
            string sourceLanguage,
            params Action<object>[] expectedResults)
        {
            var xmlString = string.Format(@"
<Workspace>
    <Project Language=""{0}"" CommonReferences=""true"">
        <Document FilePath=""SourceDocument"">
{1}
        </Document>
        <Document FilePath=""ReferencedDocument"">
{2}
        </Document>
    </Project>
</Workspace>", sourceLanguage, SecurityElement.Escape(sourceCode), SecurityElement.Escape(referencedCode));

C
Cyrus Najmabadi 已提交
254
            await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
255 256
        }

C
Cyrus Najmabadi 已提交
257
        private async Task VerifyWithReferenceWorkerAsync(string xmlString, params Action<object>[] expectedResults)
258
        {
C
Cyrus Najmabadi 已提交
259
            using (var workspace = await TestWorkspaceFactory.CreateWorkspaceAsync(xmlString))
260 261 262 263 264 265 266 267 268 269 270 271 272 273
            {
                var position = workspace.Documents.First(d => d.Name == "SourceDocument").CursorPosition.Value;
                var documentId = workspace.Documents.First(d => d.Name == "SourceDocument").Id;
                var document = workspace.CurrentSolution.GetDocument(documentId);

                var provider = new SemanticQuickInfoProvider(
                        workspace.GetService<ITextBufferFactoryService>(),
                        workspace.GetService<IContentTypeRegistryService>(),
                        workspace.GetService<IProjectionBufferFactoryService>(),
                        workspace.GetService<IEditorOptionsFactoryService>(),
                        workspace.GetService<ITextEditorFactoryService>(),
                        workspace.GetService<IGlyphService>(),
                        workspace.GetService<ClassificationTypeMap>());

C
Cyrus Najmabadi 已提交
274
                var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
                if (state != null)
                {
                    WaitForDocumentationComment(state.Content);
                }

                if (expectedResults.Length == 0)
                {
                    Assert.Null(state);
                }
                else
                {
                    Assert.NotNull(state);

                    foreach (var expected in expectedResults)
                    {
                        expected(state.Content);
                    }
                }
            }
        }

C
Cyrus Najmabadi 已提交
296
        protected async Task TestInvalidTypeInClassAsync(string code)
297 298
        {
            var codeInClass = "class C { " + code + " }";
C
Cyrus Najmabadi 已提交
299
            await TestAsync(codeInClass);
300 301
        }

302
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
303
        public async Task TestNamespaceInUsingDirective()
304
        {
C
Cyrus Najmabadi 已提交
305
            await TestAsync("using $$System;",
306 307 308
                MainDescription("namespace System"));
        }

309
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
310
        public async Task TestNamespaceInUsingDirective2()
311
        {
C
Cyrus Najmabadi 已提交
312
            await TestAsync("using System.Coll$$ections.Generic;",
313 314 315
                MainDescription("namespace System.Collections"));
        }

316
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
317
        public async Task TestNamespaceInUsingDirective3()
318
        {
C
Cyrus Najmabadi 已提交
319
            await TestAsync("using System.L$$inq;",
320 321 322
                MainDescription("namespace System.Linq"));
        }

323
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
324
        public async Task TestNamespaceInUsingDirectiveWithAlias()
325
        {
C
Cyrus Najmabadi 已提交
326
            await TestAsync("using Foo = Sys$$tem.Console;",
327 328 329
                MainDescription("namespace System"));
        }

330
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
331
        public async Task TestTypeInUsingDirectiveWithAlias()
332
        {
C
Cyrus Najmabadi 已提交
333
            await TestAsync("using Foo = System.Con$$sole;",
334 335 336 337
                MainDescription("class System.Console"));
        }

        [WorkItem(991466)]
338
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
339
        public async Task TestDocumentationInUsingDirectiveWithAlias()
340 341 342 343 344 345
        {
            var markup =
@"using I$$ = IFoo;
///<summary>summary for interface IFoo</summary>
interface IFoo {  }";

C
Cyrus Najmabadi 已提交
346
            await TestAsync(markup,
347 348 349 350 351
                MainDescription("interface IFoo"),
                Documentation("summary for interface IFoo"));
        }

        [WorkItem(991466)]
352
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
353
        public async Task TestDocumentationInUsingDirectiveWithAlias2()
354 355 356 357 358 359 360
        {
            var markup =
@"using I = IFoo;
///<summary>summary for interface IFoo</summary>
interface IFoo {  }
class C : I$$ { }";

C
Cyrus Najmabadi 已提交
361
            await TestAsync(markup,
362 363 364 365 366
                MainDescription("interface IFoo"),
                Documentation("summary for interface IFoo"));
        }

        [WorkItem(991466)]
367
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
368
        public async Task TestDocumentationInUsingDirectiveWithAlias3()
369 370 371 372 373 374 375 376 377 378
        {
            var markup =
@"using I = IFoo;
///<summary>summary for interface IFoo</summary>
interface IFoo 
{  
    void Foo();
}
class C : I$$ { }";

C
Cyrus Najmabadi 已提交
379
            await TestAsync(markup,
380 381 382 383
                MainDescription("interface IFoo"),
                Documentation("summary for interface IFoo"));
        }

384
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
385
        public async Task TestThis()
386 387 388 389 390 391
        {
            var markup =
@"
///<summary>summary for Class C</summary>
class C { string M() {  return thi$$s.ToString(); } }";

C
Cyrus Najmabadi 已提交
392
            await TestWithUsingsAsync(markup,
393 394 395 396
                MainDescription("class C"),
                Documentation("summary for Class C"));
        }

397
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
398
        public async Task TestClassWithDocComment()
399 400 401 402 403 404
        {
            var markup =
@"
///<summary>Hello!</summary>
class C { void M() { $$C obj; } }";

C
Cyrus Najmabadi 已提交
405
            await TestAsync(markup,
406 407 408 409
                MainDescription("class C"),
                Documentation("Hello!"));
        }

410
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
411
        public async Task TestSingleLineDocComments()
412 413 414 415
        {
            // Tests chosen to maximize code coverage in DocumentationCommentCompiler.WriteFormattedSingleLineComment

            // SingleLine doc comment with leading whitespace
C
Cyrus Najmabadi 已提交
416
            await TestAsync(@"
417 418 419 420 421 422
    ///<summary>Hello!</summary>
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with space before opening tag
C
Cyrus Najmabadi 已提交
423
            await TestAsync(@"
424 425 426 427 428 429
/// <summary>Hello!</summary>
class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with space before opening tag and leading whitespace
C
Cyrus Najmabadi 已提交
430
            await TestAsync(@"
431 432 433 434 435 436
    /// <summary>Hello!</summary>
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with leading whitespace and blank line
C
Cyrus Najmabadi 已提交
437
            await TestAsync(@"
438 439 440 441 442 443 444 445
    ///<summary>Hello!
    ///</summary>

    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with '\r' line separators
C
Cyrus Najmabadi 已提交
446
            await TestAsync("///<summary>Hello!\r///</summary>\rclass C { void M() { $$C obj; } }",
447 448 449 450
                MainDescription("class C"),
                Documentation("Hello!"));
        }

451
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
452
        public async Task TestMultiLineDocComments()
453 454 455 456
        {
            // Tests chosen to maximize code coverage in DocumentationCommentCompiler.WriteFormattedMultiLineComment

            // Multiline doc comment with leading whitespace
C
Cyrus Najmabadi 已提交
457
            await TestAsync(@"
458 459 460 461 462 463
    /**<summary>Hello!</summary>*/
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with space before opening tag
C
Cyrus Najmabadi 已提交
464
            await TestAsync(@"
465 466 467 468 469 470 471
/** <summary>Hello!</summary>
 **/
class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with space before opening tag and leading whitespace
C
Cyrus Najmabadi 已提交
472
            await TestAsync(@"
473 474 475 476 477 478 479 480
    /**
     ** <summary>Hello!</summary>
     **/
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with no per-line prefix
C
Cyrus Najmabadi 已提交
481
            await TestAsync(@"
482 483 484 485 486 487 488 489 490 491
/**
  <summary>
  Hello!
  </summary>
*/
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with inconsistent per-line prefix
C
Cyrus Najmabadi 已提交
492
            await TestAsync(@"
493 494 495 496 497 498 499 500 501 502
/**
 ** <summary>
    Hello!</summary>
 **
 **/
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with closing comment on final line
C
Cyrus Najmabadi 已提交
503
            await TestAsync(@"
504 505 506 507 508 509 510 511
/**
<summary>Hello!
</summary>*/
    class C { void M() { $$C obj; } }",
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with '\r' line separators
C
Cyrus Najmabadi 已提交
512
            await TestAsync("/**\r* <summary>\r* Hello!\r* </summary>\r*/\rclass C { void M() { $$C obj; } }",
513 514 515 516
                MainDescription("class C"),
                Documentation("Hello!"));
        }

517
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
518
        public async Task TestMethodWithDocComment()
519 520 521 522 523 524
        {
            var markup =
@"
///<summary>Hello!</summary>
void M() { M$$() }";

C
Cyrus Najmabadi 已提交
525
            await TestInClassAsync(markup,
526 527 528 529
                MainDescription("void C.M()"),
                Documentation("Hello!"));
        }

530
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
531
        public async Task TestInt32()
532
        {
C
Cyrus Najmabadi 已提交
533
            await TestInClassAsync(@"$$Int32 i;",
534 535 536
                MainDescription("struct System.Int32"));
        }

537
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
538
        public async Task TestBuiltInInt()
539
        {
C
Cyrus Najmabadi 已提交
540
            await TestInClassAsync(@"$$int i;",
541 542 543
                MainDescription("struct System.Int32"));
        }

544
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
545
        public async Task TestString()
546
        {
C
Cyrus Najmabadi 已提交
547
            await TestInClassAsync(@"$$String s;",
548 549 550
                MainDescription("class System.String"));
        }

551
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
552
        public async Task TestBuiltInString()
553
        {
C
Cyrus Najmabadi 已提交
554
            await TestInClassAsync(@"$$string s;",
555 556 557
                MainDescription("class System.String"));
        }

558
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
559
        public async Task TestBuiltInStringAtEndOfToken()
560
        {
C
Cyrus Najmabadi 已提交
561
            await TestInClassAsync(@"string$$ s;",
562 563 564
                MainDescription("class System.String"));
        }

565
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
566
        public async Task TestBoolean()
567
        {
C
Cyrus Najmabadi 已提交
568
            await TestInClassAsync(@"$$Boolean b;",
569 570 571
                MainDescription("struct System.Boolean"));
        }

572
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
573
        public async Task TestBuiltInBool()
574
        {
C
Cyrus Najmabadi 已提交
575
            await TestInClassAsync(@"$$bool b;",
576 577 578
                MainDescription("struct System.Boolean"));
        }

579
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
580
        public async Task TestSingle()
581
        {
C
Cyrus Najmabadi 已提交
582
            await TestInClassAsync(@"$$Single s;",
583 584 585
                MainDescription("struct System.Single"));
        }

586
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
587
        public async Task TestBuiltInFloat()
588
        {
C
Cyrus Najmabadi 已提交
589
            await TestInClassAsync(@"$$float f;",
590 591 592
                MainDescription("struct System.Single"));
        }

593
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
594
        public async Task TestVoidIsInvalid()
595
        {
C
Cyrus Najmabadi 已提交
596
            await TestInvalidTypeInClassAsync(@"$$void M() { }");
597 598
        }

599
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
600
        public async Task TestInvalidPointer1_931958()
601
        {
C
Cyrus Najmabadi 已提交
602
            await TestInvalidTypeInClassAsync(@"$$T* i;");
603 604
        }

605
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
606
        public async Task TestInvalidPointer2_931958()
607
        {
C
Cyrus Najmabadi 已提交
608
            await TestInvalidTypeInClassAsync(@"T$$* i;");
609 610
        }

611
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
612
        public async Task TestInvalidPointer3_931958()
613
        {
C
Cyrus Najmabadi 已提交
614
            await TestInvalidTypeInClassAsync(@"T*$$ i;");
615 616
        }

617
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
618
        public async Task TestListOfString()
619
        {
C
Cyrus Najmabadi 已提交
620
            await TestInClassAsync(@"$$List<string> l;",
621
                MainDescription("class System.Collections.Generic.List<T>"),
622
                TypeParameterMap($"\r\nT {FeaturesResources.Is} string"));
623 624
        }

625
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
626
        public async Task TestListOfSomethingFromSource()
627 628 629 630 631 632
        {
            var markup =
@"
///<summary>Generic List</summary>
public class GenericList<T> { Generic$$List<int> t; }";

C
Cyrus Najmabadi 已提交
633
            await TestAsync(markup,
634 635
                MainDescription("class GenericList<T>"),
                Documentation("Generic List"),
636
                TypeParameterMap($"\r\nT {FeaturesResources.Is} int"));
637 638
        }

639
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
640
        public async Task TestListOfT()
641
        {
C
Cyrus Najmabadi 已提交
642
            await TestInMethodAsync(@"class C<T> { $$List<T> l; }",
643 644 645
                MainDescription("class System.Collections.Generic.List<T>"));
        }

646
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
647
        public async Task TestDictionaryOfIntAndString()
648
        {
C
Cyrus Najmabadi 已提交
649
            await TestInClassAsync(@"$$Dictionary<int, string> d;",
650 651
                MainDescription("class System.Collections.Generic.Dictionary<TKey, TValue>"),
                TypeParameterMap(
652 653
                    Lines($"\r\nTKey {FeaturesResources.Is} int",
                          $"TValue {FeaturesResources.Is} string")));
654 655
        }

656
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
657
        public async Task TestDictionaryOfTAndU()
658
        {
C
Cyrus Najmabadi 已提交
659
            await TestInMethodAsync(@"class C<T, U> { $$Dictionary<T, U> d; }",
660 661
                MainDescription("class System.Collections.Generic.Dictionary<TKey, TValue>"),
                TypeParameterMap(
662 663
                    Lines($"\r\nTKey {FeaturesResources.Is} T",
                          $"TValue {FeaturesResources.Is} U")));
664 665
        }

666
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
667
        public async Task TestIEnumerableOfInt()
668
        {
C
Cyrus Najmabadi 已提交
669
            await TestInClassAsync(@"$$IEnumerable<int> M() { yield break; }",
670
                MainDescription("interface System.Collections.Generic.IEnumerable<out T>"),
671
                TypeParameterMap($"\r\nT {FeaturesResources.Is} int"));
672 673
        }

674
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
675
        public async Task TestEventHandler()
676
        {
C
Cyrus Najmabadi 已提交
677
            await TestInClassAsync(@"event $$EventHandler e;",
678 679 680
                MainDescription("delegate void System.EventHandler(object sender, System.EventArgs e)"));
        }

681
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
682
        public async Task TestTypeParameter()
683
        {
C
Cyrus Najmabadi 已提交
684
            await TestAsync(@"class C<T> { $$T t; }",
685
                MainDescription($"T {FeaturesResources.In} C<T>"));
686 687 688
        }

        [WorkItem(538636)]
689
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
690
        public async Task TestTypeParameterWithDocComment()
691 692 693 694 695 696 697
        {
            var markup =
@"
///<summary>Hello!</summary>
///<typeparam name=""T"">T is Type Parameter</typeparam>
class C<T> { $$T t; }";

C
Cyrus Najmabadi 已提交
698
            await TestAsync(markup,
699
                MainDescription($"T {FeaturesResources.In} C<T>"),
700 701 702
                Documentation("T is Type Parameter"));
        }

703
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
704
        public async Task TestTypeParameter1_Bug931949()
705
        {
C
Cyrus Najmabadi 已提交
706
            await TestAsync(@"class T1<T11> { $$T11 t; }",
707
                MainDescription($"T11 {FeaturesResources.In} T1<T11>"));
708 709
        }

710
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
711
        public async Task TestTypeParameter2_Bug931949()
712
        {
C
Cyrus Najmabadi 已提交
713
            await TestAsync(@"class T1<T11> { T$$11 t; }",
714
                MainDescription($"T11 {FeaturesResources.In} T1<T11>"));
715 716
        }

717
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
718
        public async Task TestTypeParameter3_Bug931949()
719
        {
C
Cyrus Najmabadi 已提交
720
            await TestAsync(@"class T1<T11> { T1$$1 t; }",
721
                MainDescription($"T11 {FeaturesResources.In} T1<T11>"));
722 723
        }

724
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
725
        public async Task TestTypeParameter4_Bug931949()
726
        {
C
Cyrus Najmabadi 已提交
727
            await TestAsync(@"class T1<T11> { T11$$ t; }",
728
                MainDescription($"T11 {FeaturesResources.In} T1<T11>"));
729 730
        }

731
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
732
        public async Task TestNullableOfInt()
733
        {
C
Cyrus Najmabadi 已提交
734
            await TestInClassAsync(@"$$Nullable<int> i; }",
735
                MainDescription("struct System.Nullable<T> where T : struct"),
736
                TypeParameterMap($"\r\nT {FeaturesResources.Is} int"));
737 738
        }

739
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
740
        public async Task TestGenericTypeDeclaredOnMethod1_Bug1946()
741
        {
C
Cyrus Najmabadi 已提交
742
            await TestAsync(@"class C { static void Meth1<T1>($$T1 i) where T1 : struct { T1 i; } }",
743
                MainDescription($"T1 {FeaturesResources.In} C.Meth1<T1> where T1 : struct"));
744 745
        }

746
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
747
        public async Task TestGenericTypeDeclaredOnMethod2_Bug1946()
748
        {
C
Cyrus Najmabadi 已提交
749
            await TestAsync(@"class C { static void Meth1<T1>(T1 i) where $$T1 : struct { T1 i; } }",
750
                MainDescription($"T1 {FeaturesResources.In} C.Meth1<T1> where T1 : struct"));
751 752
        }

753
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
754
        public async Task TestGenericTypeDeclaredOnMethod3_Bug1946()
755
        {
C
Cyrus Najmabadi 已提交
756
            await TestAsync(@"class C { static void Meth1<T1>(T1 i) where T1 : struct { $$T1 i; } }",
757
                MainDescription($"T1 {FeaturesResources.In} C.Meth1<T1> where T1 : struct"));
758 759
        }

760
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
761
        public async Task TestGenericTypeParameterConstraint_Class()
762
        {
C
Cyrus Najmabadi 已提交
763
            await TestAsync(@"class C<T> where $$T : class { }",
764
                MainDescription($"T {FeaturesResources.In} C<T> where T : class"));
765 766
        }

767
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
768
        public async Task TestGenericTypeParameterConstraint_Struct()
769
        {
C
Cyrus Najmabadi 已提交
770
            await TestAsync(@"struct S<T> where $$T : class { }",
771
                MainDescription($"T {FeaturesResources.In} S<T> where T : class"));
772 773
        }

774
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
775
        public async Task TestGenericTypeParameterConstraint_Interface()
776
        {
C
Cyrus Najmabadi 已提交
777
            await TestAsync(@"interface I<T> where $$T : class { }",
778
                MainDescription($"T {FeaturesResources.In} I<T> where T : class"));
779 780
        }

781
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
782
        public async Task TestGenericTypeParameterConstraint_Delegate()
783
        {
C
Cyrus Najmabadi 已提交
784
            await TestAsync(@"delegate void D<T>() where $$T : class;",
785
                MainDescription($"T {FeaturesResources.In} D<T> where T : class"));
786 787
        }

788
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
789
        public async Task TestMinimallyQualifiedConstraint()
790
        {
C
Cyrus Najmabadi 已提交
791
            await TestAsync(@"class C<T> where $$T : IEnumerable<int>",
792
                MainDescription($"T {FeaturesResources.In} C<T> where T : IEnumerable<int>"));
793 794
        }

795
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
796
        public async Task FullyQualifiedConstraint()
797
        {
C
Cyrus Najmabadi 已提交
798
            await TestAsync(@"class C<T> where $$T : System.Collections.Generic.IEnumerable<int>",
799
                MainDescription($"T {FeaturesResources.In} C<T> where T : System.Collections.Generic.IEnumerable<int>"));
800 801
        }

802
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
803
        public async Task TestMethodReferenceInSameMethod()
804
        {
C
Cyrus Najmabadi 已提交
805
            await TestAsync("class C { void M() { M$$(); } }",
806 807 808
                MainDescription("void C.M()"));
        }

809
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
810
        public async Task TestMethodReferenceInSameMethodWithDocComment()
811 812 813 814 815 816
        {
            var markup =
@"
///<summary>Hello World</summary>
void M() { M$$(); }";

C
Cyrus Najmabadi 已提交
817
            await TestInClassAsync(markup,
818 819 820 821
                MainDescription("void C.M()"),
                Documentation("Hello World"));
        }

822
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
823
        public async Task TestFieldInMethodBuiltIn()
824 825 826 827 828 829 830 831 832
        {
            var markup =
@"int field;

void M()
{
    field$$
}";

C
Cyrus Najmabadi 已提交
833
            await TestInClassAsync(markup,
834
                MainDescription($"({FeaturesResources.Field}) int C.field"));
835 836
        }

837
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
838
        public async Task TestFieldInMethodBuiltIn2()
839
        {
C
Cyrus Najmabadi 已提交
840
            await TestInClassAsync("int field; void M() { int f = field$$; }",
841
                MainDescription($"({FeaturesResources.Field}) int C.field"));
842 843
        }

844
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
845
        public async Task TestFieldInMethodBuiltInWithFieldInitializer()
846
        {
C
Cyrus Najmabadi 已提交
847
            await TestInClassAsync("int field = 1; void M() { int f = field $$; }");
848 849
        }

850
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
851
        public async Task TestOperatorBuiltIn()
852
        {
C
Cyrus Najmabadi 已提交
853
            await TestInMethodAsync("int x; x = x$$+1;",
854 855 856
                MainDescription("int int.operator +(int left, int right)"));
        }

857
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
858
        public async Task TestOperatorBuiltIn1()
859
        {
C
Cyrus Najmabadi 已提交
860
            await TestInMethodAsync("int x; x = x$$ + 1;",
861
                MainDescription($"({FeaturesResources.LocalVariable}) int x"));
862 863
        }

864
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
865
        public async Task TestOperatorBuiltIn2()
866
        {
C
Cyrus Najmabadi 已提交
867
            await TestInMethodAsync("int x; x = x+$$x;",
868
                MainDescription($"({FeaturesResources.LocalVariable}) int x"));
869 870
        }

871
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
872
        public async Task TestOperatorBuiltIn3()
873
        {
C
Cyrus Najmabadi 已提交
874
            await TestInMethodAsync("int x; x = x +$$ x;",
875 876 877
                MainDescription("int int.operator +(int left, int right)"));
        }

878
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
879
        public async Task TestOperatorBuiltIn4()
880
        {
C
Cyrus Najmabadi 已提交
881
            await TestInMethodAsync("int x; x = x + $$x;",
882
                MainDescription($"({FeaturesResources.LocalVariable}) int x"));
883 884
        }

885
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
886
        public async Task TestOperatorCustomTypeBuiltIn()
887 888 889 890 891 892 893
        {
            var markup =
@"class C
{
    static void M() { C c; c = c +$$ c; }
}";

C
Cyrus Najmabadi 已提交
894
            await TestAsync(markup);
895 896
        }

897
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
898
        public async Task TestOperatorCustomTypeOverload()
899 900 901 902 903 904 905 906
        {
            var markup =
@"class C
{
    static void M() { C c; c = c +$$ c; }
    static C operator+(C a, C b) { return a; }
}";

C
Cyrus Najmabadi 已提交
907
            await TestAsync(markup,
908 909 910
                MainDescription("C C.operator +(C a, C b)"));
        }

911
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
912
        public async Task TestFieldInMethodMinimal()
913 914 915 916 917 918 919 920 921
        {
            var markup =
@"DateTime field;

void M()
{
    field$$
}";

C
Cyrus Najmabadi 已提交
922
            await TestInClassAsync(markup,
923
                MainDescription($"({FeaturesResources.Field}) DateTime C.field"));
924 925
        }

926
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
927
        public async Task TestFieldInMethodQualified()
928 929 930 931 932 933 934 935 936
        {
            var markup =
@"System.IO.FileInfo file;

void M()
{
    file$$
}";

C
Cyrus Najmabadi 已提交
937
            await TestInClassAsync(markup,
938
                MainDescription($"({FeaturesResources.Field}) System.IO.FileInfo C.file"));
939 940
        }

941
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
942
        public async Task TestMemberOfStructFromSource()
943 944 945 946 947 948
        {
            var markup =
@"struct MyStruct {
public static int SomeField; }
static class Test { int a = MyStruct.Some$$Field; }";

C
Cyrus Najmabadi 已提交
949
            await TestAsync(markup,
950
                MainDescription($"({FeaturesResources.Field}) int MyStruct.SomeField"));
951 952 953
        }

        [WorkItem(538638)]
954
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
955
        public async Task TestMemberOfStructFromSourceWithDocComment()
956 957 958 959 960 961 962
        {
            var markup =
@"struct MyStruct {
///<summary>My Field</summary>
public static int SomeField; }
static class Test { int a = MyStruct.Some$$Field; }";

C
Cyrus Najmabadi 已提交
963
            await TestAsync(markup,
964
                MainDescription($"({FeaturesResources.Field}) int MyStruct.SomeField"),
965 966 967
                Documentation("My Field"));
        }

968
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
969
        public async Task TestMemberOfStructInsideMethodFromSource()
970 971 972 973 974 975
        {
            var markup =
@"struct MyStruct {
public static int SomeField; }
static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";

C
Cyrus Najmabadi 已提交
976
            await TestAsync(markup,
977
                MainDescription($"({FeaturesResources.Field}) int MyStruct.SomeField"));
978 979 980
        }

        [WorkItem(538638)]
981
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
982
        public async Task TestMemberOfStructInsideMethodFromSourceWithDocComment()
983 984 985 986 987 988 989
        {
            var markup =
@"struct MyStruct {
///<summary>My Field</summary>
public static int SomeField; }
static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";

C
Cyrus Najmabadi 已提交
990
            await TestAsync(markup,
991
                MainDescription($"({FeaturesResources.Field}) int MyStruct.SomeField"),
992 993 994
                Documentation("My Field"));
        }

995
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
996
        public async Task TestMetadataFieldMinimal()
997
        {
C
Cyrus Najmabadi 已提交
998
            await TestInMethodAsync(@"DateTime dt = DateTime.MaxValue$$",
999
                MainDescription($"({FeaturesResources.Field}) DateTime DateTime.MaxValue"));
1000 1001
        }

1002
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1003
        public async Task TestMetadataFieldQualified1()
1004 1005 1006 1007 1008 1009 1010 1011 1012
        {
            // NOTE: we qualify the field type, but not the type that contains the field in Dev10
            var markup =
@"class C {
    void M()
    {
        DateTime dt = System.DateTime.MaxValue$$
    }
}";
C
Cyrus Najmabadi 已提交
1013
            await TestAsync(markup,
1014
                MainDescription($"({FeaturesResources.Field}) System.DateTime System.DateTime.MaxValue"));
1015 1016
        }

1017
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1018
        public async Task TestMetadataFieldQualified2()
1019
        {
C
Cyrus Najmabadi 已提交
1020
            await TestAsync(@"
1021 1022 1023 1024 1025 1026
class C {
    void M()
    {
        DateTime dt = System.DateTime.MaxValue$$
    }
}",
1027
                MainDescription($"({FeaturesResources.Field}) System.DateTime System.DateTime.MaxValue"));
1028 1029
        }

1030
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1031
        public async Task TestMetadataFieldQualified3()
1032
        {
C
Cyrus Najmabadi 已提交
1033
            await TestAsync(@"
1034 1035 1036 1037 1038 1039 1040
using System;
class C {
    void M()
    {
        DateTime dt = System.DateTime.MaxValue$$
    }
}",
1041
                MainDescription($"({FeaturesResources.Field}) DateTime DateTime.MaxValue"));
1042 1043
        }

1044
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1045
        public async Task ConstructedGenericField()
1046
        {
C
Cyrus Najmabadi 已提交
1047
            await TestAsync(@"class C<T> { public T Field; }
1048 1049 1050 1051 1052 1053

class D {
    void M() {
        new C<int>().Fi$$eld.ToString();
    }
}",
1054
                MainDescription($"({FeaturesResources.Field}) int C<int>.Field"));
1055 1056
        }

1057
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1058
        public async Task UnconstructedGenericField()
1059
        {
C
Cyrus Najmabadi 已提交
1060
            await TestAsync(@"
1061 1062 1063 1064 1065 1066 1067
class C<T> {
    public T Field;

    void M() {
        Fi$$eld.ToString();
    }
}",
1068
                MainDescription($"({FeaturesResources.Field}) T C<T>.Field"));
1069 1070
        }

1071
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1072
        public async Task TestIntegerLiteral()
1073
        {
C
Cyrus Najmabadi 已提交
1074
            await TestInMethodAsync(@"int f = 37$$",
1075 1076 1077
                MainDescription("struct System.Int32"));
        }

1078
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1079
        public async Task TestTrueKeyword()
1080
        {
C
Cyrus Najmabadi 已提交
1081
            await TestInMethodAsync(@"bool f = true$$",
1082 1083 1084
                MainDescription("struct System.Boolean"));
        }

1085
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1086
        public async Task TestFalseKeyword()
1087
        {
C
Cyrus Najmabadi 已提交
1088
            await TestInMethodAsync(@"bool f = false$$",
1089 1090 1091 1092
                MainDescription("struct System.Boolean"));
        }

        [WorkItem(756226)]
1093
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1094
        public async Task TestAwaitKeywordOnGenericTaskReturningAsync()
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public async Task<int> Calc()
    {
        aw$$ait Calc();
        return 5;
    }
}";
C
Cyrus Najmabadi 已提交
1105
            await TestAsync(markup, MainDescription($"{FeaturesResources.PrefixTextForAwaitKeyword} struct System.Int32"));
1106 1107 1108
        }

        [WorkItem(756226)]
1109
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1110
        public async Task TestAwaitKeywordInDeclarationStatement()
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public async Task<int> Calc()
    {
        var x = $$await Calc();
        return 5;
    }
}";
C
Cyrus Najmabadi 已提交
1121
            await TestAsync(markup, MainDescription($"{FeaturesResources.PrefixTextForAwaitKeyword} struct System.Int32"));
1122 1123 1124
        }

        [WorkItem(756226)]
1125
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1126
        public async Task TestAwaitKeywordOnTaskReturningAsync()
1127 1128 1129 1130 1131 1132 1133 1134 1135
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public async void Calc()
    {
        aw$$ait Task.Delay(100);
    }
}";
C
Cyrus Najmabadi 已提交
1136
            await TestAsync(markup, MainDescription($"{FeaturesResources.PrefixTextForAwaitKeyword} {FeaturesResources.TextForSystemVoid}"));
1137 1138 1139
        }

        [WorkItem(756226), WorkItem(756337)]
1140
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1141
        public async Task TestNestedAwaitKeywords1()
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
        {
            var markup = @"using System;
using System.Threading.Tasks;
class AsyncExample2
{
    async Task<Task<int>> AsyncMethod()
    {
        return NewMethod();
    }

    private static Task<int> NewMethod()
    {
        int hours = 24;
        return hours;
    }

    async Task UseAsync()
    {
        Func<Task<int>> lambda = async () =>
        {
            return await await AsyncMethod();
        };

        int result = await await AsyncMethod();
        Task<Task<int>> resultTask = AsyncMethod();
        result = await awa$$it resultTask;
        result = await lambda();
    }
}";
C
Cyrus Najmabadi 已提交
1171
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.Awaitable}) {FeaturesResources.PrefixTextForAwaitKeyword} class System.Threading.Tasks.Task<TResult>"),
1172
                         TypeParameterMap($"\r\nTResult {FeaturesResources.Is} int"));
1173 1174 1175
        }

        [WorkItem(756226)]
1176
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1177
        public async Task TestNestedAwaitKeywords2()
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
        {
            var markup = @"using System;
using System.Threading.Tasks;
class AsyncExample2
{
    async Task<Task<int>> AsyncMethod()
    {
        return NewMethod();
    }

    private static Task<int> NewMethod()
    {
        int hours = 24;
        return hours;
    }

    async Task UseAsync()
    {
        Func<Task<int>> lambda = async () =>
        {
            return await await AsyncMethod();
        };

        int result = await await AsyncMethod();
        Task<Task<int>> resultTask = AsyncMethod();
        result = awa$$it await resultTask;
        result = await lambda();
    }
}";
C
Cyrus Najmabadi 已提交
1207
            await TestAsync(markup, MainDescription($"{FeaturesResources.PrefixTextForAwaitKeyword} struct System.Int32"));
1208 1209 1210
        }

        [WorkItem(756226), WorkItem(756337)]
1211
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1212
        public async Task TestAwaitablePrefixOnCustomAwaiter()
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
        {
            var markup = @"using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Z = $$C;

class C
{
    public MyAwaiter GetAwaiter() { throw new NotImplementedException(); }
}

class MyAwaiter : INotifyCompletion
{
    public void OnCompleted(Action continuation)
    {
        throw new NotImplementedException();
    }

    public bool IsCompleted { get { throw new NotImplementedException(); } }
    public void GetResult() { }
}";
C
Cyrus Najmabadi 已提交
1234
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.Awaitable}) class C"));
1235 1236 1237
        }

        [WorkItem(756226), WorkItem(756337)]
1238
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1239
        public async Task TestTaskType()
1240 1241 1242 1243 1244 1245 1246 1247 1248
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public void Calc()
    {
        Task$$ v1;
    }
}";
C
Cyrus Najmabadi 已提交
1249
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.Awaitable}) class System.Threading.Tasks.Task"));
1250 1251 1252
        }

        [WorkItem(756226), WorkItem(756337)]
1253
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1254
        public async Task TestTaskOfTType()
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
        {
            var markup = @"using System;
using System.Threading.Tasks;
class C
{
    public void Calc()
    {
        Task$$<int> v1;
    }
}";
C
Cyrus Najmabadi 已提交
1265
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.Awaitable}) class System.Threading.Tasks.Task<TResult>"),
1266
                         TypeParameterMap($"\r\nTResult {FeaturesResources.Is} int"));
1267 1268
        }

1269
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1270
        public async Task TestStringLiteral()
1271
        {
C
Cyrus Najmabadi 已提交
1272
            await TestInMethodAsync(@"string f = ""Foo""$$",
1273 1274 1275
                MainDescription("class System.String"));
        }

1276
        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1277
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1278
        public async Task TestVerbatimStringLiteral()
1279
        {
C
Cyrus Najmabadi 已提交
1280
            await TestInMethodAsync(@"string f = @""cat""$$",
1281 1282 1283 1284
                MainDescription("class System.String"));
        }

        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1285
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1286
        public async Task TestInterpolatedStringLiteral()
1287
        {
C
Cyrus Najmabadi 已提交
1288 1289 1290 1291
            await TestInMethodAsync(@"string f = $""cat""$$", MainDescription("class System.String"));
            await TestInMethodAsync(@"string f = $""c$$at""", MainDescription("class System.String"));
            await TestInMethodAsync(@"string f = $""$$cat""", MainDescription("class System.String"));
            await TestInMethodAsync(@"string f = $""cat {1$$ + 2} dog""", MainDescription("struct System.Int32"));
1292 1293 1294
        }

        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1295
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1296
        public async Task TestVerbatimInterpolatedStringLiteral()
1297
        {
C
Cyrus Najmabadi 已提交
1298 1299 1300 1301
            await TestInMethodAsync(@"string f = $@""cat""$$", MainDescription("class System.String"));
            await TestInMethodAsync(@"string f = $@""c$$at""", MainDescription("class System.String"));
            await TestInMethodAsync(@"string f = $@""$$cat""", MainDescription("class System.String"));
            await TestInMethodAsync(@"string f = $@""cat {1$$ + 2} dog""", MainDescription("struct System.Int32"));
1302 1303
        }

1304
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1305
        public async Task TestCharLiteral()
1306
        {
C
Cyrus Najmabadi 已提交
1307
            await TestInMethodAsync(@"string f = 'x'$$",
1308 1309 1310
                MainDescription("struct System.Char"));
        }

1311
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1312
        public async Task DynamicKeyword()
1313
        {
C
Cyrus Najmabadi 已提交
1314
            await TestInMethodAsync(@"dyn$$amic dyn;",
1315
                MainDescription("dynamic"),
1316
                Documentation(FeaturesResources.RepresentsAnObjectWhoseOperations));
1317 1318
        }

1319
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1320
        public async Task DynamicField()
1321
        {
C
Cyrus Najmabadi 已提交
1322
            await TestInClassAsync(@"dynamic dyn;
1323 1324 1325 1326
void M()
{
    d$$yn.Foo();
}",
1327
                MainDescription($"({FeaturesResources.Field}) dynamic C.dyn"));
1328 1329
        }

1330
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1331
        public async Task LocalProperty_Minimal()
1332
        {
C
Cyrus Najmabadi 已提交
1333
            await TestInClassAsync(@"DateTime Prop { get; set; }
1334 1335 1336 1337 1338 1339 1340
void M()
{
    P$$rop.ToString();
}",
                MainDescription("DateTime C.Prop { get; set; }"));
        }

1341
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1342
        public async Task LocalProperty_Minimal_PrivateSet()
1343
        {
C
Cyrus Najmabadi 已提交
1344
            await TestInClassAsync(@"public DateTime Prop { get; private set; }
1345 1346 1347 1348 1349 1350 1351
void M()
{
    P$$rop.ToString();
}",
                MainDescription("DateTime C.Prop { get; private set; }"));
        }

1352
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1353
        public async Task LocalProperty_Minimal_PrivateSet1()
1354
        {
C
Cyrus Najmabadi 已提交
1355
            await TestInClassAsync(@"protected internal int Prop { get; private set; }
1356 1357 1358 1359 1360 1361 1362
void M()
{
    P$$rop.ToString();
}",
                MainDescription("int C.Prop { get; private set; }"));
        }

1363
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1364
        public async Task LocalProperty_Qualified()
1365
        {
C
Cyrus Najmabadi 已提交
1366
            await TestInClassAsync(@"System.IO.FileInfo Prop { get; set; }
1367 1368 1369 1370 1371 1372 1373
void M()
{
    P$$rop.ToString();
}",
                MainDescription("System.IO.FileInfo C.Prop { get; set; }"));
        }

1374
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1375
        public async Task NonLocalProperty_Minimal()
1376
        {
C
Cyrus Najmabadi 已提交
1377
            await TestInMethodAsync(@"DateTime.No$$w.ToString();",
1378 1379 1380
                MainDescription("DateTime DateTime.Now { get; }"));
        }

1381
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1382
        public async Task NonLocalProperty_Qualified()
1383
        {
C
Cyrus Najmabadi 已提交
1384
            await TestInMethodAsync(@"System.IO.FileInfo f; f.Att$$ributes.ToString();",
1385 1386 1387
                MainDescription("System.IO.FileAttributes System.IO.FileSystemInfo.Attributes { get; set; }"));
        }

1388
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1389
        public async Task ConstructedGenericProperty()
1390
        {
C
Cyrus Najmabadi 已提交
1391
            await TestAsync(@"
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403
class C<T> {
    public T Property{ get; set }
}

class D {
    void M() {
        new C<int>().Pro$$perty.ToString();
    }
}",
                MainDescription("int C<int>.Property { get; set; }"));
        }

1404
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1405
        public async Task UnconstructedGenericProperty()
1406
        {
C
Cyrus Najmabadi 已提交
1407
            await TestAsync(@"
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417
class C<T> {
    public T Property { get; set}

    void M() {
        Pro$$perty.ToString();
    }
}",
                MainDescription("T C<T>.Property { get; set; }"));
        }

1418
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1419
        public async Task ValueInProperty()
1420
        {
C
Cyrus Najmabadi 已提交
1421
            await TestInClassAsync(@"public DateTime Property {set { foo = val$$ue; } }",
1422
                MainDescription($"({FeaturesResources.Parameter}) DateTime value"));
1423 1424
        }

1425
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1426
        public async Task EnumTypeName()
1427
        {
C
Cyrus Najmabadi 已提交
1428
            await TestInMethodAsync(@"Consol$$eColor c",
1429 1430 1431
                MainDescription("enum System.ConsoleColor"));
        }

1432
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1433
        public async Task EnumMemberNameFromMetadata()
1434
        {
C
Cyrus Najmabadi 已提交
1435
            await TestInMethodAsync(@"ConsoleColor c = ConsoleColor.Bla$$ck",
1436 1437 1438
                MainDescription("ConsoleColor.Black = 0"));
        }

1439
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1440
        public async Task FlagsEnumMemberNameFromMetadata1()
1441
        {
C
Cyrus Najmabadi 已提交
1442
            await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.Cl$$ass",
1443 1444 1445
                MainDescription("AttributeTargets.Class = 4"));
        }

1446
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1447
        public async Task FlagsEnumMemberNameFromMetadata2()
1448
        {
C
Cyrus Najmabadi 已提交
1449
            await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.A$$ll",
1450 1451 1452
                MainDescription("AttributeTargets.All = AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter"));
        }

1453
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1454
        public async Task EnumMemberNameFromSource1()
1455
        {
C
Cyrus Najmabadi 已提交
1456
            await TestAsync(@"
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473
enum E
{
    A = 1 << 0,
    B = 1 << 1,
    C = 1 << 2
}

class C
{
    void M()
    {
        var e = E.B$$;
    }
}",
    MainDescription("E.B = 1 << 1"));
        }

1474
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1475
        public async Task EnumMemberNameFromSource2()
1476
        {
C
Cyrus Najmabadi 已提交
1477
            await TestAsync(@"
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494
enum E
{
    A,
    B,
    C
}

class C
{
    void M()
    {
        var e = E.B$$;
    }
}",
    MainDescription("E.B = 1"));
        }

1495
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1496
        public async Task Parameter_InMethod_Minimal()
1497
        {
C
Cyrus Najmabadi 已提交
1498
            await TestInClassAsync(@"void M(DateTime dt) { d$$t.ToString();",
1499
                MainDescription($"({FeaturesResources.Parameter}) DateTime dt"));
1500 1501
        }

1502
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1503
        public async Task Parameter_InMethod_Qualified()
1504
        {
C
Cyrus Najmabadi 已提交
1505
            await TestInClassAsync(@"void M(System.IO.FileInfo fileInfo) { file$$Info.ToString();",
1506
                MainDescription($"({FeaturesResources.Parameter}) System.IO.FileInfo fileInfo"));
1507 1508
        }

1509
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1510
        public async Task Parameter_FromReferenceToNamedParameter()
1511
        {
C
Cyrus Najmabadi 已提交
1512
            await TestInMethodAsync(@"Console.WriteLine(va$$lue: ""Hi"");",
1513
                MainDescription($"({FeaturesResources.Parameter}) string value"));
1514 1515
        }

1516
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1517
        public async Task Parameter_DefaultValue()
1518 1519 1520
        {
            // NOTE: Dev10 doesn't show the default value, but it would be nice if we did.
            // NOTE: The "DefaultValue" property isn't implemented yet.
C
Cyrus Najmabadi 已提交
1521
            await TestInClassAsync(@"void M(int param = 42) { para$$m.ToString(); }",
1522
                MainDescription($"({FeaturesResources.Parameter}) int param = 42"));
1523 1524
        }

1525
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1526
        public async Task Parameter_Params()
1527
        {
C
Cyrus Najmabadi 已提交
1528
            await TestInClassAsync(@"void M(params DateTime[] arg) { ar$$g.ToString(); }",
1529
                MainDescription($"({FeaturesResources.Parameter}) params DateTime[] arg"));
1530 1531
        }

1532
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1533
        public async Task Parameter_Ref()
1534
        {
C
Cyrus Najmabadi 已提交
1535
            await TestInClassAsync(@"void M(ref DateTime arg) { ar$$g.ToString(); }",
1536
                MainDescription($"({FeaturesResources.Parameter}) ref DateTime arg"));
1537 1538
        }

1539
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1540
        public async Task Parameter_Out()
1541
        {
C
Cyrus Najmabadi 已提交
1542
            await TestInClassAsync(@"void M(out DateTime arg) { ar$$g.ToString(); }",
1543
                MainDescription($"({FeaturesResources.Parameter}) out DateTime arg"));
1544 1545
        }

1546
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1547
        public async Task Local_Minimal()
1548
        {
C
Cyrus Najmabadi 已提交
1549
            await TestInMethodAsync(@"DateTime dt; d$$t.ToString();",
1550
                MainDescription($"({FeaturesResources.LocalVariable}) DateTime dt"));
1551 1552
        }

1553
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1554
        public async Task Local_Qualified()
1555
        {
C
Cyrus Najmabadi 已提交
1556
            await TestInMethodAsync(@"System.IO.FileInfo fileInfo; file$$Info.ToString();",
1557
                MainDescription($"({FeaturesResources.LocalVariable}) System.IO.FileInfo fileInfo"));
1558 1559
        }

1560
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1561
        public async Task Method_MetadataOverload()
1562
        {
C
Cyrus Najmabadi 已提交
1563
            await TestInMethodAsync("Console.Write$$Line();",
1564
                MainDescription($"void Console.WriteLine() (+ 18 {FeaturesResources.Overloads})"));
1565 1566
        }

1567
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1568
        public async Task Method_SimpleWithOverload()
1569
        {
C
Cyrus Najmabadi 已提交
1570
            await TestInClassAsync(@"
1571 1572
void Method() { Met$$hod(); }
void Method(int i) { }",
1573
                MainDescription($"void C.Method() (+ 1 {FeaturesResources.Overload})"));
1574 1575
        }

1576
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1577
        public async Task Method_MoreOverloads()
1578
        {
C
Cyrus Najmabadi 已提交
1579
            await TestInClassAsync(@"
1580 1581 1582 1583
void Method() { Met$$hod(null); }
void Method(int i) { }
void Method(DateTime dt) { }
void Method(System.IO.FileInfo fileInfo) { }",
1584
                MainDescription($"void C.Method(System.IO.FileInfo fileInfo) (+ 3 {FeaturesResources.Overloads})"));
1585 1586
        }

1587
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1588
        public async Task Method_SimpleInSameClass()
1589
        {
C
Cyrus Najmabadi 已提交
1590
            await TestInClassAsync(@"DateTime GetDate(System.IO.FileInfo ft) { Get$$Date(null); }",
1591 1592 1593
                MainDescription("DateTime C.GetDate(System.IO.FileInfo ft)"));
        }

1594
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1595
        public async Task Method_OptionalParameter()
1596
        {
C
Cyrus Najmabadi 已提交
1597
            await TestInClassAsync(@"
1598 1599 1600 1601 1602
void M() { Met$$hod(); }
void Method(int i = 0) { }",
                MainDescription("void C.Method([int i = 0])"));
        }

1603
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1604
        public async Task Method_OptionalDecimalParameter()
1605
        {
C
Cyrus Najmabadi 已提交
1606
            await TestInClassAsync(@"
1607
void Foo(decimal x$$yz = 10) { }",
1608
                MainDescription($"({FeaturesResources.Parameter}) decimal xyz = 10"));
1609 1610
        }

1611
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1612
        public async Task Method_Generic()
1613 1614 1615
        {
            // Generic method don't get the instantiation info yet.  NOTE: We don't display
            // constraint info in Dev10. Should we?
C
Cyrus Najmabadi 已提交
1616
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn> {
1617 1618 1619 1620 1621 1622
    Fo$$o<int, DateTime>(37);
}",

            MainDescription("DateTime C.Foo<int, DateTime>(int arg)"));
        }

1623
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1624
        public async Task Method_UnconstructedGeneric()
1625
        {
C
Cyrus Najmabadi 已提交
1626
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) {
1627 1628 1629 1630 1631 1632
    Fo$$o<TIn, TOut>(default(TIn);
}",

                MainDescription("TOut C.Foo<TIn, TOut>(TIn arg)"));
        }

1633
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1634
        public async Task Method_Inferred()
1635
        {
C
Cyrus Najmabadi 已提交
1636
            await TestInClassAsync(@"void Foo<TIn>(TIn arg) {
1637 1638 1639 1640 1641
    Fo$$o(42);
}",
                MainDescription("void C.Foo<int>(int arg)"));
        }

1642
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1643
        public async Task Method_MultipleParams()
1644
        {
C
Cyrus Najmabadi 已提交
1645
            await TestInClassAsync(@"void Foo(DateTime dt, System.IO.FileInfo fi, int number) {
1646 1647 1648 1649 1650
    Fo$$o(DateTime.Now, null, 32);
}",
                MainDescription("void C.Foo(DateTime dt, System.IO.FileInfo fi, int number)"));
        }

1651
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1652
        public async Task Method_OptionalParam()
1653 1654
        {
            // NOTE - Default values aren't actually returned by symbols yet.
C
Cyrus Najmabadi 已提交
1655
            await TestInClassAsync(@"void Foo(int num = 42) {
1656 1657 1658 1659 1660
    Fo$$o();
}",
                MainDescription("void C.Foo([int num = 42])"));
        }

1661
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1662
        public async Task Method_ParameterModifiers()
1663 1664
        {
            // NOTE - Default values aren't actually returned by symbols yet.
C
Cyrus Najmabadi 已提交
1665
            await TestInClassAsync(@"void Foo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers) {
1666 1667 1668 1669 1670
    Fo$$o(DateTime.Now, null, 32);
}",
                MainDescription("void C.Foo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)"));
        }

1671
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1672
        public async Task Constructor()
1673
        {
C
Cyrus Najmabadi 已提交
1674
            await TestInClassAsync(@"public C() {} void M() { new C$$ ().ToString(); }",
1675 1676 1677
                MainDescription("C.C()"));
        }

1678
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1679
        public async Task Constructor_Overloads()
1680
        {
C
Cyrus Najmabadi 已提交
1681
            await TestInClassAsync(@"
1682 1683 1684 1685 1686 1687 1688 1689
public C() {}
public C(DateTime dt) {}
public C(int i) {}

void M()
{
    new C$$ (DateTime.MaxValue).ToString();
}",
1690
                MainDescription($"C.C(DateTime dt) (+ 2 {FeaturesResources.Overloads})"));
1691 1692 1693 1694 1695
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
1696
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1697
        public async Task Constructor_OverloadFromStringLiteral()
1698
        {
C
Cyrus Najmabadi 已提交
1699
            await TestInMethodAsync(@"new InvalidOperatio$$nException("""");",
1700
                MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.Overloads})"));
1701 1702 1703 1704 1705
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
1706
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1707
        public async Task Constructor_UnknownType()
1708
        {
C
Cyrus Najmabadi 已提交
1709
            await TestInvalidTypeInClassAsync(@"void M() { new F$$oo(); }");
1710 1711 1712 1713 1714
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
1715
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1716
        public async Task Constructor_OverloadFromProperty()
1717
        {
C
Cyrus Najmabadi 已提交
1718
            await TestInMethodAsync(@"new InvalidOperatio$$nException(this.GetType().Name);",
1719
                MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.Overloads})"));
1720 1721
        }

1722
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1723
        public async Task Constructor_Metadata()
1724
        {
C
Cyrus Najmabadi 已提交
1725
            await TestInMethodAsync(@"new Argument$$NullException();",
1726
                MainDescription($"ArgumentNullException.ArgumentNullException() (+ 3 {FeaturesResources.Overloads})"));
1727 1728
        }

1729
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1730
        public async Task Constructor_MetadataQualified()
1731
        {
C
Cyrus Najmabadi 已提交
1732
            await TestInMethodAsync(@"new System.IO.File$$Info(null);",
1733 1734 1735
                MainDescription("System.IO.FileInfo.FileInfo(string fileName)"));
        }

1736
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1737
        public async Task InterfaceProperty()
1738
        {
C
Cyrus Najmabadi 已提交
1739
            await TestInMethodAsync(@"
1740 1741 1742 1743 1744 1745 1746
interface I
{
    string Name$$ { get; set; }
}",
                MainDescription("string I.Name { get; set; }"));
        }

1747
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1748
        public async Task ExplicitInterfacePropertyImplementation()
1749
        {
C
Cyrus Najmabadi 已提交
1750
            await TestInMethodAsync(@"
1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766
interface I
{
    string Name { get; set; }
}

class C : I
{
    string IEmployee.Name$$
    {
       get { return """"; }
       set { }
    }
}",
                MainDescription("string C.Name { get; set; }"));
        }

1767
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1768
        public async Task Operator()
1769
        {
C
Cyrus Najmabadi 已提交
1770
            await TestInClassAsync(@"
1771 1772 1773 1774 1775 1776 1777
public static C operator +(C left, C right) { return null; }
void M(C left, C right) { return left +$$ right; }
",
                MainDescription("C C.operator +(C left, C right)"));
        }

        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
1778
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1779
        public async Task GenericMethodWithConstraintsAtDeclaration()
1780
        {
C
Cyrus Najmabadi 已提交
1781
            await TestInClassAsync(@"TOut F$$oo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn> {
1782 1783 1784 1785 1786 1787
}",

            MainDescription("TOut C.Foo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn>"));
        }

        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
1788
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1789
        public async Task GenericMethodWithMultipleConstraintsAtDeclaration()
1790
        {
C
Cyrus Najmabadi 已提交
1791
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) where TIn : Employee, new()
1792 1793 1794 1795 1796 1797 1798 1799 1800
{
    Fo$$o<TIn, TOut>(default(TIn);
}
",

            MainDescription("TOut C.Foo<TIn, TOut>(TIn arg) where TIn : Employee, new()"));
        }

        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
1801
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1802
        public async Task UnConstructedGenericMethodWithConstraintsAtInvocation()
1803
        {
C
Cyrus Najmabadi 已提交
1804
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) where TIn : Employee
1805 1806 1807 1808 1809 1810 1811 1812
{
    Fo$$o<TIn, TOut>(default(TIn);
}
",

            MainDescription("TOut C.Foo<TIn, TOut>(TIn arg) where TIn : Employee"));
        }

1813
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1814
        public async Task GenericTypeWithConstraintsAtDeclaration()
1815
        {
C
Cyrus Najmabadi 已提交
1816
            await TestAsync(@"public class Employee : IComparable<Employee>
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829
{
    public int CompareTo(Employee other)
    {
        throw new NotImplementedException();
    }
}
class Emplo$$yeeList<T> : IEnumerable<T> where T : Employee, System.IComparable<T>, new()
{
}",

            MainDescription("class EmployeeList<T> where T : Employee, System.IComparable<T>, new()"));
        }

1830
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1831
        public async Task GenericType()
1832
        {
C
Cyrus Najmabadi 已提交
1833
            await TestAsync(@"
1834 1835 1836 1837 1838
class T1<T11>
{
    $$T11 i;
}
",
1839
                MainDescription($"T11 {FeaturesResources.In} T1<T11>"));
1840 1841
        }

1842
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1843
        public async Task GenericMethod()
1844
        {
C
Cyrus Najmabadi 已提交
1845
            await TestInClassAsync(@"
1846 1847 1848 1849 1850
    static void Meth1<T1>(T1 i) where T1 : struct
    {
        $$T1 i;
    }
",
1851
                MainDescription($"T1 {FeaturesResources.In} C.Meth1<T1> where T1 : struct"));
1852 1853
        }

1854
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1855
        public async Task Var()
1856
        {
C
Cyrus Najmabadi 已提交
1857
            await TestInMethodAsync(@"
1858 1859 1860
var x = new Exception();
var y = $$x;
",
1861
                MainDescription($"({FeaturesResources.LocalVariable}) Exception x"));
1862 1863
        }

1864
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1865
        public async Task NestedInGeneric()
1866
        {
C
Cyrus Najmabadi 已提交
1867
            await TestInMethodAsync(@"
1868 1869 1870
            List<int>.Enu$$merator e;
",
                MainDescription("struct System.Collections.Generic.List<T>.Enumerator"),
1871
                TypeParameterMap($"\r\nT {FeaturesResources.Is} int"));
1872 1873
        }

1874
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1875
        public async Task NestedGenericInGeneric()
1876
        {
C
Cyrus Najmabadi 已提交
1877
            await TestAsync(@"
1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891
            class Outer<T>
{
    class Inner<U>
    {
    }

    static void M()
    {
        Outer<int>.I$$nner<string> e;
    }
}
",
                MainDescription("class Outer<T>.Inner<U>"),
                TypeParameterMap(
1892 1893
                    Lines($"\r\nT {FeaturesResources.Is} int",
                          $"U {FeaturesResources.Is} string")));
1894 1895
        }

1896
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1897
        public async Task ObjectInitializer1()
1898
        {
C
Cyrus Najmabadi 已提交
1899
            await TestInClassAsync(@"
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
    void M()
    {
        var x = new test() { $$z = 5 };
    }

    class test
    {
        public int z;
    }
",
1910
                MainDescription($"({FeaturesResources.Field}) int test.z"));
1911 1912
        }

1913
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1914
        public async Task ObjectInitializer2()
1915
        {
C
Cyrus Najmabadi 已提交
1916
            await TestInMethodAsync(@"
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932
class C
{
    void M()
    {
        var x = new test() { z = $$5 };
    }

    class test
    {
        public int z;
    }
}
",
                MainDescription("struct System.Int32"));
        }

1933
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
1934
        [WorkItem(537880)]
C
Cyrus Najmabadi 已提交
1935
        public async Task TypeArgument()
1936
        {
C
Cyrus Najmabadi 已提交
1937
            await TestAsync(@"
1938 1939 1940 1941 1942 1943 1944 1945
class C<T, Y>
{
    void M()
    {
        C<int, DateTime> variable;
        $$variable = new C<int, DateTime>();
    }
}",
1946
                MainDescription($"({FeaturesResources.LocalVariable}) C<int, DateTime> variable"));
1947 1948
        }

1949
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1950
        public async Task ForEachLoop_1()
1951
        {
C
Cyrus Najmabadi 已提交
1952
            await TestInMethodAsync(@"
1953 1954 1955 1956 1957 1958 1959
int bb = 555;
bb = bb + 1;
foreach (int cc in new int[]{ 1,2,3}){
c$$c = 1;
bb = bb + 21;
}
",
1960
                MainDescription($"({FeaturesResources.LocalVariable}) int cc"));
1961 1962
        }

1963
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1964
        public async Task TryCatchFinally_1()
1965
        {
C
Cyrus Najmabadi 已提交
1966
            await TestInMethodAsync(@"
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977
            try
            {
                int aa = 555;
                a$$a = aa + 1;
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }",
1978
                MainDescription($"({FeaturesResources.LocalVariable}) int aa"));
1979 1980
        }

1981
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1982
        public async Task TryCatchFinally_2()
1983
        {
C
Cyrus Najmabadi 已提交
1984
            await TestInMethodAsync(@"
1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996
            try
            {
            }
            catch (Exception ex)
            {
                var y = e$$x;
                var z = y;
            }
            finally
            {
            }
",
1997
                MainDescription($"({FeaturesResources.LocalVariable}) Exception ex"));
1998 1999
        }

2000
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2001
        public async Task TryCatchFinally_3()
2002
        {
C
Cyrus Najmabadi 已提交
2003
            await TestInMethodAsync(@"
2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015
            try
            {
            }
            catch (Exception ex)
            {
                var aa = 555;
                aa = a$$a + 1;
            }
            finally
            {
            }
",
2016
                MainDescription($"({FeaturesResources.LocalVariable}) int aa"));
2017 2018
        }

2019
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2020
        public async Task TryCatchFinally_4()
2021
        {
C
Cyrus Najmabadi 已提交
2022
            await TestInMethodAsync(@"
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034
            try
            {
            }
            catch (Exception ex)
            {
            }
            finally
            {
                int aa = 555;
                aa = a$$a + 1;
            }
",
2035
                MainDescription($"({FeaturesResources.LocalVariable}) int aa"));
2036 2037
        }

2038
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2039
        public async Task GenericVariable()
2040
        {
C
Cyrus Najmabadi 已提交
2041
            await TestAsync(@"
2042 2043 2044 2045 2046 2047 2048 2049 2050
            class C<T, Y>
            {
                void M()
                {
                    C<int, DateTime> variable;
                    var$$iable = new C<int, DateTime>();
                }
            }
",
2051
                MainDescription($"({FeaturesResources.LocalVariable}) C<int, DateTime> variable"));
2052 2053
        }

2054
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2055
        public async Task TestInstantiation()
2056
        {
C
Cyrus Najmabadi 已提交
2057
            await TestAsync(@"
2058 2059 2060 2061 2062 2063 2064 2065
using System.Collections.Generic;
class Program<T>
{
    static void Main(string[] args)
    {
        var p = new Dictio$$nary<int, string>();
    }
}",
2066
                MainDescription($"Dictionary<int, string>.Dictionary() (+ 5 {FeaturesResources.Overloads})"));
2067 2068
        }

2069
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2070
        public async Task TestUsingAlias_Bug4141()
2071
        {
C
Cyrus Najmabadi 已提交
2072
            await TestAsync(@"using X = A.C;
2073 2074 2075 2076 2077 2078 2079 2080
class A {
public class C { }
}
class D : X$$ { }
",
                MainDescription(@"class A.C"));
        }

2081
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2082
        public async Task TestFieldOnDeclaration()
2083
        {
C
Cyrus Najmabadi 已提交
2084
            await TestInClassAsync(@"
2085
DateTime fie$$ld;",
2086
                MainDescription($"({FeaturesResources.Field}) DateTime C.field"));
2087 2088 2089
        }

        [WorkItem(538767)]
2090
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2091
        public async Task TestGenericErrorFieldOnDeclaration()
2092
        {
C
Cyrus Najmabadi 已提交
2093
            await TestInClassAsync(@"
2094
NonExistentType<int> fi$$eld;",
2095
                MainDescription($"({FeaturesResources.Field}) NonExistentType<int> C.field"));
2096 2097 2098
        }

        [WorkItem(538822)]
2099
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2100
        public async Task TestDelegateType()
2101
        {
C
Cyrus Najmabadi 已提交
2102
            await TestInClassAsync(@"
2103 2104 2105
Fun$$c<int, string> field;",
                MainDescription("delegate TResult System.Func<in T, out TResult>(T arg)"),
                TypeParameterMap(
2106 2107
                    Lines($"\r\nT {FeaturesResources.Is} int",
                          $"TResult {FeaturesResources.Is} string")));
2108 2109 2110
        }

        [WorkItem(538824)]
2111
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2112
        public async Task TestOnDelegateInvocation()
2113
        {
C
Cyrus Najmabadi 已提交
2114
            await TestAsync(@"
2115 2116 2117 2118 2119 2120 2121 2122 2123 2124
class Program
{
    delegate void D1();
    static void Main()
    {
        D1 d = Main;
        $$d(); 
    }
}
",
2125
                MainDescription($"({FeaturesResources.LocalVariable}) D1 d"));
2126 2127 2128
        }

        [WorkItem(539240)]
2129
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2130
        public async Task TestOnArrayCreation1()
2131
        {
C
Cyrus Najmabadi 已提交
2132
            await TestAsync(@"
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142
class Program
{
    static void Main()
    {
        int[] a = n$$ew int[0];
    }
}");
        }

        [WorkItem(539240)]
2143
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2144
        public async Task TestOnArrayCreation2()
2145
        {
C
Cyrus Najmabadi 已提交
2146
            await TestAsync(@"
2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157
class Program
{
    static void Main()
    {
        int[] a = new i$$nt[0];
    }
}",
                MainDescription("struct System.Int32"));
        }

        [WorkItem(539841)]
2158
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2159
        public async Task TestIsNamedTypeAccessibleForErrorTypes()
2160
        {
C
Cyrus Najmabadi 已提交
2161
            await TestAsync(@"sealed class B<T1, T2> : A<B<T1, T2>>{
2162 2163 2164 2165 2166
    protected sealed override B<A<T>, A$$<T>> N() { }} internal class A<T>{}",
                MainDescription("class A<T>"));
        }

        [WorkItem(540075)]
2167
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2168
        public async Task TestErrorType()
2169
        {
C
Cyrus Najmabadi 已提交
2170
            await TestAsync(@"using Foo = Foo;
2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181
class C
{
    void Main()
    {
        $$Foo
    }
}",
                MainDescription("Foo"));
        }

        [WorkItem(540871)]
2182
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2183
        public async Task TestLiterals()
2184
        {
C
Cyrus Najmabadi 已提交
2185
            await TestAsync(@"class MyClass
2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205
{
    MyClass()
        : this($$10)
    {
        intI = 2;
    }
 
    public MyClass(int i) { }
 
    static int intI = 1;
 
    public static int Main()
    {
        return 1;
    }
}",
                MainDescription("struct System.Int32"));
        }

        [WorkItem(541444)]
2206
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2207
        public async Task TestErrorInForeach()
2208
        {
C
Cyrus Najmabadi 已提交
2209
            await TestAsync(@"
2210 2211 2212 2213 2214 2215 2216 2217 2218 2219
class C
{
    void Main()
    {
        foreach (int cc in null)
        {
            $$cc = 1;
        }
    }
}",
2220
                MainDescription($"({FeaturesResources.LocalVariable}) int cc"));
2221 2222 2223
        }

        [WorkItem(540438)]
2224
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2225
        public async Task TestNoQuickInfoOnAnonymousDelegate()
2226
        {
C
Cyrus Najmabadi 已提交
2227
            await TestAsync(@"
2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239
using System;

class Program
{
    static void Main(string[] args)
    {
        Action a = $$delegate { };
    }
}");
        }

        [WorkItem(541678)]
2240
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2241
        public async Task TestQuickInfoOnEvent()
2242
        {
C
Cyrus Najmabadi 已提交
2243
            await TestAsync(@"
2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266
using System;
 
public class SampleEventArgs
{
    public SampleEventArgs(string s) { Text = s; }
    public String Text { get; private set; } 
}
public class Publisher
{
    public delegate void SampleEventHandler(object sender, SampleEventArgs e);
    public event SampleEventHandler SampleEvent;
 
    protected virtual void RaiseSampleEvent()
    {
        if (Sam$$pleEvent != null)
            SampleEvent(this, new SampleEventArgs(""Hello""));
    }
}
",
                MainDescription("SampleEventHandler Publisher.SampleEvent"));
        }

        [WorkItem(542157)]
2267
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2268
        public async Task TestEvent()
2269
        {
C
Cyrus Najmabadi 已提交
2270
            await TestInMethodAsync(@"System.Console.CancelKeyPres$$s += null;",
2271 2272 2273 2274
                MainDescription("ConsoleCancelEventHandler Console.CancelKeyPress"));
        }

        [WorkItem(542157)]
2275
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2276
        public async Task TestEventPlusEqualsOperator()
2277
        {
C
Cyrus Najmabadi 已提交
2278
            await TestInMethodAsync(@"System.Console.CancelKeyPress +$$= null;",
2279 2280 2281 2282
                MainDescription("void Console.CancelKeyPress.add"));
        }

        [WorkItem(542157)]
2283
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2284
        public async Task TestEventMinusEqualsOperator()
2285
        {
C
Cyrus Najmabadi 已提交
2286
            await TestInMethodAsync(@"System.Console.CancelKeyPress -$$= null;",
2287 2288 2289 2290
                MainDescription("void Console.CancelKeyPress.remove"));
        }

        [WorkItem(541885)]
2291
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2292
        public async Task TestQuickInfoOnExtensionMethod()
2293
        {
C
Cyrus Najmabadi 已提交
2294
            await TestWithOptionsAsync(Options.Regular, @"
2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
        int[] values = { 1 };
        bool isArray = 7.I$$n(values);
    }
}
 
public static class MyExtensions
{
    public static bool In<T>(this T o, IEnumerable<T> items)
    {
        return true;
    }
}
",
2316
                MainDescription($"({CSharpFeaturesResources.Extension}) bool int.In<int>(IEnumerable<int> items)"));
2317 2318
        }

2319
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2320
        public async Task TestQuickInfoOnExtensionMethodOverloads()
2321
        {
C
Cyrus Najmabadi 已提交
2322
            await TestWithOptionsAsync(Options.Regular, @"
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
       ""1"".Test$$Ext();
    }
}
 
public static class Ex
{
    public static void TestExt<T>(this T ex) { }
    public static void TestExt<T>(this T ex, T arg) { }
    public static void TestExt(this string ex, int arg) { }
}
",
2341
                MainDescription($"({CSharpFeaturesResources.Extension}) void string.TestExt<string>() (+ 2 {FeaturesResources.Overloads})"));
2342 2343
        }

2344
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2345
        public async Task TestQuickInfoOnExtensionMethodOverloads2()
2346
        {
C
Cyrus Najmabadi 已提交
2347
            await TestWithOptionsAsync(Options.Regular, @"
2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
       ""1"".Test$$Ext();
    }
}
 
public static class Ex
{
    public static void TestExt<T>(this T ex) { }
    public static void TestExt<T>(this T ex, T arg) { }
    public static void TestExt(this int ex, int arg) { }
}
",
2366
                MainDescription($"({CSharpFeaturesResources.Extension}) void string.TestExt<string>() (+ 1 {FeaturesResources.Overload})"));
2367 2368
        }

2369
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2370
        public async Task Query1()
2371
        {
C
Cyrus Najmabadi 已提交
2372
            await TestAsync(@"
2373 2374 2375 2376 2377 2378 2379 2380 2381 2382
using System.Linq;
class C
{
    void M()
    {
        var q = from n in new int[] { 1, 2, 3, 4, 5}
                select $$n;
    }
}
",
2383
                MainDescription($"({FeaturesResources.RangeVariable}) int n"));
2384 2385
        }

2386
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2387
        public async Task Query2()
2388
        {
C
Cyrus Najmabadi 已提交
2389
            await TestAsync(@"
2390 2391 2392 2393 2394 2395 2396 2397 2398 2399
using System.Linq;
class C
{
    void M()
    {
        var q = from n$$ in new int[] { 1, 2, 3, 4, 5}
                select n;
    }
}
",
2400
                MainDescription($"({FeaturesResources.RangeVariable}) int n"));
2401 2402
        }

2403
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2404
        public async Task Query3()
2405
        {
C
Cyrus Najmabadi 已提交
2406
            await TestAsync(@"
2407 2408 2409 2410 2411 2412 2413 2414 2415
class C
{
    void M()
    {
        var q = from n in new int[] { 1, 2, 3, 4, 5}
                select $$n;
    }
}
",
2416
                MainDescription($"({FeaturesResources.RangeVariable}) ? n"));
2417 2418
        }

2419
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2420
        public async Task Query4()
2421
        {
C
Cyrus Najmabadi 已提交
2422
            await TestAsync(@"
2423 2424 2425 2426 2427 2428 2429 2430 2431
class C
{
    void M()
    {
        var q = from n$$ in new int[] { 1, 2, 3, 4, 5}
                select n;
    }
}
",
2432
                MainDescription($"({FeaturesResources.RangeVariable}) ? n"));
2433 2434
        }

2435
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2436
        public async Task Query5()
2437
        {
C
Cyrus Najmabadi 已提交
2438
            await TestAsync(@"
2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from n in new List<object>()
                select $$n;
    }
}
",
2450
                MainDescription($"({FeaturesResources.RangeVariable}) object n"));
2451 2452
        }

2453
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2454
        public async Task Query6()
2455
        {
C
Cyrus Najmabadi 已提交
2456
            await TestAsync(@"
2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from n$$ in new List<object>()
                select n;
    }
}
",
2468
                MainDescription($"({FeaturesResources.RangeVariable}) object n"));
2469 2470
        }

2471
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2472
        public async Task Query7()
2473
        {
C
Cyrus Najmabadi 已提交
2474
            await TestAsync(@"
2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from int n in new List<object>()
                select $$n;
    }
}
",
2486
                MainDescription($"({FeaturesResources.RangeVariable}) int n"));
2487 2488
        }

2489
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2490
        public async Task Query8()
2491
        {
C
Cyrus Najmabadi 已提交
2492
            await TestAsync(@"
2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from int n$$ in new List<object>()
                select n;
    }
}
",
2504
                MainDescription($"({FeaturesResources.RangeVariable}) int n"));
2505 2506
        }

2507
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2508
        public async Task Query9()
2509
        {
C
Cyrus Najmabadi 已提交
2510
            await TestAsync(@"
2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from x$$ in new List<List<int>>()
                from y in x
                select y;
    }
}
",
2523
                MainDescription($"({FeaturesResources.RangeVariable}) List<int> x"));
2524 2525
        }

2526
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2527
        public async Task Query10()
2528
        {
C
Cyrus Najmabadi 已提交
2529
            await TestAsync(@"
2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y in $$x
                select y;
    }
}
",
2542
                MainDescription($"({FeaturesResources.RangeVariable}) List<int> x"));
2543 2544
        }

2545
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2546
        public async Task Query11()
2547
        {
C
Cyrus Najmabadi 已提交
2548
            await TestAsync(@"
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y$$ in x
                select y;
    }
}
",
2561
                MainDescription($"({FeaturesResources.RangeVariable}) int y"));
2562 2563
        }

2564
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2565
        public async Task Query12()
2566
        {
C
Cyrus Najmabadi 已提交
2567
            await TestAsync(@"
2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y in x
                select $$y;
    }
}
",
2580
                MainDescription($"({FeaturesResources.RangeVariable}) int y"));
2581 2582 2583
        }

        [WorkItem(543205)]
2584
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2585
        public async Task TestErrorGlobal()
2586
        {
C
Cyrus Najmabadi 已提交
2587
            await TestAsync(@"extern alias global;
2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599
 
class myClass
{
    static int Main()
    {
        $$global::otherClass oc = new global::otherClass();
        return 0;
    }
}",
                MainDescription("<global namespace>"));
        }

2600
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2601
        public async Task DontRemoveAttributeSuffixAndProduceInvalidIdentifier1()
2602
        {
C
Cyrus Najmabadi 已提交
2603
            await TestAsync(@"
2604 2605 2606 2607 2608
using System;
class classAttribute : Attribute
{
    private classAttribute x$$;
}",
2609
                MainDescription($"({FeaturesResources.Field}) classAttribute classAttribute.x"));
2610 2611 2612
        }

        [WorkItem(544026)]
2613
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2614
        public async Task DontRemoveAttributeSuffix2()
2615
        {
C
Cyrus Najmabadi 已提交
2616
            await TestAsync(@"
2617 2618 2619 2620 2621
using System;
class class1Attribute : Attribute
{
    private class1Attribute x$$;
}",
2622
                MainDescription($"({FeaturesResources.Field}) class1Attribute class1Attribute.x"));
2623 2624
        }

2625
        [WorkItem(1696, "https://github.com/dotnet/roslyn/issues/1696")]
2626
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2627
        public async Task AttributeQuickInfoBindsToClassTest()
2628
        {
C
Cyrus Najmabadi 已提交
2629
            await TestAsync(@"
2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649
using System;

/// <summary>
/// class comment
/// </summary>
[Some$$]
class SomeAttribute : Attribute
{
    /// <summary>
    /// ctor comment
    /// </summary>
    public SomeAttribute()
    {
    }
}
",
                Documentation("class comment"));
        }

        [WorkItem(1696, "https://github.com/dotnet/roslyn/issues/1696")]
2650
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2651
        public async Task AttributeConstructorQuickInfo()
2652
        {
C
Cyrus Najmabadi 已提交
2653
            await TestAsync(@"
2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672
using System;

/// <summary>
/// class comment
/// </summary>
class SomeAttribute : Attribute
{
    /// <summary>
    /// ctor comment
    /// </summary>
    public SomeAttribute()
    {
        var s = new Some$$Attribute();
    }
}
",
                Documentation("ctor comment"));
        }

2673
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2674
        public async Task TestLabel()
2675
        {
C
Cyrus Najmabadi 已提交
2676
            await TestInClassAsync(@"void M() { Foo: int Foo; goto Foo$$; }",
2677
                MainDescription($"({FeaturesResources.Label}) Foo"));
2678 2679 2680
        }

        [WorkItem(542613)]
2681
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2682
        public async Task TestUnboundGeneric()
2683
        {
C
Cyrus Najmabadi 已提交
2684
            await TestAsync(@"
2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698
using System;
using System.Collections.Generic;
class C
{
    void M()
    {
        Type t = typeof(L$$ist<>);
    }
}",
                MainDescription("class System.Collections.Generic.List<T>"),
                NoTypeParameterMap);
        }

        [WorkItem(543113)]
2699
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2700
        public async Task TestAnonymousTypeNew1()
2701
        {
C
Cyrus Najmabadi 已提交
2702
            await TestAsync(@"
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712
class C
{
    void M()
    {
        var v = $$new { };
    }
}",
                MainDescription(@"AnonymousType 'a"),
                NoTypeParameterMap,
                AnonymousTypes(
2713 2714 2715
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{  }}"));
2716 2717 2718
        }

        [WorkItem(543873)]
2719
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2720
        public async Task TestNestedAnonymousType()
2721 2722 2723
        {
            // verify nested anonymous types are listed in the same order for different properties
            // verify first property
C
Cyrus Najmabadi 已提交
2724
            await TestInMethodAsync(@"var x = new[] { new { Name = ""BillG"", Address = new { Street = ""1 Microsoft Way"", Zip = ""98052"" } } }; x[0].$$Address",
2725 2726 2727
                MainDescription(@"'b 'a.Address { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
2728 2729 2730 2731
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{ string Name, 'b Address }}
    'b {FeaturesResources.Is} new {{ string Street, string Zip }}"));
2732 2733

            // verify second property
C
Cyrus Najmabadi 已提交
2734
            await TestInMethodAsync(@"var x = new[] { new { Name = ""BillG"", Address = new { Street = ""1 Microsoft Way"", Zip = ""98052"" } } }; x[0].$$Name",
2735 2736 2737
                MainDescription(@"string 'a.Name { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
2738 2739 2740 2741
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{ string Name, 'b Address }}
    'b {FeaturesResources.Is} new {{ string Street, string Zip }}"));
2742 2743
        }

2744
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
2745
        [WorkItem(543183)]
C
Cyrus Najmabadi 已提交
2746
        public async Task TestAssignmentOperatorInAnonymousType()
2747
        {
C
Cyrus Najmabadi 已提交
2748
            await TestAsync(@"class C
2749 2750 2751 2752 2753 2754 2755 2756 2757
{
    void M()
    {
        var a = new { A $$= 0 };
    }
}
");
        }

2758
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
2759
        [WorkItem(10731, "DevDiv_Projects/Roslyn")]
C
Cyrus Najmabadi 已提交
2760
        public async Task TestErrorAnonymousTypeDoesntShow()
2761
        {
C
Cyrus Najmabadi 已提交
2762
            await TestInMethodAsync(@"var a = new { new { N = 0 }.N, new { } }.$$N;",
2763 2764 2765
                MainDescription(@"int 'a.N { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
2766 2767 2768
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{ int N }}"));
2769 2770
        }

2771
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
2772
        [WorkItem(543553)]
C
Cyrus Najmabadi 已提交
2773
        public async Task TestArrayAssignedToVar()
2774
        {
C
Cyrus Najmabadi 已提交
2775
            await TestAsync(@"class C
2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786
{
    static void M(string[] args)
    {
        v$$ar a = args;
    }
}
",
                MainDescription("string[]"));
        }

        [WorkItem(529139)]
2787
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2788
        public async Task ColorColorRangeVariable()
2789
        {
C
Cyrus Najmabadi 已提交
2790
            await TestAsync(@"
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
using System.Collections.Generic;
using System.Linq;

namespace N1
{
    class yield
    {
        public static IEnumerable<yield> Bar()
        {
            foreach (yield yield in from yield in new yield[0]
                                    select y$$ield)
            {
                yield return yield;
            }
        }
    }
}
",
2809
                MainDescription($"({FeaturesResources.RangeVariable}) N1.yield yield"));
2810 2811 2812
        }

        [WorkItem(543550)]
2813
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2814
        public async Task QuickInfoOnOperator()
2815
        {
C
Cyrus Najmabadi 已提交
2816
            await TestAsync(@"using System.Collections.Generic;
2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839
 
class Program
{
    static void Main(string[] args)
    {
        var v = new Program() $$+ string.Empty;
    }
 
    public static implicit operator Program(string s)
    {
        return null;
    }
 
    public static IEnumerable<Program> operator +(Program p1, Program p2)
    {
        yield return p1;
        yield return p2;
    }
}
",
                MainDescription("IEnumerable<Program> Program.operator +(Program p1, Program p2)"));
        }

2840
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2841
        public async Task TestConstantField()
2842
        {
C
Cyrus Najmabadi 已提交
2843
            await TestAsync("class C { const int $$F = 1;",
2844
                MainDescription($"({FeaturesResources.Constant}) int C.F = 1"));
2845 2846
        }

2847
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2848
        public async Task TestMultipleConstantFields()
2849
        {
C
Cyrus Najmabadi 已提交
2850
            await TestAsync("class C { public const double X = 1.0, Y = 2.0, $$Z = 3.5;",
2851
                MainDescription($"({FeaturesResources.Constant}) double C.Z = 3.5"));
2852 2853
        }

2854
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2855
        public async Task TestConstantDependencies()
2856
        {
C
Cyrus Najmabadi 已提交
2857
            await TestAsync(@"class A
2858 2859 2860 2861 2862 2863 2864 2865
{
    public const int $$X = B.Z + 1;
    public const int Y = 10;
}
class B
{
    public const int Z = A.Y + 1;
}",
2866
                MainDescription($"({FeaturesResources.Constant}) int A.X = B.Z + 1"));
2867 2868
        }

2869
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2870
        public async Task TestConstantCircularDependencies()
2871
        {
C
Cyrus Najmabadi 已提交
2872
            await TestAsync(@"class A
2873 2874 2875 2876 2877 2878 2879
{
    public const int X = B.Z + 1;
}
class B
{
    public const int Z$$ = A.X + 1;
}",
2880
                MainDescription($"({FeaturesResources.Constant}) int B.Z = A.X + 1"));
2881 2882 2883
        }

        [WorkItem(544620)]
2884
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2885
        public async Task TestConstantOverflow()
2886
        {
C
Cyrus Najmabadi 已提交
2887
            await TestAsync(@"class B
2888 2889 2890
{
    public const int Z$$ = int.MaxValue + 1;
}",
2891
                MainDescription($"({FeaturesResources.Constant}) int B.Z = int.MaxValue + 1"));
2892 2893 2894
        }

        [WorkItem(544620)]
2895
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2896
        public async Task TestConstantOverflowInUncheckedContext()
2897
        {
C
Cyrus Najmabadi 已提交
2898
            await TestAsync(@"class B
2899 2900 2901
{
    public const int Z$$ = unchecked(int.MaxValue + 1);
}",
2902
                MainDescription($"({FeaturesResources.Constant}) int B.Z = unchecked(int.MaxValue + 1)"));
2903 2904
        }

2905
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2906
        public async Task TestEnumInConstantField()
2907
        {
C
Cyrus Najmabadi 已提交
2908
            await TestAsync(@"public class EnumTest
2909 2910 2911 2912 2913 2914 2915
{
    enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
    static void Main()
    {
        const int $$x = (int)Days.Sun;
    }
}",
2916
                MainDescription($"({FeaturesResources.LocalConstant}) int x = (int)Days.Sun"));
2917 2918
        }

2919
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2920
        public async Task TestConstantInDefaultExpression()
2921
        {
C
Cyrus Najmabadi 已提交
2922
            await TestAsync(@"public class EnumTest
2923 2924 2925 2926 2927 2928 2929
{
    enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
    static void Main()
    {
        const Days $$x = default(Days);
    }
}",
2930
                MainDescription($"({FeaturesResources.LocalConstant}) Days x = default(Days)"));
2931 2932
        }

2933
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2934
        public async Task TestConstantParameter()
2935
        {
C
Cyrus Najmabadi 已提交
2936
            await TestAsync("class C { void Bar(int $$b = 1); }",
2937
                MainDescription($"({FeaturesResources.Parameter}) int b = 1"));
2938 2939
        }

2940
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2941
        public async Task TestConstantLocal()
2942
        {
C
Cyrus Najmabadi 已提交
2943
            await TestAsync("class C { void Bar() { const int $$loc = 1; }",
2944
                MainDescription($"({FeaturesResources.LocalConstant}) int loc = 1"));
2945 2946 2947
        }

        [WorkItem(544416)]
2948
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2949
        public async Task TestErrorType1()
2950
        {
C
Cyrus Najmabadi 已提交
2951
            await TestInMethodAsync("var $$v1 = new Foo();",
2952
                MainDescription($"({FeaturesResources.LocalVariable}) Foo v1"));
2953 2954 2955
        }

        [WorkItem(544416)]
2956
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2957
        public async Task TestErrorType2()
2958
        {
C
Cyrus Najmabadi 已提交
2959
            await TestInMethodAsync("var $$v1 = v1;",
2960
                MainDescription($"({FeaturesResources.LocalVariable}) var v1"));
2961 2962 2963
        }

        [WorkItem(544416)]
2964
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2965
        public async Task TestErrorType3()
2966
        {
C
Cyrus Najmabadi 已提交
2967
            await TestInMethodAsync("var $$v1 = new Foo<Bar>();",
2968
                MainDescription($"({FeaturesResources.LocalVariable}) Foo<Bar> v1"));
2969 2970 2971
        }

        [WorkItem(544416)]
2972
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2973
        public async Task TestErrorType4()
2974
        {
C
Cyrus Najmabadi 已提交
2975
            await TestInMethodAsync("var $$v1 = &(x => x);",
2976
                MainDescription($"({FeaturesResources.LocalVariable}) ?* v1"));
2977 2978 2979
        }

        [WorkItem(544416)]
2980
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2981
        public async Task TestErrorType5()
2982
        {
C
Cyrus Najmabadi 已提交
2983
            await TestInMethodAsync("var $$v1 = &v1",
2984
                MainDescription($"({FeaturesResources.LocalVariable}) var* v1"));
2985 2986 2987
        }

        [WorkItem(544416)]
2988
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2989
        public async Task TestErrorType6()
2990
        {
C
Cyrus Najmabadi 已提交
2991
            await TestInMethodAsync("var $$v1 = new Foo[1]",
2992
                MainDescription($"({FeaturesResources.LocalVariable}) Foo[] v1"));
2993 2994 2995
        }

        [WorkItem(544416)]
2996
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2997
        public async Task TestErrorType7()
2998
        {
C
Cyrus Najmabadi 已提交
2999
            await TestInClassAsync("class C { void Method() { } void Foo() { var $$v1 = MethodGroup; } }",
3000
                MainDescription($"({FeaturesResources.LocalVariable}) ? v1"));
3001 3002 3003
        }

        [WorkItem(544416)]
3004
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3005
        public async Task TestErrorType8()
3006
        {
C
Cyrus Najmabadi 已提交
3007
            await TestInMethodAsync("var $$v1 = Unknown",
3008
                MainDescription($"({FeaturesResources.LocalVariable}) ? v1"));
3009 3010 3011
        }

        [WorkItem(545072)]
3012
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3013
        public async Task TestDelegateSpecialTypes()
3014
        {
C
Cyrus Najmabadi 已提交
3015
            await TestAsync("delegate void $$F(int x);",
3016 3017 3018 3019
                MainDescription("delegate void F(int x)"));
        }

        [WorkItem(545108)]
3020
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3021
        public async Task TestNullPointerParameter()
3022
        {
C
Cyrus Najmabadi 已提交
3023
            await TestAsync("class C { unsafe void $$Foo(int* x = null) { } }",
3024 3025 3026 3027
                MainDescription("void C.Foo([int* x = null])"));
        }

        [WorkItem(545098)]
3028
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3029
        public async Task TestLetIdentifier1()
3030
        {
C
Cyrus Najmabadi 已提交
3031
            await TestInMethodAsync("var q = from e in \"\" let $$y = 1 let a = new { y } select a;",
3032
                MainDescription($"({FeaturesResources.RangeVariable}) int y"));
3033 3034 3035
        }

        [WorkItem(545295)]
3036
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3037
        public async Task TestNullableDefaultValue()
3038
        {
C
Cyrus Najmabadi 已提交
3039
            await TestAsync("class Test { void $$Method(int? t1 = null) { } }",
3040 3041 3042 3043
                MainDescription("void Test.Method([int? t1 = null])"));
        }

        [WorkItem(529586)]
3044
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3045
        public async Task TestInvalidParameterInitializer()
3046
        {
C
Cyrus Najmabadi 已提交
3047
            await TestAsync(
3048 3049 3050
@"class Program { void M1(float $$j1 = ""Hello""
        + 
        ""World"") { } }",
3051
                MainDescription($@"({FeaturesResources.Parameter}) float j1 = ""Hello"" + ""World"""));
3052 3053 3054
        }

        [WorkItem(545230)]
3055
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3056
        public async Task TestComplexConstLocal()
3057
        {
C
Cyrus Najmabadi 已提交
3058
            await TestAsync(
3059 3060 3061 3062 3063 3064 3065 3066 3067 3068
@"class Program
{
    void Main()
    {
        const int MEGABYTE = 1024 *
            1024 + true;
        Blah($$MEGABYTE);
    }
}
",
3069
                MainDescription($@"({FeaturesResources.LocalConstant}) int MEGABYTE = 1024 * 1024 + true"));
3070 3071 3072
        }

        [WorkItem(545230)]
3073
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3074
        public async Task TestComplexConstField()
3075
        {
C
Cyrus Najmabadi 已提交
3076
            await TestAsync(
3077 3078 3079 3080 3081 3082 3083 3084 3085 3086
@"class Program
{
    const int a = true 
        - 
        false;
    void Main()
    {
        Foo($$a);
    }
}",
3087
                MainDescription($"({FeaturesResources.Constant}) int Program.a = true - false"));
3088 3089
        }

3090
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3091
        public async Task TestTypeParameterCrefDoesNotHaveQuickInfo()
3092
        {
C
Cyrus Najmabadi 已提交
3093
            await TestAsync(
3094 3095 3096 3097 3098 3099 3100 3101 3102
@"class C<T>
{
    ///  <see cref=""C{X$$}""/>
    static void Main(string[] args)
    {
    }
}");
        }

3103
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3104
        public async Task TestCref1()
3105
        {
C
Cyrus Najmabadi 已提交
3106
            await TestAsync(
3107 3108 3109 3110 3111 3112 3113 3114 3115 3116
@"class Program
{
    ///  <see cref=""Mai$$n""/>
    static void Main(string[] args)
    {
    }
}",
                MainDescription(@"void Program.Main(string[] args)"));
        }

3117
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3118
        public async Task TestCref2()
3119
        {
C
Cyrus Najmabadi 已提交
3120
            await TestAsync(
3121 3122 3123 3124 3125 3126 3127 3128 3129 3130
@"class Program
{
    ///  <see cref=""$$Main""/>
    static void Main(string[] args)
    {
    }
}",
                MainDescription(@"void Program.Main(string[] args)"));
        }

3131
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3132
        public async Task TestCref3()
3133
        {
C
Cyrus Najmabadi 已提交
3134
            await TestAsync(
3135 3136 3137 3138 3139 3140 3141 3142 3143
@"class Program
{
    ///  <see cref=""Main""$$/>
    static void Main(string[] args)
    {
    }
}");
        }

3144
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3145
        public async Task TestCref4()
3146
        {
C
Cyrus Najmabadi 已提交
3147
            await TestAsync(
3148 3149 3150 3151 3152 3153 3154 3155 3156
@"class Program
{
    ///  <see cref=""Main$$""/>
    static void Main(string[] args)
    {
    }
}");
        }

3157
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3158
        public async Task TestCref5()
3159
        {
C
Cyrus Najmabadi 已提交
3160
            await TestAsync(
3161 3162 3163 3164 3165 3166 3167 3168 3169 3170
@"class Program
{
    ///  <see cref=""Main""$$/>
    static void Main(string[] args)
    {
    }
}");
        }

        [WorkItem(546849)]
3171
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3172
        public async Task TestIndexedProperty()
3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209
        {
            var markup = @"class Program
{
    void M()
    {
            CCC c = new CCC();
            c.Index$$Prop[0] = ""s"";
    }
}";

            // Note that <COMImport> is required by compiler.  Bug 17013 tracks enabling indexed property for non-COM types.
            var referencedCode = @"Imports System.Runtime.InteropServices
<ComImport()>
<GuidAttribute(CCC.ClassId)>
Public Class CCC

#Region ""COM GUIDs""
    Public Const ClassId As String = ""9d965fd2-1514-44f6-accd-257ce77c46b0""
    Public Const InterfaceId As String = ""a9415060-fdf0-47e3-bc80-9c18f7f39cf6""
    Public Const EventsId As String = ""c6a866a5-5f97-4b53-a5df-3739dc8ff1bb""
# End Region

    ''' <summary>
    ''' An index property from VB
    ''' </summary>
    ''' <param name=""p1"">p1 is an integer index</param>
    ''' <returns>A string</returns>
    Public Property IndexProp(ByVal p1 As Integer, Optional ByVal p2 As Integer = 0) As String
        Get
            Return Nothing
        End Get
        Set(ByVal value As String)

        End Set
    End Property
End Class";

C
Cyrus Najmabadi 已提交
3210
            await TestWithReferenceAsync(sourceCode: markup,
3211 3212 3213 3214 3215 3216 3217
                referencedCode: referencedCode,
                sourceLanguage: LanguageNames.CSharp,
                referencedLanguage: LanguageNames.VisualBasic,
                expectedResults: MainDescription("string CCC.IndexProp[int p1, [int p2 = 0]] { get; set; }"));
        }

        [WorkItem(546918)]
3218
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3219
        public async Task TestUnconstructedGeneric()
3220
        {
C
Cyrus Najmabadi 已提交
3221
            await TestAsync(
3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235
@"class A<T> {
    enum SortOrder {
        Ascending,
        Descending,
        None
    }
    void Foo() {
        var b = $$SortOrder.Ascending;
    }
}",
                MainDescription(@"enum A<T>.SortOrder"));
        }

        [WorkItem(546970)]
3236
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3237
        public async Task TestUnconstructedGenericInCRef()
3238
        {
C
Cyrus Najmabadi 已提交
3239
            await TestAsync(
3240 3241 3242 3243 3244 3245 3246
@"
/// <see cref=""$$C{T}"" />
class C<T> { }
",
                MainDescription(@"class C<T>"));
        }

3247
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3248
        public async Task TestAwaitableMethod()
3249 3250 3251 3252 3253 3254 3255 3256 3257
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    async Task Foo()
    {
        Fo$$o();
    }
}";
3258
            var description = $"({CSharpFeaturesResources.Awaitable}) Task C.Foo()";
3259

3260
            var documentation = $@"
3261
{WorkspacesResources.Usage}
3262
  {CSharpFeaturesResources.Await} Foo();";
3263

C
Cyrus Najmabadi 已提交
3264
            await VerifyWithMscorlib45Async(markup, new[] { MainDescription(description), Usage(documentation) });
3265 3266
        }

3267
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3268
        public async Task ObsoleteItem()
3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280
        {
            var markup = @"
using System;

class Program
{
    [Obsolete]
    public void foo()
    {
        fo$$o();
    }
}";
C
Cyrus Najmabadi 已提交
3281
            await TestAsync(markup, MainDescription($"[{CSharpFeaturesResources.Deprecated}] void Program.foo()"));
3282 3283 3284
        }

        [WorkItem(751070)]
3285
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3286
        public async Task DynamicOperator()
3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301
        {
            var markup = @"

public class Test
{
    public delegate void NoParam();

    static int Main()
    {
        dynamic x = new object();
        if (((System.Func<dynamic>)(() => (x =$$= null)))())
            return 0;
        return 1;
    }
}";
C
Cyrus Najmabadi 已提交
3302
            await TestAsync(markup, MainDescription("dynamic dynamic.operator ==(dynamic left, dynamic right)"));
3303 3304
        }

3305
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3306
        public async Task TextOnlyDocComment()
3307
        {
C
Cyrus Najmabadi 已提交
3308
            await TestAsync(@"
3309 3310 3311 3312 3313 3314 3315 3316
/// <summary>
///foo
/// </summary>
class C$$
{
}", Documentation("foo"));
        }

3317
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3318
        public async Task TestTrimConcatMultiLine()
3319
        {
C
Cyrus Najmabadi 已提交
3320
            await TestAsync(@"
3321 3322 3323 3324 3325 3326 3327 3328 3329
/// <summary>
/// foo
/// bar
/// </summary>
class C$$
{
}", Documentation("foo bar"));
        }

3330
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3331
        public async Task TestCref()
3332
        {
C
Cyrus Najmabadi 已提交
3333
            await TestAsync(@"
3334 3335 3336 3337 3338 3339 3340 3341 3342
/// <summary>
/// <see cref=""C""/>
/// <seealso cref=""C""/>
/// </summary>
class C$$
{
}", Documentation("C C"));
        }

3343
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3344
        public async Task ExcludeTextOutsideSummaryBlock()
3345
        {
C
Cyrus Najmabadi 已提交
3346
            await TestAsync(@"
3347 3348 3349 3350 3351 3352 3353 3354 3355 3356
/// red
/// <summary>
/// green
/// </summary>
/// yellow
class C$$
{
}", Documentation("green"));
        }

3357
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3358
        public async Task NewlineAfterPara()
3359
        {
C
Cyrus Najmabadi 已提交
3360
            await TestAsync(@"
3361 3362 3363 3364 3365 3366 3367 3368
/// <summary>
/// <para>foo</para>
/// </summary>
class C$$
{
}", Documentation("foo"));
        }

3369
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3370
        public async Task TextOnlyDocComment_Metadata()
3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387
        {
            var referenced = @"
/// <summary>
///foo
/// </summary>
public class C
{
}";

            var code = @"
class G
{
    void foo()
    {
        C$$ c;
    }
}";
C
Cyrus Najmabadi 已提交
3388
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("foo"));
3389 3390
        }

3391
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3392
        public async Task TestTrimConcatMultiLine_Metadata()
3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410
        {
            var referenced = @"
/// <summary>
/// foo
/// bar
/// </summary>
public class C
{
}";

            var code = @"
class G
{
    void foo()
    {
        C$$ c;
    }
}";
C
Cyrus Najmabadi 已提交
3411
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("foo bar"));
3412 3413
        }

3414
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3415
        public async Task TestCref_Metadata()
3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432
        {
            var code = @"
class G
{
    void foo()
    {
        C$$ c;
    }
}";

            var referenced = @"/// <summary>
/// <see cref=""C""/>
/// <seealso cref=""C""/>
/// </summary>
public class C
{
}";
C
Cyrus Najmabadi 已提交
3433
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("C C"));
3434 3435
        }

3436
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3437
        public async Task ExcludeTextOutsideSummaryBlock_Metadata()
3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456
        {
            var code = @"
class G
{
    void foo()
    {
        C$$ c;
    }
}";

            var referenced = @"
/// red
/// <summary>
/// green
/// </summary>
/// yellow
public class C
{
}";
C
Cyrus Najmabadi 已提交
3457
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("green"));
3458 3459
        }

3460
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3461
        public async Task Param()
3462
        {
C
Cyrus Najmabadi 已提交
3463
            await TestAsync(@"
3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T>(string[] arg$$s, T otherParam)
    {
    }
}", Documentation("First parameter of C.Foo<T>(string[], T)"));
        }

3476
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3477
        public async Task Param_Metadata()
3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498
        {
            var code = @"
class G
{
    void foo()
    {
        C c;
        c.Foo<int>(arg$$s: new string[] { }, 1);
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T>(string[] args, T otherParam)
    {
    }
}";
C
Cyrus Najmabadi 已提交
3499
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("First parameter of C.Foo<T>(string[], T)"));
3500 3501
        }

3502
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3503
        public async Task Param2()
3504
        {
C
Cyrus Najmabadi 已提交
3505
            await TestAsync(@"
3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T>(string[] args, T oth$$erParam)
    {
    }
}", Documentation("Another parameter of C.Foo<T>(string[], T)"));
        }

3518
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3519
        public async Task Param2_Metadata()
3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536
        {
            var code = @"
class G
{
    void foo()
    {
        C c;
        c.Foo<int>(args: new string[] { }, other$$Param: 1);
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
C
Cyrus Najmabadi 已提交
3537
    public void Foo<T>(string[] args, T otherParam)
3538 3539 3540
    {
    }
}";
C
Cyrus Najmabadi 已提交
3541
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("Another parameter of C.Foo<T>(string[], T)"));
3542 3543
        }

3544
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3545
        public async Task TypeParam()
3546
        {
C
Cyrus Najmabadi 已提交
3547
            await TestAsync(@"
3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""Foo{T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T$$>(string[] args, T otherParam)
    {
    }
}", Documentation("A type parameter of C.Foo<T>(string[], T)"));
        }

3560
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3561
        public async Task UnboundCref()
3562
        {
C
Cyrus Najmabadi 已提交
3563
            await TestAsync(@"
3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{T}(string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T$$>(string[] args, T otherParam)
    {
    }
}", Documentation("A type parameter of foo<T>(string[], T)"));
        }

3576
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3577
        public async Task CrefInConstructor()
3578
        {
C
Cyrus Najmabadi 已提交
3579
            await TestAsync(@"
3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590
public class TestClass
{
    /// <summary> 
    /// This sample shows how to specify the <see cref=""TestClass""/> constructor as a cref attribute.
    /// </summary> 
    public TestClass$$()
    {
    }
}", Documentation("This sample shows how to specify the TestClass constructor as a cref attribute."));
        }

3591
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3592
        public async Task CrefInConstructorOverloaded()
3593
        {
C
Cyrus Najmabadi 已提交
3594
            await TestAsync(@"
3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612
public class TestClass
{
    /// <summary> 
    /// This sample shows how to specify the <see cref=""TestClass""/> constructor as a cref attribute.
    /// </summary> 
    public TestClass()
    {
    }

    /// <summary> 
    /// This sample shows how to specify the <see cref=""TestClass(int)""/> constructor as a cref attribute.
    /// </summary> 
    public TestC$$lass(int value)
    { }

    }", Documentation("This sample shows how to specify the TestClass(int) constructor as a cref attribute."));
        }

3613
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3614
        public async Task CrefInGenericMethod1()
3615
        {
C
Cyrus Najmabadi 已提交
3616
            await TestAsync(@"
3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627
public class TestClass
{
        /// <summary> 
        /// The GetGenericValue method. 
        /// <para>This sample shows how to specify the <see cref=""GetGenericValue""/> method as a cref attribute.</para>
        /// </summary> 
        public static T GetGenericVa$$lue<T>(T para) { return para; }

    }", Documentation("The GetGenericValue method.\r\n\r\nThis sample shows how to specify the TestClass.GetGenericValue<T>(T) method as a cref attribute."));
        }

3628
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3629
        public async Task CrefInGenericMethod2()
3630
        {
C
Cyrus Najmabadi 已提交
3631
            await TestAsync(@"
3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643
public class TestClass
{
        /// <summary> 
        /// The GetGenericValue method. 
        /// <para>This sample shows how to specify the <see cref=""GetGenericValue{T}(T)""/> method as a cref attribute.</para>
        /// </summary> 
        public static T GetGenericVa$$lue<T>(T para) { return para; }

    }", Documentation("The GetGenericValue method.\r\n\r\nThis sample shows how to specify the TestClass.GetGenericValue<T>(T) method as a cref attribute."));
        }

        [WorkItem(813350)]
3644
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3645
        public async Task CrefInMethodOverloading1()
3646
        {
C
Cyrus Najmabadi 已提交
3647
            await TestAsync(@"
3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669
public class TestClass
{
        public static int GetZero()
        {
            GetGenericValu$$e();
            GetGenericValue(5);
        }

        /// <summary> 
        /// This sample shows how to call the <see cref=""GetGenericValue{T}(T)""/> method
        /// </summary> 
        public static T GetGenericValue<T>(T para) { return para; }

        /// <summary> 
        /// This sample shows how to specify the <see cref=""GetGenericValue""/> method as a cref attribute.
        /// </summary> 
        public static void GetGenericValue() { }

    }", Documentation("This sample shows how to specify the TestClass.GetGenericValue() method as a cref attribute."));
        }

        [WorkItem(813350)]
3670
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3671
        public async Task CrefInMethodOverloading2()
3672
        {
C
Cyrus Najmabadi 已提交
3673
            await TestAsync(@"
3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694
public class TestClass
{
        public static int GetZero()
        {
            GetGenericValue();
            GetGenericVal$$ue(5);
        }

        /// <summary> 
        /// This sample shows how to call the <see cref=""GetGenericValue{T}(T)""/> method
        /// </summary> 
        public static T GetGenericValue<T>(T para) { return para; }

        /// <summary> 
        /// This sample shows how to specify the <see cref=""GetGenericValue""/> method as a cref attribute.
        /// </summary> 
        public static void GetGenericValue() { }

    }", Documentation("This sample shows how to call the TestClass.GetGenericValue<T>(T) method"));
        }

3695
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3696
        public async Task CrefInGenericType()
3697
        {
C
Cyrus Najmabadi 已提交
3698
            await TestAsync(@"
3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715
    /// <summary> 
    /// <remarks>This example shows how to specify the <see cref=""GenericClass{T}""/> cref.</remarks>
    /// </summary> 
    class Generic$$Class<T> { }",
    Documentation("This example shows how to specify the GenericClass<T> cref.",
        ExpectedClassifications(
            Text("This example shows how to specify the"),
            WhiteSpace(" "),
            Class("GenericClass"),
            Punctuation.OpenAngle,
            TypeParameter("T"),
            Punctuation.CloseAngle,
            WhiteSpace(" "),
            Text("cref."))));
        }

        [WorkItem(812720)]
3716
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3717
        public async Task ClassificationOfCrefsFromMetadata()
3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738
        {
            var code = @"
class G
{
    void foo()
    {
        C c;
        c.Fo$$o();
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <summary> 
    /// See <see cref=""Foo""/> method
    /// </summary> 
    public void Foo()
    {
    }
}";
C
Cyrus Najmabadi 已提交
3739
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#",
3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752
                Documentation("See C.Foo() method",
                    ExpectedClassifications(
                        Text("See"),
                        WhiteSpace(" "),
                        Class("C"),
                        Punctuation.Text("."),
                        Identifier("Foo"),
                        Punctuation.OpenParen,
                        Punctuation.CloseParen,
                        WhiteSpace(" "),
                        Text("method"))));
        }

3753
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3754
        public async Task FieldAvailableInBothLinkedFiles()
3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    int x;
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
3775
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.Field}) int C.x"), Usage("") });
3776 3777
        }

3778
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3779
        public async Task FieldUnavailableInOneLinkedFile()
3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""FOO"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
3801
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}", expectsWarningGlyph: true);
3802

C
Cyrus Najmabadi 已提交
3803
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3804 3805
        }

3806
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3807
        public async Task BindSymbolInOtherFile()
3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""FOO"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
3829
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.NotAvailable)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.Available)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}", expectsWarningGlyph: true);
3830

C
Cyrus Najmabadi 已提交
3831
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3832 3833
        }

3834
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3835
        public async Task FieldUnavailableInTwoLinkedFiles()
3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""FOO"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj3"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
            var expectedDescription = Usage(
3861
                $"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}",
3862 3863
                expectsWarningGlyph: true);

C
Cyrus Najmabadi 已提交
3864
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3865 3866
        }

3867
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3868
        public async Task ExcludeFilesWithInactiveRegions()
3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""FOO,BAR"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif

#if BAR
    void foo()
    {
        x$$
    }
#endif
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument"" />
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj3"" PreprocessorSymbols=""BAR"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
3896
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}", expectsWarningGlyph: true);
C
Cyrus Najmabadi 已提交
3897
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3898 3899 3900
        }

        [WorkItem(962353)]
3901
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3902
        public async Task NoValidSymbolsInLinkedDocuments()
3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void foo()
    {
        B$$ar();
    }
#if B
    void Bar() { }
#endif
   
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
C
Cyrus Najmabadi 已提交
3925
            await VerifyWithReferenceWorkerAsync(markup);
3926 3927 3928
        }

        [WorkItem(1020944)]
3929
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3930
        public async Task LocalsValidInLinkedDocuments()
3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void M()
    {
        int x$$;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
3950
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.LocalVariable}) int x"), Usage("") });
3951 3952 3953
        }

        [WorkItem(1020944)]
3954
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3955
        public async Task LocalWarningInLinkedDocuments()
3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""PROJ1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void M()
    {
#if PROJ1
        int x;
#endif

        int y = x$$;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
3979
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.LocalVariable}) int x"), Usage($"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}", expectsWarningGlyph: true) });
3980 3981 3982
        }

        [WorkItem(1020944)]
3983
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3984
        public async Task LabelsValidInLinkedDocuments()
3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{   
    void M()
    {
        $$LABEL: goto LABEL;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
4004
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.Label}) LABEL"), Usage("") });
4005 4006 4007
        }

        [WorkItem(1020944)]
4008
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4009
        public async Task RangeVariablesValidInLinkedDocuments()
4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
using System.Linq;
class C
{
    void M()
    {
        var x = from y in new[] {1, 2, 3} select $$y;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
4030
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.RangeVariable}) int y"), Usage("") });
4031 4032 4033
        }

        [WorkItem(1019766)]
4034
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4035
        public async Task PointerAccessibility()
4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046
        {
            var markup = @"class C
{
    unsafe static void Main()
    {
        void* p = null;
        void* q = null;
        dynamic d = true;
        var x = p =$$= q == d;
    }
}";
C
Cyrus Najmabadi 已提交
4047
            await TestAsync(markup, MainDescription("bool void*.operator ==(void* left, void* right)"));
4048 4049 4050
        }

        [WorkItem(1114300)]
4051
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4052
        public async Task AwaitingTaskOfArrayType()
4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063
        {
            var markup = @"
using System.Threading.Tasks;

class Program
{
    async Task<int[]> M()
    {
        awa$$it M();
    }
}";
C
Cyrus Najmabadi 已提交
4064
            await TestAsync(markup, MainDescription("int[]"));
4065 4066 4067
        }

        [WorkItem(1114300)]
4068
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4069
        public async Task AwaitingTaskOfDynamic()
4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080
        {
            var markup = @"
using System.Threading.Tasks;

class Program
{
    async Task<dynamic> M()
    {
        awa$$it M();
    }
}";
C
Cyrus Najmabadi 已提交
4081
            await TestAsync(markup, MainDescription("dynamic"));
4082
        }
4083

4084
        [Fact, Trait(Traits.Feature, Traits.Features.Completion)]
C
Cyrus Najmabadi 已提交
4085
        public async Task MethodOverloadDifferencesIgnored()
4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""ONE"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if ONE
    void Do(int x){}
#endif
#if TWO
    void Do(string x){}
#endif
    void Shared()
    {
        this.Do$$
    }

}]]></Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

            var expectedDescription = $"void C.Do(int x)";
C
Cyrus Najmabadi 已提交
4111
            await VerifyWithReferenceWorkerAsync(markup, MainDescription(expectedDescription));
4112
        }
4113

4114
        [Fact, Trait(Traits.Feature, Traits.Features.Completion)]
C
Cyrus Najmabadi 已提交
4115
        public async Task MethodOverloadDifferencesIgnored_ContainingType()
4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""ONE"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void Shared()
    {
        var x = GetThing().Do$$();
    }

#if ONE
    private Methods1 GetThing()
    {
        return new Methods1();
    }
#endif

#if TWO
    private Methods2 GetThing()
    {
        return new Methods2();
    }
#endif
}

#if ONE
public class Methods1
{
    public void Do(string x) { }
}
#endif

#if TWO
public class Methods2
{
    public void Do(string x) { }
}
#endif
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""TWO"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

            var expectedDescription = $"void Methods1.Do(string x)";
C
Cyrus Najmabadi 已提交
4164
            await VerifyWithReferenceWorkerAsync(markup, MainDescription(expectedDescription));
4165
        }
4166 4167 4168

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(4868, "https://github.com/dotnet/roslyn/issues/4868")]
C
Cyrus Najmabadi 已提交
4169
        public async Task QuickInfoExceptions()
4170
        {
C
Cyrus Najmabadi 已提交
4171
            await TestAsync(@"
4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182
using System;
namespace MyNs
{
    class MyException1 : Exception { }
    class MyException2 : Exception { }
    class TestClass
    {
        /// <exception cref=""MyException1""></exception>
        /// <exception cref=""T:MyNs.MyException2""></exception>
        /// <exception cref=""System.Int32""></exception>
        /// <exception cref=""double""></exception>
4183
        /// <exception cref=""Not_A_Class_But_Still_Displayed""></exception>
4184 4185 4186 4187 4188 4189 4190
        void M()
        {
            M$$();
        }
    }
}
",
4191
                Exceptions($"\r\n{WorkspacesResources.Exceptions}\r\n  MyException1\r\n  MyException2\r\n  int\r\n  double\r\n  Not_A_Class_But_Still_Displayed"));
4192
        }
4193 4194 4195

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(1516, "https://github.com/dotnet/roslyn/issues/1516")]
C
Cyrus Najmabadi 已提交
4196
        public async Task QuickInfoWithNonStandardSeeAttributesAppear()
4197
        {
C
Cyrus Najmabadi 已提交
4198
            await TestAsync(@"
4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214
class C
{
    /// <summary>
    /// <see cref=""System.String"" />
    /// <see href=""http://microsoft.com"" />
    /// <see langword=""null"" />
    /// <see unsupported-attribute=""cat"" />
    /// </summary>
    void M()
    {
        M$$();
    }
}
",
                Documentation(@"string http://microsoft.com null cat"));
        }
4215 4216 4217

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(6657, "https://github.com/dotnet/roslyn/issues/6657")]
4218
        public async Task OptionalParameterFromPreviousSubmission()
4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229
        {
            const string workspaceDefinition = @"
<Workspace>
    <Submission Language=""C#"" CommonReferences=""true"">
        void M(int x = 1) { }
    </Submission>
    <Submission Language=""C#"" CommonReferences=""true"">
        M(x$$: 2)
    </Submission>
</Workspace>
";
C
Cyrus Najmabadi 已提交
4230
            using (var workspace = await TestWorkspaceFactory.CreateWorkspaceAsync(XElement.Parse(workspaceDefinition), workspaceKind: WorkspaceKind.Interactive))
4231
            {
4232
                await TestWithOptionsAsync(workspace, MainDescription("(parameter) int x = 1"));
4233 4234
            }
        }
4235
    }
C
Cyrus Najmabadi 已提交
4236
}