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

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
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.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;

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

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

40 41 42 43 44 45
            var provider = new SemanticQuickInfoProvider(
                workspace.GetService<IProjectionBufferFactoryService>(),
                workspace.GetService<IEditorOptionsFactoryService>(),
                workspace.GetService<ITextEditorFactoryService>(),
                workspace.GetService<IGlyphService>(),
                workspace.GetService<ClassificationTypeMap>());
46

47
            await TestWithOptionsAsync(document, provider, position, expectedResults);
48 49

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

60
                await TestWithOptionsAsync(document, provider, position, expectedResults);
61 62 63
            }
        }

64
        private async Task TestWithOptionsAsync(Document document, SemanticQuickInfoProvider provider, int position, Action<object>[] expectedResults)
65
        {
C
Cyrus Najmabadi 已提交
66
            var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
            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 已提交
87
        private async Task VerifyWithMscorlib45Async(string markup, Action<object>[] expectedResults)
88 89 90 91 92 93 94 95 96 97
        {
            var xmlString = string.Format(@"
<Workspace>
    <Project Language=""C#"" CommonReferencesNet45=""true"">
        <Document FilePath=""SourceDocument"">
{0}
        </Document>
    </Project>
</Workspace>", SecurityElement.Escape(markup));

C
CyrusNajmabadi 已提交
98
            using (var workspace = TestWorkspace.Create(xmlString))
99 100 101 102 103 104 105 106 107 108 109 110
            {
                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<IProjectionBufferFactoryService>(),
                        workspace.GetService<IEditorOptionsFactoryService>(),
                        workspace.GetService<ITextEditorFactoryService>(),
                        workspace.GetService<IGlyphService>(),
                        workspace.GetService<ClassificationTypeMap>());

C
Cyrus Najmabadi 已提交
111
                var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
                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 已提交
133
        protected override async Task TestAsync(string markup, params Action<object>[] expectedResults)
134
        {
C
Cyrus Najmabadi 已提交
135 136
            await TestWithOptionsAsync(Options.Regular, markup, expectedResults);
            await TestWithOptionsAsync(Options.Script, markup, expectedResults);
137 138
        }

C
Cyrus Najmabadi 已提交
139
        protected async Task TestWithUsingsAsync(string markup, params Action<object>[] expectedResults)
140 141 142 143 144 145 146
        {
            var markupWithUsings =
@"using System;
using System.Collections.Generic;
using System.Linq;
" + markup;

C
Cyrus Najmabadi 已提交
147
            await TestAsync(markupWithUsings, expectedResults);
148 149
        }

C
Cyrus Najmabadi 已提交
150
        protected Task TestInClassAsync(string markup, params Action<object>[] expectedResults)
151 152
        {
            var markupInClass = "class C { " + markup + " }";
C
Cyrus Najmabadi 已提交
153
            return TestWithUsingsAsync(markupInClass, expectedResults);
154 155
        }

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

C
Cyrus Najmabadi 已提交
162
        private async Task TestWithReferenceAsync(string sourceCode,
163 164 165 166 167
            string referencedCode,
            string sourceLanguage,
            string referencedLanguage,
            params Action<object>[] expectedResults)
        {
C
Cyrus Najmabadi 已提交
168 169
            await TestWithMetadataReferenceHelperAsync(sourceCode, referencedCode, sourceLanguage, referencedLanguage, expectedResults);
            await TestWithProjectReferenceHelperAsync(sourceCode, referencedCode, sourceLanguage, referencedLanguage, expectedResults);
170 171 172 173

            // Multi-language projects are not supported.
            if (sourceLanguage == referencedLanguage)
            {
C
Cyrus Najmabadi 已提交
174
                await TestInSameProjectHelperAsync(sourceCode, referencedCode, sourceLanguage, expectedResults);
175 176 177
            }
        }

C
Cyrus Najmabadi 已提交
178
        private async Task TestWithMetadataReferenceHelperAsync(
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
            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 已提交
200
            await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
201 202
        }

C
Cyrus Najmabadi 已提交
203
        private async Task TestWithProjectReferenceHelperAsync(
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
            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 已提交
227
            await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
228 229
        }

C
Cyrus Najmabadi 已提交
230
        private async Task TestInSameProjectHelperAsync(
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
            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 已提交
248
            await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
249 250
        }

C
Cyrus Najmabadi 已提交
251
        private async Task VerifyWithReferenceWorkerAsync(string xmlString, params Action<object>[] expectedResults)
252
        {
C
CyrusNajmabadi 已提交
253
            using (var workspace = TestWorkspace.Create(xmlString))
254 255 256 257 258 259 260 261 262 263 264 265
            {
                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<IProjectionBufferFactoryService>(),
                        workspace.GetService<IEditorOptionsFactoryService>(),
                        workspace.GetService<ITextEditorFactoryService>(),
                        workspace.GetService<IGlyphService>(),
                        workspace.GetService<ClassificationTypeMap>());

C
Cyrus Najmabadi 已提交
266
                var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
                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 已提交
288
        protected async Task TestInvalidTypeInClassAsync(string code)
289 290
        {
            var codeInClass = "class C { " + code + " }";
C
Cyrus Najmabadi 已提交
291
            await TestAsync(codeInClass);
292 293
        }

294
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
295
        public async Task TestNamespaceInUsingDirective()
296
        {
C
CyrusNajmabadi 已提交
297 298
            await TestAsync(
@"using $$System;",
299 300 301
                MainDescription("namespace System"));
        }

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

310
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
311
        public async Task TestNamespaceInUsingDirective3()
312
        {
C
CyrusNajmabadi 已提交
313 314
            await TestAsync(
@"using System.L$$inq;",
315 316 317
                MainDescription("namespace System.Linq"));
        }

318
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
319
        public async Task TestNamespaceInUsingDirectiveWithAlias()
320
        {
C
CyrusNajmabadi 已提交
321
            await TestAsync(
322
@"using Goo = Sys$$tem.Console;",
323 324 325
                MainDescription("namespace System"));
        }

326
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
327
        public async Task TestTypeInUsingDirectiveWithAlias()
328
        {
C
CyrusNajmabadi 已提交
329
            await TestAsync(
330
@"using Goo = System.Con$$sole;",
331 332 333
                MainDescription("class System.Console"));
        }

J
Jared Parsons 已提交
334
        [WorkItem(991466, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991466")]
335
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
336
        public async Task TestDocumentationInUsingDirectiveWithAlias()
337 338
        {
            var markup =
339 340 341
@"using I$$ = IGoo;
///<summary>summary for interface IGoo</summary>
interface IGoo {  }";
342

C
Cyrus Najmabadi 已提交
343
            await TestAsync(markup,
344 345
                MainDescription("interface IGoo"),
                Documentation("summary for interface IGoo"));
346 347
        }

J
Jared Parsons 已提交
348
        [WorkItem(991466, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991466")]
349
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
350
        public async Task TestDocumentationInUsingDirectiveWithAlias2()
351 352
        {
            var markup =
353 354 355
@"using I = IGoo;
///<summary>summary for interface IGoo</summary>
interface IGoo {  }
356 357
class C : I$$ { }";

C
Cyrus Najmabadi 已提交
358
            await TestAsync(markup,
359 360
                MainDescription("interface IGoo"),
                Documentation("summary for interface IGoo"));
361 362
        }

J
Jared Parsons 已提交
363
        [WorkItem(991466, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991466")]
364
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
365
        public async Task TestDocumentationInUsingDirectiveWithAlias3()
366 367
        {
            var markup =
368 369 370
@"using I = IGoo;
///<summary>summary for interface IGoo</summary>
interface IGoo 
371
{  
372
    void Goo();
373 374 375
}
class C : I$$ { }";

C
Cyrus Najmabadi 已提交
376
            await TestAsync(markup,
377 378
                MainDescription("interface IGoo"),
                Documentation("summary for interface IGoo"));
379 380
        }

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

C
Cyrus Najmabadi 已提交
389
            await TestWithUsingsAsync(markup,
390 391 392 393
                MainDescription("class C"),
                Documentation("summary for Class C"));
        }

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

C
Cyrus Najmabadi 已提交
402
            await TestAsync(markup,
403 404 405 406
                MainDescription("class C"),
                Documentation("Hello!"));
        }

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

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

            // SingleLine doc comment with space before opening tag
C
CyrusNajmabadi 已提交
426 427 428 429 430 431 432 433 434
            await TestAsync(
@"/// <summary>Hello!</summary>
class C
{
    void M()
    {
        $$C obj;
    }
}",
435 436 437 438
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with space before opening tag and leading whitespace
C
CyrusNajmabadi 已提交
439 440 441 442 443 444 445 446 447
            await TestAsync(
@"/// <summary>Hello!</summary>
class C
{
    void M()
    {
        $$C obj;
    }
}",
448 449 450 451
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with leading whitespace and blank line
C
CyrusNajmabadi 已提交
452 453 454
            await TestAsync(
@"///<summary>Hello!
///</summary>
455

C
CyrusNajmabadi 已提交
456 457 458 459 460 461 462
class C
{
    void M()
    {
        $$C obj;
    }
}",
463 464 465 466
                MainDescription("class C"),
                Documentation("Hello!"));

            // SingleLine doc comment with '\r' line separators
C
Cyrus Najmabadi 已提交
467
            await TestAsync("///<summary>Hello!\r///</summary>\rclass C { void M() { $$C obj; } }",
468 469 470 471
                MainDescription("class C"),
                Documentation("Hello!"));
        }

472
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
473
        public async Task TestMultiLineDocComments()
474 475 476 477
        {
            // Tests chosen to maximize code coverage in DocumentationCommentCompiler.WriteFormattedMultiLineComment

            // Multiline doc comment with leading whitespace
C
CyrusNajmabadi 已提交
478 479 480 481 482 483 484 485 486
            await TestAsync(
@"/**<summary>Hello!</summary>*/
class C
{
    void M()
    {
        $$C obj;
    }
}",
487 488 489 490
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with space before opening tag
C
CyrusNajmabadi 已提交
491 492
            await TestAsync(
@"/** <summary>Hello!</summary>
493
 **/
C
CyrusNajmabadi 已提交
494 495 496 497 498 499 500
class C
{
    void M()
    {
        $$C obj;
    }
}",
501 502 503 504
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with space before opening tag and leading whitespace
C
CyrusNajmabadi 已提交
505 506 507 508 509 510 511 512 513 514 515
            await TestAsync(
@"/**
 ** <summary>Hello!</summary>
 **/
class C
{
    void M()
    {
        $$C obj;
    }
}",
516 517 518 519
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with no per-line prefix
C
CyrusNajmabadi 已提交
520 521
            await TestAsync(
@"/**
522 523 524 525
  <summary>
  Hello!
  </summary>
*/
C
CyrusNajmabadi 已提交
526 527 528 529 530 531 532
class C
{
    void M()
    {
        $$C obj;
    }
}",
533 534 535 536
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with inconsistent per-line prefix
C
CyrusNajmabadi 已提交
537 538
            await TestAsync(
@"/**
539 540 541 542
 ** <summary>
    Hello!</summary>
 **
 **/
C
CyrusNajmabadi 已提交
543 544 545 546 547 548 549
class C
{
    void M()
    {
        $$C obj;
    }
}",
550 551 552 553
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with closing comment on final line
C
CyrusNajmabadi 已提交
554 555
            await TestAsync(
@"/**
556 557
<summary>Hello!
</summary>*/
C
CyrusNajmabadi 已提交
558 559 560 561 562 563 564
class C
{
    void M()
    {
        $$C obj;
    }
}",
565 566 567 568
                MainDescription("class C"),
                Documentation("Hello!"));

            // Multiline doc comment with '\r' line separators
C
Cyrus Najmabadi 已提交
569
            await TestAsync("/**\r* <summary>\r* Hello!\r* </summary>\r*/\rclass C { void M() { $$C obj; } }",
570 571 572 573
                MainDescription("class C"),
                Documentation("Hello!"));
        }

574
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
575
        public async Task TestMethodWithDocComment()
576 577 578 579 580 581
        {
            var markup =
@"
///<summary>Hello!</summary>
void M() { M$$() }";

C
Cyrus Najmabadi 已提交
582
            await TestInClassAsync(markup,
583 584 585 586
                MainDescription("void C.M()"),
                Documentation("Hello!"));
        }

587
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
588
        public async Task TestInt32()
589
        {
590 591
            await TestInClassAsync(
@"$$Int32 i;",
592 593 594
                MainDescription("struct System.Int32"));
        }

595
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
596
        public async Task TestBuiltInInt()
597
        {
598 599
            await TestInClassAsync(
@"$$int i;",
600 601 602
                MainDescription("struct System.Int32"));
        }

603
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
604
        public async Task TestString()
605
        {
606 607
            await TestInClassAsync(
@"$$String s;",
608 609 610
                MainDescription("class System.String"));
        }

611
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
612
        public async Task TestBuiltInString()
613
        {
614 615
            await TestInClassAsync(
@"$$string s;",
616 617 618
                MainDescription("class System.String"));
        }

619
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
620
        public async Task TestBuiltInStringAtEndOfToken()
621
        {
622 623
            await TestInClassAsync(
@"string$$ s;",
624 625 626
                MainDescription("class System.String"));
        }

627
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
628
        public async Task TestBoolean()
629
        {
630 631
            await TestInClassAsync(
@"$$Boolean b;",
632 633 634
                MainDescription("struct System.Boolean"));
        }

635
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
636
        public async Task TestBuiltInBool()
637
        {
638 639
            await TestInClassAsync(
@"$$bool b;",
640 641 642
                MainDescription("struct System.Boolean"));
        }

643
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
644
        public async Task TestSingle()
645
        {
646 647
            await TestInClassAsync(
@"$$Single s;",
648 649 650
                MainDescription("struct System.Single"));
        }

651
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
652
        public async Task TestBuiltInFloat()
653
        {
654 655
            await TestInClassAsync(
@"$$float f;",
656 657 658
                MainDescription("struct System.Single"));
        }

659
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
660
        public async Task TestVoidIsInvalid()
661
        {
662 663 664 665
            await TestInvalidTypeInClassAsync(
@"$$void M()
{
}");
666 667
        }

668
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
669
        public async Task TestInvalidPointer1_931958()
670
        {
671 672
            await TestInvalidTypeInClassAsync(
@"$$T* i;");
673 674
        }

675
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
676
        public async Task TestInvalidPointer2_931958()
677
        {
678 679
            await TestInvalidTypeInClassAsync(
@"T$$* i;");
680 681
        }

682
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
683
        public async Task TestInvalidPointer3_931958()
684
        {
685 686
            await TestInvalidTypeInClassAsync(
@"T*$$ i;");
687 688
        }

689
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
690
        public async Task TestListOfString()
691
        {
692 693
            await TestInClassAsync(
@"$$List<string> l;",
694
                MainDescription("class System.Collections.Generic.List<T>"),
695
                TypeParameterMap($"\r\nT {FeaturesResources.is_} string"));
696 697
        }

698
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
699
        public async Task TestListOfSomethingFromSource()
700 701 702 703 704 705
        {
            var markup =
@"
///<summary>Generic List</summary>
public class GenericList<T> { Generic$$List<int> t; }";

C
Cyrus Najmabadi 已提交
706
            await TestAsync(markup,
707 708
                MainDescription("class GenericList<T>"),
                Documentation("Generic List"),
709
                TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
710 711
        }

712
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
713
        public async Task TestListOfT()
714
        {
715 716 717 718 719
            await TestInMethodAsync(
@"class C<T>
{
    $$List<T> l;
}",
720 721 722
                MainDescription("class System.Collections.Generic.List<T>"));
        }

723
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
724
        public async Task TestDictionaryOfIntAndString()
725
        {
726 727
            await TestInClassAsync(
@"$$Dictionary<int, string> d;",
728 729
                MainDescription("class System.Collections.Generic.Dictionary<TKey, TValue>"),
                TypeParameterMap(
730 731
                    Lines($"\r\nTKey {FeaturesResources.is_} int",
                          $"TValue {FeaturesResources.is_} string")));
732 733
        }

734
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
735
        public async Task TestDictionaryOfTAndU()
736
        {
737 738 739 740 741
            await TestInMethodAsync(
@"class C<T, U>
{
    $$Dictionary<T, U> d;
}",
742 743
                MainDescription("class System.Collections.Generic.Dictionary<TKey, TValue>"),
                TypeParameterMap(
744 745
                    Lines($"\r\nTKey {FeaturesResources.is_} T",
                          $"TValue {FeaturesResources.is_} U")));
746 747
        }

748
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
749
        public async Task TestIEnumerableOfInt()
750
        {
751 752 753 754 755
            await TestInClassAsync(
@"$$IEnumerable<int> M()
{
    yield break;
}",
756
                MainDescription("interface System.Collections.Generic.IEnumerable<out T>"),
757
                TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
758 759
        }

760
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
761
        public async Task TestEventHandler()
762
        {
763 764
            await TestInClassAsync(
@"event $$EventHandler e;",
765 766 767
                MainDescription("delegate void System.EventHandler(object sender, System.EventArgs e)"));
        }

768
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
769
        public async Task TestTypeParameter()
770
        {
C
CyrusNajmabadi 已提交
771 772 773 774 775
            await TestAsync(
@"class C<T>
{
    $$T t;
}",
776
                MainDescription($"T {FeaturesResources.in_} C<T>"));
777 778
        }

J
Jared Parsons 已提交
779
        [WorkItem(538636, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538636")]
780
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
781
        public async Task TestTypeParameterWithDocComment()
782 783 784 785 786 787 788
        {
            var markup =
@"
///<summary>Hello!</summary>
///<typeparam name=""T"">T is Type Parameter</typeparam>
class C<T> { $$T t; }";

C
Cyrus Najmabadi 已提交
789
            await TestAsync(markup,
790
                MainDescription($"T {FeaturesResources.in_} C<T>"),
791 792 793
                Documentation("T is Type Parameter"));
        }

794
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
795
        public async Task TestTypeParameter1_Bug931949()
796
        {
C
CyrusNajmabadi 已提交
797 798 799 800 801
            await TestAsync(
@"class T1<T11>
{
    $$T11 t;
}",
802
                MainDescription($"T11 {FeaturesResources.in_} T1<T11>"));
803 804
        }

805
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
806
        public async Task TestTypeParameter2_Bug931949()
807
        {
C
CyrusNajmabadi 已提交
808 809 810 811 812
            await TestAsync(
@"class T1<T11>
{
    T$$11 t;
}",
813
                MainDescription($"T11 {FeaturesResources.in_} T1<T11>"));
814 815
        }

816
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
817
        public async Task TestTypeParameter3_Bug931949()
818
        {
C
CyrusNajmabadi 已提交
819 820 821 822 823
            await TestAsync(
@"class T1<T11>
{
    T1$$1 t;
}",
824
                MainDescription($"T11 {FeaturesResources.in_} T1<T11>"));
825 826
        }

827
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
828
        public async Task TestTypeParameter4_Bug931949()
829
        {
C
CyrusNajmabadi 已提交
830 831 832 833 834
            await TestAsync(
@"class T1<T11>
{
    T11$$ t;
}",
835
                MainDescription($"T11 {FeaturesResources.in_} T1<T11>"));
836 837
        }

838
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
839
        public async Task TestNullableOfInt()
840
        {
C
Cyrus Najmabadi 已提交
841
            await TestInClassAsync(@"$$Nullable<int> i; }",
842
                MainDescription("struct System.Nullable<T> where T : struct"),
843
                TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
844 845
        }

846
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
847
        public async Task TestGenericTypeDeclaredOnMethod1_Bug1946()
848
        {
C
CyrusNajmabadi 已提交
849 850 851 852 853 854 855 856
            await TestAsync(
@"class C
{
    static void Meth1<T1>($$T1 i) where T1 : struct
    {
        T1 i;
    }
}",
857
                MainDescription($"T1 {FeaturesResources.in_} C.Meth1<T1> where T1 : struct"));
858 859
        }

860
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
861
        public async Task TestGenericTypeDeclaredOnMethod2_Bug1946()
862
        {
C
CyrusNajmabadi 已提交
863 864 865 866 867 868 869 870
            await TestAsync(
@"class C
{
    static void Meth1<T1>(T1 i) where $$T1 : struct
    {
        T1 i;
    }
}",
871
                MainDescription($"T1 {FeaturesResources.in_} C.Meth1<T1> where T1 : struct"));
872 873
        }

874
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
875
        public async Task TestGenericTypeDeclaredOnMethod3_Bug1946()
876
        {
C
CyrusNajmabadi 已提交
877 878 879 880 881 882 883 884
            await TestAsync(
@"class C
{
    static void Meth1<T1>(T1 i) where T1 : struct
    {
        $$T1 i;
    }
}",
885
                MainDescription($"T1 {FeaturesResources.in_} C.Meth1<T1> where T1 : struct"));
886 887
        }

888
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
889
        public async Task TestGenericTypeParameterConstraint_Class()
890
        {
C
CyrusNajmabadi 已提交
891 892 893 894
            await TestAsync(
@"class C<T> where $$T : class
{
}",
895
                MainDescription($"T {FeaturesResources.in_} C<T> where T : class"));
896 897
        }

898
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
899
        public async Task TestGenericTypeParameterConstraint_Struct()
900
        {
C
CyrusNajmabadi 已提交
901 902 903 904
            await TestAsync(
@"struct S<T> where $$T : class
{
}",
905
                MainDescription($"T {FeaturesResources.in_} S<T> where T : class"));
906 907
        }

908
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
909
        public async Task TestGenericTypeParameterConstraint_Interface()
910
        {
C
CyrusNajmabadi 已提交
911 912 913 914
            await TestAsync(
@"interface I<T> where $$T : class
{
}",
915
                MainDescription($"T {FeaturesResources.in_} I<T> where T : class"));
916 917
        }

918
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
919
        public async Task TestGenericTypeParameterConstraint_Delegate()
920
        {
C
CyrusNajmabadi 已提交
921 922
            await TestAsync(
@"delegate void D<T>() where $$T : class;",
923
                MainDescription($"T {FeaturesResources.in_} D<T> where T : class"));
924 925
        }

926
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
927
        public async Task TestMinimallyQualifiedConstraint()
928
        {
C
Cyrus Najmabadi 已提交
929
            await TestAsync(@"class C<T> where $$T : IEnumerable<int>",
930
                MainDescription($"T {FeaturesResources.in_} C<T> where T : IEnumerable<int>"));
931 932
        }

933
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
934
        public async Task FullyQualifiedConstraint()
935
        {
C
Cyrus Najmabadi 已提交
936
            await TestAsync(@"class C<T> where $$T : System.Collections.Generic.IEnumerable<int>",
937
                MainDescription($"T {FeaturesResources.in_} C<T> where T : System.Collections.Generic.IEnumerable<int>"));
938 939
        }

940
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
941
        public async Task TestMethodReferenceInSameMethod()
942
        {
C
CyrusNajmabadi 已提交
943 944 945 946 947 948 949 950
            await TestAsync(
@"class C
{
    void M()
    {
        M$$();
    }
}",
951 952 953
                MainDescription("void C.M()"));
        }

954
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
955
        public async Task TestMethodReferenceInSameMethodWithDocComment()
956 957 958 959 960 961
        {
            var markup =
@"
///<summary>Hello World</summary>
void M() { M$$(); }";

C
Cyrus Najmabadi 已提交
962
            await TestInClassAsync(markup,
963 964 965 966
                MainDescription("void C.M()"),
                Documentation("Hello World"));
        }

967
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
968
        public async Task TestFieldInMethodBuiltIn()
969 970 971 972 973 974 975 976 977
        {
            var markup =
@"int field;

void M()
{
    field$$
}";

C
Cyrus Najmabadi 已提交
978
            await TestInClassAsync(markup,
979
                MainDescription($"({FeaturesResources.field}) int C.field"));
980 981
        }

982
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
983
        public async Task TestFieldInMethodBuiltIn2()
984
        {
985 986 987 988 989 990 991
            await TestInClassAsync(
@"int field;

void M()
{
    int f = field$$;
}",
992
                MainDescription($"({FeaturesResources.field}) int C.field"));
993 994
        }

995
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
996
        public async Task TestFieldInMethodBuiltInWithFieldInitializer()
997
        {
998 999 1000 1001 1002
            await TestInClassAsync(
@"int field = 1;

void M()
{
C
CyrusNajmabadi 已提交
1003
    int f = field $$;
1004
}");
1005 1006
        }

1007
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1008
        public async Task TestOperatorBuiltIn()
1009
        {
1010 1011 1012 1013
            await TestInMethodAsync(
@"int x;

x = x$$+1;",
1014 1015 1016
                MainDescription("int int.operator +(int left, int right)"));
        }

1017
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1018
        public async Task TestOperatorBuiltIn1()
1019
        {
1020 1021 1022 1023
            await TestInMethodAsync(
@"int x;

x = x$$ + 1;",
1024
                MainDescription($"({FeaturesResources.local_variable}) int x"));
1025 1026
        }

1027
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1028
        public async Task TestOperatorBuiltIn2()
1029
        {
1030 1031 1032 1033
            await TestInMethodAsync(
@"int x;

x = x+$$x;",
1034
                MainDescription($"({FeaturesResources.local_variable}) int x"));
1035 1036
        }

1037
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1038
        public async Task TestOperatorBuiltIn3()
1039
        {
1040 1041 1042 1043
            await TestInMethodAsync(
@"int x;

x = x +$$ x;",
1044 1045 1046
                MainDescription("int int.operator +(int left, int right)"));
        }

1047
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1048
        public async Task TestOperatorBuiltIn4()
1049
        {
1050 1051 1052 1053
            await TestInMethodAsync(
@"int x;

x = x + $$x;",
1054
                MainDescription($"({FeaturesResources.local_variable}) int x"));
1055 1056
        }

1057
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1058
        public async Task TestOperatorCustomTypeBuiltIn()
1059 1060 1061 1062 1063 1064 1065
        {
            var markup =
@"class C
{
    static void M() { C c; c = c +$$ c; }
}";

C
Cyrus Najmabadi 已提交
1066
            await TestAsync(markup);
1067 1068
        }

1069
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1070
        public async Task TestOperatorCustomTypeOverload()
1071 1072 1073 1074 1075 1076 1077 1078
        {
            var markup =
@"class C
{
    static void M() { C c; c = c +$$ c; }
    static C operator+(C a, C b) { return a; }
}";

C
Cyrus Najmabadi 已提交
1079
            await TestAsync(markup,
1080 1081 1082
                MainDescription("C C.operator +(C a, C b)"));
        }

1083
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1084
        public async Task TestFieldInMethodMinimal()
1085 1086 1087 1088 1089 1090 1091 1092 1093
        {
            var markup =
@"DateTime field;

void M()
{
    field$$
}";

C
Cyrus Najmabadi 已提交
1094
            await TestInClassAsync(markup,
1095
                MainDescription($"({FeaturesResources.field}) DateTime C.field"));
1096 1097
        }

1098
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1099
        public async Task TestFieldInMethodQualified()
1100 1101 1102 1103 1104 1105 1106 1107 1108
        {
            var markup =
@"System.IO.FileInfo file;

void M()
{
    file$$
}";

C
Cyrus Najmabadi 已提交
1109
            await TestInClassAsync(markup,
1110
                MainDescription($"({FeaturesResources.field}) System.IO.FileInfo C.file"));
1111 1112
        }

1113
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1114
        public async Task TestMemberOfStructFromSource()
1115 1116 1117 1118 1119 1120
        {
            var markup =
@"struct MyStruct {
public static int SomeField; }
static class Test { int a = MyStruct.Some$$Field; }";

C
Cyrus Najmabadi 已提交
1121
            await TestAsync(markup,
1122
                MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"));
1123 1124
        }

J
Jared Parsons 已提交
1125
        [WorkItem(538638, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538638")]
1126
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1127
        public async Task TestMemberOfStructFromSourceWithDocComment()
1128 1129 1130 1131 1132 1133 1134
        {
            var markup =
@"struct MyStruct {
///<summary>My Field</summary>
public static int SomeField; }
static class Test { int a = MyStruct.Some$$Field; }";

C
Cyrus Najmabadi 已提交
1135
            await TestAsync(markup,
1136
                MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"),
1137 1138 1139
                Documentation("My Field"));
        }

1140
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1141
        public async Task TestMemberOfStructInsideMethodFromSource()
1142 1143 1144 1145 1146 1147
        {
            var markup =
@"struct MyStruct {
public static int SomeField; }
static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";

C
Cyrus Najmabadi 已提交
1148
            await TestAsync(markup,
1149
                MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"));
1150 1151
        }

J
Jared Parsons 已提交
1152
        [WorkItem(538638, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538638")]
1153
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1154
        public async Task TestMemberOfStructInsideMethodFromSourceWithDocComment()
1155 1156 1157 1158 1159 1160 1161
        {
            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 已提交
1162
            await TestAsync(markup,
1163
                MainDescription($"({FeaturesResources.field}) int MyStruct.SomeField"),
1164 1165 1166
                Documentation("My Field"));
        }

1167
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1168
        public async Task TestMetadataFieldMinimal()
1169
        {
C
Cyrus Najmabadi 已提交
1170
            await TestInMethodAsync(@"DateTime dt = DateTime.MaxValue$$",
1171
                MainDescription($"({FeaturesResources.field}) DateTime DateTime.MaxValue"));
1172 1173
        }

1174
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1175
        public async Task TestMetadataFieldQualified1()
1176 1177 1178 1179 1180 1181 1182 1183 1184
        {
            // 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 已提交
1185
            await TestAsync(markup,
1186
                MainDescription($"({FeaturesResources.field}) System.DateTime System.DateTime.MaxValue"));
1187 1188
        }

1189
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1190
        public async Task TestMetadataFieldQualified2()
1191
        {
C
CyrusNajmabadi 已提交
1192 1193 1194
            await TestAsync(
@"class C
{
1195 1196 1197 1198 1199
    void M()
    {
        DateTime dt = System.DateTime.MaxValue$$
    }
}",
1200
                MainDescription($"({FeaturesResources.field}) System.DateTime System.DateTime.MaxValue"));
1201 1202
        }

1203
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1204
        public async Task TestMetadataFieldQualified3()
1205
        {
C
CyrusNajmabadi 已提交
1206 1207 1208 1209 1210
            await TestAsync(
@"using System;

class C
{
1211 1212 1213 1214 1215
    void M()
    {
        DateTime dt = System.DateTime.MaxValue$$
    }
}",
1216
                MainDescription($"({FeaturesResources.field}) DateTime DateTime.MaxValue"));
1217 1218
        }

1219
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1220
        public async Task ConstructedGenericField()
1221
        {
C
CyrusNajmabadi 已提交
1222 1223 1224 1225 1226
            await TestAsync(
@"class C<T>
{
    public T Field;
}
1227

C
CyrusNajmabadi 已提交
1228 1229 1230 1231
class D
{
    void M()
    {
1232 1233 1234
        new C<int>().Fi$$eld.ToString();
    }
}",
1235
                MainDescription($"({FeaturesResources.field}) int C<int>.Field"));
1236 1237
        }

1238
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1239
        public async Task UnconstructedGenericField()
1240
        {
C
CyrusNajmabadi 已提交
1241 1242 1243
            await TestAsync(
@"class C<T>
{
1244 1245
    public T Field;

C
CyrusNajmabadi 已提交
1246 1247
    void M()
    {
1248 1249 1250
        Fi$$eld.ToString();
    }
}",
1251
                MainDescription($"({FeaturesResources.field}) T C<T>.Field"));
1252 1253
        }

1254
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1255
        public async Task TestIntegerLiteral()
1256
        {
C
Cyrus Najmabadi 已提交
1257
            await TestInMethodAsync(@"int f = 37$$",
1258 1259 1260
                MainDescription("struct System.Int32"));
        }

1261
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1262
        public async Task TestTrueKeyword()
1263
        {
C
Cyrus Najmabadi 已提交
1264
            await TestInMethodAsync(@"bool f = true$$",
1265 1266 1267
                MainDescription("struct System.Boolean"));
        }

1268
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1269
        public async Task TestFalseKeyword()
1270
        {
C
Cyrus Najmabadi 已提交
1271
            await TestInMethodAsync(@"bool f = false$$",
1272 1273 1274
                MainDescription("struct System.Boolean"));
        }

J
Jared Parsons 已提交
1275
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
1276
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1277
        public async Task TestAwaitKeywordOnGenericTaskReturningAsync()
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public async Task<int> Calc()
    {
        aw$$ait Calc();
        return 5;
    }
}";
1288
            await TestAsync(markup, MainDescription($"{FeaturesResources.Awaited_task_returns} struct System.Int32"));
1289 1290
        }

J
Jared Parsons 已提交
1291
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
1292
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1293
        public async Task TestAwaitKeywordInDeclarationStatement()
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public async Task<int> Calc()
    {
        var x = $$await Calc();
        return 5;
    }
}";
1304
            await TestAsync(markup, MainDescription($"{FeaturesResources.Awaited_task_returns} struct System.Int32"));
1305 1306
        }

J
Jared Parsons 已提交
1307
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
1308
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1309
        public async Task TestAwaitKeywordOnTaskReturningAsync()
1310 1311 1312 1313 1314 1315 1316 1317 1318
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public async void Calc()
    {
        aw$$ait Task.Delay(100);
    }
}";
1319
            await TestAsync(markup, MainDescription($"{FeaturesResources.Awaited_task_returns} {FeaturesResources.no_value}"));
1320 1321
        }

J
Jared Parsons 已提交
1322
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem(756337, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
1323
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1324
        public async Task TestNestedAwaitKeywords1()
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
        {
            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();
    }
}";
1354 1355
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) {FeaturesResources.Awaited_task_returns} class System.Threading.Tasks.Task<TResult>"),
                         TypeParameterMap($"\r\nTResult {FeaturesResources.is_} int"));
1356 1357
        }

J
Jared Parsons 已提交
1358
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
1359
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1360
        public async Task TestNestedAwaitKeywords2()
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
        {
            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();
    }
}";
1390
            await TestAsync(markup, MainDescription($"{FeaturesResources.Awaited_task_returns} struct System.Int32"));
1391 1392
        }

J
Jared Parsons 已提交
1393
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem(756337, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
1394
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1395
        public async Task TestAwaitablePrefixOnCustomAwaiter()
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416
        {
            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() { }
}";
1417
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) class C"));
1418 1419
        }

J
Jared Parsons 已提交
1420
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem(756337, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
1421
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1422
        public async Task TestTaskType()
1423 1424 1425 1426 1427 1428 1429 1430 1431
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    public void Calc()
    {
        Task$$ v1;
    }
}";
1432
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) class System.Threading.Tasks.Task"));
1433 1434
        }

J
Jared Parsons 已提交
1435
        [WorkItem(756226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem(756337, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
1436
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1437
        public async Task TestTaskOfTType()
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447
        {
            var markup = @"using System;
using System.Threading.Tasks;
class C
{
    public void Calc()
    {
        Task$$<int> v1;
    }
}";
1448 1449
            await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) class System.Threading.Tasks.Task<TResult>"),
                         TypeParameterMap($"\r\nTResult {FeaturesResources.is_} int"));
1450 1451
        }

1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468
        [WorkItem(7100, "https://github.com/dotnet/roslyn/issues/7100")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestDynamicIsntAwaitable()
        {
            var markup = @"
class C
{
    dynamic D() { return null; }
    void M()
    {
        D$$();
    }
}
";
            await TestAsync(markup, MainDescription("dynamic C.D()"));
        }

1469
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1470
        public async Task TestStringLiteral()
1471
        {
1472
            await TestInMethodAsync(@"string f = ""Goo""$$",
1473 1474 1475
                MainDescription("class System.String"));
        }

1476
        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1477
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1478
        public async Task TestVerbatimStringLiteral()
1479
        {
C
Cyrus Najmabadi 已提交
1480
            await TestInMethodAsync(@"string f = @""cat""$$",
1481 1482 1483 1484
                MainDescription("class System.String"));
        }

        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1485
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1486
        public async Task TestInterpolatedStringLiteral()
1487
        {
C
Cyrus Najmabadi 已提交
1488 1489 1490 1491
            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"));
1492 1493 1494
        }

        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1495
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1496
        public async Task TestVerbatimInterpolatedStringLiteral()
1497
        {
C
Cyrus Najmabadi 已提交
1498 1499 1500 1501
            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"));
1502 1503
        }

1504
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1505
        public async Task TestCharLiteral()
1506
        {
C
Cyrus Najmabadi 已提交
1507
            await TestInMethodAsync(@"string f = 'x'$$",
1508 1509 1510
                MainDescription("struct System.Char"));
        }

1511
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1512
        public async Task DynamicKeyword()
1513
        {
1514 1515
            await TestInMethodAsync(
@"dyn$$amic dyn;",
1516
                MainDescription("dynamic"),
1517
                Documentation(FeaturesResources.Represents_an_object_whose_operations_will_be_resolved_at_runtime));
1518 1519
        }

1520
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1521
        public async Task DynamicField()
1522
        {
1523 1524 1525
            await TestInClassAsync(
@"dynamic dyn;

1526 1527
void M()
{
1528
    d$$yn.Goo();
1529
}",
1530
                MainDescription($"({FeaturesResources.field}) dynamic C.dyn"));
1531 1532
        }

1533
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1534
        public async Task LocalProperty_Minimal()
1535
        {
1536 1537 1538
            await TestInClassAsync(
@"DateTime Prop { get; set; }

1539 1540 1541 1542 1543 1544 1545
void M()
{
    P$$rop.ToString();
}",
                MainDescription("DateTime C.Prop { get; set; }"));
        }

1546
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1547
        public async Task LocalProperty_Minimal_PrivateSet()
1548
        {
1549 1550 1551
            await TestInClassAsync(
@"public DateTime Prop { get; private set; }

1552 1553 1554 1555 1556 1557 1558
void M()
{
    P$$rop.ToString();
}",
                MainDescription("DateTime C.Prop { get; private set; }"));
        }

1559
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1560
        public async Task LocalProperty_Minimal_PrivateSet1()
1561
        {
1562 1563 1564
            await TestInClassAsync(
@"protected internal int Prop { get; private set; }

1565 1566 1567 1568 1569 1570 1571
void M()
{
    P$$rop.ToString();
}",
                MainDescription("int C.Prop { get; private set; }"));
        }

1572
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1573
        public async Task LocalProperty_Qualified()
1574
        {
1575 1576 1577
            await TestInClassAsync(
@"System.IO.FileInfo Prop { get; set; }

1578 1579 1580 1581 1582 1583 1584
void M()
{
    P$$rop.ToString();
}",
                MainDescription("System.IO.FileInfo C.Prop { get; set; }"));
        }

1585
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1586
        public async Task NonLocalProperty_Minimal()
1587
        {
C
Cyrus Najmabadi 已提交
1588
            await TestInMethodAsync(@"DateTime.No$$w.ToString();",
1589 1590 1591
                MainDescription("DateTime DateTime.Now { get; }"));
        }

1592
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1593
        public async Task NonLocalProperty_Qualified()
1594
        {
1595 1596 1597 1598
            await TestInMethodAsync(
@"System.IO.FileInfo f;

f.Att$$ributes.ToString();",
1599 1600 1601
                MainDescription("System.IO.FileAttributes System.IO.FileSystemInfo.Attributes { get; set; }"));
        }

1602
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1603
        public async Task ConstructedGenericProperty()
1604
        {
C
CyrusNajmabadi 已提交
1605 1606 1607 1608
            await TestAsync(
@"class C<T>
{
    public T Property { get; set }
1609 1610
}

C
CyrusNajmabadi 已提交
1611 1612 1613 1614
class D
{
    void M()
    {
1615 1616 1617 1618 1619 1620
        new C<int>().Pro$$perty.ToString();
    }
}",
                MainDescription("int C<int>.Property { get; set; }"));
        }

1621
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1622
        public async Task UnconstructedGenericProperty()
1623
        {
C
CyrusNajmabadi 已提交
1624 1625 1626
            await TestAsync(
@"class C<T>
{
1627 1628
    public T Property { get; set}

C
CyrusNajmabadi 已提交
1629 1630
    void M()
    {
1631 1632 1633 1634 1635 1636
        Pro$$perty.ToString();
    }
}",
                MainDescription("T C<T>.Property { get; set; }"));
        }

1637
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1638
        public async Task ValueInProperty()
1639
        {
1640 1641 1642 1643 1644
            await TestInClassAsync(
@"public DateTime Property
{
    set
    {
1645
        goo = val$$ue;
1646 1647
    }
}",
1648
                MainDescription($"({FeaturesResources.parameter}) DateTime value"));
1649 1650
        }

1651
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1652
        public async Task EnumTypeName()
1653
        {
C
Cyrus Najmabadi 已提交
1654
            await TestInMethodAsync(@"Consol$$eColor c",
1655 1656 1657
                MainDescription("enum System.ConsoleColor"));
        }

1658
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1659
        public async Task EnumMemberNameFromMetadata()
1660
        {
C
Cyrus Najmabadi 已提交
1661
            await TestInMethodAsync(@"ConsoleColor c = ConsoleColor.Bla$$ck",
1662 1663 1664
                MainDescription("ConsoleColor.Black = 0"));
        }

1665
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1666
        public async Task FlagsEnumMemberNameFromMetadata1()
1667
        {
C
Cyrus Najmabadi 已提交
1668
            await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.Cl$$ass",
1669 1670 1671
                MainDescription("AttributeTargets.Class = 4"));
        }

1672
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1673
        public async Task FlagsEnumMemberNameFromMetadata2()
1674
        {
C
Cyrus Najmabadi 已提交
1675
            await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.A$$ll",
1676 1677 1678
                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"));
        }

1679
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1680
        public async Task EnumMemberNameFromSource1()
1681
        {
C
CyrusNajmabadi 已提交
1682 1683
            await TestAsync(
@"enum E
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699
{
    A = 1 << 0,
    B = 1 << 1,
    C = 1 << 2
}

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

1700
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1701
        public async Task EnumMemberNameFromSource2()
1702
        {
C
CyrusNajmabadi 已提交
1703 1704
            await TestAsync(
@"enum E
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720
{
    A,
    B,
    C
}

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

1721
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1722
        public async Task Parameter_InMethod_Minimal()
1723
        {
1724 1725 1726 1727
            await TestInClassAsync(
@"void M(DateTime dt)
{
    d$$t.ToString();",
1728
                MainDescription($"({FeaturesResources.parameter}) DateTime dt"));
1729 1730
        }

1731
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1732
        public async Task Parameter_InMethod_Qualified()
1733
        {
1734 1735 1736 1737
            await TestInClassAsync(
@"void M(System.IO.FileInfo fileInfo)
{
    file$$Info.ToString();",
1738
                MainDescription($"({FeaturesResources.parameter}) System.IO.FileInfo fileInfo"));
1739 1740
        }

1741
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1742
        public async Task Parameter_FromReferenceToNamedParameter()
1743
        {
C
Cyrus Najmabadi 已提交
1744
            await TestInMethodAsync(@"Console.WriteLine(va$$lue: ""Hi"");",
1745
                MainDescription($"({FeaturesResources.parameter}) string value"));
1746 1747
        }

1748
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1749
        public async Task Parameter_DefaultValue()
1750 1751 1752
        {
            // NOTE: Dev10 doesn't show the default value, but it would be nice if we did.
            // NOTE: The "DefaultValue" property isn't implemented yet.
1753 1754 1755 1756 1757
            await TestInClassAsync(
@"void M(int param = 42)
{
    para$$m.ToString();
}",
1758
                MainDescription($"({FeaturesResources.parameter}) int param = 42"));
1759 1760
        }

1761
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1762
        public async Task Parameter_Params()
1763
        {
1764 1765 1766 1767 1768
            await TestInClassAsync(
@"void M(params DateTime[] arg)
{
    ar$$g.ToString();
}",
1769
                MainDescription($"({FeaturesResources.parameter}) params DateTime[] arg"));
1770 1771
        }

1772
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1773
        public async Task Parameter_Ref()
1774
        {
1775 1776 1777 1778 1779
            await TestInClassAsync(
@"void M(ref DateTime arg)
{
    ar$$g.ToString();
}",
1780
                MainDescription($"({FeaturesResources.parameter}) ref DateTime arg"));
1781 1782
        }

1783
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1784
        public async Task Parameter_Out()
1785
        {
1786 1787 1788 1789 1790
            await TestInClassAsync(
@"void M(out DateTime arg)
{
    ar$$g.ToString();
}",
1791
                MainDescription($"({FeaturesResources.parameter}) out DateTime arg"));
1792 1793
        }

1794
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1795
        public async Task Local_Minimal()
1796
        {
1797 1798 1799 1800
            await TestInMethodAsync(
@"DateTime dt;

d$$t.ToString();",
1801
                MainDescription($"({FeaturesResources.local_variable}) DateTime dt"));
1802 1803
        }

1804
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1805
        public async Task Local_Qualified()
1806
        {
1807 1808 1809 1810
            await TestInMethodAsync(
@"System.IO.FileInfo fileInfo;

file$$Info.ToString();",
1811
                MainDescription($"({FeaturesResources.local_variable}) System.IO.FileInfo fileInfo"));
1812 1813
        }

1814
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1815
        public async Task Method_MetadataOverload()
1816
        {
C
Cyrus Najmabadi 已提交
1817
            await TestInMethodAsync("Console.Write$$Line();",
1818
                MainDescription($"void Console.WriteLine() (+ 18 {FeaturesResources.overloads_})"));
1819 1820
        }

1821
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1822
        public async Task Method_SimpleWithOverload()
1823
        {
1824 1825 1826 1827 1828 1829 1830 1831 1832
            await TestInClassAsync(
@"void Method()
{
    Met$$hod();
}

void Method(int i)
{
}",
1833
                MainDescription($"void C.Method() (+ 1 {FeaturesResources.overload})"));
1834 1835
        }

1836
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1837
        public async Task Method_MoreOverloads()
1838
        {
1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855
            await TestInClassAsync(
@"void Method()
{
    Met$$hod(null);
}

void Method(int i)
{
}

void Method(DateTime dt)
{
}

void Method(System.IO.FileInfo fileInfo)
{
}",
1856
                MainDescription($"void C.Method(System.IO.FileInfo fileInfo) (+ 3 {FeaturesResources.overloads_})"));
1857 1858
        }

1859
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1860
        public async Task Method_SimpleInSameClass()
1861
        {
1862 1863 1864 1865 1866
            await TestInClassAsync(
@"DateTime GetDate(System.IO.FileInfo ft)
{
    Get$$Date(null);
}",
1867 1868 1869
                MainDescription("DateTime C.GetDate(System.IO.FileInfo ft)"));
        }

1870
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1871
        public async Task Method_OptionalParameter()
1872
        {
1873 1874 1875 1876 1877 1878 1879 1880 1881
            await TestInClassAsync(
@"void M()
{
    Met$$hod();
}

void Method(int i = 0)
{
}",
1882 1883 1884
                MainDescription("void C.Method([int i = 0])"));
        }

1885
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1886
        public async Task Method_OptionalDecimalParameter()
1887
        {
1888
            await TestInClassAsync(
1889
@"void Goo(decimal x$$yz = 10)
1890 1891
{
}",
1892
                MainDescription($"({FeaturesResources.parameter}) decimal xyz = 10"));
1893 1894
        }

1895
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1896
        public async Task Method_Generic()
1897 1898 1899
        {
            // Generic method don't get the instantiation info yet.  NOTE: We don't display
            // constraint info in Dev10. Should we?
1900
            await TestInClassAsync(
1901
@"TOut Goo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn>
1902
{
1903
    Go$$o<int, DateTime>(37);
1904 1905
}",

1906
            MainDescription("DateTime C.Goo<int, DateTime>(int arg)"));
1907 1908
        }

1909
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1910
        public async Task Method_UnconstructedGeneric()
1911
        {
1912
            await TestInClassAsync(
1913
@"TOut Goo<TIn, TOut>(TIn arg)
1914
{
1915
    Go$$o<TIn, TOut>(default(TIn);
1916 1917
}",

1918
                MainDescription("TOut C.Goo<TIn, TOut>(TIn arg)"));
1919 1920
        }

1921
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1922
        public async Task Method_Inferred()
1923
        {
1924
            await TestInClassAsync(
1925
@"void Goo<TIn>(TIn arg)
1926
{
1927
    Go$$o(42);
1928
}",
1929
                MainDescription("void C.Goo<int>(int arg)"));
1930 1931
        }

1932
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1933
        public async Task Method_MultipleParams()
1934
        {
1935
            await TestInClassAsync(
1936
@"void Goo(DateTime dt, System.IO.FileInfo fi, int number)
1937
{
1938
    Go$$o(DateTime.Now, null, 32);
1939
}",
1940
                MainDescription("void C.Goo(DateTime dt, System.IO.FileInfo fi, int number)"));
1941 1942
        }

1943
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1944
        public async Task Method_OptionalParam()
1945 1946
        {
            // NOTE - Default values aren't actually returned by symbols yet.
1947
            await TestInClassAsync(
1948
@"void Goo(int num = 42)
1949
{
1950
    Go$$o();
1951
}",
1952
                MainDescription("void C.Goo([int num = 42])"));
1953 1954
        }

1955
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1956
        public async Task Method_ParameterModifiers()
1957 1958
        {
            // NOTE - Default values aren't actually returned by symbols yet.
1959
            await TestInClassAsync(
1960
@"void Goo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)
1961
{
1962
    Go$$o(DateTime.Now, null, 32);
1963
}",
1964
                MainDescription("void C.Goo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)"));
1965 1966
        }

1967
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1968
        public async Task Constructor()
1969
        {
1970 1971 1972 1973 1974 1975 1976 1977 1978
            await TestInClassAsync(
@"public C()
{
}

void M()
{
    new C$$().ToString();
}",
1979 1980 1981
                MainDescription("C.C()"));
        }

1982
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1983
        public async Task Constructor_Overloads()
1984
        {
1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996
            await TestInClassAsync(
@"public C()
{
}

public C(DateTime dt)
{
}

public C(int i)
{
}
1997 1998 1999

void M()
{
2000
    new C$$(DateTime.MaxValue).ToString();
2001
}",
2002
                MainDescription($"C.C(DateTime dt) (+ 2 {FeaturesResources.overloads_})"));
2003 2004 2005 2006 2007
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
2008
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2009
        public async Task Constructor_OverloadFromStringLiteral()
2010
        {
2011 2012
            await TestInMethodAsync(
@"new InvalidOperatio$$nException("""");",
2013
                MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.overloads_})"));
2014 2015 2016 2017 2018
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
2019
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2020
        public async Task Constructor_UnknownType()
2021
        {
2022 2023 2024
            await TestInvalidTypeInClassAsync(
@"void M()
{
2025
    new G$$oo();
2026
}");
2027 2028 2029 2030 2031
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
2032
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2033
        public async Task Constructor_OverloadFromProperty()
2034
        {
2035 2036
            await TestInMethodAsync(
@"new InvalidOperatio$$nException(this.GetType().Name);",
2037
                MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.overloads_})"));
2038 2039
        }

2040
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2041
        public async Task Constructor_Metadata()
2042
        {
2043 2044
            await TestInMethodAsync(
@"new Argument$$NullException();",
2045
                MainDescription($"ArgumentNullException.ArgumentNullException() (+ 3 {FeaturesResources.overloads_})"));
2046 2047
        }

2048
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2049
        public async Task Constructor_MetadataQualified()
2050
        {
C
Cyrus Najmabadi 已提交
2051
            await TestInMethodAsync(@"new System.IO.File$$Info(null);",
2052 2053 2054
                MainDescription("System.IO.FileInfo.FileInfo(string fileName)"));
        }

2055
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2056
        public async Task InterfaceProperty()
2057
        {
2058 2059
            await TestInMethodAsync(
@"interface I
2060 2061 2062 2063 2064 2065
{
    string Name$$ { get; set; }
}",
                MainDescription("string I.Name { get; set; }"));
        }

2066
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2067
        public async Task ExplicitInterfacePropertyImplementation()
2068
        {
2069 2070
            await TestInMethodAsync(
@"interface I
2071 2072 2073 2074 2075 2076 2077 2078
{
    string Name { get; set; }
}

class C : I
{
    string IEmployee.Name$$
    {
2079 2080 2081 2082 2083 2084 2085 2086
        get
        {
            return """";
        }

        set
        {
        }
2087 2088 2089 2090 2091
    }
}",
                MainDescription("string C.Name { get; set; }"));
        }

2092
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2093
        public async Task Operator()
2094
        {
2095 2096 2097 2098 2099 2100 2101 2102 2103 2104
            await TestInClassAsync(
@"public static C operator +(C left, C right)
{
    return null;
}

void M(C left, C right)
{
    return left +$$ right;
}",
2105 2106 2107
                MainDescription("C C.operator +(C left, C right)"));
        }

2108
#pragma warning disable CA2243 // Attribute string literals should parse correctly
2109
        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
2110
#pragma warning restore CA2243 // Attribute string literals should parse correctly
2111
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2112
        public async Task GenericMethodWithConstraintsAtDeclaration()
2113
        {
2114
            await TestInClassAsync(
2115
@"TOut G$$oo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn>
2116
{
2117 2118
}",

2119
            MainDescription("TOut C.Goo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn>"));
2120 2121
        }

2122
#pragma warning disable CA2243 // Attribute string literals should parse correctly
2123
        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
2124
#pragma warning restore CA2243 // Attribute string literals should parse correctly
2125
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2126
        public async Task GenericMethodWithMultipleConstraintsAtDeclaration()
2127
        {
2128
            await TestInClassAsync(
2129
@"TOut Goo<TIn, TOut>(TIn arg) where TIn : Employee, new()
2130
{
2131
    Go$$o<TIn, TOut>(default(TIn);
2132
}",
2133

2134
            MainDescription("TOut C.Goo<TIn, TOut>(TIn arg) where TIn : Employee, new()"));
2135 2136
        }

2137
#pragma warning disable CA2243 // Attribute string literals should parse correctly
2138
        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
2139
#pragma warning restore CA2243 // Attribute string literals should parse correctly
2140
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2141
        public async Task UnConstructedGenericMethodWithConstraintsAtInvocation()
2142
        {
2143
            await TestInClassAsync(
2144
@"TOut Goo<TIn, TOut>(TIn arg) where TIn : Employee
2145
{
2146
    Go$$o<TIn, TOut>(default(TIn);
2147
}",
2148

2149
            MainDescription("TOut C.Goo<TIn, TOut>(TIn arg) where TIn : Employee"));
2150 2151
        }

2152
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2153
        public async Task GenericTypeWithConstraintsAtDeclaration()
2154
        {
C
CyrusNajmabadi 已提交
2155 2156
            await TestAsync(
@"public class Employee : IComparable<Employee>
2157 2158 2159 2160 2161 2162
{
    public int CompareTo(Employee other)
    {
        throw new NotImplementedException();
    }
}
C
CyrusNajmabadi 已提交
2163

2164 2165 2166 2167 2168 2169 2170
class Emplo$$yeeList<T> : IEnumerable<T> where T : Employee, System.IComparable<T>, new()
{
}",

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

2171
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2172
        public async Task GenericType()
2173
        {
C
CyrusNajmabadi 已提交
2174 2175
            await TestAsync(
@"class T1<T11>
2176 2177
{
    $$T11 i;
C
CyrusNajmabadi 已提交
2178
}",
2179
                MainDescription($"T11 {FeaturesResources.in_} T1<T11>"));
2180 2181
        }

2182
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2183
        public async Task GenericMethod()
2184
        {
2185 2186 2187 2188 2189
            await TestInClassAsync(
@"static void Meth1<T1>(T1 i) where T1 : struct
{
    $$T1 i;
}",
2190
                MainDescription($"T1 {FeaturesResources.in_} C.Meth1<T1> where T1 : struct"));
2191 2192
        }

2193
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2194
        public async Task Var()
2195
        {
2196 2197 2198
            await TestInMethodAsync(
@"var x = new Exception();
var y = $$x;",
2199
                MainDescription($"({FeaturesResources.local_variable}) Exception x"));
2200 2201
        }

2202
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2203
        public async Task NestedInGeneric()
2204
        {
2205 2206
            await TestInMethodAsync(
@"List<int>.Enu$$merator e;",
2207
                MainDescription("struct System.Collections.Generic.List<T>.Enumerator"),
2208
                TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
2209 2210
        }

2211
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2212
        public async Task NestedGenericInGeneric()
2213
        {
C
CyrusNajmabadi 已提交
2214 2215
            await TestAsync(
@"class Outer<T>
2216 2217 2218 2219 2220 2221 2222 2223 2224
{
    class Inner<U>
    {
    }

    static void M()
    {
        Outer<int>.I$$nner<string> e;
    }
C
CyrusNajmabadi 已提交
2225
}",
2226 2227
                MainDescription("class Outer<T>.Inner<U>"),
                TypeParameterMap(
2228 2229
                    Lines($"\r\nT {FeaturesResources.is_} int",
                          $"U {FeaturesResources.is_} string")));
2230 2231
        }

2232
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2233
        public async Task ObjectInitializer1()
2234
        {
2235 2236 2237 2238 2239
            await TestInClassAsync(
@"void M()
{
    var x = new test() { $$z = 5 };
}
2240

2241 2242 2243 2244
class test
{
    public int z;
}",
2245
                MainDescription($"({FeaturesResources.field}) int test.z"));
2246 2247
        }

2248
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2249
        public async Task ObjectInitializer2()
2250
        {
2251 2252
            await TestInMethodAsync(
@"class C
2253 2254 2255 2256 2257 2258 2259 2260 2261 2262
{
    void M()
    {
        var x = new test() { z = $$5 };
    }

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

2267
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
J
Jared Parsons 已提交
2268
        [WorkItem(537880, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537880")]
C
Cyrus Najmabadi 已提交
2269
        public async Task TypeArgument()
2270
        {
C
CyrusNajmabadi 已提交
2271 2272
            await TestAsync(
@"class C<T, Y>
2273 2274 2275 2276 2277 2278 2279
{
    void M()
    {
        C<int, DateTime> variable;
        $$variable = new C<int, DateTime>();
    }
}",
2280
                MainDescription($"({FeaturesResources.local_variable}) C<int, DateTime> variable"));
2281 2282
        }

2283
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2284
        public async Task ForEachLoop_1()
2285
        {
2286 2287 2288
            await TestInMethodAsync(
@"int bb = 555;

2289 2290 2291 2292
bb = bb + 1;
foreach (int cc in new int[]{ 1,2,3}){
c$$c = 1;
bb = bb + 21;
2293
}",
2294
                MainDescription($"({FeaturesResources.local_variable}) int cc"));
2295 2296
        }

2297
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2298
        public async Task TryCatchFinally_1()
2299
        {
2300 2301
            await TestInMethodAsync(
@"try
2302 2303
            {
                int aa = 555;
2304 2305

a$$a = aa + 1;
2306 2307 2308 2309 2310 2311 2312
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }",
2313
                MainDescription($"({FeaturesResources.local_variable}) int aa"));
2314 2315
        }

2316
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2317
        public async Task TryCatchFinally_2()
2318
        {
2319 2320
            await TestInMethodAsync(
@"try
2321 2322 2323 2324 2325
            {
            }
            catch (Exception ex)
            {
                var y = e$$x;
2326
var z = y;
2327 2328 2329
            }
            finally
            {
2330
            }",
2331
                MainDescription($"({FeaturesResources.local_variable}) Exception ex"));
2332 2333
        }

2334
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2335
        public async Task TryCatchFinally_3()
2336
        {
2337 2338
            await TestInMethodAsync(
@"try
2339 2340 2341 2342 2343
            {
            }
            catch (Exception ex)
            {
                var aa = 555;
2344 2345

aa = a$$a + 1;
2346 2347 2348
            }
            finally
            {
2349
            }",
2350
                MainDescription($"({FeaturesResources.local_variable}) int aa"));
2351 2352
        }

2353
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2354
        public async Task TryCatchFinally_4()
2355
        {
2356 2357
            await TestInMethodAsync(
@"try
2358 2359 2360 2361 2362 2363 2364 2365
            {
            }
            catch (Exception ex)
            {
            }
            finally
            {
                int aa = 555;
2366 2367 2368

aa = a$$a + 1;
            }",
2369
                MainDescription($"({FeaturesResources.local_variable}) int aa"));
2370 2371
        }

2372
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2373
        public async Task GenericVariable()
2374
        {
C
CyrusNajmabadi 已提交
2375 2376 2377 2378 2379 2380 2381 2382 2383
            await TestAsync(
@"class C<T, Y>
{
    void M()
    {
        C<int, DateTime> variable;
        var$$iable = new C<int, DateTime>();
    }
}",
2384
                MainDescription($"({FeaturesResources.local_variable}) C<int, DateTime> variable"));
2385 2386
        }

2387
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2388
        public async Task TestInstantiation()
2389
        {
C
CyrusNajmabadi 已提交
2390 2391 2392
            await TestAsync(
@"using System.Collections.Generic;

2393 2394 2395 2396 2397 2398 2399
class Program<T>
{
    static void Main(string[] args)
    {
        var p = new Dictio$$nary<int, string>();
    }
}",
2400
                MainDescription($"Dictionary<int, string>.Dictionary() (+ 5 {FeaturesResources.overloads_})"));
2401 2402
        }

2403
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2404
        public async Task TestUsingAlias_Bug4141()
2405
        {
C
CyrusNajmabadi 已提交
2406 2407 2408 2409 2410 2411 2412 2413
            await TestAsync(
@"using X = A.C;

class A
{
    public class C
    {
    }
2414
}
C
CyrusNajmabadi 已提交
2415 2416 2417 2418

class D : X$$
{
}",
2419 2420 2421
                MainDescription(@"class A.C"));
        }

2422
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2423
        public async Task TestFieldOnDeclaration()
2424
        {
2425 2426
            await TestInClassAsync(
@"DateTime fie$$ld;",
2427
                MainDescription($"({FeaturesResources.field}) DateTime C.field"));
2428 2429
        }

J
Jared Parsons 已提交
2430
        [WorkItem(538767, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538767")]
2431
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2432
        public async Task TestGenericErrorFieldOnDeclaration()
2433
        {
2434 2435
            await TestInClassAsync(
@"NonExistentType<int> fi$$eld;",
2436
                MainDescription($"({FeaturesResources.field}) NonExistentType<int> C.field"));
2437 2438
        }

J
Jared Parsons 已提交
2439
        [WorkItem(538822, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538822")]
2440
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2441
        public async Task TestDelegateType()
2442
        {
2443 2444
            await TestInClassAsync(
@"Fun$$c<int, string> field;",
2445 2446
                MainDescription("delegate TResult System.Func<in T, out TResult>(T arg)"),
                TypeParameterMap(
2447 2448
                    Lines($"\r\nT {FeaturesResources.is_} int",
                          $"TResult {FeaturesResources.is_} string")));
2449 2450
        }

J
Jared Parsons 已提交
2451
        [WorkItem(538824, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538824")]
2452
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2453
        public async Task TestOnDelegateInvocation()
2454
        {
C
CyrusNajmabadi 已提交
2455 2456
            await TestAsync(
@"class Program
2457 2458
{
    delegate void D1();
C
CyrusNajmabadi 已提交
2459

2460 2461 2462
    static void Main()
    {
        D1 d = Main;
C
CyrusNajmabadi 已提交
2463
        $$d();
2464
    }
C
CyrusNajmabadi 已提交
2465
}",
2466
                MainDescription($"({FeaturesResources.local_variable}) D1 d"));
2467 2468
        }

J
Jared Parsons 已提交
2469
        [WorkItem(539240, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539240")]
2470
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2471
        public async Task TestOnArrayCreation1()
2472
        {
C
CyrusNajmabadi 已提交
2473 2474
            await TestAsync(
@"class Program
2475 2476 2477 2478 2479
{
    static void Main()
    {
        int[] a = n$$ew int[0];
    }
2480
}", MainDescription("int[]"));
2481 2482
        }

J
Jared Parsons 已提交
2483
        [WorkItem(539240, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539240")]
2484
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2485
        public async Task TestOnArrayCreation2()
2486
        {
C
CyrusNajmabadi 已提交
2487 2488
            await TestAsync(
@"class Program
2489 2490 2491 2492 2493 2494 2495 2496 2497
{
    static void Main()
    {
        int[] a = new i$$nt[0];
    }
}",
                MainDescription("struct System.Int32"));
        }

J
Jared Parsons 已提交
2498
        [WorkItem(539841, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539841")]
2499
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2500
        public async Task TestIsNamedTypeAccessibleForErrorTypes()
2501
        {
C
CyrusNajmabadi 已提交
2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512
            await TestAsync(
@"sealed class B<T1, T2> : A<B<T1, T2>>
{
    protected sealed override B<A<T>, A$$<T>> N()
    {
    }
}

internal class A<T>
{
}",
2513 2514 2515
                MainDescription("class A<T>"));
        }

J
Jared Parsons 已提交
2516
        [WorkItem(540075, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540075")]
2517
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2518
        public async Task TestErrorType()
2519
        {
C
CyrusNajmabadi 已提交
2520
            await TestAsync(
2521
@"using Goo = Goo;
C
CyrusNajmabadi 已提交
2522

2523 2524 2525 2526
class C
{
    void Main()
    {
2527
        $$Goo
2528 2529
    }
}",
2530
                MainDescription("Goo"));
2531 2532
        }

2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625
        [WorkItem(16662, "https://github.com/dotnet/roslyn/issues/16662")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestShortDiscardInAssignment()
        {
            await TestAsync(
@"class C
{
    int M()
    {
        $$_ = M();
    }
}",
                MainDescription("int _"));
        }

        [WorkItem(16662, "https://github.com/dotnet/roslyn/issues/16662")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestUnderscoreLocalInAssignment()
        {
            await TestAsync(
@"class C
{
    int M()
    {
        var $$_ = M();
    }
}",
                MainDescription($"({FeaturesResources.local_variable}) int _"));
        }

        [WorkItem(16662, "https://github.com/dotnet/roslyn/issues/16662")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestShortDiscardInOutVar()
        {
            await TestAsync(
@"class C
{
    void M(out int i)
    {
        M(out $$_);
        i = 0;
    }
}",
                MainDescription($"int _"));
        }

        [WorkItem(16667, "https://github.com/dotnet/roslyn/issues/16667")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestDiscardInOutVar()
        {
            await TestAsync(
@"class C
{
    void M(out int i)
    {
        M(out var $$_);
        i = 0;
    }
}"); // No quick info (see issue #16667)
        }

        [WorkItem(16667, "https://github.com/dotnet/roslyn/issues/16667")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestDiscardInIsPattern()
        {
            await TestAsync(
@"class C
{
    void M()
    {
        if (3 is int $$_) { }
    }
}"); // No quick info (see issue #16667)
        }

        [WorkItem(16667, "https://github.com/dotnet/roslyn/issues/16667")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestDiscardInSwitchPattern()
        {
            await TestAsync(
@"class C
{
    void M()
    {
        switch (3)
        {
            case int $$_:
                return;
        }
    }
}"); // No quick info (see issue #16667)
        }

J
Jared Parsons 已提交
2626
        [WorkItem(540871, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540871")]
2627
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2628
        public async Task TestLiterals()
2629
        {
C
CyrusNajmabadi 已提交
2630 2631
            await TestAsync(
@"class MyClass
2632
{
C
CyrusNajmabadi 已提交
2633
    MyClass() : this($$10)
2634 2635 2636
    {
        intI = 2;
    }
C
CyrusNajmabadi 已提交
2637 2638 2639 2640 2641

    public MyClass(int i)
    {
    }

2642
    static int intI = 1;
C
CyrusNajmabadi 已提交
2643

2644 2645 2646 2647 2648 2649 2650 2651
    public static int Main()
    {
        return 1;
    }
}",
                MainDescription("struct System.Int32"));
        }

J
Jared Parsons 已提交
2652
        [WorkItem(541444, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541444")]
2653
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2654
        public async Task TestErrorInForeach()
2655
        {
C
CyrusNajmabadi 已提交
2656 2657
            await TestAsync(
@"class C
2658 2659 2660 2661 2662 2663 2664 2665 2666
{
    void Main()
    {
        foreach (int cc in null)
        {
            $$cc = 1;
        }
    }
}",
2667
                MainDescription($"({FeaturesResources.local_variable}) int cc"));
2668 2669
        }

J
Jared Parsons 已提交
2670
        [WorkItem(540438, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540438")]
2671
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2672
        public async Task TestNoQuickInfoOnAnonymousDelegate()
2673
        {
C
CyrusNajmabadi 已提交
2674 2675
            await TestAsync(
@"using System;
2676 2677 2678 2679 2680

class Program
{
    static void Main(string[] args)
    {
2681
        Action a = $$delegate {
C
CyrusNajmabadi 已提交
2682
        };
2683 2684 2685 2686
    }
}");
        }

J
Jared Parsons 已提交
2687
        [WorkItem(541678, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541678")]
2688
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2689
        public async Task TestQuickInfoOnEvent()
2690
        {
C
CyrusNajmabadi 已提交
2691 2692 2693
            await TestAsync(
@"using System;

2694 2695
public class SampleEventArgs
{
C
CyrusNajmabadi 已提交
2696 2697 2698 2699 2700 2701
    public SampleEventArgs(string s)
    {
        Text = s;
    }

    public String Text { get; private set; }
2702
}
C
CyrusNajmabadi 已提交
2703

2704 2705 2706
public class Publisher
{
    public delegate void SampleEventHandler(object sender, SampleEventArgs e);
C
CyrusNajmabadi 已提交
2707

2708
    public event SampleEventHandler SampleEvent;
C
CyrusNajmabadi 已提交
2709

2710 2711 2712 2713 2714
    protected virtual void RaiseSampleEvent()
    {
        if (Sam$$pleEvent != null)
            SampleEvent(this, new SampleEventArgs(""Hello""));
    }
C
CyrusNajmabadi 已提交
2715
}",
2716 2717 2718
                MainDescription("SampleEventHandler Publisher.SampleEvent"));
        }

J
Jared Parsons 已提交
2719
        [WorkItem(542157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542157")]
2720
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2721
        public async Task TestEvent()
2722
        {
C
Cyrus Najmabadi 已提交
2723
            await TestInMethodAsync(@"System.Console.CancelKeyPres$$s += null;",
2724 2725 2726
                MainDescription("ConsoleCancelEventHandler Console.CancelKeyPress"));
        }

J
Jared Parsons 已提交
2727
        [WorkItem(542157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542157")]
2728
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2729
        public async Task TestEventPlusEqualsOperator()
2730
        {
C
Cyrus Najmabadi 已提交
2731
            await TestInMethodAsync(@"System.Console.CancelKeyPress +$$= null;",
2732 2733 2734
                MainDescription("void Console.CancelKeyPress.add"));
        }

J
Jared Parsons 已提交
2735
        [WorkItem(542157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542157")]
2736
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2737
        public async Task TestEventMinusEqualsOperator()
2738
        {
C
Cyrus Najmabadi 已提交
2739
            await TestInMethodAsync(@"System.Console.CancelKeyPress -$$= null;",
2740 2741 2742
                MainDescription("void Console.CancelKeyPress.remove"));
        }

J
Jared Parsons 已提交
2743
        [WorkItem(541885, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541885")]
2744
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2745
        public async Task TestQuickInfoOnExtensionMethod()
2746
        {
2747 2748
            await TestWithOptionsAsync(Options.Regular, 
@"using System;
2749 2750
using System.Collections.Generic;
using System.Linq;
2751

2752 2753 2754 2755
class Program
{
    static void Main(string[] args)
    {
2756 2757 2758
        int[] values = {
            1
        };
2759 2760 2761
        bool isArray = 7.I$$n(values);
    }
}
2762

2763 2764 2765 2766 2767 2768
public static class MyExtensions
{
    public static bool In<T>(this T o, IEnumerable<T> items)
    {
        return true;
    }
2769
}",
2770
                MainDescription($"({CSharpFeaturesResources.extension}) bool int.In<int>(IEnumerable<int> items)"));
2771 2772
        }

2773
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2774
        public async Task TestQuickInfoOnExtensionMethodOverloads()
2775
        {
2776 2777
            await TestWithOptionsAsync(Options.Regular, 
@"using System;
2778 2779 2780 2781 2782 2783
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
2784
        ""1"".Test$$Ext();
2785 2786
    }
}
2787

2788 2789
public static class Ex
{
2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801
    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)
    {
    }
}",
2802
                MainDescription($"({CSharpFeaturesResources.extension}) void string.TestExt<string>() (+ 2 {FeaturesResources.overloads_})"));
2803 2804
        }

2805
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2806
        public async Task TestQuickInfoOnExtensionMethodOverloads2()
2807
        {
2808 2809
            await TestWithOptionsAsync(Options.Regular, 
@"using System;
2810 2811 2812 2813 2814 2815
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
2816
        ""1"".Test$$Ext();
2817 2818
    }
}
2819

2820 2821
public static class Ex
{
2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833
    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)
    {
    }
}",
2834
                MainDescription($"({CSharpFeaturesResources.extension}) void string.TestExt<string>() (+ 1 {FeaturesResources.overload})"));
2835 2836
        }

2837
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2838
        public async Task Query1()
2839
        {
C
CyrusNajmabadi 已提交
2840 2841 2842
            await TestAsync(
@"using System.Linq;

2843 2844 2845 2846
class C
{
    void M()
    {
C
CyrusNajmabadi 已提交
2847 2848
        var q = from n in new int[] { 1, 2, 3, 4, 5 }

2849 2850
                select $$n;
    }
C
CyrusNajmabadi 已提交
2851
}",
2852
                MainDescription($"({FeaturesResources.range_variable}) int n"));
2853 2854
        }

2855
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2856
        public async Task Query2()
2857
        {
C
CyrusNajmabadi 已提交
2858 2859 2860
            await TestAsync(
@"using System.Linq;

2861 2862 2863 2864
class C
{
    void M()
    {
C
CyrusNajmabadi 已提交
2865 2866
        var q = from n$$ in new int[] { 1, 2, 3, 4, 5 }

2867 2868
                select n;
    }
C
CyrusNajmabadi 已提交
2869
}",
2870
                MainDescription($"({FeaturesResources.range_variable}) int n"));
2871 2872
        }

2873
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2874
        public async Task Query3()
2875
        {
C
CyrusNajmabadi 已提交
2876 2877
            await TestAsync(
@"class C
2878 2879 2880
{
    void M()
    {
C
CyrusNajmabadi 已提交
2881 2882
        var q = from n in new int[] { 1, 2, 3, 4, 5 }

2883 2884
                select $$n;
    }
C
CyrusNajmabadi 已提交
2885
}",
2886
                MainDescription($"({FeaturesResources.range_variable}) ? n"));
2887 2888
        }

2889
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2890
        public async Task Query4()
2891
        {
C
CyrusNajmabadi 已提交
2892 2893
            await TestAsync(
@"class C
2894 2895 2896
{
    void M()
    {
C
CyrusNajmabadi 已提交
2897 2898
        var q = from n$$ in new int[] { 1, 2, 3, 4, 5 }

2899 2900
                select n;
    }
C
CyrusNajmabadi 已提交
2901
}",
2902
                MainDescription($"({FeaturesResources.range_variable}) ? n"));
2903 2904
        }

2905
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2906
        public async Task Query5()
2907
        {
C
CyrusNajmabadi 已提交
2908 2909
            await TestAsync(
@"using System.Collections.Generic;
2910
using System.Linq;
C
CyrusNajmabadi 已提交
2911

2912 2913 2914 2915 2916 2917 2918
class C
{
    void M()
    {
        var q = from n in new List<object>()
                select $$n;
    }
C
CyrusNajmabadi 已提交
2919
}",
2920
                MainDescription($"({FeaturesResources.range_variable}) object n"));
2921 2922
        }

2923
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2924
        public async Task Query6()
2925
        {
C
CyrusNajmabadi 已提交
2926 2927
            await TestAsync(
@"using System.Collections.Generic;
2928
using System.Linq;
C
CyrusNajmabadi 已提交
2929

2930 2931 2932 2933 2934 2935 2936
class C
{
    void M()
    {
        var q = from n$$ in new List<object>()
                select n;
    }
C
CyrusNajmabadi 已提交
2937
}",
2938
                MainDescription($"({FeaturesResources.range_variable}) object n"));
2939 2940
        }

2941
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2942
        public async Task Query7()
2943
        {
C
CyrusNajmabadi 已提交
2944 2945
            await TestAsync(
@"using System.Collections.Generic;
2946
using System.Linq;
C
CyrusNajmabadi 已提交
2947

2948 2949 2950 2951 2952 2953 2954
class C
{
    void M()
    {
        var q = from int n in new List<object>()
                select $$n;
    }
C
CyrusNajmabadi 已提交
2955
}",
2956
                MainDescription($"({FeaturesResources.range_variable}) int n"));
2957 2958
        }

2959
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2960
        public async Task Query8()
2961
        {
C
CyrusNajmabadi 已提交
2962 2963
            await TestAsync(
@"using System.Collections.Generic;
2964
using System.Linq;
C
CyrusNajmabadi 已提交
2965

2966 2967 2968 2969 2970 2971 2972
class C
{
    void M()
    {
        var q = from int n$$ in new List<object>()
                select n;
    }
C
CyrusNajmabadi 已提交
2973
}",
2974
                MainDescription($"({FeaturesResources.range_variable}) int n"));
2975 2976
        }

2977
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2978
        public async Task Query9()
2979
        {
C
CyrusNajmabadi 已提交
2980 2981
            await TestAsync(
@"using System.Collections.Generic;
2982
using System.Linq;
C
CyrusNajmabadi 已提交
2983

2984 2985 2986 2987 2988 2989 2990 2991
class C
{
    void M()
    {
        var q = from x$$ in new List<List<int>>()
                from y in x
                select y;
    }
C
CyrusNajmabadi 已提交
2992
}",
2993
                MainDescription($"({FeaturesResources.range_variable}) List<int> x"));
2994 2995
        }

2996
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2997
        public async Task Query10()
2998
        {
C
CyrusNajmabadi 已提交
2999 3000
            await TestAsync(
@"using System.Collections.Generic;
3001
using System.Linq;
C
CyrusNajmabadi 已提交
3002

3003 3004 3005 3006 3007 3008 3009 3010
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y in $$x
                select y;
    }
C
CyrusNajmabadi 已提交
3011
}",
3012
                MainDescription($"({FeaturesResources.range_variable}) List<int> x"));
3013 3014
        }

3015
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3016
        public async Task Query11()
3017
        {
C
CyrusNajmabadi 已提交
3018 3019
            await TestAsync(
@"using System.Collections.Generic;
3020
using System.Linq;
C
CyrusNajmabadi 已提交
3021

3022 3023 3024 3025 3026 3027 3028 3029
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y$$ in x
                select y;
    }
C
CyrusNajmabadi 已提交
3030
}",
3031
                MainDescription($"({FeaturesResources.range_variable}) int y"));
3032 3033
        }

3034
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3035
        public async Task Query12()
3036
        {
C
CyrusNajmabadi 已提交
3037 3038
            await TestAsync(
@"using System.Collections.Generic;
3039
using System.Linq;
C
CyrusNajmabadi 已提交
3040

3041 3042 3043 3044 3045 3046 3047 3048
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y in x
                select $$y;
    }
C
CyrusNajmabadi 已提交
3049
}",
3050
                MainDescription($"({FeaturesResources.range_variable}) int y"));
3051 3052
        }

J
Jared Parsons 已提交
3053
        [WorkItem(543205, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543205")]
3054
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3055
        public async Task TestErrorGlobal()
3056
        {
C
CyrusNajmabadi 已提交
3057 3058 3059
            await TestAsync(
@"extern alias global;

3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070
class myClass
{
    static int Main()
    {
        $$global::otherClass oc = new global::otherClass();
        return 0;
    }
}",
                MainDescription("<global namespace>"));
        }

3071
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3072
        public async Task DontRemoveAttributeSuffixAndProduceInvalidIdentifier1()
3073
        {
C
CyrusNajmabadi 已提交
3074 3075 3076
            await TestAsync(
@"using System;

3077 3078 3079 3080
class classAttribute : Attribute
{
    private classAttribute x$$;
}",
3081
                MainDescription($"({FeaturesResources.field}) classAttribute classAttribute.x"));
3082 3083
        }

J
Jared Parsons 已提交
3084
        [WorkItem(544026, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544026")]
3085
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3086
        public async Task DontRemoveAttributeSuffix2()
3087
        {
C
CyrusNajmabadi 已提交
3088 3089 3090
            await TestAsync(
@"using System;

3091 3092 3093 3094
class class1Attribute : Attribute
{
    private class1Attribute x$$;
}",
3095
                MainDescription($"({FeaturesResources.field}) class1Attribute class1Attribute.x"));
3096 3097
        }

3098
        [WorkItem(1696, "https://github.com/dotnet/roslyn/issues/1696")]
3099
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3100
        public async Task AttributeQuickInfoBindsToClassTest()
3101
        {
C
CyrusNajmabadi 已提交
3102 3103
            await TestAsync(
@"using System;
3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116

/// <summary>
/// class comment
/// </summary>
[Some$$]
class SomeAttribute : Attribute
{
    /// <summary>
    /// ctor comment
    /// </summary>
    public SomeAttribute()
    {
    }
C
CyrusNajmabadi 已提交
3117
}",
3118 3119 3120 3121
                Documentation("class comment"));
        }

        [WorkItem(1696, "https://github.com/dotnet/roslyn/issues/1696")]
3122
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3123
        public async Task AttributeConstructorQuickInfo()
3124
        {
C
CyrusNajmabadi 已提交
3125 3126
            await TestAsync(
@"using System;
3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139

/// <summary>
/// class comment
/// </summary>
class SomeAttribute : Attribute
{
    /// <summary>
    /// ctor comment
    /// </summary>
    public SomeAttribute()
    {
        var s = new Some$$Attribute();
    }
C
CyrusNajmabadi 已提交
3140
}",
3141 3142 3143
                Documentation("ctor comment"));
        }

3144
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3145
        public async Task TestLabel()
3146
        {
3147 3148 3149
            await TestInClassAsync(
@"void M()
{
3150 3151 3152
Goo:
    int Goo;
    goto Goo$$;
3153
}",
3154
                MainDescription($"({FeaturesResources.label}) Goo"));
3155 3156
        }

J
Jared Parsons 已提交
3157
        [WorkItem(542613, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542613")]
3158
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3159
        public async Task TestUnboundGeneric()
3160
        {
C
CyrusNajmabadi 已提交
3161 3162
            await TestAsync(
@"using System;
3163
using System.Collections.Generic;
C
CyrusNajmabadi 已提交
3164

3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175
class C
{
    void M()
    {
        Type t = typeof(L$$ist<>);
    }
}",
                MainDescription("class System.Collections.Generic.List<T>"),
                NoTypeParameterMap);
        }

J
Jared Parsons 已提交
3176
        [WorkItem(543113, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543113")]
3177
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3178
        public async Task TestAnonymousTypeNew1()
3179
        {
C
CyrusNajmabadi 已提交
3180 3181
            await TestAsync(
@"class C
3182 3183 3184 3185 3186 3187 3188 3189 3190
{
    void M()
    {
        var v = $$new { };
    }
}",
                MainDescription(@"AnonymousType 'a"),
                NoTypeParameterMap,
                AnonymousTypes(
3191
$@"
3192 3193
{FeaturesResources.Anonymous_Types_colon}
    'a {FeaturesResources.is_} new {{  }}"));
3194 3195
        }

J
Jared Parsons 已提交
3196
        [WorkItem(543873, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543873")]
3197
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3198
        public async Task TestNestedAnonymousType()
3199 3200 3201
        {
            // verify nested anonymous types are listed in the same order for different properties
            // verify first property
3202 3203 3204 3205
            await TestInMethodAsync(
@"var x = new[] { new { Name = ""BillG"", Address = new { Street = ""1 Microsoft Way"", Zip = ""98052"" } } };

x[0].$$Address",
3206 3207 3208
                MainDescription(@"'b 'a.Address { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
3209
$@"
3210 3211 3212
{FeaturesResources.Anonymous_Types_colon}
    'a {FeaturesResources.is_} new {{ string Name, 'b Address }}
    'b {FeaturesResources.is_} new {{ string Street, string Zip }}"));
3213 3214

            // verify second property
3215 3216 3217 3218
            await TestInMethodAsync(
@"var x = new[] { new { Name = ""BillG"", Address = new { Street = ""1 Microsoft Way"", Zip = ""98052"" } } };

x[0].$$Name",
3219 3220 3221
                MainDescription(@"string 'a.Name { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
3222
$@"
3223 3224 3225
{FeaturesResources.Anonymous_Types_colon}
    'a {FeaturesResources.is_} new {{ string Name, 'b Address }}
    'b {FeaturesResources.is_} new {{ string Street, string Zip }}"));
3226 3227
        }

3228
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
J
Jared Parsons 已提交
3229
        [WorkItem(543183, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543183")]
C
Cyrus Najmabadi 已提交
3230
        public async Task TestAssignmentOperatorInAnonymousType()
3231
        {
C
CyrusNajmabadi 已提交
3232 3233
            await TestAsync(
@"class C
3234 3235 3236 3237 3238
{
    void M()
    {
        var a = new { A $$= 0 };
    }
C
CyrusNajmabadi 已提交
3239
}");
3240 3241
        }

3242
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
3243
        [WorkItem(10731, "DevDiv_Projects/Roslyn")]
C
Cyrus Najmabadi 已提交
3244
        public async Task TestErrorAnonymousTypeDoesntShow()
3245
        {
3246 3247
            await TestInMethodAsync(
@"var a = new { new { N = 0 }.N, new { } }.$$N;",
3248 3249 3250
                MainDescription(@"int 'a.N { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
3251
$@"
3252 3253
{FeaturesResources.Anonymous_Types_colon}
    'a {FeaturesResources.is_} new {{ int N }}"));
3254 3255
        }

3256
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
J
Jared Parsons 已提交
3257
        [WorkItem(543553, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543553")]
C
Cyrus Najmabadi 已提交
3258
        public async Task TestArrayAssignedToVar()
3259
        {
C
CyrusNajmabadi 已提交
3260 3261
            await TestAsync(
@"class C
3262 3263 3264 3265 3266
{
    static void M(string[] args)
    {
        v$$ar a = args;
    }
C
CyrusNajmabadi 已提交
3267
}",
3268 3269 3270
                MainDescription("string[]"));
        }

J
Jared Parsons 已提交
3271
        [WorkItem(529139, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529139")]
3272
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3273
        public async Task ColorColorRangeVariable()
3274
        {
C
CyrusNajmabadi 已提交
3275 3276
            await TestAsync(
@"using System.Collections.Generic;
3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291
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;
            }
        }
    }
C
CyrusNajmabadi 已提交
3292
}",
3293
                MainDescription($"({FeaturesResources.range_variable}) N1.yield yield"));
3294 3295
        }

J
Jared Parsons 已提交
3296
        [WorkItem(543550, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543550")]
3297
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3298
        public async Task QuickInfoOnOperator()
3299
        {
C
CyrusNajmabadi 已提交
3300 3301 3302
            await TestAsync(
@"using System.Collections.Generic;

3303 3304 3305 3306 3307 3308
class Program
{
    static void Main(string[] args)
    {
        var v = new Program() $$+ string.Empty;
    }
C
CyrusNajmabadi 已提交
3309

3310 3311 3312 3313
    public static implicit operator Program(string s)
    {
        return null;
    }
C
CyrusNajmabadi 已提交
3314

3315 3316 3317 3318 3319
    public static IEnumerable<Program> operator +(Program p1, Program p2)
    {
        yield return p1;
        yield return p2;
    }
C
CyrusNajmabadi 已提交
3320
}",
3321 3322 3323
                MainDescription("IEnumerable<Program> Program.operator +(Program p1, Program p2)"));
        }

3324
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3325
        public async Task TestConstantField()
3326
        {
C
CyrusNajmabadi 已提交
3327 3328 3329 3330
            await TestAsync(
@"class C
{
    const int $$F = 1;",
3331
                MainDescription($"({FeaturesResources.constant}) int C.F = 1"));
3332 3333
        }

3334
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3335
        public async Task TestMultipleConstantFields()
3336
        {
C
CyrusNajmabadi 已提交
3337 3338 3339 3340
            await TestAsync(
@"class C
{
    public const double X = 1.0, Y = 2.0, $$Z = 3.5;",
3341
                MainDescription($"({FeaturesResources.constant}) double C.Z = 3.5"));
3342 3343
        }

3344
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3345
        public async Task TestConstantDependencies()
3346
        {
C
CyrusNajmabadi 已提交
3347 3348
            await TestAsync(
@"class A
3349 3350 3351 3352
{
    public const int $$X = B.Z + 1;
    public const int Y = 10;
}
C
CyrusNajmabadi 已提交
3353

3354 3355 3356 3357
class B
{
    public const int Z = A.Y + 1;
}",
3358
                MainDescription($"({FeaturesResources.constant}) int A.X = B.Z + 1"));
3359 3360
        }

3361
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3362
        public async Task TestConstantCircularDependencies()
3363
        {
C
CyrusNajmabadi 已提交
3364 3365
            await TestAsync(
@"class A
3366 3367 3368
{
    public const int X = B.Z + 1;
}
C
CyrusNajmabadi 已提交
3369

3370 3371 3372 3373
class B
{
    public const int Z$$ = A.X + 1;
}",
3374
                MainDescription($"({FeaturesResources.constant}) int B.Z = A.X + 1"));
3375 3376
        }

J
Jared Parsons 已提交
3377
        [WorkItem(544620, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544620")]
3378
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3379
        public async Task TestConstantOverflow()
3380
        {
C
CyrusNajmabadi 已提交
3381 3382
            await TestAsync(
@"class B
3383 3384 3385
{
    public const int Z$$ = int.MaxValue + 1;
}",
3386
                MainDescription($"({FeaturesResources.constant}) int B.Z = int.MaxValue + 1"));
3387 3388
        }

J
Jared Parsons 已提交
3389
        [WorkItem(544620, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544620")]
3390
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3391
        public async Task TestConstantOverflowInUncheckedContext()
3392
        {
C
CyrusNajmabadi 已提交
3393 3394
            await TestAsync(
@"class B
3395 3396 3397
{
    public const int Z$$ = unchecked(int.MaxValue + 1);
}",
3398
                MainDescription($"({FeaturesResources.constant}) int B.Z = unchecked(int.MaxValue + 1)"));
3399 3400
        }

3401
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3402
        public async Task TestEnumInConstantField()
3403
        {
C
CyrusNajmabadi 已提交
3404 3405
            await TestAsync(
@"public class EnumTest
3406
{
C
CyrusNajmabadi 已提交
3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417
    enum Days
    {
        Sun,
        Mon,
        Tue,
        Wed,
        Thu,
        Fri,
        Sat
    };

3418 3419 3420 3421 3422
    static void Main()
    {
        const int $$x = (int)Days.Sun;
    }
}",
3423
                MainDescription($"({FeaturesResources.local_constant}) int x = (int)Days.Sun"));
3424 3425
        }

3426
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3427
        public async Task TestConstantInDefaultExpression()
3428
        {
C
CyrusNajmabadi 已提交
3429 3430
            await TestAsync(
@"public class EnumTest
3431
{
C
CyrusNajmabadi 已提交
3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442
    enum Days
    {
        Sun,
        Mon,
        Tue,
        Wed,
        Thu,
        Fri,
        Sat
    };

3443 3444 3445 3446 3447
    static void Main()
    {
        const Days $$x = default(Days);
    }
}",
3448
                MainDescription($"({FeaturesResources.local_constant}) Days x = default(Days)"));
3449 3450
        }

3451
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3452
        public async Task TestConstantParameter()
3453
        {
C
CyrusNajmabadi 已提交
3454 3455 3456 3457 3458
            await TestAsync(
@"class C
{
    void Bar(int $$b = 1);
}",
3459
                MainDescription($"({FeaturesResources.parameter}) int b = 1"));
3460 3461
        }

3462
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3463
        public async Task TestConstantLocal()
3464
        {
C
CyrusNajmabadi 已提交
3465 3466 3467 3468 3469 3470 3471
            await TestAsync(
@"class C
{
    void Bar()
    {
        const int $$loc = 1;
    }",
3472
                MainDescription($"({FeaturesResources.local_constant}) int loc = 1"));
3473 3474
        }

J
Jared Parsons 已提交
3475
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3476
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3477
        public async Task TestErrorType1()
3478
        {
3479
            await TestInMethodAsync(
3480 3481
@"var $$v1 = new Goo();",
                MainDescription($"({FeaturesResources.local_variable}) Goo v1"));
3482 3483
        }

J
Jared Parsons 已提交
3484
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3485
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3486
        public async Task TestErrorType2()
3487
        {
3488 3489
            await TestInMethodAsync(
@"var $$v1 = v1;",
3490
                MainDescription($"({FeaturesResources.local_variable}) var v1"));
3491 3492
        }

J
Jared Parsons 已提交
3493
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3494
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3495
        public async Task TestErrorType3()
3496
        {
3497
            await TestInMethodAsync(
3498 3499
@"var $$v1 = new Goo<Bar>();",
                MainDescription($"({FeaturesResources.local_variable}) Goo<Bar> v1"));
3500 3501
        }

J
Jared Parsons 已提交
3502
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3503
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3504
        public async Task TestErrorType4()
3505
        {
3506 3507
            await TestInMethodAsync(
@"var $$v1 = &(x => x);",
3508
                MainDescription($"({FeaturesResources.local_variable}) ?* v1"));
3509 3510
        }

J
Jared Parsons 已提交
3511
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3512
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3513
        public async Task TestErrorType5()
3514
        {
C
Cyrus Najmabadi 已提交
3515
            await TestInMethodAsync("var $$v1 = &v1",
3516
                MainDescription($"({FeaturesResources.local_variable}) var* v1"));
3517 3518
        }

J
Jared Parsons 已提交
3519
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3520
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3521
        public async Task TestErrorType6()
3522
        {
3523 3524
            await TestInMethodAsync("var $$v1 = new Goo[1]",
                MainDescription($"({FeaturesResources.local_variable}) Goo[] v1"));
3525 3526
        }

J
Jared Parsons 已提交
3527
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3528
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3529
        public async Task TestErrorType7()
3530
        {
3531 3532 3533 3534 3535 3536 3537
            await TestInClassAsync(
@"class C
{
    void Method()
    {
    }

3538
    void Goo()
3539 3540 3541 3542
    {
        var $$v1 = MethodGroup;
    }
}",
3543
                MainDescription($"({FeaturesResources.local_variable}) ? v1"));
3544 3545
        }

J
Jared Parsons 已提交
3546
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3547
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3548
        public async Task TestErrorType8()
3549
        {
C
Cyrus Najmabadi 已提交
3550
            await TestInMethodAsync("var $$v1 = Unknown",
3551
                MainDescription($"({FeaturesResources.local_variable}) ? v1"));
3552 3553
        }

J
Jared Parsons 已提交
3554
        [WorkItem(545072, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545072")]
3555
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3556
        public async Task TestDelegateSpecialTypes()
3557
        {
C
CyrusNajmabadi 已提交
3558 3559
            await TestAsync(
@"delegate void $$F(int x);",
3560 3561 3562
                MainDescription("delegate void F(int x)"));
        }

J
Jared Parsons 已提交
3563
        [WorkItem(545108, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545108")]
3564
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3565
        public async Task TestNullPointerParameter()
3566
        {
C
CyrusNajmabadi 已提交
3567 3568 3569
            await TestAsync(
@"class C
{
3570
    unsafe void $$Goo(int* x = null)
C
CyrusNajmabadi 已提交
3571 3572 3573
    {
    }
}",
3574
                MainDescription("void C.Goo([int* x = null])"));
3575 3576
        }

J
Jared Parsons 已提交
3577
        [WorkItem(545098, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545098")]
3578
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3579
        public async Task TestLetIdentifier1()
3580
        {
C
Cyrus Najmabadi 已提交
3581
            await TestInMethodAsync("var q = from e in \"\" let $$y = 1 let a = new { y } select a;",
3582
                MainDescription($"({FeaturesResources.range_variable}) int y"));
3583 3584
        }

J
Jared Parsons 已提交
3585
        [WorkItem(545295, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545295")]
3586
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3587
        public async Task TestNullableDefaultValue()
3588
        {
C
CyrusNajmabadi 已提交
3589 3590 3591 3592 3593 3594 3595
            await TestAsync(
@"class Test
{
    void $$Method(int? t1 = null)
    {
    }
}",
3596 3597 3598
                MainDescription("void Test.Method([int? t1 = null])"));
        }

J
Jared Parsons 已提交
3599
        [WorkItem(529586, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529586")]
3600
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3601
        public async Task TestInvalidParameterInitializer()
3602
        {
C
Cyrus Najmabadi 已提交
3603
            await TestAsync(
C
CyrusNajmabadi 已提交
3604 3605 3606 3607 3608 3609 3610 3611
@"class Program
{
    void M1(float $$j1 = ""Hello""
+
""World"")
    {
    }
}",
3612
                MainDescription($@"({FeaturesResources.parameter}) float j1 = ""Hello"" + ""World"""));
3613 3614
        }

J
Jared Parsons 已提交
3615
        [WorkItem(545230, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545230")]
3616
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3617
        public async Task TestComplexConstLocal()
3618
        {
C
Cyrus Najmabadi 已提交
3619
            await TestAsync(
3620 3621 3622 3623 3624 3625 3626 3627
@"class Program
{
    void Main()
    {
        const int MEGABYTE = 1024 *
            1024 + true;
        Blah($$MEGABYTE);
    }
C
CyrusNajmabadi 已提交
3628
}",
3629
                MainDescription($@"({FeaturesResources.local_constant}) int MEGABYTE = 1024 * 1024 + true"));
3630 3631
        }

J
Jared Parsons 已提交
3632
        [WorkItem(545230, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545230")]
3633
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3634
        public async Task TestComplexConstField()
3635
        {
C
Cyrus Najmabadi 已提交
3636
            await TestAsync(
3637 3638
@"class Program
{
C
CyrusNajmabadi 已提交
3639 3640
    const int a = true
        -
3641
        false;
C
CyrusNajmabadi 已提交
3642

3643 3644
    void Main()
    {
3645
        Goo($$a);
3646 3647
    }
}",
3648
                MainDescription($"({FeaturesResources.constant}) int Program.a = true - false"));
3649 3650
        }

3651
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3652
        public async Task TestTypeParameterCrefDoesNotHaveQuickInfo()
3653
        {
C
Cyrus Najmabadi 已提交
3654
            await TestAsync(
3655 3656 3657 3658 3659 3660 3661 3662 3663
@"class C<T>
{
    ///  <see cref=""C{X$$}""/>
    static void Main(string[] args)
    {
    }
}");
        }

3664
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3665
        public async Task TestCref1()
3666
        {
C
Cyrus Najmabadi 已提交
3667
            await TestAsync(
3668 3669 3670 3671 3672 3673 3674 3675 3676 3677
@"class Program
{
    ///  <see cref=""Mai$$n""/>
    static void Main(string[] args)
    {
    }
}",
                MainDescription(@"void Program.Main(string[] args)"));
        }

3678
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3679
        public async Task TestCref2()
3680
        {
C
Cyrus Najmabadi 已提交
3681
            await TestAsync(
3682 3683 3684 3685 3686 3687 3688 3689 3690 3691
@"class Program
{
    ///  <see cref=""$$Main""/>
    static void Main(string[] args)
    {
    }
}",
                MainDescription(@"void Program.Main(string[] args)"));
        }

3692
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3693
        public async Task TestCref3()
3694
        {
C
Cyrus Najmabadi 已提交
3695
            await TestAsync(
3696 3697 3698 3699 3700 3701 3702 3703 3704
@"class Program
{
    ///  <see cref=""Main""$$/>
    static void Main(string[] args)
    {
    }
}");
        }

3705
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3706
        public async Task TestCref4()
3707
        {
C
Cyrus Najmabadi 已提交
3708
            await TestAsync(
3709 3710 3711 3712 3713 3714 3715 3716 3717
@"class Program
{
    ///  <see cref=""Main$$""/>
    static void Main(string[] args)
    {
    }
}");
        }

3718
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3719
        public async Task TestCref5()
3720
        {
C
Cyrus Najmabadi 已提交
3721
            await TestAsync(
3722 3723 3724 3725 3726 3727 3728 3729 3730
@"class Program
{
    ///  <see cref=""Main""$$/>
    static void Main(string[] args)
    {
    }
}");
        }

J
Jared Parsons 已提交
3731
        [WorkItem(546849, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546849")]
3732
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3733
        public async Task TestIndexedProperty()
3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770
        {
            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 已提交
3771
            await TestWithReferenceAsync(sourceCode: markup,
3772 3773 3774 3775 3776 3777
                referencedCode: referencedCode,
                sourceLanguage: LanguageNames.CSharp,
                referencedLanguage: LanguageNames.VisualBasic,
                expectedResults: MainDescription("string CCC.IndexProp[int p1, [int p2 = 0]] { get; set; }"));
        }

J
Jared Parsons 已提交
3778
        [WorkItem(546918, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546918")]
3779
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3780
        public async Task TestUnconstructedGeneric()
3781
        {
C
Cyrus Najmabadi 已提交
3782
            await TestAsync(
C
CyrusNajmabadi 已提交
3783 3784 3785 3786
@"class A<T>
{
    enum SortOrder
    {
3787 3788 3789 3790
        Ascending,
        Descending,
        None
    }
C
CyrusNajmabadi 已提交
3791

3792
    void Goo()
C
CyrusNajmabadi 已提交
3793
    {
3794 3795 3796 3797 3798 3799
        var b = $$SortOrder.Ascending;
    }
}",
                MainDescription(@"enum A<T>.SortOrder"));
        }

J
Jared Parsons 已提交
3800
        [WorkItem(546970, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546970")]
3801
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3802
        public async Task TestUnconstructedGenericInCRef()
3803
        {
C
Cyrus Najmabadi 已提交
3804
            await TestAsync(
C
CyrusNajmabadi 已提交
3805 3806 3807 3808
@"/// <see cref=""$$C{T}"" />
class C<T>
{
}",
3809 3810 3811
                MainDescription(@"class C<T>"));
        }

3812
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3813
        public async Task TestAwaitableMethod()
3814 3815 3816 3817
        {
            var markup = @"using System.Threading.Tasks;
class C
{
3818
    async Task Goo()
3819
    {
3820
        Go$$o();
3821 3822
    }
}";
3823
            var description = $"({CSharpFeaturesResources.awaitable}) Task C.Goo()";
3824

3825
            var documentation = $@"
3826
{WorkspacesResources.Usage_colon}
3827
  {SyntaxFacts.GetText(SyntaxKind.AwaitKeyword)} Goo();";
3828

C
Cyrus Najmabadi 已提交
3829
            await VerifyWithMscorlib45Async(markup, new[] { MainDescription(description), Usage(documentation) });
3830 3831
        }

3832
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3833
        public async Task ObsoleteItem()
3834 3835 3836 3837 3838 3839 3840
        {
            var markup = @"
using System;

class Program
{
    [Obsolete]
3841
    public void goo()
3842
    {
3843
        go$$o();
3844 3845
    }
}";
3846
            await TestAsync(markup, MainDescription($"[{CSharpFeaturesResources.deprecated}] void Program.goo()"));
3847 3848
        }

J
Jared Parsons 已提交
3849
        [WorkItem(751070, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/751070")]
3850
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3851
        public async Task DynamicOperator()
3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866
        {
            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 已提交
3867
            await TestAsync(markup, MainDescription("dynamic dynamic.operator ==(dynamic left, dynamic right)"));
3868 3869
        }

3870
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3871
        public async Task TextOnlyDocComment()
3872
        {
C
CyrusNajmabadi 已提交
3873 3874
            await TestAsync(
@"/// <summary>
3875
///goo
3876 3877 3878
/// </summary>
class C$$
{
3879
}", Documentation("goo"));
3880 3881
        }

3882
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3883
        public async Task TestTrimConcatMultiLine()
3884
        {
C
CyrusNajmabadi 已提交
3885 3886
            await TestAsync(
@"/// <summary>
3887
/// goo
3888 3889 3890 3891
/// bar
/// </summary>
class C$$
{
3892
}", Documentation("goo bar"));
3893 3894
        }

3895
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3896
        public async Task TestCref()
3897
        {
C
CyrusNajmabadi 已提交
3898 3899
            await TestAsync(
@"/// <summary>
3900 3901 3902 3903 3904 3905 3906 3907
/// <see cref=""C""/>
/// <seealso cref=""C""/>
/// </summary>
class C$$
{
}", Documentation("C C"));
        }

3908
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3909
        public async Task ExcludeTextOutsideSummaryBlock()
3910
        {
C
CyrusNajmabadi 已提交
3911 3912
            await TestAsync(
@"/// red
3913 3914 3915 3916 3917 3918 3919 3920 3921
/// <summary>
/// green
/// </summary>
/// yellow
class C$$
{
}", Documentation("green"));
        }

3922
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3923
        public async Task NewlineAfterPara()
3924
        {
C
CyrusNajmabadi 已提交
3925 3926
            await TestAsync(
@"/// <summary>
3927
/// <para>goo</para>
3928 3929 3930
/// </summary>
class C$$
{
3931
}", Documentation("goo"));
3932 3933
        }

3934
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3935
        public async Task TextOnlyDocComment_Metadata()
3936 3937 3938
        {
            var referenced = @"
/// <summary>
3939
///goo
3940 3941 3942 3943 3944 3945 3946 3947
/// </summary>
public class C
{
}";

            var code = @"
class G
{
3948
    void goo()
3949 3950 3951 3952
    {
        C$$ c;
    }
}";
3953
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("goo"));
3954 3955
        }

3956
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3957
        public async Task TestTrimConcatMultiLine_Metadata()
3958 3959 3960
        {
            var referenced = @"
/// <summary>
3961
/// goo
3962 3963 3964 3965 3966 3967 3968 3969 3970
/// bar
/// </summary>
public class C
{
}";

            var code = @"
class G
{
3971
    void goo()
3972 3973 3974 3975
    {
        C$$ c;
    }
}";
3976
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("goo bar"));
3977 3978
        }

3979
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3980
        public async Task TestCref_Metadata()
3981 3982 3983 3984
        {
            var code = @"
class G
{
3985
    void goo()
3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997
    {
        C$$ c;
    }
}";

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

4001
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4002
        public async Task ExcludeTextOutsideSummaryBlock_Metadata()
4003 4004 4005 4006
        {
            var code = @"
class G
{
4007
    void goo()
4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021
    {
        C$$ c;
    }
}";

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

4025
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4026
        public async Task Param()
4027
        {
C
CyrusNajmabadi 已提交
4028 4029
            await TestAsync(
@"/// <summary></summary>
4030 4031
public class C
{
4032 4033 4034 4035
    /// <typeparam name=""T"">A type parameter of <see cref=""goo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Goo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Goo{T}(string[], T)""/></param>
    public void Goo<T>(string[] arg$$s, T otherParam)
4036 4037
    {
    }
4038
}", Documentation("First parameter of C.Goo<T>(string[], T)"));
4039 4040
        }

4041
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4042
        public async Task Param_Metadata()
4043 4044 4045 4046
        {
            var code = @"
class G
{
4047
    void goo()
4048 4049
    {
        C c;
4050
        c.Goo<int>(arg$$s: new string[] { }, 1);
4051 4052 4053 4054 4055 4056
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
4057 4058 4059 4060
    /// <typeparam name=""T"">A type parameter of <see cref=""goo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Goo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Goo{T}(string[], T)""/></param>
    public void Goo<T>(string[] args, T otherParam)
4061 4062 4063
    {
    }
}";
4064
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("First parameter of C.Goo<T>(string[], T)"));
4065 4066
        }

4067
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4068
        public async Task Param2()
4069
        {
C
CyrusNajmabadi 已提交
4070 4071
            await TestAsync(
@"/// <summary></summary>
4072 4073
public class C
{
4074 4075 4076 4077
    /// <typeparam name=""T"">A type parameter of <see cref=""goo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Goo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Goo{T}(string[], T)""/></param>
    public void Goo<T>(string[] args, T oth$$erParam)
4078 4079
    {
    }
4080
}", Documentation("Another parameter of C.Goo<T>(string[], T)"));
4081 4082
        }

4083
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4084
        public async Task Param2_Metadata()
4085 4086 4087 4088
        {
            var code = @"
class G
{
4089
    void goo()
4090 4091
    {
        C c;
4092
        c.Goo<int>(args: new string[] { }, other$$Param: 1);
4093 4094 4095 4096 4097 4098
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
4099 4100 4101 4102
    /// <typeparam name=""T"">A type parameter of <see cref=""goo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Goo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Goo{T}(string[], T)""/></param>
    public void Goo<T>(string[] args, T otherParam)
4103 4104 4105
    {
    }
}";
4106
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("Another parameter of C.Goo<T>(string[], T)"));
4107 4108
        }

4109
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4110
        public async Task TypeParam()
4111
        {
C
CyrusNajmabadi 已提交
4112 4113
            await TestAsync(
@"/// <summary></summary>
4114 4115
public class C
{
4116 4117 4118 4119
    /// <typeparam name=""T"">A type parameter of <see cref=""Goo{T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Goo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Goo{T}(string[], T)""/></param>
    public void Goo<T$$>(string[] args, T otherParam)
4120 4121
    {
    }
4122
}", Documentation("A type parameter of C.Goo<T>(string[], T)"));
4123 4124
        }

4125
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4126
        public async Task UnboundCref()
4127
        {
C
CyrusNajmabadi 已提交
4128 4129
            await TestAsync(
@"/// <summary></summary>
4130 4131
public class C
{
4132 4133 4134 4135
    /// <typeparam name=""T"">A type parameter of <see cref=""goo{T}(string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Goo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Goo{T}(string[], T)""/></param>
    public void Goo<T$$>(string[] args, T otherParam)
4136 4137
    {
    }
4138
}", Documentation("A type parameter of goo<T>(string[], T)"));
4139 4140
        }

4141
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4142
        public async Task CrefInConstructor()
4143
        {
C
CyrusNajmabadi 已提交
4144 4145
            await TestAsync(
@"public class TestClass
4146 4147 4148 4149 4150 4151 4152 4153 4154 4155
{
    /// <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."));
        }

4156
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4157
        public async Task CrefInConstructorOverloaded()
4158
        {
C
CyrusNajmabadi 已提交
4159 4160
            await TestAsync(
@"public class TestClass
4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172
{
    /// <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)
C
CyrusNajmabadi 已提交
4173 4174 4175
    {
    }
}", Documentation("This sample shows how to specify the TestClass(int) constructor as a cref attribute."));
4176 4177
        }

4178
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4179
        public async Task CrefInGenericMethod1()
4180
        {
C
CyrusNajmabadi 已提交
4181 4182
            await TestAsync(
@"public class TestClass
4183
{
C
CyrusNajmabadi 已提交
4184 4185 4186 4187 4188 4189 4190 4191 4192
    /// <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."));
4193 4194
        }

4195
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4196
        public async Task CrefInGenericMethod2()
4197
        {
C
CyrusNajmabadi 已提交
4198 4199
            await TestAsync(
@"public class TestClass
4200
{
C
CyrusNajmabadi 已提交
4201 4202 4203 4204 4205 4206 4207 4208 4209
    /// <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."));
4210 4211
        }

J
Jared Parsons 已提交
4212
        [WorkItem(813350, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/813350")]
4213
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4214
        public async Task CrefInMethodOverloading1()
4215
        {
C
CyrusNajmabadi 已提交
4216 4217
            await TestAsync(
@"public class TestClass
4218
{
C
CyrusNajmabadi 已提交
4219 4220 4221 4222 4223
    public static int GetZero()
    {
        GetGenericValu$$e();
        GetGenericValue(5);
    }
4224

C
CyrusNajmabadi 已提交
4225 4226 4227 4228 4229 4230 4231
    /// <summary> 
    /// This sample shows how to call the <see cref=""GetGenericValue{T}(T)""/> method
    /// </summary> 
    public static T GetGenericValue<T>(T para)
    {
        return para;
    }
4232

C
CyrusNajmabadi 已提交
4233 4234 4235 4236 4237 4238 4239
    /// <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."));
4240 4241
        }

J
Jared Parsons 已提交
4242
        [WorkItem(813350, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/813350")]
4243
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4244
        public async Task CrefInMethodOverloading2()
4245
        {
C
CyrusNajmabadi 已提交
4246 4247
            await TestAsync(
@"public class TestClass
4248
{
C
CyrusNajmabadi 已提交
4249 4250 4251 4252 4253
    public static int GetZero()
    {
        GetGenericValue();
        GetGenericVal$$ue(5);
    }
4254

C
CyrusNajmabadi 已提交
4255 4256 4257 4258 4259 4260 4261
    /// <summary> 
    /// This sample shows how to call the <see cref=""GetGenericValue{T}(T)""/> method
    /// </summary> 
    public static T GetGenericValue<T>(T para)
    {
        return para;
    }
4262

C
CyrusNajmabadi 已提交
4263 4264 4265 4266 4267 4268 4269
    /// <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"));
4270 4271
        }

4272
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4273
        public async Task CrefInGenericType()
4274
        {
C
CyrusNajmabadi 已提交
4275 4276 4277 4278 4279 4280 4281
            await TestAsync(
@"/// <summary> 
/// <remarks>This example shows how to specify the <see cref=""GenericClass{T}""/> cref.</remarks>
/// </summary> 
class Generic$$Class<T>
{
}",
4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293
    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."))));
        }

J
Jared Parsons 已提交
4294
        [WorkItem(812720, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/812720")]
4295
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4296
        public async Task ClassificationOfCrefsFromMetadata()
4297 4298 4299 4300
        {
            var code = @"
class G
{
4301
    void goo()
4302 4303
    {
        C c;
4304
        c.Go$$o();
4305 4306 4307 4308 4309 4310 4311
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <summary> 
4312
    /// See <see cref=""Goo""/> method
4313
    /// </summary> 
4314
    public void Goo()
4315 4316 4317
    {
    }
}";
C
Cyrus Najmabadi 已提交
4318
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#",
4319
                Documentation("See C.Goo() method",
4320 4321 4322 4323 4324
                    ExpectedClassifications(
                        Text("See"),
                        WhiteSpace(" "),
                        Class("C"),
                        Punctuation.Text("."),
4325
                        Identifier("Goo"),
4326 4327 4328 4329 4330 4331
                        Punctuation.OpenParen,
                        Punctuation.CloseParen,
                        WhiteSpace(" "),
                        Text("method"))));
        }

4332
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4333
        public async Task FieldAvailableInBothLinkedFiles()
4334 4335 4336 4337 4338 4339 4340
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    int x;
4341
    void goo()
4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

4354
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.field}) int C.x"), Usage("") });
4355 4356
        }

4357
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4358
        public async Task FieldUnavailableInOneLinkedFile()
4359 4360
        {
            var markup = @"<Workspace>
4361
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""GOO"">
4362 4363 4364
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
4365
#if GOO
4366 4367
    int x;
#endif
4368
    void goo()
4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
4380
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj2", FeaturesResources.Not_Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_context}", expectsWarningGlyph: true);
4381

C
Cyrus Najmabadi 已提交
4382
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
4383 4384
        }

4385
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4386
        public async Task BindSymbolInOtherFile()
4387 4388 4389 4390 4391 4392
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
4393
#if GOO
4394 4395
    int x;
#endif
4396
    void goo()
4397 4398 4399 4400 4401 4402 4403
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
4404
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""GOO"">
4405 4406 4407
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
4408
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Not_Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj2", FeaturesResources.Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_context}", expectsWarningGlyph: true);
4409

C
Cyrus Najmabadi 已提交
4410
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
4411 4412
        }

4413
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4414
        public async Task FieldUnavailableInTwoLinkedFiles()
4415 4416
        {
            var markup = @"<Workspace>
4417
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""GOO"">
4418 4419 4420
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
4421
#if GOO
4422 4423
    int x;
#endif
4424
    void goo()
4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439
    {
        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(
4440
                $"\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj2", FeaturesResources.Not_Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj3", FeaturesResources.Not_Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_context}",
4441 4442
                expectsWarningGlyph: true);

C
Cyrus Najmabadi 已提交
4443
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
4444 4445
        }

4446
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4447
        public async Task ExcludeFilesWithInactiveRegions()
4448 4449
        {
            var markup = @"<Workspace>
4450
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""GOO,BAR"">
4451 4452 4453
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
4454
#if GOO
4455 4456 4457 4458
    int x;
#endif

#if BAR
4459
    void goo()
4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474
    {
        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>";
4475
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj3", FeaturesResources.Not_Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_context}", expectsWarningGlyph: true);
C
Cyrus Najmabadi 已提交
4476
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
4477 4478
        }

J
Jared Parsons 已提交
4479
        [WorkItem(962353, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/962353")]
4480
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4481
        public async Task NoValidSymbolsInLinkedDocuments()
4482 4483 4484 4485 4486 4487
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
4488
    void goo()
4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503
    {
        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 已提交
4504
            await VerifyWithReferenceWorkerAsync(markup);
4505 4506
        }

J
Jared Parsons 已提交
4507
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
4508
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4509
        public async Task LocalsValidInLinkedDocuments()
4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528
        {
            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>";

4529
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.local_variable}) int x"), Usage("") });
4530 4531
        }

J
Jared Parsons 已提交
4532
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
4533
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4534
        public async Task LocalWarningInLinkedDocuments()
4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557
        {
            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>";

4558
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.local_variable}) int x"), Usage($"\r\n{string.Format(FeaturesResources._0_1, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources._0_1, "Proj2", FeaturesResources.Not_Available)}\r\n\r\n{FeaturesResources.You_can_use_the_navigation_bar_to_switch_context}", expectsWarningGlyph: true) });
4559 4560
        }

J
Jared Parsons 已提交
4561
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
4562
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4563
        public async Task LabelsValidInLinkedDocuments()
4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582
        {
            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>";

4583
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.label}) LABEL"), Usage("") });
4584 4585
        }

J
Jared Parsons 已提交
4586
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
4587
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4588
        public async Task RangeVariablesValidInLinkedDocuments()
4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608
        {
            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>";

4609
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.range_variable}) int y"), Usage("") });
4610 4611
        }

J
Jared Parsons 已提交
4612
        [WorkItem(1019766, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1019766")]
4613
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4614
        public async Task PointerAccessibility()
4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625
        {
            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 已提交
4626
            await TestAsync(markup, MainDescription("bool void*.operator ==(void* left, void* right)"));
4627 4628
        }

J
Jared Parsons 已提交
4629
        [WorkItem(1114300, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1114300")]
4630
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4631
        public async Task AwaitingTaskOfArrayType()
4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642
        {
            var markup = @"
using System.Threading.Tasks;

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

J
Jared Parsons 已提交
4646
        [WorkItem(1114300, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1114300")]
4647
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4648
        public async Task AwaitingTaskOfDynamic()
4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659
        {
            var markup = @"
using System.Threading.Tasks;

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

4663
        [Fact, Trait(Traits.Feature, Traits.Features.Completion)]
C
Cyrus Najmabadi 已提交
4664
        public async Task MethodOverloadDifferencesIgnored()
4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689
        {
            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 已提交
4690
            await VerifyWithReferenceWorkerAsync(markup, MainDescription(expectedDescription));
4691
        }
4692

4693
        [Fact, Trait(Traits.Feature, Traits.Features.Completion)]
C
Cyrus Najmabadi 已提交
4694
        public async Task MethodOverloadDifferencesIgnored_ContainingType()
4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742
        {
            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 已提交
4743
            await VerifyWithReferenceWorkerAsync(markup, MainDescription(expectedDescription));
4744
        }
4745 4746 4747

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(4868, "https://github.com/dotnet/roslyn/issues/4868")]
C
Cyrus Najmabadi 已提交
4748
        public async Task QuickInfoExceptions()
4749
        {
C
CyrusNajmabadi 已提交
4750 4751 4752
            await TestAsync(
@"using System;

4753 4754
namespace MyNs
{
C
CyrusNajmabadi 已提交
4755 4756 4757 4758 4759 4760 4761 4762
    class MyException1 : Exception
    {
    }

    class MyException2 : Exception
    {
    }

4763 4764 4765 4766 4767 4768
    class TestClass
    {
        /// <exception cref=""MyException1""></exception>
        /// <exception cref=""T:MyNs.MyException2""></exception>
        /// <exception cref=""System.Int32""></exception>
        /// <exception cref=""double""></exception>
4769
        /// <exception cref=""Not_A_Class_But_Still_Displayed""></exception>
4770 4771 4772 4773 4774
        void M()
        {
            M$$();
        }
    }
C
CyrusNajmabadi 已提交
4775
}",
4776
                Exceptions($"\r\n{WorkspacesResources.Exceptions_colon}\r\n  MyException1\r\n  MyException2\r\n  int\r\n  double\r\n  Not_A_Class_But_Still_Displayed"));
4777
        }
4778 4779 4780

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(1516, "https://github.com/dotnet/roslyn/issues/1516")]
C
Cyrus Najmabadi 已提交
4781
        public async Task QuickInfoWithNonStandardSeeAttributesAppear()
4782
        {
C
CyrusNajmabadi 已提交
4783 4784
            await TestAsync(
@"class C
4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795
{
    /// <summary>
    /// <see cref=""System.String"" />
    /// <see href=""http://microsoft.com"" />
    /// <see langword=""null"" />
    /// <see unsupported-attribute=""cat"" />
    /// </summary>
    void M()
    {
        M$$();
    }
C
CyrusNajmabadi 已提交
4796
}",
4797 4798
                Documentation(@"string http://microsoft.com null cat"));
        }
4799 4800 4801

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(6657, "https://github.com/dotnet/roslyn/issues/6657")]
4802
        public async Task OptionalParameterFromPreviousSubmission()
4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813
        {
            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
CyrusNajmabadi 已提交
4814
            using (var workspace = TestWorkspace.Create(XElement.Parse(workspaceDefinition), workspaceKind: WorkspaceKind.Interactive))
4815
            {
4816
                await TestWithOptionsAsync(workspace, MainDescription("(parameter) int x = 1"));
4817 4818
            }
        }
C
CyrusNajmabadi 已提交
4819 4820 4821 4822

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TupleProperty()
        {
4823 4824
            await TestInMethodAsync(
@"interface I
C
CyrusNajmabadi 已提交
4825 4826 4827
{
    (int, int) Name { get; set; }
}
4828

C
CyrusNajmabadi 已提交
4829 4830 4831 4832
class C : I
{
    (int, int) I.Name$$
    {
4833 4834 4835 4836 4837 4838 4839 4840
        get
        {
            throw new System.Exception();
        }

        set
        {
        }
C
CyrusNajmabadi 已提交
4841 4842 4843 4844
    }
}",
                MainDescription("(int, int) C.Name { get; set; }"));
        }
4845

4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953
        [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task ValueTupleWithArity0VariableName()
        {
            await TestAsync(
@"
using System;
public class C
{
    void M()
    {
        var y$$ = ValueTuple.Create();
    }
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
                MainDescription("(local variable) ValueTuple y"));
        }

        [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task ValueTupleWithArity0ImplicitVar()
        {
            await TestAsync(
@"
using System;
public class C
{
    void M()
    {
        var$$ y = ValueTuple.Create();
    }
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
                MainDescription("struct System.ValueTuple"));
        }

        [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task ValueTupleWithArity1VariableName()
        {
            await TestAsync(
@"
using System;
public class C
{
    void M()
    {
        var y$$ = ValueTuple.Create(1);
    }
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
                MainDescription("(local variable) ValueTuple<int> y"));
        }

        [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task ValueTupleWithArity1ImplicitVar()
        {
            await TestAsync(
@"
using System;
public class C
{
    void M()
    {
        var$$ y = ValueTuple.Create(1);
    }
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
                MainDescription("ValueTuple<System.Int32>"));
        }

        [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task ValueTupleWithArity2VariableName()
        {
            await TestAsync(
@"
using System;
public class C
{
    void M()
    {
        var y$$ = ValueTuple.Create(1, 1);
    }
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
                MainDescription("(local variable) (int, int) y"));
        }

        [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task ValueTupleWithArity2ImplicitVar()
        {
            await TestAsync(
@"
using System;
public class C
{
    void M()
    {
        var$$ y = ValueTuple.Create(1, 1);
    }
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
                MainDescription("(System.Int32, System.Int32)"));
        }

4954 4955 4956 4957 4958 4959 4960 4961 4962 4963
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestRefMethod()
        {
            await TestInMethodAsync(
@"using System;

class Program
{
    static void Main(string[] args)
    {
4964
        ref int i = ref $$goo();
4965 4966
    }

4967
    private static ref int goo()
4968 4969 4970 4971
    {
        throw new NotImplementedException();
    }
}",
4972
                MainDescription("ref int Program.goo()"));
4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984
        }

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        public async Task TestRefLocal()
        {
            await TestInMethodAsync(
@"using System;

class Program
{
    static void Main(string[] args)
    {
4985
        ref int $$i = ref goo();
4986 4987
    }

4988
    private static ref int goo()
4989 4990 4991 4992 4993 4994
    {
        throw new NotImplementedException();
    }
}",
                MainDescription($"({FeaturesResources.local_variable}) ref int i"));
        }
A
AlekseyTs 已提交
4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(410932, "https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?id=410932")]
        public async Task TestGenericMethodInDocComment()
        {
            await TestAsync(
@"
class Test
{
    T F<T>()
    {
        F<T>();
    }

    /// <summary>
    /// <see cref=""F$${T}()""/>
    /// </summary>
    void S()
    { }
}
",
            MainDescription("T Test.F<T>()"));
        }
5018
    }
S
Sam Harwell 已提交
5019
}