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

using System;
using System.Linq;
using System.Security;
using System.Threading;
C
Cyrus Najmabadi 已提交
7
using System.Threading.Tasks;
8
using System.Xml.Linq;
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Editor.CSharp.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.QuickInfo;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

void M()
{
    field$$
}";

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

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

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

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

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

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

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

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

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

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

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

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

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

void M()
{
    field$$
}";

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

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

void M()
{
    file$$
}";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285
        [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()"));
        }

1286
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1287
        public async Task TestStringLiteral()
1288
        {
C
Cyrus Najmabadi 已提交
1289
            await TestInMethodAsync(@"string f = ""Foo""$$",
1290 1291 1292
                MainDescription("class System.String"));
        }

1293
        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1294
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1295
        public async Task TestVerbatimStringLiteral()
1296
        {
C
Cyrus Najmabadi 已提交
1297
            await TestInMethodAsync(@"string f = @""cat""$$",
1298 1299 1300 1301
                MainDescription("class System.String"));
        }

        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1302
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1303
        public async Task TestInterpolatedStringLiteral()
1304
        {
C
Cyrus Najmabadi 已提交
1305 1306 1307 1308
            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"));
1309 1310 1311
        }

        [WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
1312
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1313
        public async Task TestVerbatimInterpolatedStringLiteral()
1314
        {
C
Cyrus Najmabadi 已提交
1315 1316 1317 1318
            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"));
1319 1320
        }

1321
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1322
        public async Task TestCharLiteral()
1323
        {
C
Cyrus Najmabadi 已提交
1324
            await TestInMethodAsync(@"string f = 'x'$$",
1325 1326 1327
                MainDescription("struct System.Char"));
        }

1328
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1329
        public async Task DynamicKeyword()
1330
        {
C
Cyrus Najmabadi 已提交
1331
            await TestInMethodAsync(@"dyn$$amic dyn;",
1332
                MainDescription("dynamic"),
1333
                Documentation(FeaturesResources.RepresentsAnObjectWhoseOperations));
1334 1335
        }

1336
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1337
        public async Task DynamicField()
1338
        {
C
Cyrus Najmabadi 已提交
1339
            await TestInClassAsync(@"dynamic dyn;
1340 1341 1342 1343
void M()
{
    d$$yn.Foo();
}",
1344
                MainDescription($"({FeaturesResources.Field}) dynamic C.dyn"));
1345 1346
        }

1347
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1348
        public async Task LocalProperty_Minimal()
1349
        {
C
Cyrus Najmabadi 已提交
1350
            await TestInClassAsync(@"DateTime Prop { get; set; }
1351 1352 1353 1354 1355 1356 1357
void M()
{
    P$$rop.ToString();
}",
                MainDescription("DateTime C.Prop { get; set; }"));
        }

1358
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1359
        public async Task LocalProperty_Minimal_PrivateSet()
1360
        {
C
Cyrus Najmabadi 已提交
1361
            await TestInClassAsync(@"public DateTime Prop { get; private set; }
1362 1363 1364 1365 1366 1367 1368
void M()
{
    P$$rop.ToString();
}",
                MainDescription("DateTime C.Prop { get; private set; }"));
        }

1369
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1370
        public async Task LocalProperty_Minimal_PrivateSet1()
1371
        {
C
Cyrus Najmabadi 已提交
1372
            await TestInClassAsync(@"protected internal int Prop { get; private set; }
1373 1374 1375 1376 1377 1378 1379
void M()
{
    P$$rop.ToString();
}",
                MainDescription("int C.Prop { get; private set; }"));
        }

1380
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1381
        public async Task LocalProperty_Qualified()
1382
        {
C
Cyrus Najmabadi 已提交
1383
            await TestInClassAsync(@"System.IO.FileInfo Prop { get; set; }
1384 1385 1386 1387 1388 1389 1390
void M()
{
    P$$rop.ToString();
}",
                MainDescription("System.IO.FileInfo C.Prop { get; set; }"));
        }

1391
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1392
        public async Task NonLocalProperty_Minimal()
1393
        {
C
Cyrus Najmabadi 已提交
1394
            await TestInMethodAsync(@"DateTime.No$$w.ToString();",
1395 1396 1397
                MainDescription("DateTime DateTime.Now { get; }"));
        }

1398
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1399
        public async Task NonLocalProperty_Qualified()
1400
        {
C
Cyrus Najmabadi 已提交
1401
            await TestInMethodAsync(@"System.IO.FileInfo f; f.Att$$ributes.ToString();",
1402 1403 1404
                MainDescription("System.IO.FileAttributes System.IO.FileSystemInfo.Attributes { get; set; }"));
        }

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

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

1421
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1422
        public async Task UnconstructedGenericProperty()
1423
        {
C
Cyrus Najmabadi 已提交
1424
            await TestAsync(@"
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434
class C<T> {
    public T Property { get; set}

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

1435
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1436
        public async Task ValueInProperty()
1437
        {
C
Cyrus Najmabadi 已提交
1438
            await TestInClassAsync(@"public DateTime Property {set { foo = val$$ue; } }",
1439
                MainDescription($"({FeaturesResources.Parameter}) DateTime value"));
1440 1441
        }

1442
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1443
        public async Task EnumTypeName()
1444
        {
C
Cyrus Najmabadi 已提交
1445
            await TestInMethodAsync(@"Consol$$eColor c",
1446 1447 1448
                MainDescription("enum System.ConsoleColor"));
        }

1449
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1450
        public async Task EnumMemberNameFromMetadata()
1451
        {
C
Cyrus Najmabadi 已提交
1452
            await TestInMethodAsync(@"ConsoleColor c = ConsoleColor.Bla$$ck",
1453 1454 1455
                MainDescription("ConsoleColor.Black = 0"));
        }

1456
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1457
        public async Task FlagsEnumMemberNameFromMetadata1()
1458
        {
C
Cyrus Najmabadi 已提交
1459
            await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.Cl$$ass",
1460 1461 1462
                MainDescription("AttributeTargets.Class = 4"));
        }

1463
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1464
        public async Task FlagsEnumMemberNameFromMetadata2()
1465
        {
C
Cyrus Najmabadi 已提交
1466
            await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.A$$ll",
1467 1468 1469
                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"));
        }

1470
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1471
        public async Task EnumMemberNameFromSource1()
1472
        {
C
Cyrus Najmabadi 已提交
1473
            await TestAsync(@"
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490
enum E
{
    A = 1 << 0,
    B = 1 << 1,
    C = 1 << 2
}

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

1491
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1492
        public async Task EnumMemberNameFromSource2()
1493
        {
C
Cyrus Najmabadi 已提交
1494
            await TestAsync(@"
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511
enum E
{
    A,
    B,
    C
}

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

1512
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1513
        public async Task Parameter_InMethod_Minimal()
1514
        {
C
Cyrus Najmabadi 已提交
1515
            await TestInClassAsync(@"void M(DateTime dt) { d$$t.ToString();",
1516
                MainDescription($"({FeaturesResources.Parameter}) DateTime dt"));
1517 1518
        }

1519
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1520
        public async Task Parameter_InMethod_Qualified()
1521
        {
C
Cyrus Najmabadi 已提交
1522
            await TestInClassAsync(@"void M(System.IO.FileInfo fileInfo) { file$$Info.ToString();",
1523
                MainDescription($"({FeaturesResources.Parameter}) System.IO.FileInfo fileInfo"));
1524 1525
        }

1526
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1527
        public async Task Parameter_FromReferenceToNamedParameter()
1528
        {
C
Cyrus Najmabadi 已提交
1529
            await TestInMethodAsync(@"Console.WriteLine(va$$lue: ""Hi"");",
1530
                MainDescription($"({FeaturesResources.Parameter}) string value"));
1531 1532
        }

1533
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1534
        public async Task Parameter_DefaultValue()
1535 1536 1537
        {
            // NOTE: Dev10 doesn't show the default value, but it would be nice if we did.
            // NOTE: The "DefaultValue" property isn't implemented yet.
C
Cyrus Najmabadi 已提交
1538
            await TestInClassAsync(@"void M(int param = 42) { para$$m.ToString(); }",
1539
                MainDescription($"({FeaturesResources.Parameter}) int param = 42"));
1540 1541
        }

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

1549
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1550
        public async Task Parameter_Ref()
1551
        {
C
Cyrus Najmabadi 已提交
1552
            await TestInClassAsync(@"void M(ref DateTime arg) { ar$$g.ToString(); }",
1553
                MainDescription($"({FeaturesResources.Parameter}) ref DateTime arg"));
1554 1555
        }

1556
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1557
        public async Task Parameter_Out()
1558
        {
C
Cyrus Najmabadi 已提交
1559
            await TestInClassAsync(@"void M(out DateTime arg) { ar$$g.ToString(); }",
1560
                MainDescription($"({FeaturesResources.Parameter}) out DateTime arg"));
1561 1562
        }

1563
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1564
        public async Task Local_Minimal()
1565
        {
C
Cyrus Najmabadi 已提交
1566
            await TestInMethodAsync(@"DateTime dt; d$$t.ToString();",
1567
                MainDescription($"({FeaturesResources.LocalVariable}) DateTime dt"));
1568 1569
        }

1570
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1571
        public async Task Local_Qualified()
1572
        {
C
Cyrus Najmabadi 已提交
1573
            await TestInMethodAsync(@"System.IO.FileInfo fileInfo; file$$Info.ToString();",
1574
                MainDescription($"({FeaturesResources.LocalVariable}) System.IO.FileInfo fileInfo"));
1575 1576
        }

1577
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1578
        public async Task Method_MetadataOverload()
1579
        {
C
Cyrus Najmabadi 已提交
1580
            await TestInMethodAsync("Console.Write$$Line();",
1581
                MainDescription($"void Console.WriteLine() (+ 18 {FeaturesResources.Overloads})"));
1582 1583
        }

1584
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1585
        public async Task Method_SimpleWithOverload()
1586
        {
C
Cyrus Najmabadi 已提交
1587
            await TestInClassAsync(@"
1588 1589
void Method() { Met$$hod(); }
void Method(int i) { }",
1590
                MainDescription($"void C.Method() (+ 1 {FeaturesResources.Overload})"));
1591 1592
        }

1593
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1594
        public async Task Method_MoreOverloads()
1595
        {
C
Cyrus Najmabadi 已提交
1596
            await TestInClassAsync(@"
1597 1598 1599 1600
void Method() { Met$$hod(null); }
void Method(int i) { }
void Method(DateTime dt) { }
void Method(System.IO.FileInfo fileInfo) { }",
1601
                MainDescription($"void C.Method(System.IO.FileInfo fileInfo) (+ 3 {FeaturesResources.Overloads})"));
1602 1603
        }

1604
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1605
        public async Task Method_SimpleInSameClass()
1606
        {
C
Cyrus Najmabadi 已提交
1607
            await TestInClassAsync(@"DateTime GetDate(System.IO.FileInfo ft) { Get$$Date(null); }",
1608 1609 1610
                MainDescription("DateTime C.GetDate(System.IO.FileInfo ft)"));
        }

1611
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1612
        public async Task Method_OptionalParameter()
1613
        {
C
Cyrus Najmabadi 已提交
1614
            await TestInClassAsync(@"
1615 1616 1617 1618 1619
void M() { Met$$hod(); }
void Method(int i = 0) { }",
                MainDescription("void C.Method([int i = 0])"));
        }

1620
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1621
        public async Task Method_OptionalDecimalParameter()
1622
        {
C
Cyrus Najmabadi 已提交
1623
            await TestInClassAsync(@"
1624
void Foo(decimal x$$yz = 10) { }",
1625
                MainDescription($"({FeaturesResources.Parameter}) decimal xyz = 10"));
1626 1627
        }

1628
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1629
        public async Task Method_Generic()
1630 1631 1632
        {
            // Generic method don't get the instantiation info yet.  NOTE: We don't display
            // constraint info in Dev10. Should we?
C
Cyrus Najmabadi 已提交
1633
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn> {
1634 1635 1636 1637 1638 1639
    Fo$$o<int, DateTime>(37);
}",

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

1640
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1641
        public async Task Method_UnconstructedGeneric()
1642
        {
C
Cyrus Najmabadi 已提交
1643
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) {
1644 1645 1646 1647 1648 1649
    Fo$$o<TIn, TOut>(default(TIn);
}",

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

1650
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1651
        public async Task Method_Inferred()
1652
        {
C
Cyrus Najmabadi 已提交
1653
            await TestInClassAsync(@"void Foo<TIn>(TIn arg) {
1654 1655 1656 1657 1658
    Fo$$o(42);
}",
                MainDescription("void C.Foo<int>(int arg)"));
        }

1659
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1660
        public async Task Method_MultipleParams()
1661
        {
C
Cyrus Najmabadi 已提交
1662
            await TestInClassAsync(@"void Foo(DateTime dt, System.IO.FileInfo fi, int number) {
1663 1664 1665 1666 1667
    Fo$$o(DateTime.Now, null, 32);
}",
                MainDescription("void C.Foo(DateTime dt, System.IO.FileInfo fi, int number)"));
        }

1668
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1669
        public async Task Method_OptionalParam()
1670 1671
        {
            // NOTE - Default values aren't actually returned by symbols yet.
C
Cyrus Najmabadi 已提交
1672
            await TestInClassAsync(@"void Foo(int num = 42) {
1673 1674 1675 1676 1677
    Fo$$o();
}",
                MainDescription("void C.Foo([int num = 42])"));
        }

1678
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1679
        public async Task Method_ParameterModifiers()
1680 1681
        {
            // NOTE - Default values aren't actually returned by symbols yet.
C
Cyrus Najmabadi 已提交
1682
            await TestInClassAsync(@"void Foo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers) {
1683 1684 1685 1686 1687
    Fo$$o(DateTime.Now, null, 32);
}",
                MainDescription("void C.Foo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)"));
        }

1688
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1689
        public async Task Constructor()
1690
        {
C
Cyrus Najmabadi 已提交
1691
            await TestInClassAsync(@"public C() {} void M() { new C$$ ().ToString(); }",
1692 1693 1694
                MainDescription("C.C()"));
        }

1695
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1696
        public async Task Constructor_Overloads()
1697
        {
C
Cyrus Najmabadi 已提交
1698
            await TestInClassAsync(@"
1699 1700 1701 1702 1703 1704 1705 1706
public C() {}
public C(DateTime dt) {}
public C(int i) {}

void M()
{
    new C$$ (DateTime.MaxValue).ToString();
}",
1707
                MainDescription($"C.C(DateTime dt) (+ 2 {FeaturesResources.Overloads})"));
1708 1709 1710 1711 1712
        }

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

        /// <summary>
        /// Regression for 3923
        /// </summary>
1723
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1724
        public async Task Constructor_UnknownType()
1725
        {
C
Cyrus Najmabadi 已提交
1726
            await TestInvalidTypeInClassAsync(@"void M() { new F$$oo(); }");
1727 1728 1729 1730 1731
        }

        /// <summary>
        /// Regression for 3923
        /// </summary>
1732
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1733
        public async Task Constructor_OverloadFromProperty()
1734
        {
C
Cyrus Najmabadi 已提交
1735
            await TestInMethodAsync(@"new InvalidOperatio$$nException(this.GetType().Name);",
1736
                MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.Overloads})"));
1737 1738
        }

1739
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1740
        public async Task Constructor_Metadata()
1741
        {
C
Cyrus Najmabadi 已提交
1742
            await TestInMethodAsync(@"new Argument$$NullException();",
1743
                MainDescription($"ArgumentNullException.ArgumentNullException() (+ 3 {FeaturesResources.Overloads})"));
1744 1745
        }

1746
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1747
        public async Task Constructor_MetadataQualified()
1748
        {
C
Cyrus Najmabadi 已提交
1749
            await TestInMethodAsync(@"new System.IO.File$$Info(null);",
1750 1751 1752
                MainDescription("System.IO.FileInfo.FileInfo(string fileName)"));
        }

1753
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1754
        public async Task InterfaceProperty()
1755
        {
C
Cyrus Najmabadi 已提交
1756
            await TestInMethodAsync(@"
1757 1758 1759 1760 1761 1762 1763
interface I
{
    string Name$$ { get; set; }
}",
                MainDescription("string I.Name { get; set; }"));
        }

1764
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1765
        public async Task ExplicitInterfacePropertyImplementation()
1766
        {
C
Cyrus Najmabadi 已提交
1767
            await TestInMethodAsync(@"
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783
interface I
{
    string Name { get; set; }
}

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

1784
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1785
        public async Task Operator()
1786
        {
C
Cyrus Najmabadi 已提交
1787
            await TestInClassAsync(@"
1788 1789 1790 1791 1792 1793 1794
public static C operator +(C left, C right) { return null; }
void M(C left, C right) { return left +$$ right; }
",
                MainDescription("C C.operator +(C left, C right)"));
        }

        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
1795
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1796
        public async Task GenericMethodWithConstraintsAtDeclaration()
1797
        {
C
Cyrus Najmabadi 已提交
1798
            await TestInClassAsync(@"TOut F$$oo<TIn, TOut>(TIn arg) where TIn : IEquatable<TIn> {
1799 1800 1801 1802 1803 1804
}",

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

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

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

        [WorkItem(792629, "generic type parameter constraints for methods in quick info")]
1818
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1819
        public async Task UnConstructedGenericMethodWithConstraintsAtInvocation()
1820
        {
C
Cyrus Najmabadi 已提交
1821
            await TestInClassAsync(@"TOut Foo<TIn, TOut>(TIn arg) where TIn : Employee
1822 1823 1824 1825 1826 1827 1828 1829
{
    Fo$$o<TIn, TOut>(default(TIn);
}
",

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

1830
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1831
        public async Task GenericTypeWithConstraintsAtDeclaration()
1832
        {
C
Cyrus Najmabadi 已提交
1833
            await TestAsync(@"public class Employee : IComparable<Employee>
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846
{
    public int CompareTo(Employee other)
    {
        throw new NotImplementedException();
    }
}
class Emplo$$yeeList<T> : IEnumerable<T> where T : Employee, System.IComparable<T>, new()
{
}",

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

1847
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1848
        public async Task GenericType()
1849
        {
C
Cyrus Najmabadi 已提交
1850
            await TestAsync(@"
1851 1852 1853 1854 1855
class T1<T11>
{
    $$T11 i;
}
",
1856
                MainDescription($"T11 {FeaturesResources.In} T1<T11>"));
1857 1858
        }

1859
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1860
        public async Task GenericMethod()
1861
        {
C
Cyrus Najmabadi 已提交
1862
            await TestInClassAsync(@"
1863 1864 1865 1866 1867
    static void Meth1<T1>(T1 i) where T1 : struct
    {
        $$T1 i;
    }
",
1868
                MainDescription($"T1 {FeaturesResources.In} C.Meth1<T1> where T1 : struct"));
1869 1870
        }

1871
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1872
        public async Task Var()
1873
        {
C
Cyrus Najmabadi 已提交
1874
            await TestInMethodAsync(@"
1875 1876 1877
var x = new Exception();
var y = $$x;
",
1878
                MainDescription($"({FeaturesResources.LocalVariable}) Exception x"));
1879 1880
        }

1881
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1882
        public async Task NestedInGeneric()
1883
        {
C
Cyrus Najmabadi 已提交
1884
            await TestInMethodAsync(@"
1885 1886 1887
            List<int>.Enu$$merator e;
",
                MainDescription("struct System.Collections.Generic.List<T>.Enumerator"),
1888
                TypeParameterMap($"\r\nT {FeaturesResources.Is} int"));
1889 1890
        }

1891
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1892
        public async Task NestedGenericInGeneric()
1893
        {
C
Cyrus Najmabadi 已提交
1894
            await TestAsync(@"
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908
            class Outer<T>
{
    class Inner<U>
    {
    }

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

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

    class test
    {
        public int z;
    }
",
1927
                MainDescription($"({FeaturesResources.Field}) int test.z"));
1928 1929
        }

1930
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1931
        public async Task ObjectInitializer2()
1932
        {
C
Cyrus Najmabadi 已提交
1933
            await TestInMethodAsync(@"
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949
class C
{
    void M()
    {
        var x = new test() { z = $$5 };
    }

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

1950
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
J
Jared Parsons 已提交
1951
        [WorkItem(537880, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537880")]
C
Cyrus Najmabadi 已提交
1952
        public async Task TypeArgument()
1953
        {
C
Cyrus Najmabadi 已提交
1954
            await TestAsync(@"
1955 1956 1957 1958 1959 1960 1961 1962
class C<T, Y>
{
    void M()
    {
        C<int, DateTime> variable;
        $$variable = new C<int, DateTime>();
    }
}",
1963
                MainDescription($"({FeaturesResources.LocalVariable}) C<int, DateTime> variable"));
1964 1965
        }

1966
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1967
        public async Task ForEachLoop_1()
1968
        {
C
Cyrus Najmabadi 已提交
1969
            await TestInMethodAsync(@"
1970 1971 1972 1973 1974 1975 1976
int bb = 555;
bb = bb + 1;
foreach (int cc in new int[]{ 1,2,3}){
c$$c = 1;
bb = bb + 21;
}
",
1977
                MainDescription($"({FeaturesResources.LocalVariable}) int cc"));
1978 1979
        }

1980
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1981
        public async Task TryCatchFinally_1()
1982
        {
C
Cyrus Najmabadi 已提交
1983
            await TestInMethodAsync(@"
1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994
            try
            {
                int aa = 555;
                a$$a = aa + 1;
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }",
1995
                MainDescription($"({FeaturesResources.LocalVariable}) int aa"));
1996 1997
        }

1998
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
1999
        public async Task TryCatchFinally_2()
2000
        {
C
Cyrus Najmabadi 已提交
2001
            await TestInMethodAsync(@"
2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
            try
            {
            }
            catch (Exception ex)
            {
                var y = e$$x;
                var z = y;
            }
            finally
            {
            }
",
2014
                MainDescription($"({FeaturesResources.LocalVariable}) Exception ex"));
2015 2016
        }

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

2036
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2037
        public async Task TryCatchFinally_4()
2038
        {
C
Cyrus Najmabadi 已提交
2039
            await TestInMethodAsync(@"
2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051
            try
            {
            }
            catch (Exception ex)
            {
            }
            finally
            {
                int aa = 555;
                aa = a$$a + 1;
            }
",
2052
                MainDescription($"({FeaturesResources.LocalVariable}) int aa"));
2053 2054
        }

2055
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2056
        public async Task GenericVariable()
2057
        {
C
Cyrus Najmabadi 已提交
2058
            await TestAsync(@"
2059 2060 2061 2062 2063 2064 2065 2066 2067
            class C<T, Y>
            {
                void M()
                {
                    C<int, DateTime> variable;
                    var$$iable = new C<int, DateTime>();
                }
            }
",
2068
                MainDescription($"({FeaturesResources.LocalVariable}) C<int, DateTime> variable"));
2069 2070
        }

2071
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2072
        public async Task TestInstantiation()
2073
        {
C
Cyrus Najmabadi 已提交
2074
            await TestAsync(@"
2075 2076 2077 2078 2079 2080 2081 2082
using System.Collections.Generic;
class Program<T>
{
    static void Main(string[] args)
    {
        var p = new Dictio$$nary<int, string>();
    }
}",
2083
                MainDescription($"Dictionary<int, string>.Dictionary() (+ 5 {FeaturesResources.Overloads})"));
2084 2085
        }

2086
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2087
        public async Task TestUsingAlias_Bug4141()
2088
        {
C
Cyrus Najmabadi 已提交
2089
            await TestAsync(@"using X = A.C;
2090 2091 2092 2093 2094 2095 2096 2097
class A {
public class C { }
}
class D : X$$ { }
",
                MainDescription(@"class A.C"));
        }

2098
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2099
        public async Task TestFieldOnDeclaration()
2100
        {
C
Cyrus Najmabadi 已提交
2101
            await TestInClassAsync(@"
2102
DateTime fie$$ld;",
2103
                MainDescription($"({FeaturesResources.Field}) DateTime C.field"));
2104 2105
        }

J
Jared Parsons 已提交
2106
        [WorkItem(538767, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538767")]
2107
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2108
        public async Task TestGenericErrorFieldOnDeclaration()
2109
        {
C
Cyrus Najmabadi 已提交
2110
            await TestInClassAsync(@"
2111
NonExistentType<int> fi$$eld;",
2112
                MainDescription($"({FeaturesResources.Field}) NonExistentType<int> C.field"));
2113 2114
        }

J
Jared Parsons 已提交
2115
        [WorkItem(538822, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538822")]
2116
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2117
        public async Task TestDelegateType()
2118
        {
C
Cyrus Najmabadi 已提交
2119
            await TestInClassAsync(@"
2120 2121 2122
Fun$$c<int, string> field;",
                MainDescription("delegate TResult System.Func<in T, out TResult>(T arg)"),
                TypeParameterMap(
2123 2124
                    Lines($"\r\nT {FeaturesResources.Is} int",
                          $"TResult {FeaturesResources.Is} string")));
2125 2126
        }

J
Jared Parsons 已提交
2127
        [WorkItem(538824, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538824")]
2128
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2129
        public async Task TestOnDelegateInvocation()
2130
        {
C
Cyrus Najmabadi 已提交
2131
            await TestAsync(@"
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141
class Program
{
    delegate void D1();
    static void Main()
    {
        D1 d = Main;
        $$d(); 
    }
}
",
2142
                MainDescription($"({FeaturesResources.LocalVariable}) D1 d"));
2143 2144
        }

J
Jared Parsons 已提交
2145
        [WorkItem(539240, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539240")]
2146
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2147
        public async Task TestOnArrayCreation1()
2148
        {
C
Cyrus Najmabadi 已提交
2149
            await TestAsync(@"
2150 2151 2152 2153 2154 2155 2156 2157 2158
class Program
{
    static void Main()
    {
        int[] a = n$$ew int[0];
    }
}");
        }

J
Jared Parsons 已提交
2159
        [WorkItem(539240, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539240")]
2160
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2161
        public async Task TestOnArrayCreation2()
2162
        {
C
Cyrus Najmabadi 已提交
2163
            await TestAsync(@"
2164 2165 2166 2167 2168 2169 2170 2171 2172 2173
class Program
{
    static void Main()
    {
        int[] a = new i$$nt[0];
    }
}",
                MainDescription("struct System.Int32"));
        }

J
Jared Parsons 已提交
2174
        [WorkItem(539841, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539841")]
2175
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2176
        public async Task TestIsNamedTypeAccessibleForErrorTypes()
2177
        {
C
Cyrus Najmabadi 已提交
2178
            await TestAsync(@"sealed class B<T1, T2> : A<B<T1, T2>>{
2179 2180 2181 2182
    protected sealed override B<A<T>, A$$<T>> N() { }} internal class A<T>{}",
                MainDescription("class A<T>"));
        }

J
Jared Parsons 已提交
2183
        [WorkItem(540075, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540075")]
2184
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2185
        public async Task TestErrorType()
2186
        {
C
Cyrus Najmabadi 已提交
2187
            await TestAsync(@"using Foo = Foo;
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197
class C
{
    void Main()
    {
        $$Foo
    }
}",
                MainDescription("Foo"));
        }

J
Jared Parsons 已提交
2198
        [WorkItem(540871, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540871")]
2199
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2200
        public async Task TestLiterals()
2201
        {
C
Cyrus Najmabadi 已提交
2202
            await TestAsync(@"class MyClass
2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221
{
    MyClass()
        : this($$10)
    {
        intI = 2;
    }
 
    public MyClass(int i) { }
 
    static int intI = 1;
 
    public static int Main()
    {
        return 1;
    }
}",
                MainDescription("struct System.Int32"));
        }

J
Jared Parsons 已提交
2222
        [WorkItem(541444, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541444")]
2223
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2224
        public async Task TestErrorInForeach()
2225
        {
C
Cyrus Najmabadi 已提交
2226
            await TestAsync(@"
2227 2228 2229 2230 2231 2232 2233 2234 2235 2236
class C
{
    void Main()
    {
        foreach (int cc in null)
        {
            $$cc = 1;
        }
    }
}",
2237
                MainDescription($"({FeaturesResources.LocalVariable}) int cc"));
2238 2239
        }

J
Jared Parsons 已提交
2240
        [WorkItem(540438, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540438")]
2241
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2242
        public async Task TestNoQuickInfoOnAnonymousDelegate()
2243
        {
C
Cyrus Najmabadi 已提交
2244
            await TestAsync(@"
2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255
using System;

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

J
Jared Parsons 已提交
2256
        [WorkItem(541678, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541678")]
2257
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2258
        public async Task TestQuickInfoOnEvent()
2259
        {
C
Cyrus Najmabadi 已提交
2260
            await TestAsync(@"
2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282
using System;
 
public class SampleEventArgs
{
    public SampleEventArgs(string s) { Text = s; }
    public String Text { get; private set; } 
}
public class Publisher
{
    public delegate void SampleEventHandler(object sender, SampleEventArgs e);
    public event SampleEventHandler SampleEvent;
 
    protected virtual void RaiseSampleEvent()
    {
        if (Sam$$pleEvent != null)
            SampleEvent(this, new SampleEventArgs(""Hello""));
    }
}
",
                MainDescription("SampleEventHandler Publisher.SampleEvent"));
        }

J
Jared Parsons 已提交
2283
        [WorkItem(542157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542157")]
2284
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2285
        public async Task TestEvent()
2286
        {
C
Cyrus Najmabadi 已提交
2287
            await TestInMethodAsync(@"System.Console.CancelKeyPres$$s += null;",
2288 2289 2290
                MainDescription("ConsoleCancelEventHandler Console.CancelKeyPress"));
        }

J
Jared Parsons 已提交
2291
        [WorkItem(542157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542157")]
2292
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2293
        public async Task TestEventPlusEqualsOperator()
2294
        {
C
Cyrus Najmabadi 已提交
2295
            await TestInMethodAsync(@"System.Console.CancelKeyPress +$$= null;",
2296 2297 2298
                MainDescription("void Console.CancelKeyPress.add"));
        }

J
Jared Parsons 已提交
2299
        [WorkItem(542157, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542157")]
2300
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2301
        public async Task TestEventMinusEqualsOperator()
2302
        {
C
Cyrus Najmabadi 已提交
2303
            await TestInMethodAsync(@"System.Console.CancelKeyPress -$$= null;",
2304 2305 2306
                MainDescription("void Console.CancelKeyPress.remove"));
        }

J
Jared Parsons 已提交
2307
        [WorkItem(541885, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541885")]
2308
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2309
        public async Task TestQuickInfoOnExtensionMethod()
2310
        {
C
Cyrus Najmabadi 已提交
2311
            await TestWithOptionsAsync(Options.Regular, @"
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
        int[] values = { 1 };
        bool isArray = 7.I$$n(values);
    }
}
 
public static class MyExtensions
{
    public static bool In<T>(this T o, IEnumerable<T> items)
    {
        return true;
    }
}
",
2333
                MainDescription($"({CSharpFeaturesResources.Extension}) bool int.In<int>(IEnumerable<int> items)"));
2334 2335
        }

2336
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2337
        public async Task TestQuickInfoOnExtensionMethodOverloads()
2338
        {
C
Cyrus Najmabadi 已提交
2339
            await TestWithOptionsAsync(Options.Regular, @"
2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357
using System;
using System.Linq;

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

2361
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2362
        public async Task TestQuickInfoOnExtensionMethodOverloads2()
2363
        {
C
Cyrus Najmabadi 已提交
2364
            await TestWithOptionsAsync(Options.Regular, @"
2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382
using System;
using System.Linq;

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

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

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

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

2436
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2437
        public async Task Query4()
2438
        {
C
Cyrus Najmabadi 已提交
2439
            await TestAsync(@"
2440 2441 2442 2443 2444 2445 2446 2447 2448
class C
{
    void M()
    {
        var q = from n$$ in new int[] { 1, 2, 3, 4, 5}
                select n;
    }
}
",
2449
                MainDescription($"({FeaturesResources.RangeVariable}) ? n"));
2450 2451
        }

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

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

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

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

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

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

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

2581
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2582
        public async Task Query12()
2583
        {
C
Cyrus Najmabadi 已提交
2584
            await TestAsync(@"
2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596
using System.Collections.Generic;
using System.Linq;
class C
{
    void M()
    {
        var q = from x in new List<List<int>>()
                from y in x
                select $$y;
    }
}
",
2597
                MainDescription($"({FeaturesResources.RangeVariable}) int y"));
2598 2599
        }

J
Jared Parsons 已提交
2600
        [WorkItem(543205, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543205")]
2601
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2602
        public async Task TestErrorGlobal()
2603
        {
C
Cyrus Najmabadi 已提交
2604
            await TestAsync(@"extern alias global;
2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616
 
class myClass
{
    static int Main()
    {
        $$global::otherClass oc = new global::otherClass();
        return 0;
    }
}",
                MainDescription("<global namespace>"));
        }

2617
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2618
        public async Task DontRemoveAttributeSuffixAndProduceInvalidIdentifier1()
2619
        {
C
Cyrus Najmabadi 已提交
2620
            await TestAsync(@"
2621 2622 2623 2624 2625
using System;
class classAttribute : Attribute
{
    private classAttribute x$$;
}",
2626
                MainDescription($"({FeaturesResources.Field}) classAttribute classAttribute.x"));
2627 2628
        }

J
Jared Parsons 已提交
2629
        [WorkItem(544026, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544026")]
2630
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2631
        public async Task DontRemoveAttributeSuffix2()
2632
        {
C
Cyrus Najmabadi 已提交
2633
            await TestAsync(@"
2634 2635 2636 2637 2638
using System;
class class1Attribute : Attribute
{
    private class1Attribute x$$;
}",
2639
                MainDescription($"({FeaturesResources.Field}) class1Attribute class1Attribute.x"));
2640 2641
        }

2642
        [WorkItem(1696, "https://github.com/dotnet/roslyn/issues/1696")]
2643
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2644
        public async Task AttributeQuickInfoBindsToClassTest()
2645
        {
C
Cyrus Najmabadi 已提交
2646
            await TestAsync(@"
2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666
using System;

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

        [WorkItem(1696, "https://github.com/dotnet/roslyn/issues/1696")]
2667
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2668
        public async Task AttributeConstructorQuickInfo()
2669
        {
C
Cyrus Najmabadi 已提交
2670
            await TestAsync(@"
2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689
using System;

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

2690
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2691
        public async Task TestLabel()
2692
        {
C
Cyrus Najmabadi 已提交
2693
            await TestInClassAsync(@"void M() { Foo: int Foo; goto Foo$$; }",
2694
                MainDescription($"({FeaturesResources.Label}) Foo"));
2695 2696
        }

J
Jared Parsons 已提交
2697
        [WorkItem(542613, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542613")]
2698
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2699
        public async Task TestUnboundGeneric()
2700
        {
C
Cyrus Najmabadi 已提交
2701
            await TestAsync(@"
2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714
using System;
using System.Collections.Generic;
class C
{
    void M()
    {
        Type t = typeof(L$$ist<>);
    }
}",
                MainDescription("class System.Collections.Generic.List<T>"),
                NoTypeParameterMap);
        }

J
Jared Parsons 已提交
2715
        [WorkItem(543113, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543113")]
2716
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2717
        public async Task TestAnonymousTypeNew1()
2718
        {
C
Cyrus Najmabadi 已提交
2719
            await TestAsync(@"
2720 2721 2722 2723 2724 2725 2726 2727 2728 2729
class C
{
    void M()
    {
        var v = $$new { };
    }
}",
                MainDescription(@"AnonymousType 'a"),
                NoTypeParameterMap,
                AnonymousTypes(
2730 2731 2732
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{  }}"));
2733 2734
        }

J
Jared Parsons 已提交
2735
        [WorkItem(543873, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543873")]
2736
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2737
        public async Task TestNestedAnonymousType()
2738 2739 2740
        {
            // verify nested anonymous types are listed in the same order for different properties
            // verify first property
C
Cyrus Najmabadi 已提交
2741
            await TestInMethodAsync(@"var x = new[] { new { Name = ""BillG"", Address = new { Street = ""1 Microsoft Way"", Zip = ""98052"" } } }; x[0].$$Address",
2742 2743 2744
                MainDescription(@"'b 'a.Address { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
2745 2746 2747 2748
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{ string Name, 'b Address }}
    'b {FeaturesResources.Is} new {{ string Street, string Zip }}"));
2749 2750

            // verify second property
C
Cyrus Najmabadi 已提交
2751
            await TestInMethodAsync(@"var x = new[] { new { Name = ""BillG"", Address = new { Street = ""1 Microsoft Way"", Zip = ""98052"" } } }; x[0].$$Name",
2752 2753 2754
                MainDescription(@"string 'a.Name { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
2755 2756 2757 2758
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{ string Name, 'b Address }}
    'b {FeaturesResources.Is} new {{ string Street, string Zip }}"));
2759 2760
        }

2761
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
J
Jared Parsons 已提交
2762
        [WorkItem(543183, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543183")]
C
Cyrus Najmabadi 已提交
2763
        public async Task TestAssignmentOperatorInAnonymousType()
2764
        {
C
Cyrus Najmabadi 已提交
2765
            await TestAsync(@"class C
2766 2767 2768 2769 2770 2771 2772 2773 2774
{
    void M()
    {
        var a = new { A $$= 0 };
    }
}
");
        }

2775
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
2776
        [WorkItem(10731, "DevDiv_Projects/Roslyn")]
C
Cyrus Najmabadi 已提交
2777
        public async Task TestErrorAnonymousTypeDoesntShow()
2778
        {
C
Cyrus Najmabadi 已提交
2779
            await TestInMethodAsync(@"var a = new { new { N = 0 }.N, new { } }.$$N;",
2780 2781 2782
                MainDescription(@"int 'a.N { get; }"),
                NoTypeParameterMap,
                AnonymousTypes(
2783 2784 2785
$@"
{FeaturesResources.AnonymousTypes}
    'a {FeaturesResources.Is} new {{ int N }}"));
2786 2787
        }

2788
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
J
Jared Parsons 已提交
2789
        [WorkItem(543553, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543553")]
C
Cyrus Najmabadi 已提交
2790
        public async Task TestArrayAssignedToVar()
2791
        {
C
Cyrus Najmabadi 已提交
2792
            await TestAsync(@"class C
2793 2794 2795 2796 2797 2798 2799 2800 2801 2802
{
    static void M(string[] args)
    {
        v$$ar a = args;
    }
}
",
                MainDescription("string[]"));
        }

J
Jared Parsons 已提交
2803
        [WorkItem(529139, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529139")]
2804
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2805
        public async Task ColorColorRangeVariable()
2806
        {
C
Cyrus Najmabadi 已提交
2807
            await TestAsync(@"
2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825
using System.Collections.Generic;
using System.Linq;

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

J
Jared Parsons 已提交
2829
        [WorkItem(543550, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543550")]
2830
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2831
        public async Task QuickInfoOnOperator()
2832
        {
C
Cyrus Najmabadi 已提交
2833
            await TestAsync(@"using System.Collections.Generic;
2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856
 
class Program
{
    static void Main(string[] args)
    {
        var v = new Program() $$+ string.Empty;
    }
 
    public static implicit operator Program(string s)
    {
        return null;
    }
 
    public static IEnumerable<Program> operator +(Program p1, Program p2)
    {
        yield return p1;
        yield return p2;
    }
}
",
                MainDescription("IEnumerable<Program> Program.operator +(Program p1, Program p2)"));
        }

2857
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2858
        public async Task TestConstantField()
2859
        {
C
Cyrus Najmabadi 已提交
2860
            await TestAsync("class C { const int $$F = 1;",
2861
                MainDescription($"({FeaturesResources.Constant}) int C.F = 1"));
2862 2863
        }

2864
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2865
        public async Task TestMultipleConstantFields()
2866
        {
C
Cyrus Najmabadi 已提交
2867
            await TestAsync("class C { public const double X = 1.0, Y = 2.0, $$Z = 3.5;",
2868
                MainDescription($"({FeaturesResources.Constant}) double C.Z = 3.5"));
2869 2870
        }

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

2886
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2887
        public async Task TestConstantCircularDependencies()
2888
        {
C
Cyrus Najmabadi 已提交
2889
            await TestAsync(@"class A
2890 2891 2892 2893 2894 2895 2896
{
    public const int X = B.Z + 1;
}
class B
{
    public const int Z$$ = A.X + 1;
}",
2897
                MainDescription($"({FeaturesResources.Constant}) int B.Z = A.X + 1"));
2898 2899
        }

J
Jared Parsons 已提交
2900
        [WorkItem(544620, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544620")]
2901
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2902
        public async Task TestConstantOverflow()
2903
        {
C
Cyrus Najmabadi 已提交
2904
            await TestAsync(@"class B
2905 2906 2907
{
    public const int Z$$ = int.MaxValue + 1;
}",
2908
                MainDescription($"({FeaturesResources.Constant}) int B.Z = int.MaxValue + 1"));
2909 2910
        }

J
Jared Parsons 已提交
2911
        [WorkItem(544620, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544620")]
2912
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2913
        public async Task TestConstantOverflowInUncheckedContext()
2914
        {
C
Cyrus Najmabadi 已提交
2915
            await TestAsync(@"class B
2916 2917 2918
{
    public const int Z$$ = unchecked(int.MaxValue + 1);
}",
2919
                MainDescription($"({FeaturesResources.Constant}) int B.Z = unchecked(int.MaxValue + 1)"));
2920 2921
        }

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

2936
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2937
        public async Task TestConstantInDefaultExpression()
2938
        {
C
Cyrus Najmabadi 已提交
2939
            await TestAsync(@"public class EnumTest
2940 2941 2942 2943 2944 2945 2946
{
    enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
    static void Main()
    {
        const Days $$x = default(Days);
    }
}",
2947
                MainDescription($"({FeaturesResources.LocalConstant}) Days x = default(Days)"));
2948 2949
        }

2950
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2951
        public async Task TestConstantParameter()
2952
        {
C
Cyrus Najmabadi 已提交
2953
            await TestAsync("class C { void Bar(int $$b = 1); }",
2954
                MainDescription($"({FeaturesResources.Parameter}) int b = 1"));
2955 2956
        }

2957
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2958
        public async Task TestConstantLocal()
2959
        {
C
Cyrus Najmabadi 已提交
2960
            await TestAsync("class C { void Bar() { const int $$loc = 1; }",
2961
                MainDescription($"({FeaturesResources.LocalConstant}) int loc = 1"));
2962 2963
        }

J
Jared Parsons 已提交
2964
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
2965
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2966
        public async Task TestErrorType1()
2967
        {
C
Cyrus Najmabadi 已提交
2968
            await TestInMethodAsync("var $$v1 = new Foo();",
2969
                MainDescription($"({FeaturesResources.LocalVariable}) Foo v1"));
2970 2971
        }

J
Jared Parsons 已提交
2972
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
2973
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2974
        public async Task TestErrorType2()
2975
        {
C
Cyrus Najmabadi 已提交
2976
            await TestInMethodAsync("var $$v1 = v1;",
2977
                MainDescription($"({FeaturesResources.LocalVariable}) var v1"));
2978 2979
        }

J
Jared Parsons 已提交
2980
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
2981
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2982
        public async Task TestErrorType3()
2983
        {
C
Cyrus Najmabadi 已提交
2984
            await TestInMethodAsync("var $$v1 = new Foo<Bar>();",
2985
                MainDescription($"({FeaturesResources.LocalVariable}) Foo<Bar> v1"));
2986 2987
        }

J
Jared Parsons 已提交
2988
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
2989
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2990
        public async Task TestErrorType4()
2991
        {
C
Cyrus Najmabadi 已提交
2992
            await TestInMethodAsync("var $$v1 = &(x => x);",
2993
                MainDescription($"({FeaturesResources.LocalVariable}) ?* v1"));
2994 2995
        }

J
Jared Parsons 已提交
2996
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
2997
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
2998
        public async Task TestErrorType5()
2999
        {
C
Cyrus Najmabadi 已提交
3000
            await TestInMethodAsync("var $$v1 = &v1",
3001
                MainDescription($"({FeaturesResources.LocalVariable}) var* v1"));
3002 3003
        }

J
Jared Parsons 已提交
3004
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3005
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3006
        public async Task TestErrorType6()
3007
        {
C
Cyrus Najmabadi 已提交
3008
            await TestInMethodAsync("var $$v1 = new Foo[1]",
3009
                MainDescription($"({FeaturesResources.LocalVariable}) Foo[] v1"));
3010 3011
        }

J
Jared Parsons 已提交
3012
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3013
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3014
        public async Task TestErrorType7()
3015
        {
C
Cyrus Najmabadi 已提交
3016
            await TestInClassAsync("class C { void Method() { } void Foo() { var $$v1 = MethodGroup; } }",
3017
                MainDescription($"({FeaturesResources.LocalVariable}) ? v1"));
3018 3019
        }

J
Jared Parsons 已提交
3020
        [WorkItem(544416, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544416")]
3021
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3022
        public async Task TestErrorType8()
3023
        {
C
Cyrus Najmabadi 已提交
3024
            await TestInMethodAsync("var $$v1 = Unknown",
3025
                MainDescription($"({FeaturesResources.LocalVariable}) ? v1"));
3026 3027
        }

J
Jared Parsons 已提交
3028
        [WorkItem(545072, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545072")]
3029
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3030
        public async Task TestDelegateSpecialTypes()
3031
        {
C
Cyrus Najmabadi 已提交
3032
            await TestAsync("delegate void $$F(int x);",
3033 3034 3035
                MainDescription("delegate void F(int x)"));
        }

J
Jared Parsons 已提交
3036
        [WorkItem(545108, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545108")]
3037
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3038
        public async Task TestNullPointerParameter()
3039
        {
C
Cyrus Najmabadi 已提交
3040
            await TestAsync("class C { unsafe void $$Foo(int* x = null) { } }",
3041 3042 3043
                MainDescription("void C.Foo([int* x = null])"));
        }

J
Jared Parsons 已提交
3044
        [WorkItem(545098, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545098")]
3045
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3046
        public async Task TestLetIdentifier1()
3047
        {
C
Cyrus Najmabadi 已提交
3048
            await TestInMethodAsync("var q = from e in \"\" let $$y = 1 let a = new { y } select a;",
3049
                MainDescription($"({FeaturesResources.RangeVariable}) int y"));
3050 3051
        }

J
Jared Parsons 已提交
3052
        [WorkItem(545295, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545295")]
3053
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3054
        public async Task TestNullableDefaultValue()
3055
        {
C
Cyrus Najmabadi 已提交
3056
            await TestAsync("class Test { void $$Method(int? t1 = null) { } }",
3057 3058 3059
                MainDescription("void Test.Method([int? t1 = null])"));
        }

J
Jared Parsons 已提交
3060
        [WorkItem(529586, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529586")]
3061
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3062
        public async Task TestInvalidParameterInitializer()
3063
        {
C
Cyrus Najmabadi 已提交
3064
            await TestAsync(
3065 3066 3067
@"class Program { void M1(float $$j1 = ""Hello""
        + 
        ""World"") { } }",
3068
                MainDescription($@"({FeaturesResources.Parameter}) float j1 = ""Hello"" + ""World"""));
3069 3070
        }

J
Jared Parsons 已提交
3071
        [WorkItem(545230, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545230")]
3072
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3073
        public async Task TestComplexConstLocal()
3074
        {
C
Cyrus Najmabadi 已提交
3075
            await TestAsync(
3076 3077 3078 3079 3080 3081 3082 3083 3084 3085
@"class Program
{
    void Main()
    {
        const int MEGABYTE = 1024 *
            1024 + true;
        Blah($$MEGABYTE);
    }
}
",
3086
                MainDescription($@"({FeaturesResources.LocalConstant}) int MEGABYTE = 1024 * 1024 + true"));
3087 3088
        }

J
Jared Parsons 已提交
3089
        [WorkItem(545230, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545230")]
3090
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3091
        public async Task TestComplexConstField()
3092
        {
C
Cyrus Najmabadi 已提交
3093
            await TestAsync(
3094 3095 3096 3097 3098 3099 3100 3101 3102 3103
@"class Program
{
    const int a = true 
        - 
        false;
    void Main()
    {
        Foo($$a);
    }
}",
3104
                MainDescription($"({FeaturesResources.Constant}) int Program.a = true - false"));
3105 3106
        }

3107
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3108
        public async Task TestTypeParameterCrefDoesNotHaveQuickInfo()
3109
        {
C
Cyrus Najmabadi 已提交
3110
            await TestAsync(
3111 3112 3113 3114 3115 3116 3117 3118 3119
@"class C<T>
{
    ///  <see cref=""C{X$$}""/>
    static void Main(string[] args)
    {
    }
}");
        }

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

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

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

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

3174
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3175
        public async Task TestCref5()
3176
        {
C
Cyrus Najmabadi 已提交
3177
            await TestAsync(
3178 3179 3180 3181 3182 3183 3184 3185 3186
@"class Program
{
    ///  <see cref=""Main""$$/>
    static void Main(string[] args)
    {
    }
}");
        }

J
Jared Parsons 已提交
3187
        [WorkItem(546849, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546849")]
3188
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3189
        public async Task TestIndexedProperty()
3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226
        {
            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 已提交
3227
            await TestWithReferenceAsync(sourceCode: markup,
3228 3229 3230 3231 3232 3233
                referencedCode: referencedCode,
                sourceLanguage: LanguageNames.CSharp,
                referencedLanguage: LanguageNames.VisualBasic,
                expectedResults: MainDescription("string CCC.IndexProp[int p1, [int p2 = 0]] { get; set; }"));
        }

J
Jared Parsons 已提交
3234
        [WorkItem(546918, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546918")]
3235
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3236
        public async Task TestUnconstructedGeneric()
3237
        {
C
Cyrus Najmabadi 已提交
3238
            await TestAsync(
3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251
@"class A<T> {
    enum SortOrder {
        Ascending,
        Descending,
        None
    }
    void Foo() {
        var b = $$SortOrder.Ascending;
    }
}",
                MainDescription(@"enum A<T>.SortOrder"));
        }

J
Jared Parsons 已提交
3252
        [WorkItem(546970, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546970")]
3253
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3254
        public async Task TestUnconstructedGenericInCRef()
3255
        {
C
Cyrus Najmabadi 已提交
3256
            await TestAsync(
3257 3258 3259 3260 3261 3262 3263
@"
/// <see cref=""$$C{T}"" />
class C<T> { }
",
                MainDescription(@"class C<T>"));
        }

3264
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3265
        public async Task TestAwaitableMethod()
3266 3267 3268 3269 3270 3271 3272 3273 3274
        {
            var markup = @"using System.Threading.Tasks;
class C
{
    async Task Foo()
    {
        Fo$$o();
    }
}";
3275
            var description = $"({CSharpFeaturesResources.Awaitable}) Task C.Foo()";
3276

3277
            var documentation = $@"
3278
{WorkspacesResources.Usage}
R
Ravi Chande 已提交
3279
  {SyntaxFacts.GetText(SyntaxKind.AwaitKeyword)} Foo();";
3280

C
Cyrus Najmabadi 已提交
3281
            await VerifyWithMscorlib45Async(markup, new[] { MainDescription(description), Usage(documentation) });
3282 3283
        }

3284
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3285
        public async Task ObsoleteItem()
3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297
        {
            var markup = @"
using System;

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

J
Jared Parsons 已提交
3301
        [WorkItem(751070, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/751070")]
3302
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3303
        public async Task DynamicOperator()
3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318
        {
            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 已提交
3319
            await TestAsync(markup, MainDescription("dynamic dynamic.operator ==(dynamic left, dynamic right)"));
3320 3321
        }

3322
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3323
        public async Task TextOnlyDocComment()
3324
        {
C
Cyrus Najmabadi 已提交
3325
            await TestAsync(@"
3326 3327 3328 3329 3330 3331 3332 3333
/// <summary>
///foo
/// </summary>
class C$$
{
}", Documentation("foo"));
        }

3334
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3335
        public async Task TestTrimConcatMultiLine()
3336
        {
C
Cyrus Najmabadi 已提交
3337
            await TestAsync(@"
3338 3339 3340 3341 3342 3343 3344 3345 3346
/// <summary>
/// foo
/// bar
/// </summary>
class C$$
{
}", Documentation("foo bar"));
        }

3347
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3348
        public async Task TestCref()
3349
        {
C
Cyrus Najmabadi 已提交
3350
            await TestAsync(@"
3351 3352 3353 3354 3355 3356 3357 3358 3359
/// <summary>
/// <see cref=""C""/>
/// <seealso cref=""C""/>
/// </summary>
class C$$
{
}", Documentation("C C"));
        }

3360
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3361
        public async Task ExcludeTextOutsideSummaryBlock()
3362
        {
C
Cyrus Najmabadi 已提交
3363
            await TestAsync(@"
3364 3365 3366 3367 3368 3369 3370 3371 3372 3373
/// red
/// <summary>
/// green
/// </summary>
/// yellow
class C$$
{
}", Documentation("green"));
        }

3374
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3375
        public async Task NewlineAfterPara()
3376
        {
C
Cyrus Najmabadi 已提交
3377
            await TestAsync(@"
3378 3379 3380 3381 3382 3383 3384 3385
/// <summary>
/// <para>foo</para>
/// </summary>
class C$$
{
}", Documentation("foo"));
        }

3386
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3387
        public async Task TextOnlyDocComment_Metadata()
3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404
        {
            var referenced = @"
/// <summary>
///foo
/// </summary>
public class C
{
}";

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

3408
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3409
        public async Task TestTrimConcatMultiLine_Metadata()
3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427
        {
            var referenced = @"
/// <summary>
/// foo
/// bar
/// </summary>
public class C
{
}";

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

3431
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3432
        public async Task TestCref_Metadata()
3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449
        {
            var code = @"
class G
{
    void foo()
    {
        C$$ c;
    }
}";

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

3453
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3454
        public async Task ExcludeTextOutsideSummaryBlock_Metadata()
3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473
        {
            var code = @"
class G
{
    void foo()
    {
        C$$ c;
    }
}";

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

3477
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3478
        public async Task Param()
3479
        {
C
Cyrus Najmabadi 已提交
3480
            await TestAsync(@"
3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T>(string[] arg$$s, T otherParam)
    {
    }
}", Documentation("First parameter of C.Foo<T>(string[], T)"));
        }

3493
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3494
        public async Task Param_Metadata()
3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515
        {
            var code = @"
class G
{
    void foo()
    {
        C c;
        c.Foo<int>(arg$$s: new string[] { }, 1);
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T>(string[] args, T otherParam)
    {
    }
}";
C
Cyrus Najmabadi 已提交
3516
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("First parameter of C.Foo<T>(string[], T)"));
3517 3518
        }

3519
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3520
        public async Task Param2()
3521
        {
C
Cyrus Najmabadi 已提交
3522
            await TestAsync(@"
3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T>(string[] args, T oth$$erParam)
    {
    }
}", Documentation("Another parameter of C.Foo<T>(string[], T)"));
        }

3535
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3536
        public async Task Param2_Metadata()
3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553
        {
            var code = @"
class G
{
    void foo()
    {
        C c;
        c.Foo<int>(args: new string[] { }, other$$Param: 1);
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{ T} (string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
C
Cyrus Najmabadi 已提交
3554
    public void Foo<T>(string[] args, T otherParam)
3555 3556 3557
    {
    }
}";
C
Cyrus Najmabadi 已提交
3558
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#", Documentation("Another parameter of C.Foo<T>(string[], T)"));
3559 3560
        }

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

3577
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3578
        public async Task UnboundCref()
3579
        {
C
Cyrus Najmabadi 已提交
3580
            await TestAsync(@"
3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592
/// <summary></summary>
public class C
{
    /// <typeparam name=""T"">A type parameter of <see cref=""foo{T}(string[], T)""/></typeparam>
    /// <param name=""args"">First parameter of <see cref=""Foo{T} (string[], T)""/></param>
    /// <param name=""otherParam"">Another parameter of <see cref=""Foo{T}(string[], T)""/></param>
    public void Foo<T$$>(string[] args, T otherParam)
    {
    }
}", Documentation("A type parameter of foo<T>(string[], T)"));
        }

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

3608
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3609
        public async Task CrefInConstructorOverloaded()
3610
        {
C
Cyrus Najmabadi 已提交
3611
            await TestAsync(@"
3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629
public class TestClass
{
    /// <summary> 
    /// This sample shows how to specify the <see cref=""TestClass""/> constructor as a cref attribute.
    /// </summary> 
    public TestClass()
    {
    }

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

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

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

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

3645
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3646
        public async Task CrefInGenericMethod2()
3647
        {
C
Cyrus Najmabadi 已提交
3648
            await TestAsync(@"
3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659
public class TestClass
{
        /// <summary> 
        /// The GetGenericValue method. 
        /// <para>This sample shows how to specify the <see cref=""GetGenericValue{T}(T)""/> method as a cref attribute.</para>
        /// </summary> 
        public static T GetGenericVa$$lue<T>(T para) { return para; }

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

J
Jared Parsons 已提交
3660
        [WorkItem(813350, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/813350")]
3661
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3662
        public async Task CrefInMethodOverloading1()
3663
        {
C
Cyrus Najmabadi 已提交
3664
            await TestAsync(@"
3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685
public class TestClass
{
        public static int GetZero()
        {
            GetGenericValu$$e();
            GetGenericValue(5);
        }

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

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

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

J
Jared Parsons 已提交
3686
        [WorkItem(813350, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/813350")]
3687
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3688
        public async Task CrefInMethodOverloading2()
3689
        {
C
Cyrus Najmabadi 已提交
3690
            await TestAsync(@"
3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711
public class TestClass
{
        public static int GetZero()
        {
            GetGenericValue();
            GetGenericVal$$ue(5);
        }

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

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

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

3712
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3713
        public async Task CrefInGenericType()
3714
        {
C
Cyrus Najmabadi 已提交
3715
            await TestAsync(@"
3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731
    /// <summary> 
    /// <remarks>This example shows how to specify the <see cref=""GenericClass{T}""/> cref.</remarks>
    /// </summary> 
    class Generic$$Class<T> { }",
    Documentation("This example shows how to specify the GenericClass<T> cref.",
        ExpectedClassifications(
            Text("This example shows how to specify the"),
            WhiteSpace(" "),
            Class("GenericClass"),
            Punctuation.OpenAngle,
            TypeParameter("T"),
            Punctuation.CloseAngle,
            WhiteSpace(" "),
            Text("cref."))));
        }

J
Jared Parsons 已提交
3732
        [WorkItem(812720, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/812720")]
3733
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3734
        public async Task ClassificationOfCrefsFromMetadata()
3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755
        {
            var code = @"
class G
{
    void foo()
    {
        C c;
        c.Fo$$o();
    }
}";
            var referenced = @"
/// <summary></summary>
public class C
{
    /// <summary> 
    /// See <see cref=""Foo""/> method
    /// </summary> 
    public void Foo()
    {
    }
}";
C
Cyrus Najmabadi 已提交
3756
            await TestWithMetadataReferenceHelperAsync(code, referenced, "C#", "C#",
3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769
                Documentation("See C.Foo() method",
                    ExpectedClassifications(
                        Text("See"),
                        WhiteSpace(" "),
                        Class("C"),
                        Punctuation.Text("."),
                        Identifier("Foo"),
                        Punctuation.OpenParen,
                        Punctuation.CloseParen,
                        WhiteSpace(" "),
                        Text("method"))));
        }

3770
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3771
        public async Task FieldAvailableInBothLinkedFiles()
3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    int x;
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

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

3795
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3796
        public async Task FieldUnavailableInOneLinkedFile()
3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""FOO"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
3818
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}", expectsWarningGlyph: true);
3819

C
Cyrus Najmabadi 已提交
3820
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3821 3822
        }

3823
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3824
        public async Task BindSymbolInOtherFile()
3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"" PreprocessorSymbols=""FOO"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
3846
            var expectedDescription = Usage($"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.NotAvailable)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.Available)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}", expectsWarningGlyph: true);
3847

C
Cyrus Najmabadi 已提交
3848
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3849 3850
        }

3851
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3852
        public async Task FieldUnavailableInTwoLinkedFiles()
3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""FOO"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif
    void foo()
    {
        x$$
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj3"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
            var expectedDescription = Usage(
3878
                $"\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}",
3879 3880
                expectsWarningGlyph: true);

C
Cyrus Najmabadi 已提交
3881
            await VerifyWithReferenceWorkerAsync(markup, new[] { expectedDescription });
3882 3883
        }

3884
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3885
        public async Task ExcludeFilesWithInactiveRegions()
3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""FOO,BAR"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
#if FOO
    int x;
#endif

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

J
Jared Parsons 已提交
3917
        [WorkItem(962353, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/962353")]
3918
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3919
        public async Task NoValidSymbolsInLinkedDocuments()
3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void foo()
    {
        B$$ar();
    }
#if B
    void Bar() { }
#endif
   
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";
C
Cyrus Najmabadi 已提交
3942
            await VerifyWithReferenceWorkerAsync(markup);
3943 3944
        }

J
Jared Parsons 已提交
3945
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
3946
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3947
        public async Task LocalsValidInLinkedDocuments()
3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void M()
    {
        int x$$;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
3967
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.LocalVariable}) int x"), Usage("") });
3968 3969
        }

J
Jared Parsons 已提交
3970
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
3971
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
3972
        public async Task LocalWarningInLinkedDocuments()
3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"" PreprocessorSymbols=""PROJ1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{
    void M()
    {
#if PROJ1
        int x;
#endif

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

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

J
Jared Parsons 已提交
3999
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
4000
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4001
        public async Task LabelsValidInLinkedDocuments()
4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
class C
{   
    void M()
    {
        $$LABEL: goto LABEL;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
4021
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.Label}) LABEL"), Usage("") });
4022 4023
        }

J
Jared Parsons 已提交
4024
        [WorkItem(1020944, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1020944")]
4025
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4026
        public async Task RangeVariablesValidInLinkedDocuments()
4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046
        {
            var markup = @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj1"">
        <Document FilePath=""SourceDocument""><![CDATA[
using System.Linq;
class C
{
    void M()
    {
        var x = from y in new[] {1, 2, 3} select $$y;
    }
}
]]>
        </Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""Proj2"">
        <Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""SourceDocument""/>
    </Project>
</Workspace>";

C
Cyrus Najmabadi 已提交
4047
            await VerifyWithReferenceWorkerAsync(markup, new[] { MainDescription($"({FeaturesResources.RangeVariable}) int y"), Usage("") });
4048 4049
        }

J
Jared Parsons 已提交
4050
        [WorkItem(1019766, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1019766")]
4051
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4052
        public async Task PointerAccessibility()
4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063
        {
            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 已提交
4064
            await TestAsync(markup, MainDescription("bool void*.operator ==(void* left, void* right)"));
4065 4066
        }

J
Jared Parsons 已提交
4067
        [WorkItem(1114300, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1114300")]
4068
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4069
        public async Task AwaitingTaskOfArrayType()
4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080
        {
            var markup = @"
using System.Threading.Tasks;

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

J
Jared Parsons 已提交
4084
        [WorkItem(1114300, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1114300")]
4085
        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
C
Cyrus Najmabadi 已提交
4086
        public async Task AwaitingTaskOfDynamic()
4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097
        {
            var markup = @"
using System.Threading.Tasks;

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

4101
        [Fact, Trait(Traits.Feature, Traits.Features.Completion)]
C
Cyrus Najmabadi 已提交
4102
        public async Task MethodOverloadDifferencesIgnored()
4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127
        {
            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 已提交
4128
            await VerifyWithReferenceWorkerAsync(markup, MainDescription(expectedDescription));
4129
        }
4130

4131
        [Fact, Trait(Traits.Feature, Traits.Features.Completion)]
C
Cyrus Najmabadi 已提交
4132
        public async Task MethodOverloadDifferencesIgnored_ContainingType()
4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180
        {
            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 已提交
4181
            await VerifyWithReferenceWorkerAsync(markup, MainDescription(expectedDescription));
4182
        }
4183 4184 4185

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(4868, "https://github.com/dotnet/roslyn/issues/4868")]
C
Cyrus Najmabadi 已提交
4186
        public async Task QuickInfoExceptions()
4187
        {
C
Cyrus Najmabadi 已提交
4188
            await TestAsync(@"
4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199
using System;
namespace MyNs
{
    class MyException1 : Exception { }
    class MyException2 : Exception { }
    class TestClass
    {
        /// <exception cref=""MyException1""></exception>
        /// <exception cref=""T:MyNs.MyException2""></exception>
        /// <exception cref=""System.Int32""></exception>
        /// <exception cref=""double""></exception>
4200
        /// <exception cref=""Not_A_Class_But_Still_Displayed""></exception>
4201 4202 4203 4204 4205 4206 4207
        void M()
        {
            M$$();
        }
    }
}
",
4208
                Exceptions($"\r\n{WorkspacesResources.Exceptions}\r\n  MyException1\r\n  MyException2\r\n  int\r\n  double\r\n  Not_A_Class_But_Still_Displayed"));
4209
        }
4210 4211 4212

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(1516, "https://github.com/dotnet/roslyn/issues/1516")]
C
Cyrus Najmabadi 已提交
4213
        public async Task QuickInfoWithNonStandardSeeAttributesAppear()
4214
        {
C
Cyrus Najmabadi 已提交
4215
            await TestAsync(@"
4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231
class C
{
    /// <summary>
    /// <see cref=""System.String"" />
    /// <see href=""http://microsoft.com"" />
    /// <see langword=""null"" />
    /// <see unsupported-attribute=""cat"" />
    /// </summary>
    void M()
    {
        M$$();
    }
}
",
                Documentation(@"string http://microsoft.com null cat"));
        }
4232 4233 4234

        [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
        [WorkItem(6657, "https://github.com/dotnet/roslyn/issues/6657")]
4235
        public async Task OptionalParameterFromPreviousSubmission()
4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246
        {
            const string workspaceDefinition = @"
<Workspace>
    <Submission Language=""C#"" CommonReferences=""true"">
        void M(int x = 1) { }
    </Submission>
    <Submission Language=""C#"" CommonReferences=""true"">
        M(x$$: 2)
    </Submission>
</Workspace>
";
C
Cyrus Najmabadi 已提交
4247
            using (var workspace = await TestWorkspace.CreateAsync(XElement.Parse(workspaceDefinition), workspaceKind: WorkspaceKind.Interactive))
4248
            {
4249
                await TestWithOptionsAsync(workspace, MainDescription("(parameter) int x = 1"));
4250 4251
            }
        }
4252
    }
C
Cyrus Najmabadi 已提交
4253
}