PageRenderTime 974ms CodeModel.GetById 10ms app.highlight 826ms RepoModel.GetById 3ms app.codeStats 7ms

/Src/Compilers/CSharp/Test/Symbol/Compilation/SemanticModelGetSemanticInfoTests.cs

https://github.com/EkardNT/Roslyn
C# | 14316 lines | 12454 code | 1797 blank | 65 comment | 2 complexity | b50c7b40e0c17e90b05a8fb0ebd9f65c MD5 | raw file
    1// Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
    2
    3using System;
    4using System.Collections.Immutable;
    5using System.Linq;
    6using Microsoft.CodeAnalysis.CSharp.Symbols;
    7using Microsoft.CodeAnalysis.CSharp.Syntax;
    8using Microsoft.CodeAnalysis.Text;
    9using Roslyn.Test.Utilities;
   10using Xunit;
   11
   12// Note: the easiest way to create new unit tests that use GetSemanticInfo
   13// is to use the SemanticInfo unit test generate in Editor Test App. 
   14
   15namespace Microsoft.CodeAnalysis.CSharp.UnitTests
   16{
   17    using Utils = CompilationUtils;
   18    using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
   19
   20    public class GetExtendedSemanticInfoTests : SemanticModelTestBase
   21    {
   22        [Fact]
   23        public void FailedOverloadResolution()
   24        {
   25            string sourceCode = @"
   26class Program
   27{
   28    static void Main(string[] args)
   29    {
   30        int i = 8;
   31        int j = i + q;
   32        /*<bind>*/X.f/*</bind>*/(""hello"");
   33    }
   34}
   35
   36class X
   37{
   38    public static void f() { }
   39    public static void f(int i) { }
   40}
   41";
   42            var semanticInfo = GetSemanticInfoForTest(sourceCode);
   43
   44            Assert.Null(semanticInfo.Type);
   45            Assert.Null(semanticInfo.ConvertedType);
   46            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
   47
   48            Assert.Null(semanticInfo.Symbol);
   49            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
   50            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
   51            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
   52            Assert.Equal("void X.f()", sortedCandidates[0].ToTestDisplayString());
   53            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
   54            Assert.Equal("void X.f(System.Int32 i)", sortedCandidates[1].ToTestDisplayString());
   55            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
   56
   57            Assert.Equal(2, semanticInfo.MethodGroup.Length);
   58            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
   59            Assert.Equal("void X.f()", sortedMethodGroup[0].ToTestDisplayString());
   60            Assert.Equal("void X.f(System.Int32 i)", sortedMethodGroup[1].ToTestDisplayString());
   61
   62            Assert.False(semanticInfo.IsCompileTimeConstant);
   63        }
   64
   65        [Fact]
   66        public void SimpleGenericType()
   67        {
   68            string sourceCode = @"
   69using System;
   70
   71class Program
   72{
   73    /*<bind>*/K<int>/*</bind>*/ f;
   74}
   75
   76class K<T>
   77{ }
   78";
   79            var semanticInfo = GetSemanticInfoForTest(sourceCode);
   80
   81            Assert.Equal("K<System.Int32>", semanticInfo.Type.ToTestDisplayString());
   82            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
   83            Assert.Equal("K<System.Int32>", semanticInfo.ConvertedType.ToTestDisplayString());
   84            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
   85            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
   86
   87            Assert.Equal("K<System.Int32>", semanticInfo.Symbol.ToTestDisplayString());
   88            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
   89            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
   90
   91            Assert.Equal(0, semanticInfo.MethodGroup.Length);
   92
   93            Assert.False(semanticInfo.IsCompileTimeConstant);
   94        }
   95
   96        [Fact]
   97        public void WrongArity1()
   98        {
   99            string sourceCode = @"
  100using System;
  101
  102class Program
  103{
  104    /*<bind>*/K<int, string>/*</bind>*/ f;
  105}
  106
  107class K<T>
  108{ }
  109";
  110            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  111
  112            Assert.Equal("K<T>", semanticInfo.Type.ToTestDisplayString());
  113            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  114            Assert.Equal("K<T>", semanticInfo.ConvertedType.ToTestDisplayString());
  115            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  116            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  117
  118            Assert.Null(semanticInfo.Symbol);
  119            Assert.Equal(CandidateReason.WrongArity, semanticInfo.CandidateReason);
  120            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  121            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  122            Assert.Equal("K<T>", sortedCandidates[0].ToTestDisplayString());
  123            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  124
  125            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  126
  127            Assert.False(semanticInfo.IsCompileTimeConstant);
  128        }
  129
  130        [Fact]
  131        public void WrongArity2()
  132        {
  133            string sourceCode = @"
  134using System;
  135
  136class Program
  137{
  138    /*<bind>*/K/*</bind>*/ f;
  139}
  140
  141class K<T>
  142{ }
  143";
  144            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  145
  146            Assert.Equal("K<T>", semanticInfo.Type.ToTestDisplayString());
  147            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  148            Assert.Equal("K<T>", semanticInfo.ConvertedType.ToTestDisplayString());
  149            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  150            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  151
  152            Assert.Null(semanticInfo.Symbol);
  153            Assert.Equal(CandidateReason.WrongArity, semanticInfo.CandidateReason);
  154            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  155            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  156            Assert.Equal("K<T>", sortedCandidates[0].ToTestDisplayString());
  157            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  158
  159            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  160
  161            Assert.False(semanticInfo.IsCompileTimeConstant);
  162        }
  163
  164        [Fact]
  165        public void WrongArity3()
  166        {
  167            string sourceCode = @"
  168using System;
  169
  170class Program
  171{
  172    static void Main()
  173    {
  174        /*<bind>*/K<int, int>/*</bind>*/.f();
  175    }
  176
  177}
  178
  179class K<T>
  180{
  181    void f() { }
  182}
  183
  184";
  185            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  186
  187            Assert.Equal("K<T>", semanticInfo.Type.ToTestDisplayString());
  188            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  189            Assert.Equal("K<T>", semanticInfo.ConvertedType.ToTestDisplayString());
  190            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  191            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  192
  193            Assert.Null(semanticInfo.Symbol);
  194            Assert.Equal(CandidateReason.WrongArity, semanticInfo.CandidateReason);
  195            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  196            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  197            Assert.Equal("K<T>", sortedCandidates[0].ToTestDisplayString());
  198            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  199
  200            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  201
  202            Assert.False(semanticInfo.IsCompileTimeConstant);
  203        }
  204
  205        [Fact]
  206        public void WrongArity4()
  207        {
  208            string sourceCode = @"
  209
  210using System;
  211
  212class Program
  213{
  214    static K Main()
  215    {
  216        /*<bind>*/K/*</bind>*/.f();
  217    }
  218
  219}
  220
  221class K<T>
  222{
  223    void f() { }
  224}
  225";
  226            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  227
  228            Assert.Equal("K<T>", semanticInfo.Type.ToTestDisplayString());
  229            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  230            Assert.Equal("K<T>", semanticInfo.ConvertedType.ToTestDisplayString());
  231            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  232            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  233
  234            Assert.Null(semanticInfo.Symbol);
  235            Assert.Equal(CandidateReason.WrongArity, semanticInfo.CandidateReason);
  236            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  237            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  238            Assert.Equal("K<T>", sortedCandidates[0].ToTestDisplayString());
  239            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  240
  241            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  242
  243            Assert.False(semanticInfo.IsCompileTimeConstant);
  244        }
  245
  246        [Fact]
  247        public void NotInvocable()
  248        {
  249            string sourceCode = @"
  250using System;
  251
  252class Program
  253{
  254    static void Main()
  255    {
  256        K./*<bind>*/f/*</bind>*/();
  257    }
  258
  259}
  260
  261class K
  262{
  263    public int f;
  264}
  265";
  266            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  267
  268            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
  269            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
  270            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
  271            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
  272            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  273
  274            Assert.Null(semanticInfo.Symbol);
  275            Assert.Equal(CandidateReason.NotInvocable, semanticInfo.CandidateReason);
  276            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  277            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  278            Assert.Equal("System.Int32 K.f", sortedCandidates[0].ToTestDisplayString());
  279            Assert.Equal(SymbolKind.Field, sortedCandidates[0].Kind);
  280
  281            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  282
  283            Assert.False(semanticInfo.IsCompileTimeConstant);
  284        }
  285
  286        [Fact]
  287        public void InaccessibleField()
  288        {
  289            string sourceCode = @"
  290class Program
  291{
  292    static void Main()
  293    {
  294        K./*<bind>*/f/*</bind>*/ = 3;
  295    }
  296}
  297
  298class K
  299{
  300    private int f;
  301}
  302";
  303            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  304
  305            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
  306            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
  307            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
  308            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
  309            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  310
  311            Assert.Null(semanticInfo.Symbol);
  312            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
  313            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  314            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  315            Assert.Equal("System.Int32 K.f", sortedCandidates[0].ToTestDisplayString());
  316            Assert.Equal(SymbolKind.Field, sortedCandidates[0].Kind);
  317
  318            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  319
  320            Assert.False(semanticInfo.IsCompileTimeConstant);
  321        }
  322
  323        [Fact]
  324        public void InaccessibleFieldAssignment()
  325        {
  326            string sourceCode =
  327@"class A
  328{
  329    string F;
  330}
  331class B
  332{
  333    static void M(A a)
  334    {
  335        /*<bind>*/a.F/*</bind>*/ = string.Empty;
  336    }
  337}";
  338            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  339            Assert.Equal(SpecialType.System_String, semanticInfo.Type.SpecialType);
  340            var symbol = semanticInfo.Symbol;
  341            Assert.Null(symbol);
  342            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
  343            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  344            symbol = semanticInfo.CandidateSymbols[0];
  345            Assert.Equal("System.String A.F", symbol.ToTestDisplayString());
  346            Assert.Equal(SymbolKind.Field, symbol.Kind);
  347        }
  348
  349        [WorkItem(542481, "DevDiv")]
  350        [Fact]
  351        public void InaccessibleBaseClassConstructor01()
  352        {
  353            string sourceCode = @"
  354namespace Test
  355{
  356    public class Base
  357    {
  358        protected Base() { }
  359    }
  360
  361    public class Derived : Base
  362    {
  363        void M()
  364        {
  365            Base b = /*<bind>*/new Base()/*</bind>*/;
  366        }
  367    }
  368}";
  369            var semanticInfo = GetSemanticInfoForTest<ObjectCreationExpressionSyntax>(sourceCode);
  370
  371            Assert.Null(semanticInfo.Symbol);
  372            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
  373            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  374            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  375            Assert.Equal("Test.Base..ctor()", sortedCandidates[0].ToTestDisplayString());
  376            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
  377        }
  378
  379        [WorkItem(542481, "DevDiv")]
  380        [Fact]
  381        public void InaccessibleBaseClassConstructor02()
  382        {
  383            string sourceCode = @"
  384namespace Test
  385{
  386    public class Base
  387    {
  388        protected Base() { }
  389    }
  390
  391    public class Derived : Base
  392    {
  393        void M()
  394        {
  395            Base b = new /*<bind>*/Base/*</bind>*/();
  396        }
  397    }
  398}";
  399            var semanticInfo = GetSemanticInfoForTest<NameSyntax>(sourceCode);
  400
  401            Assert.Null(semanticInfo.Type);
  402            Assert.Null(semanticInfo.ConvertedType);
  403
  404            Assert.Equal("Test.Base", semanticInfo.Symbol.ToTestDisplayString());
  405            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
  406            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
  407            Assert.Equal(0, semanticInfo.MemberGroup.Length);
  408        }
  409
  410        [Fact]
  411        public void InaccessibleFieldMethodArg()
  412        {
  413            string sourceCode =
  414@"class A
  415{
  416    string F;
  417}
  418class B
  419{
  420    static void M(A a)
  421    {
  422        M(/*<bind>*/a.F/*</bind>*/);
  423    }
  424    static void M(string s) { }
  425}";
  426            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  427            Assert.Equal(SpecialType.System_String, semanticInfo.Type.SpecialType);
  428            var symbol = semanticInfo.Symbol;
  429            Assert.Null(symbol);
  430            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
  431            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  432            symbol = semanticInfo.CandidateSymbols[0];
  433            Assert.Equal("System.String A.F", symbol.ToTestDisplayString());
  434            Assert.Equal(SymbolKind.Field, symbol.Kind);
  435        }
  436
  437        [Fact]
  438        public void TypeNotAVariable()
  439        {
  440            string sourceCode = @"
  441using System;
  442
  443class Program
  444{
  445    static void Main()
  446    {
  447        /*<bind>*/K/*</bind>*/ = 12;
  448    }
  449
  450}
  451
  452class K
  453{
  454}
  455";
  456            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  457
  458            Assert.Equal("K", semanticInfo.Type.ToTestDisplayString());
  459            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  460            Assert.Equal("K", semanticInfo.ConvertedType.ToTestDisplayString());
  461            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  462            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  463
  464            Assert.Null(semanticInfo.Symbol);
  465            Assert.Equal(CandidateReason.NotAVariable, semanticInfo.CandidateReason);
  466            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  467            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  468            Assert.Equal("K", sortedCandidates[0].ToTestDisplayString());
  469            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  470
  471            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  472
  473            Assert.False(semanticInfo.IsCompileTimeConstant);
  474        }
  475
  476        [Fact]
  477        public void InaccessibleType1()
  478        {
  479            string sourceCode = @"
  480using System;
  481
  482class Program
  483{
  484    static void Main()
  485    {
  486        /*<bind>*/K.J/*</bind>*/ = v;
  487    }
  488
  489}
  490
  491class K
  492{
  493    protected class J { }
  494}
  495";
  496            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  497
  498            Assert.Equal("?", semanticInfo.Type.ToTestDisplayString());
  499            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
  500            Assert.Equal("?", semanticInfo.ConvertedType.ToTestDisplayString());
  501            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
  502            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  503
  504            Assert.Null(semanticInfo.Symbol);
  505            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
  506            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  507            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  508            Assert.Equal("K.J", sortedCandidates[0].ToTestDisplayString());
  509            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  510
  511            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  512
  513            Assert.False(semanticInfo.IsCompileTimeConstant);
  514        }
  515
  516        [Fact]
  517        public void AmbiguousTypesBetweenUsings1()
  518        {
  519            string sourceCode = @"
  520using System;
  521using N1;
  522using N2;
  523
  524class Program
  525{
  526    /*<bind>*/A/*</bind>*/ field;
  527}
  528
  529namespace N1
  530{
  531    class A { }
  532}
  533
  534namespace N2
  535{
  536    class A { }
  537}
  538";
  539            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  540
  541            Assert.Equal("N1.A", semanticInfo.Type.ToTestDisplayString());
  542            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
  543            Assert.Equal("N1.A", semanticInfo.ConvertedType.ToTestDisplayString());
  544            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
  545            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  546
  547            Assert.Null(semanticInfo.Symbol);
  548            Assert.Equal(CandidateReason.Ambiguous, semanticInfo.CandidateReason);
  549            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
  550            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  551            Assert.Equal("N1.A", sortedCandidates[0].ToTestDisplayString());
  552            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  553            Assert.Equal("N2.A", sortedCandidates[1].ToTestDisplayString());
  554            Assert.Equal(SymbolKind.NamedType, sortedCandidates[1].Kind);
  555
  556            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  557
  558            Assert.False(semanticInfo.IsCompileTimeConstant);
  559        }
  560
  561        [Fact]
  562        public void AmbiguousTypesBetweenUsings2()
  563        {
  564            string sourceCode = @"
  565using System;
  566using N1;
  567using N2;
  568
  569class Program
  570{
  571    void f()
  572    {
  573        /*<bind>*/A/*</bind>*/.g();
  574    }
  575}
  576
  577namespace N1
  578{
  579    class A { }
  580}
  581
  582namespace N2
  583{
  584    class A { }
  585}
  586";
  587            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  588
  589            Assert.Equal("N1.A", semanticInfo.Type.ToTestDisplayString());
  590            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
  591            Assert.Equal("N1.A", semanticInfo.ConvertedType.ToTestDisplayString());
  592            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
  593            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  594
  595            Assert.Null(semanticInfo.Symbol);
  596            Assert.Equal(CandidateReason.Ambiguous, semanticInfo.CandidateReason);
  597            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
  598            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  599            Assert.Equal("N1.A", sortedCandidates[0].ToTestDisplayString());
  600            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  601            Assert.Equal("N2.A", sortedCandidates[1].ToTestDisplayString());
  602            Assert.Equal(SymbolKind.NamedType, sortedCandidates[1].Kind);
  603
  604            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  605
  606            Assert.False(semanticInfo.IsCompileTimeConstant);
  607        }
  608
  609        [Fact]
  610        public void AmbiguousTypesBetweenUsings3()
  611        {
  612            string sourceCode = @"
  613using System;
  614using N1;
  615using N2;
  616
  617class Program
  618{
  619    void f()
  620    {
  621        /*<bind>*/A<int>/*</bind>*/.g();
  622    }
  623}
  624
  625namespace N1
  626{
  627    class A<T> { }
  628}
  629
  630namespace N2
  631{
  632    class A<U> { }
  633}
  634";
  635            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  636
  637            Assert.Equal("N1.A<System.Int32>", semanticInfo.Type.ToTestDisplayString());
  638            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
  639            Assert.Equal("N1.A<System.Int32>", semanticInfo.ConvertedType.ToTestDisplayString());
  640            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
  641            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  642
  643            Assert.Null(semanticInfo.Symbol);
  644            Assert.Equal(CandidateReason.Ambiguous, semanticInfo.CandidateReason);
  645            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
  646            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  647            Assert.Equal("N1.A<T>", sortedCandidates[0].ToTestDisplayString());
  648            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
  649            Assert.Equal("N2.A<U>", sortedCandidates[1].ToTestDisplayString());
  650            Assert.Equal(SymbolKind.NamedType, sortedCandidates[1].Kind);
  651
  652            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  653
  654            Assert.False(semanticInfo.IsCompileTimeConstant);
  655        }
  656
  657        [Fact]
  658        public void AmbiguityBetweenInterfaceMembers()
  659        {
  660            string sourceCode = @"
  661using System;
  662using System.Collections.Generic;
  663using System.Linq;
  664using System.Text;
  665
  666interface I1
  667{
  668    public int P { get; }
  669}
  670
  671interface I2
  672{
  673    public string P { get; }
  674}
  675
  676interface I3 : I1, I2
  677{ }
  678
  679public class Class1
  680{
  681    void f()
  682    {
  683        I3 x = null;
  684        int o = x./*<bind>*/P/*</bind>*/;
  685    }
  686}
  687";
  688            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  689
  690            Assert.Equal("I1.P", semanticInfo.Type.ToTestDisplayString());
  691            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
  692            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
  693            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
  694            Assert.Equal(ConversionKind.NoConversion, semanticInfo.ImplicitConversion.Kind);
  695
  696            Assert.Null(semanticInfo.Symbol);
  697            Assert.Equal(CandidateReason.Ambiguous, semanticInfo.CandidateReason);
  698            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
  699            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  700            Assert.Equal("System.Int32 I1.P { get; }", sortedCandidates[0].ToTestDisplayString());
  701            Assert.Equal(SymbolKind.Property, sortedCandidates[0].Kind);
  702            Assert.Equal("System.String I2.P { get; }", sortedCandidates[1].ToTestDisplayString());
  703            Assert.Equal(SymbolKind.Property, sortedCandidates[1].Kind);
  704
  705            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  706
  707            Assert.False(semanticInfo.IsCompileTimeConstant);
  708        }
  709
  710        [Fact]
  711        public void Alias1()
  712        {
  713            string sourceCode = @"
  714using O = System.Object;
  715
  716partial class A : /*<bind>*/O/*</bind>*/ {}
  717
  718";
  719            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  720
  721            Assert.Equal("System.Object", semanticInfo.Type.ToTestDisplayString());
  722            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  723            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
  724            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  725            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  726
  727            Assert.NotNull(semanticInfo.Symbol);
  728            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
  729
  730            var aliasInfo = GetAliasInfoForTest(sourceCode);
  731            Assert.NotNull(aliasInfo);
  732            Assert.Equal("O=System.Object", aliasInfo.ToTestDisplayString());
  733            Assert.Equal(SymbolKind.Alias, aliasInfo.Kind);
  734
  735            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  736
  737            Assert.False(semanticInfo.IsCompileTimeConstant);
  738        }
  739
  740        [Fact]
  741        public void Alias2()
  742        {
  743            string sourceCode = @"
  744using O = System.Object;
  745
  746partial class A {
  747    void f()
  748    {
  749        /*<bind>*/O/*</bind>*/.ReferenceEquals(null, null);
  750    }
  751}
  752
  753";
  754            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  755            var aliasInfo = GetAliasInfoForTest(sourceCode);
  756
  757            Assert.Equal("System.Object", semanticInfo.Type.ToTestDisplayString());
  758            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
  759            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
  760            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
  761            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  762
  763            Assert.NotNull(semanticInfo.Symbol);
  764            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
  765
  766            Assert.Equal("O=System.Object", aliasInfo.ToTestDisplayString());
  767            Assert.Equal(SymbolKind.Alias, aliasInfo.Kind);
  768
  769            Assert.Equal(0, semanticInfo.MethodGroup.Length);
  770
  771            Assert.False(semanticInfo.IsCompileTimeConstant);
  772        }
  773
  774        [WorkItem(539002, "DevDiv")]
  775        [Fact]
  776        public void IncompleteGenericMethodCall()
  777        {
  778            string sourceCode = @"
  779class Array
  780{
  781  public static void Find<T>(T t) { }
  782}
  783class C
  784{
  785  static void Main()
  786  {
  787    /*<bind>*/Array.Find<int>/*</bind>*/(
  788  }
  789}
  790";
  791            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  792
  793            Assert.Null(semanticInfo.Type);
  794            Assert.Null(semanticInfo.ConvertedType);
  795            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
  796
  797            Assert.Null(semanticInfo.Symbol);
  798            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
  799            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
  800            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
  801            Assert.Equal("void Array.Find<System.Int32>(System.Int32 t)", sortedCandidates[0].ToTestDisplayString());
  802            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
  803
  804            Assert.Equal(1, semanticInfo.MethodGroup.Length);
  805            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
  806            Assert.Equal("void Array.Find<System.Int32>(System.Int32 t)", sortedMethodGroup[0].ToTestDisplayString());
  807
  808            Assert.False(semanticInfo.IsCompileTimeConstant);
  809        }
  810
  811        [Fact]
  812        public void IncompleteExtensionMethodCall()
  813        {
  814            string sourceCode =
  815@"interface I<T> { }
  816class A { }
  817class B : A { }
  818class C
  819{
  820    static void M(A a)
  821    {
  822        /*<bind>*/a.M/*</bind>*/(
  823    }
  824}
  825static class S
  826{
  827    internal static void M(this object o, int x) { }
  828    internal static void M(this A a, int x, int y) { }
  829    internal static void M(this B b) { }
  830    internal static void M(this string s) { }
  831    internal static void M<T>(this T t, object o) { }
  832    internal static void M<T>(this T[] t) { }
  833    internal static void M<T, U>(this T x, I<T> y, U z) { }
  834}";
  835            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  836            Assert.Null(semanticInfo.Symbol);
  837            Utils.CheckSymbols(semanticInfo.MethodGroup,
  838                "void object.M(int x)",
  839                "void A.M(int x, int y)",
  840                "void A.M<A>(object o)",
  841                "void A.M<A, U>(I<A> y, U z)");
  842            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
  843                "void object.M(int x)",
  844                "void A.M(int x, int y)",
  845                "void A.M<A>(object o)",
  846                "void A.M<A, U>(I<A> y, U z)");
  847            Utils.CheckReducedExtensionMethod((MethodSymbol)semanticInfo.MethodGroup[3],
  848                "void A.M<A, U>(I<A> y, U z)",
  849                "void S.M<T, U>(T x, I<T> y, U z)",
  850                "void T.M<T, U>(I<T> y, U z)",
  851                "void S.M<T, U>(T x, I<T> y, U z)");
  852        }
  853
  854        [Fact]
  855        public void IncompleteExtensionMethodCallBadThisType()
  856        {
  857            string sourceCode =
  858@"interface I<T> { }
  859class B
  860{
  861    static void M(I<A> a)
  862    {
  863        /*<bind>*/a.M/*</bind>*/(
  864    }
  865}
  866static class S
  867{
  868    internal static void M(this object o) { }
  869    internal static void M<T>(this T t, object o) { }
  870    internal static void M<T>(this T[] t) { }
  871    internal static void M<T, U>(this I<T> x, I<T> y, U z) { }
  872}";
  873            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  874            Utils.CheckSymbols(semanticInfo.MethodGroup,
  875                "void object.M()",
  876                "void I<A>.M<I<A>>(object o)",
  877                "void I<A>.M<A, U>(I<A> y, U z)");
  878        }
  879
  880        [WorkItem(541141, "DevDiv")]
  881        [Fact]
  882        public void IncompleteGenericExtensionMethodCall()
  883        {
  884            string sourceCode =
  885@"using System.Linq;
  886class C
  887{
  888    static void M(double[] a)
  889    {
  890        /*<bind>*/a.Where/*</bind>*/(
  891    }
  892}";
  893            var compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
  894            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
  895            Utils.CheckSymbols(semanticInfo.MethodGroup,
  896                "IEnumerable<double> IEnumerable<double>.Where<double>(Func<double, bool> predicate)",
  897                "IEnumerable<double> IEnumerable<double>.Where<double>(Func<double, int, bool> predicate)");
  898        }
  899
  900        [WorkItem(541349, "DevDiv")]
  901        [Fact]
  902        public void GenericExtensionMethodCallExplicitTypeArgs()
  903        {
  904            string sourceCode =
  905@"interface I<T> { }
  906class C
  907{
  908    static void M(object o)
  909    {
  910        /*<bind>*/o.E<int>/*</bind>*/();
  911    }
  912}
  913static class S
  914{
  915    internal static void E(this object x, object y) { }
  916    internal static void E<T>(this object o) { }
  917    internal static void E<T>(this object o, T t) { }
  918    internal static void E<T>(this I<T> t) { }
  919    internal static void E<T, U>(this I<T> t) { }
  920}";
  921            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  922            Utils.CheckSymbol(semanticInfo.Symbol,
  923                "void object.E<int>()");
  924            Utils.CheckSymbols(semanticInfo.MethodGroup,
  925                "void object.E<int>()",
  926                "void object.E<int>(int t)");
  927            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
  928        }
  929
  930        [Fact]
  931        public void GenericExtensionMethodCallExplicitTypeArgsOfT()
  932        {
  933            string sourceCode =
  934@"interface I<T> { }
  935class C
  936{
  937    static void M<T, U>(T t, U u)
  938    {
  939        /*<bind>*/t.E<T, U>/*</bind>*/(u);
  940    }
  941}
  942static class S
  943{
  944    internal static void E(this object x, object y) { }
  945    internal static void E<T>(this object o) { }
  946    internal static void E<T, U>(this T t, U u) { }
  947    internal static void E<T, U>(this I<T> t, U u) { }
  948}";
  949            var semanticInfo = GetSemanticInfoForTest(sourceCode);
  950            Utils.CheckSymbols(semanticInfo.MethodGroup,
  951                "void T.E<T, U>(U u)");
  952        }
  953
  954        [WorkItem(541297, "DevDiv")]
  955        [Fact]
  956        public void GenericExtensionMethodCall()
  957        {
  958            // Single applicable overload with valid argument.
  959            var semanticInfo = GetSemanticInfoForTest(
  960@"class C
  961{
  962    static void M(string s)
  963    {
  964        /*<bind>*/s.E(s)/*</bind>*/;
  965    }
  966}
  967static class S
  968{
  969    internal static void E<T>(this T x, object y) { }
  970    internal static void E<T, U>(this T x, U y) { }
  971}");
  972            Utils.CheckSymbol(semanticInfo.Symbol,
  973                "void string.E<string, string>(string y)");
  974            Utils.CheckSymbols(semanticInfo.MethodGroup);
  975            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
  976
  977            // Multiple applicable overloads with valid arguments.
  978            semanticInfo = GetSemanticInfoForTest(
  979@"class C
  980{
  981    static void M(string s, object o)
  982    {
  983        /*<bind>*/s.E(s, o)/*</bind>*/;
  984    }
  985}
  986static class S
  987{
  988    internal static void E<T>(this object x, T y, object z) { }
  989    internal static void E<T, U>(this T x, object y, U z) { }
  990}");
  991            Assert.Null(semanticInfo.Symbol);
  992            Utils.CheckSymbols(semanticInfo.MethodGroup);
  993            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
  994                "void object.E<string>(string y, object z)",
  995                "void string.E<string, object>(object y, object z)");
  996
  997            // Multiple applicable overloads with error argument.
  998            semanticInfo = GetSemanticInfoForTest(
  999@"class C
 1000{
 1001    static void M(string s)
 1002    {
 1003        /*<bind>*/s.E(t, s)/*</bind>*/;
 1004    }
 1005}
 1006static class S
 1007{
 1008    internal static void E<T>(this T x, T y, object z) { }
 1009    internal static void E<T, U>(this T x, string y, U z) { }
 1010}");
 1011            Assert.Null(semanticInfo.Symbol);
 1012            Utils.CheckSymbols(semanticInfo.MethodGroup);
 1013            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
 1014                "void string.E<string>(string y, object z)",
 1015                "void string.E<string, string>(string y, string z)");
 1016
 1017            // Multiple overloads but all inaccessible.
 1018            semanticInfo = GetSemanticInfoForTest(
 1019@"class C
 1020{
 1021    static void M(string s)
 1022    {
 1023        /*<bind>*/s.E()/*</bind>*/;
 1024    }
 1025}
 1026static class S
 1027{
 1028    static void E(this string x) { }
 1029    static void E<T>(this T x) { }
 1030}");
 1031            Assert.Null(semanticInfo.Symbol);
 1032            Utils.CheckSymbols(semanticInfo.MethodGroup);
 1033            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
 1034                "void string.E()",
 1035                "void string.E<string>()"
 1036                );
 1037        }
 1038
 1039        [Fact]
 1040        public void GenericExtensionDelegateMethod()
 1041        {
 1042            // Single applicable overload.
 1043            var semanticInfo = GetSemanticInfoForTest(
 1044@"class C
 1045{
 1046    static void M(string s)
 1047    {
 1048        System.Action<string> a = /*<bind>*/s.E/*</bind>*/;
 1049    }
 1050}
 1051static class S
 1052{
 1053    internal static void E<T>(this T x, T y) { }
 1054    internal static void E<T>(this object x, T y) { }
 1055}");
 1056            Utils.CheckSymbol(semanticInfo.Symbol,
 1057                "void string.E<string>(string y)");
 1058            Utils.CheckSymbols(semanticInfo.MethodGroup,
 1059                "void string.E<string>(string y)",
 1060                "void object.E<T>(T y)");
 1061            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1062
 1063            // Multiple applicable overloads.
 1064            semanticInfo = GetSemanticInfoForTest(
 1065@"class C
 1066{
 1067    static void M(string s)
 1068    {
 1069        System.Action<string> a = /*<bind>*/s.E/*</bind>*/;
 1070    }
 1071}
 1072static class S
 1073{
 1074    internal static void E<T>(this T x, T y) { }
 1075    internal static void E<T, U>(this T x, U y) { }
 1076}");
 1077            Assert.Null(semanticInfo.Symbol);
 1078            Utils.CheckSymbols(semanticInfo.MethodGroup,
 1079                "void string.E<string>(string y)",
 1080                "void string.E<string, U>(U y)");
 1081            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
 1082                "void string.E<string>(string y)",
 1083                "void string.E<string, U>(U y)");
 1084        }
 1085
 1086        /// <summary>
 1087        /// Overloads from different scopes should
 1088        /// be included in method group.
 1089        /// </summary>
 1090        [WorkItem(541890, "DevDiv")]
 1091        [Fact]
 1092        public void IncompleteExtensionOverloadedDifferentScopes()
 1093        {
 1094            // Instance methods and extension method (implicit instance).
 1095            var sourceCode =
 1096@"class C
 1097{
 1098    void M()
 1099    {
 1100        /*<bind>*/F/*</bind>*/(
 1101    }
 1102    void F(int x) { }
 1103    void F(object x, object y) { }
 1104}
 1105static class E
 1106{
 1107    internal static void F(this object x, object y) { }
 1108}";
 1109            var compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1110            var type = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
 1111            var tree = compilation.SyntaxTrees[0];
 1112            var model = compilation.GetSemanticModel(tree);
 1113            var expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1114            var symbols = model.GetMemberGroup(expr);
 1115            Utils.CheckSymbols(symbols,
 1116                "void C.F(int x)",
 1117                "void C.F(object x, object y)");
 1118            symbols = model.LookupSymbols(expr.SpanStart, container: null, name: "F", includeReducedExtensionMethods: true);
 1119            Utils.CheckSymbols(symbols,
 1120                "void C.F(int x)",
 1121                "void C.F(object x, object y)");
 1122            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1123            Utils.CheckSymbols(symbols,
 1124                "void C.F(int x)",
 1125                "void C.F(object x, object y)",
 1126                "void object.F(object y)");
 1127
 1128            // Instance methods and extension method (explicit instance).
 1129            sourceCode =
 1130@"class C
 1131{
 1132    void M()
 1133    {
 1134        /*<bind>*/this.F/*</bind>*/(
 1135    }
 1136    void F(int x) { }
 1137    void F(object x, object y) { }
 1138}
 1139static class E
 1140{
 1141    internal static void F(this object x, object y) { }
 1142}";
 1143            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1144            type = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
 1145            tree = compilation.SyntaxTrees[0];
 1146            model = compilation.GetSemanticModel(tree);
 1147            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1148            symbols = model.GetMemberGroup(expr);
 1149            Utils.CheckSymbols(symbols,
 1150                "void C.F(int x)",
 1151                "void C.F(object x, object y)",
 1152                "void object.F(object y)");
 1153            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1154            Utils.CheckSymbols(symbols,
 1155                "void C.F(int x)",
 1156                "void C.F(object x, object y)",
 1157                "void object.F(object y)");
 1158
 1159            // Applicable instance method and inapplicable extension method.
 1160            sourceCode =
 1161@"class C
 1162{
 1163    void M()
 1164    {
 1165        /*<bind>*/this.F<string>/*</bind>*/(
 1166    }
 1167    void F<T>(T t) { }
 1168}
 1169static class E
 1170{
 1171    internal static void F(this object x) { }
 1172}";
 1173            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1174            type = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
 1175            tree = compilation.SyntaxTrees[0];
 1176            model = compilation.GetSemanticModel(tree);
 1177            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1178            symbols = model.GetMemberGroup(expr);
 1179            Utils.CheckSymbols(symbols,
 1180                "void C.F<string>(string t)");
 1181            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1182            Utils.CheckSymbols(symbols,
 1183                "void C.F<T>(T t)",
 1184                "void object.F()");
 1185
 1186            // Inaccessible instance method and accessible extension method.
 1187            sourceCode =
 1188@"class A
 1189{
 1190    void F() { }
 1191}
 1192class B : A
 1193{
 1194    static void M(A a)
 1195    {
 1196        /*<bind>*/a.F/*</bind>*/(
 1197    }
 1198}
 1199static class E
 1200{
 1201    internal static void F(this object x) { }
 1202}";
 1203            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1204            type = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("A");
 1205            tree = compilation.SyntaxTrees[0];
 1206            model = compilation.GetSemanticModel(tree);
 1207            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1208            symbols = model.GetMemberGroup(expr);
 1209            Utils.CheckSymbols(symbols,
 1210                "void object.F()");
 1211            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1212            Utils.CheckSymbols(symbols,
 1213                "void object.F()");
 1214
 1215            // Inapplicable instance method and applicable extension method.
 1216            sourceCode =
 1217@"class C
 1218{
 1219    void M()
 1220    {
 1221        /*<bind>*/this.F<string>/*</bind>*/(
 1222    }
 1223    void F(object o) { }
 1224}
 1225static class E
 1226{
 1227    internal static void F<T>(this object x) { }
 1228}";
 1229            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1230            type = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
 1231            tree = compilation.SyntaxTrees[0];
 1232            model = compilation.GetSemanticModel(tree);
 1233            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1234            symbols = model.GetMemberGroup(expr);
 1235            Utils.CheckSymbols(symbols,
 1236                "void object.F<string>()");
 1237            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1238            Utils.CheckSymbols(symbols,
 1239                "void C.F(object o)",
 1240                "void object.F<T>()");
 1241
 1242            // Viable instance and extension methods, binding to extension method.
 1243            sourceCode =
 1244@"class C
 1245{
 1246    void M()
 1247    {
 1248        /*<bind>*/this.F/*</bind>*/();
 1249    }
 1250    void F(object o) { }
 1251}
 1252static class E
 1253{
 1254    internal static void F(this object x) { }
 1255}";
 1256            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1257            type = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
 1258            tree = compilation.SyntaxTrees[0];
 1259            model = compilation.GetSemanticModel(tree);
 1260            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1261            symbols = model.GetMemberGroup(expr);
 1262            Utils.CheckSymbols(symbols,
 1263                "void C.F(object o)",
 1264                "void object.F()");
 1265            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1266            Utils.CheckSymbols(symbols,
 1267                "void C.F(object o)",
 1268                "void object.F()");
 1269
 1270            // Applicable and inaccessible extension methods.
 1271            sourceCode =
 1272@"class C
 1273{
 1274    void M(string s)
 1275    {
 1276        /*<bind>*/s.F<string>/*</bind>*/(
 1277    }
 1278}
 1279static class E
 1280{
 1281    internal static void F(this object x, object y) { }
 1282    internal static void F<T>(this T t) { }
 1283}";
 1284            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1285            type = compilation.GetSpecialType(SpecialType.System_String);
 1286            tree = compilation.SyntaxTrees[0];
 1287            model = compilation.GetSemanticModel(tree);
 1288            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1289            symbols = model.GetMemberGroup(expr);
 1290            Utils.CheckSymbols(symbols,
 1291                "void string.F<string>()");
 1292            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1293            Utils.CheckSymbols(symbols,
 1294                "void object.F(object y)",
 1295                "void string.F<string>()");
 1296
 1297            // Inapplicable and inaccessible extension methods.
 1298            sourceCode =
 1299@"class C
 1300{
 1301    void M(string s)
 1302    {
 1303        /*<bind>*/s.F<string>/*</bind>*/(
 1304    }
 1305}
 1306static class E
 1307{
 1308    internal static void F(this object x, object y) { }
 1309    private static void F<T>(this T t) { }
 1310}";
 1311            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1312            type = compilation.GetSpecialType(SpecialType.System_String);
 1313            tree = compilation.SyntaxTrees[0];
 1314            model = compilation.GetSemanticModel(tree);
 1315            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1316            symbols = model.GetMemberGroup(expr);
 1317            Utils.CheckSymbols(symbols,
 1318                "void string.F<string>()");
 1319            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1320            Utils.CheckSymbols(symbols,
 1321                "void object.F(object y)");
 1322
 1323            // Multiple scopes.
 1324            sourceCode =
 1325@"namespace N1
 1326{
 1327    static class E
 1328    {
 1329        internal static void F(this object o) { }
 1330    }
 1331}
 1332namespace N2
 1333{
 1334    using N1;
 1335    class C
 1336    {
 1337        static void M(C c)
 1338        {
 1339            /*<bind>*/c.F/*</bind>*/(
 1340        }
 1341        void F(int x) { }
 1342    }
 1343    static class E
 1344    {
 1345        internal static void F(this object x, object y) { }
 1346    }
 1347}
 1348static class E
 1349{
 1350    internal static void F(this object x, object y, object z) { }
 1351}";
 1352            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1353            type = compilation.GlobalNamespace.GetMember<NamespaceSymbol>("N2").GetMember<NamedTypeSymbol>("C");
 1354            tree = compilation.SyntaxTrees[0];
 1355            model = compilation.GetSemanticModel(tree);
 1356            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1357            symbols = model.GetMemberGroup(expr);
 1358            Utils.CheckSymbols(symbols,
 1359                "void C.F(int x)",
 1360                "void object.F(object y)",
 1361                "void object.F()",
 1362                "void object.F(object y, object z)");
 1363            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1364            Utils.CheckSymbols(symbols,
 1365                "void C.F(int x)",
 1366                "void object.F(object y)",
 1367                "void object.F()",
 1368                "void object.F(object y, object z)");
 1369
 1370            // Multiple scopes, no instance methods.
 1371            sourceCode =
 1372@"namespace N
 1373{
 1374    class C
 1375    {
 1376        static void M(C c)
 1377        {
 1378            /*<bind>*/c.F/*</bind>*/(
 1379        }
 1380    }
 1381    static class E
 1382    {
 1383        internal static void F(this object x, object y) { }
 1384    }
 1385}
 1386static class E
 1387{
 1388    internal static void F(this object x, object y, object z) { }
 1389}";
 1390            compilation = CreateCompilationWithMscorlib(references: new MetadataReference[] { SystemCoreRef }, text: sourceCode);
 1391            type = compilation.GlobalNamespace.GetMember<NamespaceSymbol>("N").GetMember<NamedTypeSymbol>("C");
 1392            tree = compilation.SyntaxTrees[0];
 1393            model = compilation.GetSemanticModel(tree);
 1394            expr = GetSyntaxNodeOfTypeForBinding<ExpressionSyntax>(GetSyntaxNodeList(tree));
 1395            symbols = model.GetMemberGroup(expr);
 1396            Utils.CheckSymbols(symbols,
 1397                "void object.F(object y)",
 1398                "void object.F(object y, object z)");
 1399            symbols = model.LookupSymbols(expr.SpanStart, container: type, name: "F", includeReducedExtensionMethods: true);
 1400            Utils.CheckSymbols(symbols,
 1401                "void object.F(object y)",
 1402                "void object.F(object y, object z)");
 1403        }
 1404
 1405        [Fact]
 1406        public void PropertyGroup()
 1407        {
 1408            var source1 =
 1409@"Imports System
 1410Imports System.Runtime.InteropServices
 1411<Assembly: PrimaryInteropAssembly(0, 0)> 
 1412<Assembly: Guid(""165F752D-E9C4-4F7E-B0D0-CDFD7A36E210"")> 
 1413<ComImport()>
 1414<Guid(""165F752D-E9C4-4F7E-B0D0-CDFD7A36E211"")>
 1415Public Class A
 1416    Property P(Optional x As Integer = 0) As Object
 1417        Get
 1418            Return Nothing
 1419        End Get
 1420        Set
 1421        End Set
 1422    End Property
 1423    Property P(x As Integer, y As Integer) As Integer
 1424        Get
 1425            Return Nothing
 1426        End Get
 1427        Set
 1428        End Set
 1429    End Property
 1430    Property P(x As Integer, y As String) As String
 1431        Get
 1432            Return Nothing
 1433        End Get
 1434        Set
 1435        End Set
 1436    End Property
 1437End Class";
 1438            var reference1 = BasicCompilationUtils.CompileToMetadata(source1, verify: false);
 1439
 1440            // Assignment (property group).
 1441            var source2 =
 1442@"class B
 1443{
 1444    static void M(A a)
 1445    {
 1446        /*<bind>*/a.P/*</bind>*/[1, null] = string.Empty;
 1447    }
 1448}";
 1449            var compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1450            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1451            Utils.CheckSymbol(semanticInfo.Symbol, "string A.P[int x, string y]");
 1452            Utils.CheckSymbols(semanticInfo.MemberGroup,
 1453                "object A.P[int x = 0]",
 1454                "int A.P[int x, int y]",
 1455                "string A.P[int x, string y]");
 1456            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1457
 1458            // Assignment (property access).
 1459            source2 =
 1460@"class B
 1461{
 1462    static void M(A a)
 1463    {
 1464        /*<bind>*/a.P[1, null]/*</bind>*/ = string.Empty;
 1465    }
 1466}";
 1467            compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1468            semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1469            Utils.CheckSymbol(semanticInfo.Symbol, "string A.P[int x, string y]");
 1470            Utils.CheckSymbols(semanticInfo.MemberGroup);
 1471            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1472
 1473            // Object initializer.
 1474            source2 =
 1475@"class B
 1476{
 1477    static A F = new A() { /*<bind>*/P/*</bind>*/ = 1 };
 1478}";
 1479            compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1480            semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1481            Utils.CheckSymbol(semanticInfo.Symbol, "object A.P[int x = 0]");
 1482            Utils.CheckSymbols(semanticInfo.MemberGroup);
 1483            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1484
 1485            // Incomplete reference, overload resolution failure (property group).
 1486            source2 =
 1487@"class B
 1488{
 1489    static void M(A a)
 1490    {
 1491        var o = /*<bind>*/a.P/*</bind>*/[1, a
 1492    }
 1493}";
 1494            compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1495            semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1496            Assert.Null(semanticInfo.Symbol);
 1497            Utils.CheckSymbols(semanticInfo.MemberGroup,
 1498                "object A.P[int x = 0]",
 1499                "int A.P[int x, int y]",
 1500                "string A.P[int x, string y]");
 1501            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
 1502                "object A.P[int x = 0]",
 1503                "int A.P[int x, int y]",
 1504                "string A.P[int x, string y]");
 1505
 1506            // Incomplete reference, overload resolution failure (property access).
 1507            source2 =
 1508@"class B
 1509{
 1510    static void M(A a)
 1511    {
 1512        var o = /*<bind>*/a.P[1, a/*</bind>*/
 1513    }
 1514}";
 1515            compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1516            semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1517            Assert.Null(semanticInfo.Symbol);
 1518            Utils.CheckSymbols(semanticInfo.MemberGroup);
 1519            Utils.CheckSymbols(semanticInfo.CandidateSymbols,
 1520                "object A.P[int x = 0]",
 1521                "int A.P[int x, int y]",
 1522                "string A.P[int x, string y]");
 1523        }
 1524
 1525        [Fact]
 1526        public void PropertyGroupOverloadsOverridesHides()
 1527        {
 1528            var source1 =
 1529@"Imports System
 1530Imports System.Runtime.InteropServices
 1531<Assembly: PrimaryInteropAssembly(0, 0)> 
 1532<Assembly: Guid(""165F752D-E9C4-4F7E-B0D0-CDFD7A36E210"")> 
 1533<ComImport()>
 1534<Guid(""165F752D-E9C4-4F7E-B0D0-CDFD7A36E211"")>
 1535Public Class A
 1536    Overridable ReadOnly Property P1(index As Object) As Object
 1537        Get
 1538            Return Nothing
 1539        End Get
 1540    End Property
 1541    ReadOnly Property P2(index As Object) As Object
 1542        Get
 1543            Return Nothing
 1544        End Get
 1545    End Property
 1546    ReadOnly Property P2(x As Object, y As Object) As Object
 1547        Get
 1548            Return Nothing
 1549        End Get
 1550    End Property
 1551    ReadOnly Property P3(index As Object) As Object
 1552        Get
 1553            Return Nothing
 1554        End Get
 1555    End Property
 1556    ReadOnly Property P3(x As Object, y As Object) As Object
 1557        Get
 1558            Return Nothing
 1559        End Get
 1560    End Property
 1561End Class
 1562<ComImport()>
 1563<Guid(""165F752D-E9C4-4F7E-B0D0-CDFD7A36E212"")>
 1564Public Class B
 1565    Inherits A
 1566    Overrides ReadOnly Property P1(index As Object) As Object
 1567        Get
 1568            Return Nothing
 1569        End Get
 1570    End Property
 1571    Shadows ReadOnly Property P2(index As String) As Object
 1572        Get
 1573            Return Nothing
 1574        End Get
 1575    End Property
 1576End Class";
 1577            var reference1 = BasicCompilationUtils.CompileToMetadata(source1, verify: false);
 1578
 1579            // Overridden property.
 1580            var source2 =
 1581@"class C
 1582{
 1583    static object F(B b)
 1584    {
 1585        return /*<bind>*/b.P1/*</bind>*/[null];
 1586    }
 1587}";
 1588            var compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1589            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1590            Utils.CheckSymbol(semanticInfo.Symbol, "object B.P1[object index]");
 1591            Utils.CheckSymbols(semanticInfo.MemberGroup, "object B.P1[object index]");
 1592            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1593
 1594            // Hidden property.
 1595            source2 =
 1596@"class C
 1597{
 1598    static object F(B b)
 1599    {
 1600        return /*<bind>*/b.P2/*</bind>*/[null];
 1601    }
 1602}";
 1603            compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1604            semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1605            Utils.CheckSymbol(semanticInfo.Symbol, "object B.P2[string index]");
 1606            Utils.CheckSymbols(semanticInfo.MemberGroup, "object B.P2[string index]");
 1607            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1608
 1609            // Overloaded property.
 1610            source2 =
 1611@"class C
 1612{
 1613    static object F(B b)
 1614    {
 1615        return /*<bind>*/b.P3/*</bind>*/[null];
 1616    }
 1617}";
 1618            compilation = CreateCompilationWithMscorlib(source2, new[] { reference1 });
 1619            semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(compilation);
 1620            Utils.CheckSymbol(semanticInfo.Symbol, "object A.P3[object index]");
 1621            Utils.CheckSymbols(semanticInfo.MemberGroup, "object A.P3[object index]", "object A.P3[object x, object y]");
 1622            Utils.CheckSymbols(semanticInfo.CandidateSymbols);
 1623        }
 1624
 1625        [WorkItem(538859, "DevDiv")]
 1626        [Fact]
 1627        public void ThisExpression()
 1628        {
 1629            string sourceCode = @"
 1630class C
 1631{
 1632    void M()
 1633    {
 1634        /*<bind>*/this/*</bind>*/.ToString();
 1635    }
 1636}
 1637";
 1638            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1639
 1640            Assert.Equal("C", semanticInfo.Type.ToTestDisplayString());
 1641            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 1642            Assert.Equal("C", semanticInfo.ConvertedType.ToTestDisplayString());
 1643            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 1644            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1645
 1646            Assert.Equal("C @this", semanticInfo.Symbol.ToTestDisplayString());
 1647            Assert.Equal(SymbolKind.Parameter, semanticInfo.Symbol.Kind);
 1648            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1649
 1650            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1651
 1652            Assert.False(semanticInfo.IsCompileTimeConstant);
 1653        }
 1654
 1655        [WorkItem(538143, "DevDiv")]
 1656        [Fact]
 1657        public void GetSemanticInfoOfNull()
 1658        {
 1659            var compilation = CreateCompilationWithMscorlib("");
 1660            var tree = compilation.SyntaxTrees[0];
 1661            var model = compilation.GetSemanticModel(tree);
 1662
 1663            Assert.Throws<ArgumentNullException>(() => model.GetSymbolInfo((ExpressionSyntax)null));
 1664            Assert.Throws<ArgumentNullException>(() => model.GetTypeInfo((ExpressionSyntax)null));
 1665            Assert.Throws<ArgumentNullException>(() => model.GetMemberGroup((ExpressionSyntax)null));
 1666            Assert.Throws<ArgumentNullException>(() => model.GetConstantValue((ExpressionSyntax)null));
 1667
 1668            Assert.Throws<ArgumentNullException>(() => model.GetSymbolInfo((ConstructorInitializerSyntax)null));
 1669            Assert.Throws<ArgumentNullException>(() => model.GetTypeInfo((ConstructorInitializerSyntax)null));
 1670            Assert.Throws<ArgumentNullException>(() => model.GetMemberGroup((ConstructorInitializerSyntax)null));
 1671        }
 1672
 1673        [WorkItem(537860, "DevDiv")]
 1674        [Fact]
 1675        public void UsingNamespaceName()
 1676        {
 1677            string sourceCode = @"
 1678using /*<bind>*/System/*</bind>*/;
 1679
 1680class Test
 1681{
 1682}
 1683";
 1684            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1685
 1686            Assert.Null(semanticInfo.Type);
 1687            Assert.Null(semanticInfo.ConvertedType);
 1688            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1689
 1690            Assert.Equal("System", semanticInfo.Symbol.ToTestDisplayString());
 1691            Assert.Equal(SymbolKind.Namespace, semanticInfo.Symbol.Kind);
 1692            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1693
 1694            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1695
 1696            Assert.False(semanticInfo.IsCompileTimeConstant);
 1697        }
 1698
 1699        [WorkItem(3017, "DevDiv_Projects/Roslyn")]
 1700        [Fact]
 1701        public void VariableUsedInForInit()
 1702        {
 1703            string sourceCode = @"
 1704class Test
 1705{
 1706    void Fill()
 1707    {
 1708        for (int i = 0; /*<bind>*/i/*</bind>*/ < 10 ; i++ )
 1709        {
 1710        }
 1711    }
 1712}
 1713";
 1714            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1715
 1716            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 1717            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 1718            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 1719            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 1720            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1721
 1722            Assert.Equal("System.Int32 i", semanticInfo.Symbol.ToTestDisplayString());
 1723            Assert.Equal(SymbolKind.Local, semanticInfo.Symbol.Kind);
 1724            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1725
 1726            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1727
 1728            Assert.False(semanticInfo.IsCompileTimeConstant);
 1729        }
 1730
 1731        [WorkItem(527269, "DevDiv")]
 1732        [Fact]
 1733        public void NullLiteral()
 1734        {
 1735            string sourceCode = @"
 1736class Test
 1737{
 1738    public static void Main()
 1739    {
 1740        string s = /*<bind>*/null/*</bind>*/;
 1741    }
 1742}
 1743";
 1744            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1745
 1746            Assert.Null(semanticInfo.Type);
 1747            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 1748            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 1749            Assert.Equal(ConversionKind.ImplicitReference, semanticInfo.ImplicitConversion.Kind);
 1750
 1751            Assert.Null(semanticInfo.Symbol);
 1752            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1753
 1754            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1755
 1756            Assert.True(semanticInfo.IsCompileTimeConstant);
 1757            Assert.Equal(null, semanticInfo.ConstantValue.Value);
 1758        }
 1759
 1760        [WorkItem(3019, "DevDiv_Projects/Roslyn")]
 1761        [Fact]
 1762        public void PostfixIncrement()
 1763        {
 1764            string sourceCode = @"
 1765class Test
 1766{
 1767    public static void Main()
 1768    {
 1769        int i = 10;
 1770        /*<bind>*/i++/*</bind>*/;
 1771    }
 1772}
 1773";
 1774            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1775
 1776            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 1777            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 1778            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 1779            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 1780            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1781
 1782            Assert.Equal("System.Int32 System.Int32.op_Increment(System.Int32 value)", semanticInfo.Symbol.ToTestDisplayString());
 1783            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1784
 1785            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1786
 1787            Assert.False(semanticInfo.IsCompileTimeConstant);
 1788        }
 1789
 1790        [WorkItem(3199, "DevDiv_Projects/Roslyn")]
 1791        [Fact]
 1792        public void ConditionalOrExpr()
 1793        {
 1794            string sourceCode = @"
 1795class Program
 1796{
 1797  static void T1()
 1798  {
 1799      bool result = /*<bind>*/true || true/*</bind>*/;
 1800  }
 1801}
 1802";
 1803            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1804
 1805            Assert.Equal("System.Boolean", semanticInfo.Type.ToTestDisplayString());
 1806            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 1807            Assert.Equal("System.Boolean", semanticInfo.ConvertedType.ToTestDisplayString());
 1808            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 1809            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1810
 1811            Assert.Null(semanticInfo.Symbol);
 1812            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1813
 1814            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1815
 1816            Assert.True(semanticInfo.IsCompileTimeConstant);
 1817            Assert.Equal(true, semanticInfo.ConstantValue);
 1818        }
 1819
 1820        [WorkItem(3222, "DevDiv_Projects/Roslyn")]
 1821        [Fact]
 1822        public void ConditionalOperExpr()
 1823        {
 1824            string sourceCode = @"
 1825class Program
 1826{
 1827    static void Main()
 1828    {
 1829        int i = /*<bind>*/(true ? 0 : 1)/*</bind>*/;
 1830    }
 1831}
 1832";
 1833            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1834
 1835            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 1836            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 1837            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 1838            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 1839            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1840
 1841            Assert.Null(semanticInfo.Symbol);
 1842            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1843
 1844            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1845
 1846            Assert.True(semanticInfo.IsCompileTimeConstant);
 1847            Assert.Equal(0, semanticInfo.ConstantValue);
 1848        }
 1849
 1850        [WorkItem(3223, "DevDiv_Projects/Roslyn")]
 1851        [Fact]
 1852        public void DefaultValueExpr()
 1853        {
 1854            string sourceCode = @"
 1855class Test
 1856{
 1857    static void Main(string[] args)
 1858    {
 1859        int s = /*<bind>*/default(int)/*</bind>*/;
 1860    }
 1861}
 1862";
 1863            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1864
 1865            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 1866            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 1867            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 1868            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 1869            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1870
 1871            Assert.Null(semanticInfo.Symbol);
 1872            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1873
 1874            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1875
 1876            Assert.True(semanticInfo.IsCompileTimeConstant);
 1877            Assert.Equal(0, semanticInfo.ConstantValue);
 1878        }
 1879
 1880        [WorkItem(537979, "DevDiv")]
 1881        [Fact]
 1882        public void StringConcatWithInt()
 1883        {
 1884            string sourceCode = @"
 1885public class Test
 1886{
 1887    public static void Main(string[] args)
 1888    {
 1889        string str =  /*<bind>*/""Count value is: "" + 5/*</bind>*/ ;
 1890    }
 1891}
 1892";
 1893            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1894
 1895            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 1896            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 1897            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 1898            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 1899            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1900
 1901            Assert.Equal("System.String System.String.op_Addition(System.String left, System.Object right)", semanticInfo.Symbol.ToTestDisplayString());
 1902            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1903
 1904            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1905
 1906            Assert.False(semanticInfo.IsCompileTimeConstant);
 1907        }
 1908
 1909        [WorkItem(3226, "DevDiv_Projects/Roslyn")]
 1910        [Fact]
 1911        public void StringConcatWithIntAndNullableInt()
 1912        {
 1913            string sourceCode = @"
 1914public class Test
 1915{
 1916    public static void Main(string[] args)
 1917    {
 1918        string str = /*<bind>*/""Count value is: "" + (int?) 10 + 5/*</bind>*/;
 1919    }
 1920}
 1921";
 1922            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1923
 1924            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 1925            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 1926            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 1927            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 1928            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1929
 1930            Assert.Equal("System.String System.String.op_Addition(System.String left, System.Object right)", semanticInfo.Symbol.ToTestDisplayString());
 1931            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1932
 1933            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1934
 1935            Assert.False(semanticInfo.IsCompileTimeConstant);
 1936        }
 1937
 1938        [WorkItem(3234, "DevDiv_Projects/Roslyn")]
 1939        [Fact]
 1940        public void AsOper()
 1941        {
 1942            string sourceCode = @"
 1943public class Test
 1944{
 1945    public static void Main(string[] args)
 1946    {
 1947        object o = null;
 1948        string str = /*<bind>*/o as string/*</bind>*/;
 1949    }
 1950}
 1951";
 1952            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1953
 1954            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 1955            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 1956            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 1957            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 1958            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 1959
 1960            Assert.Null(semanticInfo.Symbol);
 1961            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1962
 1963            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1964
 1965            Assert.False(semanticInfo.IsCompileTimeConstant);
 1966        }
 1967
 1968        [WorkItem(537983, "DevDiv")]
 1969        [Fact]
 1970        public void AddWithUIntAndInt()
 1971        {
 1972            string sourceCode = @"
 1973public class Test
 1974{
 1975    public static void Main(string[] args)
 1976    {
 1977        uint ui = 0;
 1978        ulong ui2 = /*<bind>*/ui + 5/*</bind>*/ ;
 1979    }
 1980}
 1981";
 1982            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 1983
 1984            Assert.Equal("System.UInt32", semanticInfo.Type.ToTestDisplayString());
 1985            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 1986            Assert.Equal("System.UInt64", semanticInfo.ConvertedType.ToTestDisplayString());
 1987            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 1988            Assert.Equal(ConversionKind.ImplicitNumeric, semanticInfo.ImplicitConversion.Kind);
 1989
 1990            Assert.Equal("System.UInt32 System.UInt32.op_Addition(System.UInt32 left, System.UInt32 right)", semanticInfo.Symbol.ToTestDisplayString());
 1991            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 1992
 1993            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 1994
 1995            Assert.False(semanticInfo.IsCompileTimeConstant);
 1996        }
 1997
 1998        [WorkItem(527314, "DevDiv")]
 1999        [Fact()]
 2000        public void AddExprWithNullableUInt64AndInt32()
 2001        {
 2002            string sourceCode = @"
 2003public class Test
 2004{
 2005    public static void Main(string[] args)
 2006    {
 2007        ulong? ui = 0;
 2008        ulong? ui2 = /*<bind>*/ui + 5/*</bind>*/ ;
 2009    }
 2010}
 2011";
 2012            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2013
 2014            Assert.Equal("System.UInt64?", semanticInfo.Type.ToTestDisplayString());
 2015            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2016            Assert.Equal("System.UInt64?", semanticInfo.ConvertedType.ToTestDisplayString());
 2017            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2018            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2019
 2020            Assert.Equal("ulong.operator +(ulong, ulong)", semanticInfo.Symbol.ToString());
 2021            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2022
 2023            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2024
 2025            Assert.False(semanticInfo.IsCompileTimeConstant);
 2026        }
 2027
 2028        [WorkItem(3248, "DevDiv_Projects/Roslyn")]
 2029        [Fact]
 2030        public void NegatedIsExpr()
 2031        {
 2032            string sourceCode = @"
 2033using System;
 2034
 2035public class Test
 2036{
 2037    public static void Main()    
 2038    {
 2039      Exception e = new Exception(); 
 2040      bool bl = /*<bind>*/!(e is DivideByZeroException)/*</bind>*/;     
 2041    }
 2042}
 2043";
 2044            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2045
 2046            Assert.Equal("System.Boolean", semanticInfo.Type.ToTestDisplayString());
 2047            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2048            Assert.Equal("System.Boolean", semanticInfo.ConvertedType.ToTestDisplayString());
 2049            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2050            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2051
 2052            Assert.Equal("System.Boolean System.Boolean.op_LogicalNot(System.Boolean value)", semanticInfo.Symbol.ToTestDisplayString());
 2053            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2054
 2055            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2056
 2057            Assert.False(semanticInfo.IsCompileTimeConstant);
 2058        }
 2059
 2060        [WorkItem(3249, "DevDiv_Projects/Roslyn")]
 2061        [Fact]
 2062        public void IsExpr()
 2063        {
 2064            string sourceCode = @"
 2065using System;
 2066
 2067public class Test
 2068{
 2069    public static void Main()    
 2070    {
 2071      Exception e = new Exception(); 
 2072      bool bl = /*<bind>*/ (e is DivideByZeroException) /*</bind>*/ ;     
 2073    }
 2074}
 2075";
 2076            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2077
 2078            Assert.Equal("System.Boolean", semanticInfo.Type.ToTestDisplayString());
 2079            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2080            Assert.Equal("System.Boolean", semanticInfo.ConvertedType.ToTestDisplayString());
 2081            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2082            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2083
 2084            Assert.Null(semanticInfo.Symbol);
 2085            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2086
 2087            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2088
 2089            Assert.False(semanticInfo.IsCompileTimeConstant);
 2090        }
 2091
 2092        [WorkItem(527324, "DevDiv")]
 2093        [Fact]
 2094        public void ExceptionCatchVariable()
 2095        {
 2096            string sourceCode = @"
 2097using System;
 2098
 2099public class Test
 2100{
 2101    public static void Main()    
 2102    {
 2103      try
 2104      {
 2105      }
 2106      catch (Exception e)
 2107      {
 2108        bool bl = (/*<bind>*/e/*</bind>*/ is DivideByZeroException) ;     
 2109      }
 2110    }
 2111}
 2112";
 2113            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2114
 2115            Assert.Equal("System.Exception", semanticInfo.Type.ToTestDisplayString());
 2116            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 2117            Assert.Equal("System.Exception", semanticInfo.ConvertedType.ToTestDisplayString());
 2118            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 2119            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2120
 2121            Assert.Equal("System.Exception e", semanticInfo.Symbol.ToTestDisplayString());
 2122            Assert.Equal(SymbolKind.Local, semanticInfo.Symbol.Kind);
 2123            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2124
 2125            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2126
 2127            Assert.False(semanticInfo.IsCompileTimeConstant);
 2128        }
 2129
 2130        [WorkItem(3478, "DevDiv_Projects/Roslyn")]
 2131        [Fact]
 2132        public void GenericInvocation()
 2133        {
 2134            string sourceCode = @"
 2135class Program { 
 2136    public static void Ref<T>(T array) 
 2137    {
 2138    } 
 2139
 2140    static void Main() 
 2141    { 
 2142      /*<bind>*/Ref<object>(null)/*</bind>*/;
 2143    }
 2144}
 2145";
 2146            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2147
 2148            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 2149            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2150            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 2151            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2152            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2153
 2154            Assert.Equal("void Program.Ref<System.Object>(System.Object array)", semanticInfo.Symbol.ToTestDisplayString());
 2155            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2156            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2157
 2158            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2159
 2160            Assert.False(semanticInfo.IsCompileTimeConstant);
 2161        }
 2162
 2163        [WorkItem(538039, "DevDiv")]
 2164        [Fact]
 2165        public void GlobalAliasQualifiedName()
 2166        {
 2167            string sourceCode = @"
 2168namespace N1 
 2169{
 2170    interface I1
 2171    {
 2172        void Method();
 2173    }
 2174}
 2175
 2176namespace N2
 2177{
 2178    class Test : N1.I1
 2179    {
 2180        void /*<bind>*/global::N1.I1/*</bind>*/.Method()
 2181        {
 2182        }        
 2183    }
 2184}
 2185";
 2186            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2187
 2188            Assert.Equal("N1.I1", semanticInfo.Type.ToTestDisplayString());
 2189            Assert.Equal(TypeKind.Interface, semanticInfo.Type.TypeKind);
 2190            Assert.Equal("N1.I1", semanticInfo.ConvertedType.ToTestDisplayString());
 2191            Assert.Equal(TypeKind.Interface, semanticInfo.ConvertedType.TypeKind);
 2192            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2193
 2194            Assert.Equal("N1.I1", semanticInfo.Symbol.ToTestDisplayString());
 2195            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 2196            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2197
 2198            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2199
 2200            Assert.False(semanticInfo.IsCompileTimeConstant);
 2201        }
 2202
 2203        [WorkItem(527363, "DevDiv")]
 2204        [Fact]
 2205        public void ArrayInitializer()
 2206        {
 2207            string sourceCode = @"
 2208class Test
 2209{
 2210    static void Main() 
 2211    {
 2212        int[] arr = new int[] /*<bind>*/{5}/*</bind>*/;
 2213    }
 2214}
 2215";
 2216            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2217
 2218            Assert.Null(semanticInfo.Type);
 2219            Assert.Null(semanticInfo.ConvertedType);
 2220            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2221
 2222            Assert.Null(semanticInfo.Symbol);
 2223            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2224
 2225            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2226
 2227            Assert.False(semanticInfo.IsCompileTimeConstant);
 2228        }
 2229
 2230        [WorkItem(538041, "DevDiv")]
 2231        [Fact]
 2232        public void AliasQualifiedName()
 2233        {
 2234            string sourceCode = @"
 2235using NSA = A;
 2236
 2237namespace A 
 2238{
 2239    class Foo {}
 2240}
 2241
 2242namespace B
 2243{
 2244    class Test
 2245    {
 2246        class NSA
 2247        {
 2248        }
 2249
 2250        static void Main() 
 2251        {
 2252            /*<bind>*/NSA::Foo/*</bind>*/ foo = new NSA::Foo();
 2253
 2254        }
 2255    }
 2256}
 2257";
 2258            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2259
 2260            Assert.Equal("A.Foo", semanticInfo.Type.ToTestDisplayString());
 2261            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 2262            Assert.Equal("A.Foo", semanticInfo.ConvertedType.ToTestDisplayString());
 2263            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 2264            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2265
 2266            Assert.Equal("A.Foo", semanticInfo.Symbol.ToTestDisplayString());
 2267            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 2268            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2269
 2270            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2271
 2272            Assert.False(semanticInfo.IsCompileTimeConstant);
 2273        }
 2274
 2275        [WorkItem(538021, "DevDiv")]
 2276        [Fact]
 2277        public void EnumToStringInvocationExpr()
 2278        {
 2279            string sourceCode = @"
 2280using System;
 2281
 2282enum E { Red, Blue, Green}
 2283
 2284public class MainClass
 2285{
 2286    public static int Main ()
 2287    {
 2288        E e = E.Red;
 2289        string s = /*<bind>*/e.ToString()/*</bind>*/;
 2290    }
 2291}
 2292";
 2293            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2294
 2295            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 2296            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 2297            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 2298            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 2299            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2300
 2301            Assert.Equal("System.String System.Enum.ToString()", semanticInfo.Symbol.ToTestDisplayString());
 2302            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2303            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2304
 2305            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2306
 2307            Assert.False(semanticInfo.IsCompileTimeConstant);
 2308        }
 2309
 2310        [WorkItem(538026, "DevDiv")]
 2311        [Fact]
 2312        public void ExplIfaceMethInvocationExpr()
 2313        {
 2314            string sourceCode = @"
 2315namespace N1 
 2316{
 2317    interface I1
 2318    {
 2319        int Method();
 2320    }
 2321}
 2322
 2323namespace N2
 2324{
 2325    class Test : N1.I1
 2326    {
 2327        int N1.I1.Method()
 2328        {
 2329            return 5;
 2330        }
 2331        
 2332        static int Main() 
 2333        {
 2334            Test t = new Test();
 2335            if (/*<bind>*/((N1.I1)t).Method()/*</bind>*/ != 5)
 2336                return 1;
 2337            
 2338            return 0;
 2339        }
 2340    }
 2341}
 2342";
 2343            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2344
 2345            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 2346            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2347            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 2348            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2349            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2350
 2351            Assert.Equal("System.Int32 N1.I1.Method()", semanticInfo.Symbol.ToTestDisplayString());
 2352            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2353            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2354
 2355            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2356
 2357            Assert.False(semanticInfo.IsCompileTimeConstant);
 2358        }
 2359
 2360        [WorkItem(538027, "DevDiv")]
 2361        [Fact]
 2362        public void InvocExprWithAliasIdentifierNameSameAsType()
 2363        {
 2364            string sourceCode = @"
 2365using N1 = NFoo;
 2366
 2367namespace NFoo
 2368{
 2369    class Foo 
 2370    {
 2371        public static void method() { }
 2372    }
 2373}
 2374
 2375namespace N2
 2376{
 2377    class N1 { }
 2378
 2379    class Test
 2380    {
 2381        static void Main() 
 2382        {
 2383            /*<bind>*/N1::Foo.method()/*</bind>*/;
 2384            
 2385        }
 2386    }
 2387}
 2388";
 2389            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2390
 2391            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 2392            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2393            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 2394            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2395            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2396
 2397            Assert.Equal("void NFoo.Foo.method()", semanticInfo.Symbol.ToTestDisplayString());
 2398            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2399            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2400
 2401            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2402
 2403            Assert.False(semanticInfo.IsCompileTimeConstant);
 2404        }
 2405
 2406        [WorkItem(3498, "DevDiv_Projects/Roslyn")]
 2407        [Fact]
 2408        public void BaseAccessMethodInvocExpr()
 2409        {
 2410            string sourceCode = @"
 2411using System;
 2412
 2413public class BaseClass
 2414{
 2415    public virtual void MyMeth()
 2416    {
 2417    }
 2418}
 2419
 2420public class MyClass : BaseClass
 2421{
 2422    public override void MyMeth()
 2423    {
 2424        /*<bind>*/base.MyMeth()/*</bind>*/;
 2425    }
 2426
 2427    public static void Main()
 2428    {
 2429    }
 2430}
 2431";
 2432            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2433
 2434            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 2435            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2436            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 2437            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2438            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2439
 2440            Assert.Equal("void BaseClass.MyMeth()", semanticInfo.Symbol.ToTestDisplayString());
 2441            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2442            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2443
 2444            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2445
 2446            Assert.False(semanticInfo.IsCompileTimeConstant);
 2447        }
 2448
 2449        [WorkItem(538104, "DevDiv")]
 2450        [Fact]
 2451        public void OverloadResolutionForVirtualMethods()
 2452        {
 2453            string sourceCode = @"
 2454using System;
 2455class Program
 2456{
 2457    static void Main()
 2458    {
 2459        D d = new D();
 2460        string s = ""hello""; long l = 1;
 2461        /*<bind>*/d.foo(ref s, l, l)/*</bind>*/;
 2462    }
 2463}
 2464public class B
 2465{
 2466    // Should bind to this method.
 2467    public virtual int foo(ref string x, long y, long z)
 2468    {
 2469        Console.WriteLine(""Base: foo(ref string x, long y, long z)"");
 2470        return 0;
 2471    }
 2472    public virtual void foo(ref string x, params long[] y)
 2473    {
 2474        Console.WriteLine(""Base: foo(ref string x, params long[] y)"");
 2475    }
 2476}
 2477public class D: B
 2478{
 2479    // Roslyn erroneously binds to this override.
 2480    // Roslyn binds to the correct method above if you comment out this override.
 2481    public override void foo(ref string x, params long[] y)
 2482    {
 2483        Console.WriteLine(""Derived: foo(ref string x, params long[] y)"");
 2484    }
 2485}
 2486";
 2487            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2488
 2489            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 2490            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2491            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 2492            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2493            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2494
 2495            Assert.Equal("System.Int32 B.foo(ref System.String x, System.Int64 y, System.Int64 z)", semanticInfo.Symbol.ToTestDisplayString());
 2496            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2497            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2498
 2499            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2500
 2501            Assert.False(semanticInfo.IsCompileTimeConstant);
 2502        }
 2503
 2504        [WorkItem(538104, "DevDiv")]
 2505        [Fact]
 2506        public void OverloadResolutionForVirtualMethods2()
 2507        {
 2508            string sourceCode = @"
 2509using System;
 2510class Program
 2511{
 2512    static void Main()
 2513    {
 2514        D d = new D();
 2515        int i = 1;
 2516        /*<bind>*/d.foo(i, i)/*</bind>*/;
 2517    } 
 2518}
 2519public class B
 2520{
 2521    public virtual int foo(params int[] x)
 2522    {
 2523        Console.WriteLine(""""Base: foo(params int[] x)"""");
 2524        return 0;
 2525    }
 2526    public virtual void foo(params object[] x)
 2527    {
 2528        Console.WriteLine(""""Base: foo(params object[] x)"""");
 2529    }
 2530}
 2531public class D: B
 2532{
 2533    public override void foo(params object[] x)
 2534    {
 2535        Console.WriteLine(""""Derived: foo(params object[] x)"""");
 2536    }
 2537}
 2538";
 2539            var semanticInfo = GetSemanticInfoForTest<InvocationExpressionSyntax>(sourceCode);
 2540
 2541            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 2542            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2543            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 2544            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2545            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2546
 2547            Assert.Equal("System.Int32 B.foo(params System.Int32[] x)", semanticInfo.Symbol.ToTestDisplayString());
 2548            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2549            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2550
 2551            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2552
 2553            Assert.False(semanticInfo.IsCompileTimeConstant);
 2554        }
 2555
 2556        [Fact]
 2557        public void ThisInStaticMethod()
 2558        {
 2559            string sourceCode = @"
 2560using System;
 2561
 2562class Program
 2563{
 2564    static void Main(string[] args)
 2565    {
 2566        object o = /*<bind>*/this/*</bind>*/;
 2567    }
 2568
 2569}
 2570";
 2571            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2572
 2573            Assert.Equal("Program", semanticInfo.Type.ToTestDisplayString());
 2574            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 2575            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 2576            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 2577            Assert.Equal(ConversionKind.ImplicitReference, semanticInfo.ImplicitConversion.Kind);
 2578
 2579            Assert.Null(semanticInfo.Symbol);
 2580            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 2581            Assert.Equal("Program @this", semanticInfo.CandidateSymbols[0].ToTestDisplayString());
 2582            Assert.Equal(CandidateReason.StaticInstanceMismatch, semanticInfo.CandidateReason);
 2583
 2584            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2585
 2586            Assert.False(semanticInfo.IsCompileTimeConstant);
 2587        }
 2588
 2589
 2590        [Fact]
 2591        public void Constructor1()
 2592        {
 2593            string sourceCode = @"
 2594using System;
 2595
 2596class Program
 2597{
 2598    static void Main(string[] args)
 2599    {
 2600        object o = new /*<bind>*/A/*</bind>*/(4);
 2601    }
 2602}
 2603
 2604class A
 2605{
 2606    public A() { }
 2607    public A(int x) { }
 2608}
 2609";
 2610            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2611
 2612            Assert.Null(semanticInfo.Type);
 2613            Assert.Null(semanticInfo.ConvertedType);
 2614            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2615
 2616            Assert.Equal("A", semanticInfo.Symbol.ToTestDisplayString());
 2617            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 2618            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2619
 2620            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2621
 2622            Assert.False(semanticInfo.IsCompileTimeConstant);
 2623        }
 2624
 2625        [Fact]
 2626        public void Constructor2()
 2627        {
 2628            string sourceCode = @"
 2629using System;
 2630
 2631class Program
 2632{
 2633    static void Main(string[] args)
 2634    {
 2635        object o = /*<bind>*/new A(4)/*</bind>*/;
 2636    }
 2637}
 2638
 2639class A
 2640{
 2641    public A() { }
 2642    public A(int x) { }
 2643}
 2644";
 2645            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2646
 2647            Assert.Equal("A", semanticInfo.Type.ToTestDisplayString());
 2648            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 2649            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 2650            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 2651            Assert.Equal(ConversionKind.ImplicitReference, semanticInfo.ImplicitConversion.Kind);
 2652
 2653            Assert.Equal("A..ctor(System.Int32 x)", semanticInfo.Symbol.ToTestDisplayString());
 2654            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2655            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2656
 2657            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 2658            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2659            Assert.Equal("A..ctor()", sortedMethodGroup[0].ToTestDisplayString());
 2660            Assert.Equal("A..ctor(System.Int32 x)", sortedMethodGroup[1].ToTestDisplayString());
 2661
 2662            Assert.False(semanticInfo.IsCompileTimeConstant);
 2663        }
 2664
 2665        [Fact]
 2666        public void FailedOverloadResolution1()
 2667        {
 2668            string sourceCode = @"
 2669using System;
 2670
 2671class Program
 2672{
 2673    static void Main(string[] args)
 2674    {
 2675        object o = null;
 2676        /*<bind>*/A.f(o)/*</bind>*/;
 2677    }
 2678}
 2679
 2680class A
 2681{
 2682    public void f(int x, int y) { }
 2683    public void f(string z) { }
 2684}
 2685";
 2686            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2687
 2688            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 2689            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2690            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 2691            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2692            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2693
 2694            Assert.Null(semanticInfo.Symbol);
 2695            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 2696            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
 2697            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2698            Assert.Equal("void A.f(System.Int32 x, System.Int32 y)", sortedCandidates[0].ToTestDisplayString());
 2699            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 2700            Assert.Equal("void A.f(System.String z)", sortedCandidates[1].ToTestDisplayString());
 2701            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 2702
 2703            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2704
 2705            Assert.False(semanticInfo.IsCompileTimeConstant);
 2706        }
 2707
 2708        [Fact]
 2709        public void FailedOverloadResolution2()
 2710        {
 2711            string sourceCode = @"
 2712using System;
 2713
 2714class Program
 2715{
 2716    static void Main(string[] args)
 2717    {
 2718        object o = null;
 2719        A./*<bind>*/f/*</bind>*/(o);
 2720    }
 2721}
 2722
 2723class A
 2724{
 2725    public void f(int x, int y) { }
 2726    public void f(string z) { }
 2727}
 2728";
 2729            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2730
 2731            Assert.Null(semanticInfo.Type);
 2732            Assert.Null(semanticInfo.ConvertedType);
 2733            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2734
 2735            Assert.Null(semanticInfo.Symbol);
 2736            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 2737            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
 2738            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2739            Assert.Equal("void A.f(System.Int32 x, System.Int32 y)", sortedCandidates[0].ToTestDisplayString());
 2740            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 2741            Assert.Equal("void A.f(System.String z)", sortedCandidates[1].ToTestDisplayString());
 2742            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 2743
 2744            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 2745            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2746            Assert.Equal("void A.f(System.Int32 x, System.Int32 y)", sortedMethodGroup[0].ToTestDisplayString());
 2747            Assert.Equal("void A.f(System.String z)", sortedMethodGroup[1].ToTestDisplayString());
 2748
 2749            Assert.False(semanticInfo.IsCompileTimeConstant);
 2750        }
 2751
 2752        [WorkItem(541745, "DevDiv")]
 2753        [Fact]
 2754        public void FailedOverloadResolution3()
 2755        {
 2756            string sourceCode = @"
 2757class C
 2758{
 2759    public int M { get; set; }
 2760}
 2761static class Extensions1
 2762{
 2763    public static int M(this C c) { return 0; }
 2764}
 2765static class Extensions2
 2766{
 2767    public static int M(this C c) { return 0; }
 2768}
 2769
 2770class Foo
 2771{
 2772    void M()
 2773    {
 2774        C c = new C();
 2775        /*<bind>*/c.M/*</bind>*/();
 2776    }
 2777}
 2778";
 2779            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 2780
 2781            Assert.Null(semanticInfo.Type);
 2782            Assert.Null(semanticInfo.ConvertedType);
 2783            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2784
 2785            Assert.Null(semanticInfo.Symbol);
 2786            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 2787            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
 2788            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2789            Assert.Equal("System.Int32 C.M()", sortedCandidates[0].ToTestDisplayString());
 2790            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 2791            Assert.Equal("System.Int32 C.M()", sortedCandidates[1].ToTestDisplayString());
 2792            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 2793
 2794            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 2795            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2796            Assert.Equal("System.Int32 C.M()", sortedMethodGroup[0].ToTestDisplayString());
 2797            Assert.Equal("System.Int32 C.M()", sortedMethodGroup[1].ToTestDisplayString());
 2798
 2799            Assert.False(semanticInfo.IsCompileTimeConstant);
 2800        }
 2801
 2802        [WorkItem(542833, "DevDiv")]
 2803        [Fact]
 2804        public void FailedOverloadResolution4()
 2805        {
 2806            string sourceCode = @"
 2807class C
 2808{
 2809    public int M; 
 2810}
 2811
 2812static class Extensions
 2813{
 2814    public static int M(this C c, int i) { return 0; }
 2815}
 2816class Foo
 2817{
 2818    void M()
 2819    {
 2820        C c = new C();
 2821        /*<bind>*/c.M/*</bind>*/();
 2822    }
 2823}
 2824";
 2825            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 2826
 2827            Assert.Null(semanticInfo.Type);
 2828            Assert.Null(semanticInfo.ConvertedType);
 2829            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2830
 2831            Assert.Null(semanticInfo.Symbol);
 2832            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 2833            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 2834            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2835            Assert.Equal("System.Int32 C.M(System.Int32 i)", sortedCandidates[0].ToTestDisplayString());
 2836            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 2837
 2838            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 2839            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2840            Assert.Equal("System.Int32 C.M(System.Int32 i)", sortedMethodGroup[0].ToTestDisplayString());
 2841
 2842            Assert.False(semanticInfo.IsCompileTimeConstant);
 2843        }
 2844
 2845        [Fact]
 2846        public void SucceededOverloadResolution1()
 2847        {
 2848            string sourceCode = @"
 2849using System;
 2850
 2851class Program
 2852{
 2853    static void Main(string[] args)
 2854    {
 2855        object o = null;
 2856        /*<bind>*/A.f(""hi"")/*</bind>*/;
 2857    }
 2858}
 2859
 2860class A
 2861{
 2862    public static void f(int x, int y) { }
 2863    public static int f(string z) { return 3; }
 2864}
 2865";
 2866            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2867
 2868            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 2869            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2870            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 2871            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2872            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2873
 2874            Assert.Equal("System.Int32 A.f(System.String z)", semanticInfo.Symbol.ToTestDisplayString());
 2875            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2876            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2877
 2878            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 2879
 2880            Assert.False(semanticInfo.IsCompileTimeConstant);
 2881        }
 2882
 2883        [Fact]
 2884        public void SuceededOverloadResolution2()
 2885        {
 2886            string sourceCode = @"
 2887using System;
 2888
 2889class Program
 2890{
 2891    static void Main(string[] args)
 2892    {
 2893        object o = null;
 2894        A./*<bind>*/f/*</bind>*/(""hi"");
 2895    }
 2896}
 2897
 2898class A
 2899{
 2900    public static void f(int x, int y) { }
 2901    public static int f(string z) { return 3; }
 2902}
 2903";
 2904            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 2905
 2906            Assert.Null(semanticInfo.Type);
 2907            Assert.Null(semanticInfo.ConvertedType);
 2908            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2909
 2910            Assert.Equal("System.Int32 A.f(System.String z)", semanticInfo.Symbol.ToTestDisplayString());
 2911            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 2912            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 2913
 2914            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 2915            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2916            Assert.Equal("System.Int32 A.f(System.String z)", sortedMethodGroup[0].ToTestDisplayString());
 2917            Assert.Equal("void A.f(System.Int32 x, System.Int32 y)", sortedMethodGroup[1].ToTestDisplayString());
 2918
 2919            Assert.False(semanticInfo.IsCompileTimeConstant);
 2920        }
 2921
 2922        [WorkItem(541878, "DevDiv")]
 2923        [Fact]
 2924        public void TestCandidateReasonForInaccessibleMethod()
 2925        {
 2926            string sourceCode = @"
 2927class Test
 2928{
 2929    class NestedTest
 2930    {
 2931        static void Method1()
 2932        {
 2933        }
 2934    }
 2935
 2936    static void Main()
 2937    {
 2938        /*<bind>*/NestedTest.Method1()/*</bind>*/;
 2939    }
 2940}
 2941";
 2942            var semanticInfo = GetSemanticInfoForTest<InvocationExpressionSyntax>(sourceCode);
 2943
 2944            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 2945            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 2946            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 2947            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 2948            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2949
 2950            Assert.Null(semanticInfo.Symbol);
 2951            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
 2952            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 2953            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2954            Assert.Equal("void Test.NestedTest.Method1()", sortedCandidates[0].ToTestDisplayString());
 2955            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 2956        }
 2957
 2958        [WorkItem(541879, "DevDiv")]
 2959        [Fact]
 2960        public void InaccessibleTypeInObjectCreationExpression()
 2961        {
 2962            string sourceCode = @"
 2963class Test
 2964{
 2965    class NestedTest
 2966    {
 2967        class NestedNestedTest
 2968        {
 2969        }
 2970    }
 2971
 2972    static void Main()
 2973    {
 2974        var nnt = /*<bind>*/new NestedTest.NestedNestedTest()/*</bind>*/;
 2975    }
 2976}
 2977";
 2978            var semanticInfo = GetSemanticInfoForTest<ObjectCreationExpressionSyntax>(sourceCode);
 2979
 2980            Assert.Equal("Test.NestedTest.NestedNestedTest", semanticInfo.Type.ToTestDisplayString());
 2981            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 2982            Assert.Equal("Test.NestedTest.NestedNestedTest", semanticInfo.ConvertedType.ToTestDisplayString());
 2983            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 2984            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 2985
 2986            Assert.Null(semanticInfo.Symbol);
 2987            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
 2988            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 2989            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 2990            Assert.Equal("Test.NestedTest.NestedNestedTest..ctor()", sortedCandidates[0].ToTestDisplayString());
 2991            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 2992        }
 2993
 2994        [WorkItem(541883, "DevDiv")]
 2995        [Fact]
 2996        public void InheritedMemberHiding()
 2997        {
 2998            string sourceCode = @"
 2999public class A
 3000{
 3001    public static int m() { return 1; }
 3002}
 3003
 3004public class B : A
 3005{
 3006    public static int m() { return 5; }
 3007
 3008    public static void Main1()
 3009    {
 3010        /*<bind>*/m/*</bind>*/(10);
 3011    }
 3012}
 3013";
 3014            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 3015
 3016            Assert.Null(semanticInfo.Type);
 3017            Assert.Null(semanticInfo.ConvertedType);
 3018            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3019
 3020            Assert.Null(semanticInfo.Symbol);
 3021            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 3022            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 3023            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3024            Assert.Equal("System.Int32 B.m()", sortedCandidates[0].ToTestDisplayString());
 3025            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 3026
 3027            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3028            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3029            Assert.Equal("System.Int32 B.m()", sortedMethodGroup[0].ToTestDisplayString());
 3030        }
 3031
 3032
 3033        [WorkItem(538106, "DevDiv")]
 3034        [Fact]
 3035        public void UsingAliasNameSystemInvocExpr()
 3036        {
 3037            string sourceCode = @"
 3038using System = MySystem.IO.StreamReader;
 3039
 3040namespace N1
 3041{
 3042    using NullStreamReader = System::NullStreamReader;
 3043    class Test
 3044    {
 3045        static int Main()
 3046        {
 3047            NullStreamReader nr = new NullStreamReader();
 3048
 3049            /*<bind>*/nr.ReadLine()/*</bind>*/;
 3050            return 0;
 3051        }
 3052    }
 3053}
 3054
 3055namespace MySystem
 3056{
 3057    namespace IO
 3058    {
 3059        namespace StreamReader
 3060        {
 3061            public class NullStreamReader
 3062            {
 3063                public string ReadLine() { return null; }
 3064            }
 3065        }
 3066    }
 3067}
 3068";
 3069            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3070
 3071            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 3072            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3073            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 3074            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3075            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3076
 3077            Assert.Equal("System.String MySystem.IO.StreamReader.NullStreamReader.ReadLine()", semanticInfo.Symbol.ToTestDisplayString());
 3078            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3079            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3080
 3081            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3082
 3083            Assert.False(semanticInfo.IsCompileTimeConstant);
 3084        }
 3085
 3086        [WorkItem(538109, "DevDiv")]
 3087        [Fact]
 3088        public void InterfaceMethodImplInvocExpr()
 3089        {
 3090            string sourceCode = @"
 3091interface ISomething
 3092{
 3093    string ToString();
 3094}
 3095
 3096class A : ISomething
 3097{
 3098    string ISomething.ToString()
 3099    {
 3100        return null;
 3101    }
 3102}
 3103
 3104class Test
 3105{
 3106    static void Main()
 3107    {
 3108        ISomething isome = new A();
 3109
 3110        /*<bind>*/isome.ToString()/*</bind>*/;
 3111    }
 3112}
 3113";
 3114            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3115
 3116            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 3117            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3118            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 3119            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3120            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3121
 3122            Assert.Equal("System.String ISomething.ToString()", semanticInfo.Symbol.ToTestDisplayString());
 3123            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3124            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3125
 3126            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3127
 3128            Assert.False(semanticInfo.IsCompileTimeConstant);
 3129        }
 3130
 3131        [WorkItem(538112, "DevDiv")]
 3132        [Fact]
 3133        public void MemberAccessMethodWithNew()
 3134        {
 3135            string sourceCode = @"
 3136public class MyBase
 3137{
 3138    public void MyMeth()
 3139    {
 3140    }
 3141}
 3142
 3143public class MyClass : MyBase
 3144{
 3145    new public void MyMeth()
 3146    {
 3147    }
 3148
 3149    public static void Main()
 3150    {
 3151        MyClass test = new MyClass();
 3152        /*<bind>*/test.MyMeth/*</bind>*/();
 3153    }
 3154}
 3155";
 3156            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3157
 3158            Assert.Null(semanticInfo.Type);
 3159            Assert.Null(semanticInfo.ConvertedType);
 3160            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3161
 3162            Assert.Equal("void MyClass.MyMeth()", semanticInfo.Symbol.ToTestDisplayString());
 3163            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3164            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3165
 3166            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3167            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3168            Assert.Equal("void MyClass.MyMeth()", sortedMethodGroup[0].ToTestDisplayString());
 3169
 3170            Assert.False(semanticInfo.IsCompileTimeConstant);
 3171        }
 3172
 3173        [WorkItem(527386, "DevDiv")]
 3174        [Fact]
 3175        public void MethodGroupWithStaticInstanceSameName()
 3176        {
 3177            string sourceCode = @"
 3178class D
 3179{
 3180    public static void M2(int x, int y)
 3181    {
 3182    }
 3183
 3184    public void M2(int x)
 3185    {
 3186    }
 3187}
 3188
 3189class C
 3190{
 3191    public static void Main()
 3192    {
 3193        D d = new D();
 3194        /*<bind>*/d.M2/*</bind>*/(5);
 3195    }
 3196}
 3197";
 3198            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3199
 3200            Assert.Null(semanticInfo.Type);
 3201            Assert.Null(semanticInfo.ConvertedType);
 3202            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3203
 3204            Assert.Equal("void D.M2(System.Int32 x)", semanticInfo.Symbol.ToTestDisplayString());
 3205            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3206            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3207
 3208            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 3209            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3210            Assert.Equal("void D.M2(System.Int32 x)", sortedMethodGroup[0].ToTestDisplayString());
 3211            Assert.Equal("void D.M2(System.Int32 x, System.Int32 y)", sortedMethodGroup[1].ToTestDisplayString());
 3212
 3213            Assert.False(semanticInfo.IsCompileTimeConstant);
 3214        }
 3215
 3216        [WorkItem(538123, "DevDiv")]
 3217        [Fact]
 3218        public void VirtualOverriddenMember()
 3219        {
 3220            string sourceCode = @"
 3221public class C1
 3222{
 3223    public virtual void M1()
 3224    {
 3225    }
 3226}
 3227
 3228public class C2:C1
 3229{
 3230    public override void M1()
 3231    {
 3232    }
 3233}
 3234
 3235public class Test
 3236{
 3237    static void Main()
 3238    {
 3239        C2 c2 = new C2();
 3240        /*<bind>*/c2.M1/*</bind>*/();
 3241    }
 3242}
 3243";
 3244            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3245
 3246            Assert.Null(semanticInfo.Type);
 3247            Assert.Null(semanticInfo.ConvertedType);
 3248            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3249
 3250            Assert.Equal("void C2.M1()", semanticInfo.Symbol.ToTestDisplayString());
 3251            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3252            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3253
 3254            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3255            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3256            Assert.Equal("void C2.M1()", sortedMethodGroup[0].ToTestDisplayString());
 3257
 3258            Assert.False(semanticInfo.IsCompileTimeConstant);
 3259        }
 3260
 3261        [WorkItem(538125, "DevDiv")]
 3262        [Fact]
 3263        public void AbstractOverriddenMember()
 3264        {
 3265            string sourceCode = @"
 3266public abstract class AbsClass
 3267{
 3268    public abstract void Test();
 3269}
 3270
 3271public class TestClass : AbsClass
 3272{
 3273    public  override void Test() { }
 3274
 3275    public static void Main()
 3276    {
 3277        TestClass tc = new TestClass();
 3278         /*<bind>*/tc.Test/*</bind>*/();
 3279
 3280    }
 3281}
 3282";
 3283            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3284
 3285            Assert.Null(semanticInfo.Type);
 3286            Assert.Null(semanticInfo.ConvertedType);
 3287            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3288
 3289            Assert.Equal("void TestClass.Test()", semanticInfo.Symbol.ToTestDisplayString());
 3290            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3291            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3292
 3293            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3294            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3295            Assert.Equal("void TestClass.Test()", sortedMethodGroup[0].ToTestDisplayString());
 3296
 3297            Assert.False(semanticInfo.IsCompileTimeConstant);
 3298        }
 3299
 3300        [Fact]
 3301        public void DiamondInheritanceMember()
 3302        {
 3303            string sourceCode = @"
 3304public interface IB { void M(); }
 3305public interface IM1 : IB {}
 3306public interface IM2 : IB {}
 3307public interface ID : IM1, IM2 {}
 3308public class Program
 3309{
 3310    public static void Main()
 3311    {
 3312        ID id = null;
 3313       /*<bind>*/id.M/*</bind>*/();
 3314    }
 3315}
 3316";
 3317            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3318
 3319            // We must ensure that the method is only found once, even though there are two paths to it.
 3320
 3321            Assert.Null(semanticInfo.Type);
 3322            Assert.Null(semanticInfo.ConvertedType);
 3323            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3324
 3325            Assert.Equal("void IB.M()", semanticInfo.Symbol.ToTestDisplayString());
 3326            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3327            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3328
 3329            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3330            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3331            Assert.Equal("void IB.M()", sortedMethodGroup[0].ToTestDisplayString());
 3332
 3333            Assert.False(semanticInfo.IsCompileTimeConstant);
 3334        }
 3335
 3336        [Fact]
 3337        public void InconsistentlyHiddenMember()
 3338        {
 3339            string sourceCode = @"
 3340public interface IB { void M(); }
 3341public interface IL : IB {}
 3342public interface IR : IB { new void M(); }
 3343public interface ID : IR, IL {}
 3344public class Program
 3345{
 3346    public static void Main()
 3347    {
 3348        ID id = null;
 3349       /*<bind>*/id.M/*</bind>*/();
 3350    }
 3351}
 3352";
 3353            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3354
 3355            // Even though there is a "path" from ID to IB.M via IL on which IB.M is not hidden,
 3356            // it is still hidden because *any possible hiding* hides the method.
 3357
 3358            Assert.Null(semanticInfo.Type);
 3359            Assert.Null(semanticInfo.ConvertedType);
 3360            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3361
 3362            Assert.Equal("void IR.M()", semanticInfo.Symbol.ToTestDisplayString());
 3363            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3364            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3365
 3366            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3367            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3368            Assert.Equal("void IR.M()", sortedMethodGroup[0].ToTestDisplayString());
 3369
 3370            Assert.False(semanticInfo.IsCompileTimeConstant);
 3371        }
 3372
 3373        [WorkItem(538138, "DevDiv")]
 3374        [Fact]
 3375        public void ParenExprWithMethodInvocExpr()
 3376        {
 3377            string sourceCode = @"
 3378class Test
 3379{
 3380    public static int Meth1()
 3381    {
 3382        return 9;
 3383    }
 3384
 3385    public static void Main()
 3386    {
 3387        int var1 = /*<bind>*/(Meth1())/*</bind>*/;
 3388    }
 3389}
 3390";
 3391            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3392
 3393            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 3394            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 3395            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 3396            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 3397            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3398
 3399            Assert.Equal("System.Int32 Test.Meth1()", semanticInfo.Symbol.ToTestDisplayString());
 3400            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3401            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3402
 3403            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3404
 3405            Assert.False(semanticInfo.IsCompileTimeConstant);
 3406        }
 3407
 3408        [WorkItem(527397, "DevDiv")]
 3409        [Fact()]
 3410        public void ExplicitIdentityCastExpr()
 3411        {
 3412            string sourceCode = @"
 3413class Test
 3414{
 3415    public static void Main()
 3416    {
 3417        int i = 10;
 3418        object j = /*<bind>*/(int)i/*</bind>*/;
 3419    }
 3420}
 3421";
 3422            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3423
 3424            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 3425            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 3426            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 3427            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3428            Assert.Equal(ConversionKind.Boxing, semanticInfo.ImplicitConversion.Kind);
 3429
 3430            Assert.Null(semanticInfo.Symbol);
 3431            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 3432            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3433
 3434            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3435
 3436            Assert.False(semanticInfo.IsCompileTimeConstant);
 3437        }
 3438
 3439        [WorkItem(3652, "DevDiv_Projects/Roslyn")]
 3440        [WorkItem(529056, "DevDiv")]
 3441        [WorkItem(543619, "DevDiv")]
 3442        [Fact()]
 3443        public void OutOfBoundsConstCastToByte()
 3444        {
 3445            string sourceCode = @"
 3446class Test
 3447{
 3448    public static void Main()
 3449    {
 3450        byte j = unchecked(/*<bind>*/(byte)-123/*</bind>*/);
 3451    }
 3452}
 3453";
 3454            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3455
 3456            Assert.Equal("System.Byte", semanticInfo.Type.ToTestDisplayString());
 3457            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 3458            Assert.Equal("System.Byte", semanticInfo.ConvertedType.ToTestDisplayString());
 3459            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 3460            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3461
 3462            Assert.Null(semanticInfo.Symbol);
 3463            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 3464            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3465
 3466            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3467
 3468            Assert.True(semanticInfo.IsCompileTimeConstant);
 3469            Assert.Equal((byte)133, semanticInfo.ConstantValue);
 3470        }
 3471
 3472        [WorkItem(538160, "DevDiv")]
 3473        [Fact]
 3474        public void InsideCollectionsNamespace()
 3475        {
 3476            string sourceCode = @"
 3477using System;
 3478
 3479namespace Collections
 3480{
 3481    public class Test
 3482    {
 3483        public static /*<bind>*/void/*</bind>*/ Main()
 3484        {
 3485        }
 3486    }
 3487}
 3488";
 3489            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3490
 3491            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 3492            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 3493            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 3494            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 3495            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3496
 3497            Assert.Equal("System.Void", semanticInfo.Symbol.ToTestDisplayString());
 3498            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3499            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3500
 3501            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3502
 3503            Assert.False(semanticInfo.IsCompileTimeConstant);
 3504        }
 3505
 3506        [WorkItem(538161, "DevDiv")]
 3507        [Fact]
 3508        public void ErrorTypeNameSameAsVariable()
 3509        {
 3510            string sourceCode = @"
 3511public class A
 3512{
 3513    public static void RunTest()
 3514    {
 3515        /*<bind>*/B/*</bind>*/ B = new B();
 3516
 3517    }
 3518}
 3519";
 3520            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3521
 3522            Assert.Equal("B", semanticInfo.Type.ToTestDisplayString());
 3523            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 3524            Assert.Equal("B", semanticInfo.ConvertedType.ToTestDisplayString());
 3525            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 3526            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3527
 3528            Assert.Null(semanticInfo.Symbol);
 3529            Assert.Equal(CandidateReason.NotATypeOrNamespace, semanticInfo.CandidateReason);
 3530            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 3531            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 3532            Assert.Equal("B B", sortedCandidates[0].ToTestDisplayString());
 3533            Assert.Equal(SymbolKind.Local, sortedCandidates[0].Kind);
 3534
 3535            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3536
 3537            Assert.False(semanticInfo.IsCompileTimeConstant);
 3538        }
 3539
 3540        [WorkItem(537117, "DevDiv")]
 3541        [WorkItem(537127, "DevDiv")]
 3542        [Fact]
 3543        public void SystemNamespace()
 3544        {
 3545            string sourceCode = @"
 3546namespace System
 3547{
 3548    class A 
 3549    {
 3550        /*<bind>*/System/*</bind>*/.Exception c;
 3551    }
 3552}
 3553";
 3554            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3555
 3556            Assert.Null(semanticInfo.Type);
 3557            Assert.Null(semanticInfo.ConvertedType);
 3558            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3559
 3560            Assert.Equal("System", semanticInfo.Symbol.ToTestDisplayString());
 3561            Assert.Equal(SymbolKind.Namespace, semanticInfo.Symbol.Kind);
 3562            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3563
 3564            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3565
 3566            Assert.False(semanticInfo.IsCompileTimeConstant);
 3567        }
 3568
 3569        [WorkItem(537118, "DevDiv")]
 3570        [Fact]
 3571        public void SystemNamespace2()
 3572        {
 3573            string sourceCode = @"
 3574namespace N1
 3575{
 3576    namespace N2
 3577    {
 3578        public class A1 { }
 3579    }
 3580    public class A2
 3581    {
 3582        /*<bind>*/N1.N2.A1/*</bind>*/ a;
 3583    }
 3584}
 3585";
 3586            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3587
 3588            Assert.Equal("N1.N2.A1", semanticInfo.Type.ToTestDisplayString());
 3589            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3590            Assert.Equal("N1.N2.A1", semanticInfo.ConvertedType.ToTestDisplayString());
 3591            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3592            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3593
 3594            Assert.Equal("N1.N2.A1", semanticInfo.Symbol.ToTestDisplayString());
 3595            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3596            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3597
 3598            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3599
 3600            Assert.False(semanticInfo.IsCompileTimeConstant);
 3601        }
 3602
 3603        [WorkItem(537119, "DevDiv")]
 3604        [Fact]
 3605        public void SystemNamespace3()
 3606        {
 3607            string sourceCode = @"
 3608class H<T>
 3609{
 3610}
 3611
 3612class A
 3613{
 3614}
 3615
 3616namespace N1
 3617{
 3618    public class A1
 3619    {
 3620        /*<bind>*/H<A>/*</bind>*/ a;
 3621    }
 3622}
 3623";
 3624            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3625
 3626            Assert.Equal("H<A>", semanticInfo.Type.ToTestDisplayString());
 3627            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3628            Assert.Equal("H<A>", semanticInfo.ConvertedType.ToTestDisplayString());
 3629            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3630            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3631
 3632            Assert.Equal("H<A>", semanticInfo.Symbol.ToTestDisplayString());
 3633            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3634            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3635
 3636            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3637
 3638            Assert.False(semanticInfo.IsCompileTimeConstant);
 3639        }
 3640
 3641        [WorkItem(537124, "DevDiv")]
 3642        [Fact]
 3643        public void SystemNamespace4()
 3644        {
 3645            string sourceCode = @"
 3646using System;
 3647
 3648class H<T>
 3649{
 3650}
 3651
 3652class H<T1, T2>
 3653{
 3654}
 3655
 3656class A
 3657{
 3658}
 3659
 3660namespace N1
 3661{
 3662    public class A1
 3663    {
 3664        /*<bind>*/H<H<A>, H<A>>/*</bind>*/ a;
 3665    }
 3666}
 3667";
 3668            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3669
 3670            Assert.Equal("H<H<A>, H<A>>", semanticInfo.Type.ToTestDisplayString());
 3671            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3672            Assert.Equal("H<H<A>, H<A>>", semanticInfo.ConvertedType.ToTestDisplayString());
 3673            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3674            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3675
 3676            Assert.Equal("H<H<A>, H<A>>", semanticInfo.Symbol.ToTestDisplayString());
 3677            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3678            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3679
 3680            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3681
 3682            Assert.False(semanticInfo.IsCompileTimeConstant);
 3683        }
 3684
 3685        [WorkItem(537160, "DevDiv")]
 3686        [Fact]
 3687        public void SystemNamespace5()
 3688        {
 3689            string sourceCode = @"
 3690namespace N1
 3691{
 3692    namespace N2
 3693    {
 3694        public class A2
 3695        {
 3696            public class A1 { }
 3697            /*<bind>*/N1.N2.A2.A1/*</bind>*/ a;
 3698        }
 3699    }
 3700}
 3701";
 3702            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3703
 3704            Assert.Equal("N1.N2.A2.A1", semanticInfo.Type.ToTestDisplayString());
 3705            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3706            Assert.Equal("N1.N2.A2.A1", semanticInfo.ConvertedType.ToTestDisplayString());
 3707            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3708            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3709
 3710            Assert.Equal("N1.N2.A2.A1", semanticInfo.Symbol.ToTestDisplayString());
 3711            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3712            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3713
 3714            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3715
 3716            Assert.False(semanticInfo.IsCompileTimeConstant);
 3717        }
 3718
 3719        [WorkItem(537161, "DevDiv")]
 3720        [Fact]
 3721        public void SystemNamespace6()
 3722        {
 3723            string sourceCode = @"
 3724namespace N1
 3725{
 3726    class NC1
 3727    {
 3728        public class A1 { }
 3729    }
 3730    public class A2
 3731    {
 3732        /*<bind>*/N1.NC1.A1/*</bind>*/ a;
 3733    }
 3734}
 3735";
 3736            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3737
 3738            Assert.Equal("N1.NC1.A1", semanticInfo.Type.ToTestDisplayString());
 3739            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3740            Assert.Equal("N1.NC1.A1", semanticInfo.ConvertedType.ToTestDisplayString());
 3741            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3742            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3743
 3744            Assert.Equal("N1.NC1.A1", semanticInfo.Symbol.ToTestDisplayString());
 3745            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3746            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3747
 3748            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3749
 3750            Assert.False(semanticInfo.IsCompileTimeConstant);
 3751        }
 3752
 3753        [WorkItem(537340, "DevDiv")]
 3754        [Fact]
 3755        public void LeftOfDottedTypeName()
 3756        {
 3757            string sourceCode = @"
 3758class Main 
 3759{  
 3760   A./*<bind>*/B/*</bind>*/ x; // this refers to the B within A.
 3761}
 3762
 3763class A {    
 3764   public class B {}
 3765}
 3766
 3767class B {}
 3768
 3769";
 3770            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3771
 3772            Assert.Equal("A.B", semanticInfo.Type.ToTestDisplayString());
 3773            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3774            Assert.Equal("A.B", semanticInfo.ConvertedType.ToTestDisplayString());
 3775            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3776            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3777
 3778            Assert.Equal("A.B", semanticInfo.Symbol.ToTestDisplayString());
 3779            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3780            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3781
 3782            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3783
 3784            Assert.False(semanticInfo.IsCompileTimeConstant);
 3785        }
 3786
 3787        [WorkItem(537592, "DevDiv")]
 3788        [Fact]
 3789        public void Parameters()
 3790        {
 3791            string sourceCode = @"
 3792class C
 3793{
 3794    void M(DateTime dt)
 3795    {
 3796        /*<bind>*/dt/*</bind>*/.ToString();
 3797    }
 3798}
 3799";
 3800            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3801
 3802            Assert.Equal("DateTime", semanticInfo.Type.ToTestDisplayString());
 3803            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 3804            Assert.Equal("DateTime", semanticInfo.ConvertedType.ToTestDisplayString());
 3805            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 3806            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3807
 3808            Assert.Equal("DateTime dt", semanticInfo.Symbol.ToTestDisplayString());
 3809            Assert.Equal(SymbolKind.Parameter, semanticInfo.Symbol.Kind);
 3810            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3811
 3812            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3813
 3814            Assert.False(semanticInfo.IsCompileTimeConstant);
 3815        }
 3816
 3817        // TODO: This should probably have a candidate symbol!
 3818        [WorkItem(527212, "DevDiv")]
 3819        [Fact]
 3820        public void FieldMemberOfConstructedType()
 3821        {
 3822            string sourceCode = @"
 3823class C<T> {
 3824    public T Field;
 3825}
 3826class D {
 3827    void M() {
 3828        new C<int>./*<bind>*/Field/*</bind>*/.ToString();
 3829    }
 3830}
 3831";
 3832            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3833
 3834            Assert.Equal("C<System.Int32>.Field", semanticInfo.Type.ToTestDisplayString());
 3835            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 3836            Assert.Equal("C<System.Int32>.Field", semanticInfo.ConvertedType.ToTestDisplayString());
 3837            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 3838            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3839
 3840            Assert.Null(semanticInfo.Symbol);
 3841
 3842            // Should bind to "field" with a candidateReason (not a typeornamespace>)Skip:
 3843            Assert.NotEqual(CandidateReason.None, semanticInfo.CandidateReason);
 3844            Assert.NotEqual(0, semanticInfo.CandidateSymbols.Length);
 3845
 3846            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3847
 3848            Assert.False(semanticInfo.IsCompileTimeConstant);
 3849        }
 3850
 3851        [WorkItem(537593, "DevDiv")]
 3852        [Fact]
 3853        public void Constructor()
 3854        {
 3855            string sourceCode = @"
 3856class C
 3857{
 3858    public C() { /*<bind>*/new C()/*</bind>*/.ToString(); }
 3859}
 3860";
 3861            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3862
 3863            Assert.Equal("C", semanticInfo.Type.ToTestDisplayString());
 3864            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3865            Assert.Equal("C", semanticInfo.ConvertedType.ToTestDisplayString());
 3866            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3867            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3868
 3869            Assert.Equal("C..ctor()", semanticInfo.Symbol.ToTestDisplayString());
 3870            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 3871            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3872
 3873            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 3874            Assert.Equal("C..ctor()", semanticInfo.MethodGroup[0].ToTestDisplayString());
 3875
 3876            Assert.False(semanticInfo.IsCompileTimeConstant);
 3877        }
 3878
 3879        [WorkItem(538046, "DevDiv")]
 3880        [Fact]
 3881        public void TypeNameInTypeThatMatchesNamespace()
 3882        {
 3883            string sourceCode = @"
 3884namespace T
 3885{
 3886    class T
 3887    {
 3888        void M()
 3889        {
 3890            /*<bind>*/T/*</bind>*/.T T = new T.T();
 3891        }
 3892    }
 3893}
 3894
 3895";
 3896            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3897
 3898            Assert.Equal("T.T", semanticInfo.Type.ToTestDisplayString());
 3899            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 3900            Assert.Equal("T.T", semanticInfo.ConvertedType.ToTestDisplayString());
 3901            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3902            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3903
 3904            Assert.Equal("T.T", semanticInfo.Symbol.ToTestDisplayString());
 3905            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 3906            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3907
 3908            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3909
 3910            Assert.False(semanticInfo.IsCompileTimeConstant);
 3911        }
 3912
 3913        [WorkItem(538267, "DevDiv")]
 3914        [Fact]
 3915        public void RHSExpressionInTryParent()
 3916        {
 3917            string sourceCode = @"
 3918using System;
 3919public class Test
 3920{
 3921    static int Main()
 3922    {
 3923        try
 3924        {
 3925            object obj = /*<bind>*/null/*</bind>*/;
 3926        }
 3927        catch {}
 3928
 3929        return 0;
 3930    }
 3931}
 3932
 3933";
 3934            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3935
 3936            Assert.Null(semanticInfo.Type);
 3937            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 3938            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 3939            Assert.Equal(ConversionKind.ImplicitReference, semanticInfo.ImplicitConversion.Kind);
 3940
 3941            Assert.Null(semanticInfo.Symbol);
 3942            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 3943            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3944
 3945            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3946
 3947            Assert.True(semanticInfo.IsCompileTimeConstant);
 3948            Assert.Equal(null, semanticInfo.ConstantValue.Value);
 3949        }
 3950
 3951        [WorkItem(538215, "DevDiv")]
 3952        [Fact]
 3953        public void GenericArgumentInBase1()
 3954        {
 3955            string sourceCode = @"
 3956public class X 
 3957{
 3958    public interface Z { }
 3959}
 3960class A<T>
 3961{
 3962    public class X { }
 3963}
 3964class B : A<B.Y./*<bind>*/Z/*</bind>*/>
 3965{
 3966    public class Y : X { }
 3967}
 3968";
 3969            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 3970
 3971            Assert.Equal("B.Y.Z", semanticInfo.Type.ToTestDisplayString());
 3972            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 3973            Assert.Equal("B.Y.Z", semanticInfo.ConvertedType.ToTestDisplayString());
 3974            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 3975            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 3976
 3977            Assert.Null(semanticInfo.Symbol);
 3978            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 3979            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 3980
 3981            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 3982
 3983            Assert.False(semanticInfo.IsCompileTimeConstant);
 3984        }
 3985
 3986        [WorkItem(538215, "DevDiv")]
 3987        [Fact]
 3988        public void GenericArgumentInBase2()
 3989        {
 3990            string sourceCode = @"
 3991public class X 
 3992{
 3993    public interface Z { }
 3994}
 3995class A<T>
 3996{
 3997    public class X { }
 3998}
 3999class B : /*<bind>*/A<B.Y.Z>/*</bind>*/
 4000{
 4001    public class Y : X { }
 4002}
 4003";
 4004            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4005
 4006            Assert.Equal("A<B.Y.Z>", semanticInfo.Type.ToTestDisplayString());
 4007            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4008            Assert.Equal("A<B.Y.Z>", semanticInfo.ConvertedType.ToTestDisplayString());
 4009            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4010            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4011
 4012            Assert.Equal("A<B.Y.Z>", semanticInfo.Symbol.ToTestDisplayString());
 4013            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 4014            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4015
 4016            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4017
 4018            Assert.False(semanticInfo.IsCompileTimeConstant);
 4019        }
 4020
 4021        [WorkItem(538097, "DevDiv")]
 4022        [Fact]
 4023        public void InvokedLocal1()
 4024        {
 4025            string sourceCode = @"
 4026class C
 4027{
 4028  static void Foo()
 4029  {
 4030    int x = 10;
 4031    /*<bind>*/x/*</bind>*/();
 4032  }
 4033}
 4034";
 4035            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4036
 4037            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 4038            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4039            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4040            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4041            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4042
 4043            Assert.Equal("System.Int32 x", semanticInfo.Symbol.ToTestDisplayString());
 4044            Assert.Equal(SymbolKind.Local, semanticInfo.Symbol.Kind);
 4045            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4046
 4047            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4048
 4049            Assert.False(semanticInfo.IsCompileTimeConstant);
 4050        }
 4051
 4052        [WorkItem(538318, "DevDiv")]
 4053        [Fact]
 4054        public void TooManyConstructorArgs()
 4055        {
 4056            string sourceCode = @"
 4057class C
 4058{
 4059  C() {}
 4060  void M()
 4061  {
 4062    /*<bind>*/new C(null
 4063/*</bind>*/  }
 4064}
 4065";
 4066            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4067
 4068            Assert.Equal("C", semanticInfo.Type.ToTestDisplayString());
 4069            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4070            Assert.Equal("C", semanticInfo.ConvertedType.ToTestDisplayString());
 4071            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4072            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4073
 4074            Assert.Null(semanticInfo.Symbol);
 4075            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 4076            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 4077            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4078            Assert.Equal("C..ctor()", sortedCandidates[0].ToTestDisplayString());
 4079            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 4080
 4081            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 4082            Assert.Equal("C..ctor()", semanticInfo.MethodGroup[0].ToTestDisplayString());
 4083
 4084            Assert.False(semanticInfo.IsCompileTimeConstant);
 4085        }
 4086
 4087        [WorkItem(538185, "DevDiv")]
 4088        [Fact]
 4089        public void NamespaceAndFieldSameName1()
 4090        {
 4091            string sourceCode = @"
 4092class C
 4093{
 4094    void M()
 4095    {
 4096        /*<bind>*/System/*</bind>*/.String x = F();
 4097    }
 4098    string F()
 4099    {
 4100        return null;
 4101    }
 4102    public int System;
 4103}
 4104";
 4105            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4106
 4107            Assert.Null(semanticInfo.Type);
 4108            Assert.Null(semanticInfo.ConvertedType);
 4109            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4110
 4111            Assert.Equal("System", semanticInfo.Symbol.ToTestDisplayString());
 4112            Assert.Equal(SymbolKind.Namespace, semanticInfo.Symbol.Kind);
 4113            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4114
 4115            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4116
 4117            Assert.False(semanticInfo.IsCompileTimeConstant);
 4118        }
 4119
 4120        [Fact]
 4121        public void PEProperty()
 4122        {
 4123            string sourceCode = @"
 4124class C
 4125{
 4126  void M(string s)
 4127  {
 4128    /*<bind>*/s.Length/*</bind>*/;
 4129  }
 4130}
 4131";
 4132            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4133
 4134            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 4135            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4136            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4137            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4138            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4139
 4140            Assert.Equal("System.Int32 System.String.Length { get; }", semanticInfo.Symbol.ToTestDisplayString());
 4141            Assert.Equal(SymbolKind.Property, semanticInfo.Symbol.Kind);
 4142            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4143
 4144            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4145
 4146            Assert.False(semanticInfo.IsCompileTimeConstant);
 4147        }
 4148
 4149        [Fact]
 4150        public void NotPresentGenericType1()
 4151        {
 4152            string sourceCode = @"
 4153
 4154class Class { void Test() { /*<bind>*/List<int>/*</bind>*/ l; } }
 4155";
 4156            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4157
 4158            Assert.Equal("List<System.Int32>", semanticInfo.Type.ToTestDisplayString());
 4159            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 4160            Assert.Equal("List<System.Int32>", semanticInfo.ConvertedType.ToTestDisplayString());
 4161            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 4162            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4163
 4164            Assert.Null(semanticInfo.Symbol);
 4165            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 4166            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4167
 4168            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4169
 4170            Assert.False(semanticInfo.IsCompileTimeConstant);
 4171        }
 4172
 4173        [Fact]
 4174        public void NotPresentGenericType2()
 4175        {
 4176            string sourceCode = @"
 4177
 4178class Class {
 4179    /*<bind>*/List<int>/*</bind>*/ Test() { return null;}
 4180}
 4181";
 4182            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4183
 4184            Assert.Equal("List<System.Int32>", semanticInfo.Type.ToTestDisplayString());
 4185            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 4186            Assert.Equal("List<System.Int32>", semanticInfo.ConvertedType.ToTestDisplayString());
 4187            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 4188            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4189
 4190            Assert.Null(semanticInfo.Symbol);
 4191            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 4192            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4193
 4194            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4195
 4196            Assert.False(semanticInfo.IsCompileTimeConstant);
 4197        }
 4198
 4199        [Fact]
 4200        public void BadArityConstructorCall()
 4201        {
 4202            string sourceCode = @"
 4203class C<T1>
 4204{
 4205    public void Test()
 4206    {
 4207        C c = new /*<bind>*/C/*</bind>*/();
 4208    }
 4209}
 4210
 4211";
 4212            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(sourceCode);
 4213
 4214            Assert.Null(semanticInfo.Type);
 4215            Assert.Null(semanticInfo.ConvertedType);
 4216            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4217
 4218            Assert.Null(semanticInfo.Symbol);
 4219            Assert.Equal(CandidateReason.WrongArity, semanticInfo.CandidateReason);
 4220            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 4221            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4222            Assert.Equal("C<T1>", sortedCandidates[0].ToTestDisplayString());
 4223            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
 4224
 4225            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4226
 4227            Assert.False(semanticInfo.IsCompileTimeConstant);
 4228        }
 4229
 4230        [Fact]
 4231        public void BadArityConstructorCall2()
 4232        {
 4233            string sourceCode = @"
 4234class C<T1>
 4235{
 4236    public void Test()
 4237    {
 4238        C c = /*<bind>*/new C()/*</bind>*/;
 4239    }
 4240}
 4241
 4242";
 4243            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(sourceCode);
 4244
 4245            Assert.Equal("C<T1>", semanticInfo.Type.ToTestDisplayString());
 4246            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4247            Assert.Equal("C<T1>", semanticInfo.ConvertedType.ToTestDisplayString());
 4248            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4249            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4250
 4251            Assert.Equal("C<T1>..ctor()", semanticInfo.Symbol.ToTestDisplayString());
 4252            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 4253            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4254
 4255            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 4256            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4257            Assert.Equal("C<T1>..ctor()", sortedMethodGroup[0].ToTestDisplayString());
 4258
 4259            Assert.False(semanticInfo.IsCompileTimeConstant);
 4260        }
 4261
 4262        [Fact]
 4263        public void UnresolvedBaseConstructor()
 4264        {
 4265            string sourceCode = @"
 4266class C : B {
 4267    public C(int i) /*<bind>*/: base(i)/*</bind>*/ { }
 4268    public C(string j, string k) : base() { }
 4269}
 4270
 4271class B {
 4272    public B(string a, string b) { }
 4273    public B() { }
 4274    int i; 
 4275}
 4276";
 4277            var semanticInfo = GetSemanticInfoForTest<ConstructorInitializerSyntax>(sourceCode);
 4278
 4279            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 4280            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4281            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 4282            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4283            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4284
 4285            Assert.Null(semanticInfo.Symbol);
 4286            Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason);
 4287            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
 4288            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4289            Assert.Equal("B..ctor()", sortedCandidates[0].ToTestDisplayString());
 4290            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 4291            Assert.Equal("B..ctor(System.String a, System.String b)", sortedCandidates[1].ToTestDisplayString());
 4292            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 4293
 4294            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4295
 4296            Assert.False(semanticInfo.IsCompileTimeConstant);
 4297        }
 4298
 4299        [Fact]
 4300        public void BoundBaseConstructor()
 4301        {
 4302            string sourceCode = @"
 4303class C : B {
 4304    public C(int i) /*<bind>*/: base(""hi"", ""hello"")/*</bind>*/ { }
 4305    public C(string j, string k) : base() { }
 4306}
 4307
 4308class B
 4309{
 4310    public B(string a, string b) { }
 4311    public B() { }
 4312    int i;
 4313}
 4314";
 4315            var semanticInfo = GetSemanticInfoForTest<ConstructorInitializerSyntax>(sourceCode);
 4316
 4317            Assert.Equal("System.Void", semanticInfo.Type.ToTestDisplayString());
 4318            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4319            Assert.Equal("System.Void", semanticInfo.ConvertedType.ToTestDisplayString());
 4320            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4321            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4322
 4323            Assert.Equal("B..ctor(System.String a, System.String b)", semanticInfo.Symbol.ToTestDisplayString());
 4324            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 4325            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4326
 4327            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4328
 4329            Assert.False(semanticInfo.IsCompileTimeConstant);
 4330        }
 4331
 4332        [WorkItem(540998, "DevDiv")]
 4333        [Fact]
 4334        public void DeclarationWithinSwitchStatement()
 4335        {
 4336            string sourceCode =
 4337@"class C
 4338{
 4339    static void M(int i)
 4340    {
 4341        switch (i)
 4342        {
 4343            case 0:
 4344                string name = /*<bind>*/null/*</bind>*/;
 4345                if (name != null)
 4346                {
 4347                }
 4348                break;
 4349        }
 4350    }
 4351}";
 4352            var semanticInfo = GetSemanticInfoForTest(sourceCode);
 4353            Assert.NotNull(semanticInfo);
 4354        }
 4355
 4356        [WorkItem(537573, "DevDiv")]
 4357        [Fact]
 4358        public void UndeclaredTypeAndCheckContainingSymbol()
 4359        {
 4360            string sourceCode = @"
 4361class C1
 4362{
 4363    void M()
 4364    {
 4365        /*<bind>*/F/*</bind>*/ f;
 4366    }
 4367}
 4368";
 4369            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4370
 4371            Assert.Equal("F", semanticInfo.Type.ToTestDisplayString());
 4372            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 4373            Assert.Equal("F", semanticInfo.ConvertedType.ToTestDisplayString());
 4374            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 4375            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4376
 4377            Assert.Null(semanticInfo.Symbol);
 4378            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 4379            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4380
 4381            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4382
 4383            Assert.False(semanticInfo.IsCompileTimeConstant);
 4384
 4385            Assert.Equal(SymbolKind.Namespace, semanticInfo.Type.ContainingSymbol.Kind);
 4386            Assert.True(((NamespaceSymbol)semanticInfo.Type.ContainingSymbol).IsGlobalNamespace);
 4387        }
 4388
 4389        [WorkItem(538538, "DevDiv")]
 4390        [Fact]
 4391        public void AliasQualifier()
 4392        {
 4393            string sourceCode = @"
 4394using X = A;
 4395namespace A.B { }
 4396namespace N
 4397{
 4398using /*<bind>*/X/*</bind>*/::B;
 4399class X { }
 4400}
 4401";
 4402            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4403
 4404            Assert.Null(semanticInfo.Type);
 4405            Assert.Null(semanticInfo.ConvertedType);
 4406            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4407
 4408            Assert.NotNull(semanticInfo.Symbol);
 4409            Assert.Equal("A", semanticInfo.Symbol.ToTestDisplayString());
 4410            Assert.Equal(SymbolKind.Namespace, semanticInfo.Symbol.Kind);
 4411            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4412
 4413            var aliasInfo = GetAliasInfoForTest(sourceCode);
 4414            Assert.NotNull(aliasInfo);
 4415            Assert.Equal("X=A", aliasInfo.ToTestDisplayString());
 4416            Assert.Equal(SymbolKind.Alias, aliasInfo.Kind);
 4417
 4418            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4419
 4420            Assert.False(semanticInfo.IsCompileTimeConstant);
 4421        }
 4422
 4423        [Fact]
 4424        public void AliasQualifier2()
 4425        {
 4426            string sourceCode = @"
 4427using S = System.String;
 4428
 4429{
 4430    class X 
 4431    { 
 4432        void Foo()
 4433        {
 4434            string x;
 4435            x = /*<bind>*/S/*</bind>*/.Empty;
 4436        }
 4437    }
 4438}
 4439";
 4440            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4441
 4442            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 4443            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4444            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 4445            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4446            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4447
 4448            Assert.NotNull(semanticInfo.Symbol);
 4449            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4450
 4451            var aliasInfo = GetAliasInfoForTest(sourceCode);
 4452            Assert.Equal("S=System.String", aliasInfo.ToTestDisplayString());
 4453            Assert.Equal(SymbolKind.Alias, aliasInfo.Kind);
 4454            Assert.Equal("String", aliasInfo.Target.Name);
 4455
 4456            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4457
 4458            Assert.False(semanticInfo.IsCompileTimeConstant);
 4459        }
 4460
 4461        [Fact]
 4462        public void PropertyAccessor()
 4463        {
 4464            string sourceCode = @"
 4465class C
 4466{
 4467    private object p = null;
 4468    internal object P { set { p = /*<bind>*/value/*</bind>*/; } }
 4469}
 4470";
 4471            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4472
 4473            Assert.Equal("System.Object", semanticInfo.Type.ToTestDisplayString());
 4474            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4475            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 4476            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4477            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4478
 4479            Assert.Equal("System.Object value", semanticInfo.Symbol.ToTestDisplayString());
 4480            Assert.Equal(SymbolKind.Parameter, semanticInfo.Symbol.Kind);
 4481            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4482
 4483            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4484
 4485            Assert.False(semanticInfo.IsCompileTimeConstant);
 4486        }
 4487
 4488        [Fact]
 4489        public void IndexerAccessorValue()
 4490        {
 4491            string sourceCode =
 4492@"class C
 4493{
 4494    string[] values = new string[10];
 4495    internal string this[int i]
 4496    {
 4497        get { return values[i]; }
 4498        set { values[i] = /*<bind>*/value/*</bind>*/; }
 4499    }
 4500}";
 4501            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4502            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 4503            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 4504            Assert.Equal("System.String value", semanticInfo.Symbol.ToTestDisplayString());
 4505        }
 4506
 4507        [Fact]
 4508        public void IndexerAccessorParameter()
 4509        {
 4510            string sourceCode =
 4511@"class C
 4512{
 4513    string[] values = new string[10];
 4514    internal string this[short i]
 4515    {
 4516        get { return values[/*<bind>*/i/*</bind>*/]; }
 4517    }
 4518}";
 4519            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4520            Assert.Equal("System.Int16", semanticInfo.Type.ToTestDisplayString());
 4521            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4522            Assert.Equal("System.Int16 i", semanticInfo.Symbol.ToTestDisplayString());
 4523        }
 4524
 4525        [Fact]
 4526        public void IndexerAccessNamedParameter()
 4527        {
 4528            string sourceCode =
 4529@"class C
 4530{
 4531    string[] values = new string[10];
 4532    internal string this[short i]
 4533    {
 4534        get { return values[i]; }
 4535    }
 4536    void Method()
 4537    {
 4538        string s = this[/*<bind>*/i/*</bind>*/: 0];
 4539    }
 4540}";
 4541            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4542            Assert.NotNull(semanticInfo);
 4543            Assert.Null(semanticInfo.Type);
 4544            Assert.Null(semanticInfo.ConvertedType);
 4545
 4546            var symbol = semanticInfo.Symbol;
 4547            Assert.Equal(SymbolKind.Parameter, symbol.Kind);
 4548            Assert.True(symbol.ContainingSymbol.Kind == SymbolKind.Property && ((IPropertySymbol)symbol.ContainingSymbol).IsIndexer);
 4549            Assert.Equal("System.Int16 i", symbol.ToTestDisplayString());
 4550        }
 4551
 4552        [Fact]
 4553        public void LocalConstant()
 4554        {
 4555            string sourceCode = @"
 4556class C
 4557{
 4558    static void M()
 4559    {
 4560        const int i = 1;
 4561        const int j = i + 1;
 4562        const int k = /*<bind>*/j/*</bind>*/ - 2;
 4563    }
 4564}
 4565";
 4566            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4567
 4568            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 4569            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4570            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4571            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4572            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4573
 4574            Assert.Equal("System.Int32 j", semanticInfo.Symbol.ToTestDisplayString());
 4575            Assert.Equal(SymbolKind.Local, semanticInfo.Symbol.Kind);
 4576            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4577
 4578            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4579
 4580            Assert.True(semanticInfo.IsCompileTimeConstant);
 4581            Assert.Equal(2, semanticInfo.ConstantValue);
 4582
 4583            var symbol = (LocalSymbol)semanticInfo.Symbol;
 4584            Assert.True(symbol.HasConstantValue);
 4585            Assert.Equal(2, symbol.ConstantValue);
 4586        }
 4587
 4588        [Fact]
 4589        public void FieldConstant()
 4590        {
 4591            string sourceCode = @"
 4592class C
 4593{
 4594    const int i = 1;
 4595    const int j = i + 1;
 4596    static void M()
 4597    {
 4598        const int k = /*<bind>*/j/*</bind>*/ - 2;
 4599    }
 4600}
 4601";
 4602            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4603
 4604            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 4605            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4606            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4607            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4608            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4609
 4610            Assert.Equal("System.Int32 C.j", semanticInfo.Symbol.ToTestDisplayString());
 4611            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 4612            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4613
 4614            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4615
 4616            Assert.True(semanticInfo.IsCompileTimeConstant);
 4617            Assert.Equal(2, semanticInfo.ConstantValue);
 4618
 4619            var symbol = (FieldSymbol)semanticInfo.Symbol;
 4620            Assert.Equal("j", symbol.Name);
 4621            Assert.True(symbol.HasConstantValue);
 4622            Assert.Equal(2, symbol.ConstantValue);
 4623        }
 4624
 4625        [Fact]
 4626        public void FieldInitializer()
 4627        {
 4628            string sourceCode = @"
 4629class C
 4630{
 4631    int F = /*<bind>*/G() + 1/*</bind>*/;
 4632    static int G()
 4633    {
 4634        return 1;
 4635    }
 4636}
 4637";
 4638            var semanticInfo = GetSemanticInfoForTest<BinaryExpressionSyntax>(sourceCode);
 4639
 4640            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 4641            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4642            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4643            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4644            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4645
 4646            Assert.Equal("System.Int32 System.Int32.op_Addition(System.Int32 left, System.Int32 right)", semanticInfo.Symbol.ToTestDisplayString());
 4647            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 4648            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4649
 4650            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4651
 4652            Assert.False(semanticInfo.IsCompileTimeConstant);
 4653        }
 4654
 4655        [Fact]
 4656        public void EnumConstant()
 4657        {
 4658            string sourceCode = @"
 4659enum E { A, B, C, D = B }
 4660class C
 4661{
 4662    static void M(E e)
 4663    {
 4664        M(/*<bind>*/E.C/*</bind>*/);
 4665    }
 4666}
 4667";
 4668            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 4669
 4670            Assert.Equal("E", semanticInfo.Type.ToTestDisplayString());
 4671            Assert.Equal(TypeKind.Enum, semanticInfo.Type.TypeKind);
 4672            Assert.Equal("E", semanticInfo.ConvertedType.ToTestDisplayString());
 4673            Assert.Equal(TypeKind.Enum, semanticInfo.ConvertedType.TypeKind);
 4674            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4675
 4676            Assert.Equal("E.C", semanticInfo.Symbol.ToTestDisplayString());
 4677            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 4678            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4679
 4680            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4681
 4682            Assert.True(semanticInfo.IsCompileTimeConstant);
 4683            Assert.Equal(2, semanticInfo.ConstantValue);
 4684
 4685            var symbol = (SourceEnumConstantSymbol)semanticInfo.Symbol;
 4686            Assert.Equal("C", symbol.Name);
 4687            Assert.True(symbol.HasConstantValue);
 4688            Assert.Equal(2, symbol.ConstantValue);
 4689        }
 4690
 4691        [Fact]
 4692        public void BadEnumConstant()
 4693        {
 4694            string sourceCode = @"
 4695enum E { W = Z, X, Y }
 4696class C
 4697{
 4698    static void M(E e)
 4699    {
 4700        M(/*<bind>*/E.Y/*</bind>*/);
 4701    }
 4702}
 4703";
 4704            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 4705
 4706            Assert.Equal("E", semanticInfo.Type.ToTestDisplayString());
 4707            Assert.Equal(TypeKind.Enum, semanticInfo.Type.TypeKind);
 4708            Assert.Equal("E", semanticInfo.ConvertedType.ToTestDisplayString());
 4709            Assert.Equal(TypeKind.Enum, semanticInfo.ConvertedType.TypeKind);
 4710            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4711
 4712            Assert.Equal("E.Y", semanticInfo.Symbol.ToTestDisplayString());
 4713            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 4714            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4715
 4716            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4717
 4718            Assert.False(semanticInfo.IsCompileTimeConstant);
 4719
 4720            var symbol = (SourceEnumConstantSymbol)semanticInfo.Symbol;
 4721            Assert.Equal("Y", symbol.Name);
 4722            Assert.False(symbol.HasConstantValue);
 4723        }
 4724
 4725        [Fact]
 4726        public void CircularEnumConstant01()
 4727        {
 4728            string sourceCode = @"
 4729enum E { A = B, B }
 4730class C
 4731{
 4732    static void M(E e)
 4733    {
 4734        M(/*<bind>*/E.B/*</bind>*/);
 4735    }
 4736}
 4737";
 4738            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 4739
 4740            Assert.Equal("E", semanticInfo.Type.ToTestDisplayString());
 4741            Assert.Equal(TypeKind.Enum, semanticInfo.Type.TypeKind);
 4742            Assert.Equal("E", semanticInfo.ConvertedType.ToTestDisplayString());
 4743            Assert.Equal(TypeKind.Enum, semanticInfo.ConvertedType.TypeKind);
 4744            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4745
 4746            Assert.Equal("E.B", semanticInfo.Symbol.ToTestDisplayString());
 4747            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 4748            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4749
 4750            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4751
 4752            Assert.False(semanticInfo.IsCompileTimeConstant);
 4753
 4754            var symbol = (SourceEnumConstantSymbol)semanticInfo.Symbol;
 4755            Assert.Equal("B", symbol.Name);
 4756            Assert.False(symbol.HasConstantValue);
 4757        }
 4758
 4759        [Fact]
 4760        public void CircularEnumConstant02()
 4761        {
 4762            string sourceCode = @"
 4763enum E { A = 10, B = C, C, D }
 4764class C
 4765{
 4766    static void M(E e)
 4767    {
 4768        M(/*<bind>*/E.D/*</bind>*/);
 4769    }
 4770}
 4771";
 4772            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 4773
 4774            Assert.Equal("E", semanticInfo.Type.ToTestDisplayString());
 4775            Assert.Equal(TypeKind.Enum, semanticInfo.Type.TypeKind);
 4776            Assert.Equal("E", semanticInfo.ConvertedType.ToTestDisplayString());
 4777            Assert.Equal(TypeKind.Enum, semanticInfo.ConvertedType.TypeKind);
 4778            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4779
 4780            Assert.Equal("E.D", semanticInfo.Symbol.ToTestDisplayString());
 4781            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 4782            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4783
 4784            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4785
 4786            Assert.False(semanticInfo.IsCompileTimeConstant);
 4787
 4788            var symbol = (SourceEnumConstantSymbol)semanticInfo.Symbol;
 4789            Assert.Equal("D", symbol.Name);
 4790            Assert.False(symbol.HasConstantValue);
 4791        }
 4792
 4793        [Fact]
 4794        public void EnumInitializer()
 4795        {
 4796            string sourceCode = @"
 4797enum E { A, B = 3 }
 4798enum F { C, D = 1 + /*<bind>*/E.B/*</bind>*/ }
 4799
 4800";
 4801            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 4802
 4803            Assert.Equal("E", semanticInfo.Type.ToTestDisplayString());
 4804            Assert.Equal(TypeKind.Enum, semanticInfo.Type.TypeKind);
 4805            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4806            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4807            Assert.Equal(ConversionKind.ImplicitNumeric, semanticInfo.ImplicitConversion.Kind);
 4808
 4809            Assert.Equal("E.B", semanticInfo.Symbol.ToTestDisplayString());
 4810            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 4811            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4812
 4813            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4814
 4815            Assert.True(semanticInfo.IsCompileTimeConstant);
 4816            Assert.Equal(3, semanticInfo.ConstantValue);
 4817
 4818            var symbol = (SourceEnumConstantSymbol)semanticInfo.Symbol;
 4819            Assert.Equal("B", symbol.Name);
 4820            Assert.True(symbol.HasConstantValue);
 4821            Assert.Equal(3, symbol.ConstantValue);
 4822        }
 4823
 4824        [Fact]
 4825        public void ParameterOfExplicitInterfaceImplementation()
 4826        {
 4827            string sourceCode = @"
 4828class Class : System.IFormattable
 4829{
 4830    string System.IFormattable.ToString(string format, System.IFormatProvider formatProvider)
 4831    {
 4832        return /*<bind>*/format/*</bind>*/;
 4833    }
 4834}
 4835";
 4836            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4837
 4838            Assert.Equal("System.String", semanticInfo.Type.ToTestDisplayString());
 4839            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4840            Assert.Equal("System.String", semanticInfo.ConvertedType.ToTestDisplayString());
 4841            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4842            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4843
 4844            Assert.Equal("System.String format", semanticInfo.Symbol.ToTestDisplayString());
 4845            Assert.Equal(SymbolKind.Parameter, semanticInfo.Symbol.Kind);
 4846            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4847
 4848            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4849
 4850            Assert.False(semanticInfo.IsCompileTimeConstant);
 4851        }
 4852
 4853        [Fact]
 4854        public void BaseConstructorInitializer()
 4855        {
 4856            string sourceCode = @"
 4857class Class
 4858{
 4859    Class(int x) : this(/*<bind>*/x/*</bind>*/ , x) { }
 4860    Class(int x, int y) { }
 4861}
 4862";
 4863            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4864
 4865            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 4866            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 4867            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 4868            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 4869            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4870
 4871            Assert.Equal("System.Int32 x", semanticInfo.Symbol.ToTestDisplayString());
 4872            Assert.Equal(SymbolKind.Parameter, semanticInfo.Symbol.Kind);
 4873            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 4874            Assert.Equal(MethodKind.Constructor, ((MethodSymbol)semanticInfo.Symbol.ContainingSymbol).MethodKind);
 4875
 4876            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 4877
 4878            Assert.False(semanticInfo.IsCompileTimeConstant);
 4879
 4880            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.ContainingSymbol.Kind);
 4881            Assert.Equal(MethodKind.Constructor, ((MethodSymbol)semanticInfo.Symbol.ContainingSymbol).MethodKind);
 4882        }
 4883
 4884        [WorkItem(541011, "DevDiv")]
 4885        [WorkItem(527831, "DevDiv")]
 4886        [WorkItem(538794, "DevDiv")]
 4887        [Fact]
 4888        public void InaccessibleMethodGroup()
 4889        {
 4890            string sourceCode = @"
 4891class C
 4892{
 4893    private static void M(long i) { }
 4894    private static void M(int i) { }
 4895}
 4896class D
 4897{
 4898    void Foo()
 4899    {
 4900        C./*<bind>*/M/*</bind>*/(1);
 4901    }
 4902}
 4903";
 4904            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 4905
 4906            Assert.Null(semanticInfo.Type);
 4907            Assert.Null(semanticInfo.ConvertedType);
 4908            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4909
 4910            Assert.Null(semanticInfo.Symbol);
 4911            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
 4912            Assert.Equal(2, semanticInfo.CandidateSymbols.Length);
 4913            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4914            Assert.Equal("void C.M(System.Int32 i)", sortedCandidates[0].ToTestDisplayString());
 4915            Assert.Equal("void C.M(System.Int64 i)", sortedCandidates[1].ToTestDisplayString());
 4916            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 4917            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 4918
 4919            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 4920            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4921            Assert.Equal("void C.M(System.Int32 i)", sortedMethodGroup[0].ToTestDisplayString());
 4922            Assert.Equal("void C.M(System.Int64 i)", sortedMethodGroup[1].ToTestDisplayString());
 4923
 4924            Assert.False(semanticInfo.IsCompileTimeConstant);
 4925        }
 4926
 4927        [WorkItem(542782, "DevDiv")]
 4928        [Fact]
 4929        public void InaccessibleMethodGroup_Constructors_ObjectCreationExpressionSyntax()
 4930        {
 4931            string sourceCode = @"
 4932using System;
 4933
 4934class Program
 4935{
 4936    public static void Main(string[] args)
 4937    {
 4938        var x = /*<bind>*/new Class1(3, 7)/*</bind>*/;
 4939    }
 4940}
 4941
 4942class Class1
 4943{
 4944    protected Class1() { }
 4945    protected Class1(int x) { }
 4946    private Class1(int a, long b) { }
 4947}
 4948";
 4949            var semanticInfo = GetSemanticInfoForTest<ObjectCreationExpressionSyntax>(sourceCode);
 4950
 4951            Assert.Equal("Class1", semanticInfo.Type.ToTestDisplayString());
 4952            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 4953            Assert.Equal("Class1", semanticInfo.ConvertedType.ToTestDisplayString());
 4954            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 4955            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 4956
 4957            Assert.Null(semanticInfo.Symbol);
 4958            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
 4959            Assert.Equal(3, semanticInfo.CandidateSymbols.Length);
 4960            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4961            Assert.Equal("Class1..ctor()", sortedCandidates[0].ToTestDisplayString());
 4962            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 4963            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedCandidates[1].ToTestDisplayString());
 4964            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 4965            Assert.Equal("Class1..ctor(System.Int32 x)", sortedCandidates[2].ToTestDisplayString());
 4966            Assert.Equal(SymbolKind.Method, sortedCandidates[2].Kind);
 4967
 4968            Assert.Equal(3, semanticInfo.MethodGroup.Length);
 4969            sortedCandidates = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 4970            Assert.Equal("Class1..ctor()", sortedCandidates[0].ToTestDisplayString());
 4971            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 4972            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedCandidates[1].ToTestDisplayString());
 4973            Assert.Equal(SymbolKind.Method, sortedCandidates[1].Kind);
 4974            Assert.Equal("Class1..ctor(System.Int32 x)", sortedCandidates[2].ToTestDisplayString());
 4975            Assert.Equal(SymbolKind.Method, sortedCandidates[2].Kind);
 4976
 4977            Assert.False(semanticInfo.IsCompileTimeConstant);
 4978        }
 4979
 4980        [WorkItem(542782, "DevDiv")]
 4981        [Fact]
 4982        public void InaccessibleMethodGroup_Constructors_IdentifierNameSyntax()
 4983        {
 4984            string sourceCode = @"
 4985using System;
 4986
 4987class Program
 4988{
 4989    public static void Main(string[] args)
 4990    {
 4991        var x = new /*<bind>*/Class1/*</bind>*/(3, 7);
 4992    }
 4993}
 4994
 4995class Class1
 4996{
 4997    protected Class1() { }
 4998    protected Class1(int x) { }
 4999    private Class1(int a, long b) { }
 5000}
 5001";
 5002            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5003
 5004            Assert.Null(semanticInfo.Type);
 5005            Assert.Null(semanticInfo.ConvertedType);
 5006            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5007
 5008            Assert.Equal("Class1", semanticInfo.Symbol.ToTestDisplayString());
 5009            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 5010            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5011
 5012            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5013
 5014            Assert.False(semanticInfo.IsCompileTimeConstant);
 5015        }
 5016
 5017        [WorkItem(542782, "DevDiv")]
 5018        [Fact]
 5019        public void InaccessibleMethodGroup_AttributeSyntax()
 5020        {
 5021            string sourceCode = @"
 5022using System;
 5023
 5024class Program
 5025{
 5026    [/*<bind>*/Class1(3, 7)/*</bind>*/]
 5027    public static void Main(string[] args)
 5028    {
 5029    }
 5030}
 5031
 5032class Class1 : Attribute
 5033{
 5034    protected Class1() { }
 5035    protected Class1(int x) { }
 5036    private Class1(int a, long b) { }
 5037}
 5038";
 5039            var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode);
 5040
 5041            Assert.Equal("Class1", semanticInfo.Type.ToTestDisplayString());
 5042            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 5043            Assert.Equal("Class1", semanticInfo.ConvertedType.ToTestDisplayString());
 5044            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5045            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5046
 5047            Assert.Null(semanticInfo.Symbol);
 5048            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
 5049
 5050            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 5051            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5052            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedCandidates[0].ToTestDisplayString());
 5053            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 5054
 5055            Assert.Equal(3, semanticInfo.MethodGroup.Length);
 5056            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5057            Assert.Equal("Class1..ctor()", sortedMethodGroup[0].ToTestDisplayString());
 5058            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedMethodGroup[1].ToTestDisplayString());
 5059            Assert.Equal("Class1..ctor(System.Int32 x)", sortedMethodGroup[2].ToTestDisplayString());
 5060
 5061            Assert.False(semanticInfo.IsCompileTimeConstant);
 5062        }
 5063
 5064        [WorkItem(542782, "DevDiv")]
 5065        [Fact]
 5066        public void InaccessibleMethodGroup_Attribute_IdentifierNameSyntax()
 5067        {
 5068            string sourceCode = @"
 5069using System;
 5070
 5071class Program
 5072{
 5073    [/*<bind>*/Class1/*</bind>*/(3, 7)]
 5074    public static void Main(string[] args)
 5075    {
 5076    }
 5077}
 5078
 5079class Class1 : Attribute
 5080{
 5081    protected Class1() { }
 5082    protected Class1(int x) { }
 5083    private Class1(int a, long b) { }
 5084}
 5085";
 5086            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5087
 5088            Assert.Equal("Class1", semanticInfo.Type.ToTestDisplayString());
 5089            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 5090            Assert.Equal("Class1", semanticInfo.ConvertedType.ToTestDisplayString());
 5091            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5092            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5093
 5094            Assert.Null(semanticInfo.Symbol);
 5095            Assert.Equal(CandidateReason.Inaccessible, semanticInfo.CandidateReason);
 5096            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 5097            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5098            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedCandidates[0].ToTestDisplayString());
 5099            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 5100
 5101            Assert.Equal(3, semanticInfo.MethodGroup.Length);
 5102            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5103            Assert.Equal("Class1..ctor()", sortedMethodGroup[0].ToTestDisplayString());
 5104            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedMethodGroup[1].ToTestDisplayString());
 5105            Assert.Equal("Class1..ctor(System.Int32 x)", sortedMethodGroup[2].ToTestDisplayString());
 5106
 5107            Assert.False(semanticInfo.IsCompileTimeConstant);
 5108        }
 5109
 5110        [WorkItem(542782, "DevDiv")]
 5111        [Fact]
 5112        public void InaccesibleConstructorsFiltered_ObjectCreationExpressionSyntax()
 5113        {
 5114            string sourceCode = @"
 5115using System;
 5116
 5117class Program
 5118{
 5119    public static void Main(string[] args)
 5120    {
 5121        var x = /*<bind>*/new Class1(3, 7)/*</bind>*/;
 5122    }
 5123}
 5124
 5125class Class1
 5126{
 5127    protected Class1() { }
 5128    public Class1(int x) { }
 5129    public Class1(int a, long b) { }
 5130}
 5131";
 5132            var semanticInfo = GetSemanticInfoForTest<ObjectCreationExpressionSyntax>(sourceCode);
 5133
 5134            Assert.Equal("Class1", semanticInfo.Type.ToTestDisplayString());
 5135            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 5136            Assert.Equal("Class1", semanticInfo.ConvertedType.ToTestDisplayString());
 5137            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5138            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5139
 5140            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", semanticInfo.Symbol.ToTestDisplayString());
 5141            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 5142            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5143
 5144            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 5145            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5146            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedMethodGroup[0].ToTestDisplayString());
 5147            Assert.Equal("Class1..ctor(System.Int32 x)", sortedMethodGroup[1].ToTestDisplayString());
 5148
 5149            Assert.False(semanticInfo.IsCompileTimeConstant);
 5150        }
 5151
 5152        [WorkItem(542782, "DevDiv")]
 5153        [Fact]
 5154        public void InaccesibleConstructorsFiltered_IdentifierNameSyntax()
 5155        {
 5156            string sourceCode = @"
 5157using System;
 5158
 5159class Program
 5160{
 5161    public static void Main(string[] args)
 5162    {
 5163        var x = new /*<bind>*/Class1/*</bind>*/(3, 7);
 5164    }
 5165}
 5166
 5167class Class1
 5168{
 5169    protected Class1() { }
 5170    public Class1(int x) { }
 5171    public Class1(int a, long b) { }
 5172}
 5173";
 5174            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5175
 5176            Assert.Null(semanticInfo.Type);
 5177            Assert.Null(semanticInfo.ConvertedType);
 5178            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5179
 5180            Assert.Equal("Class1", semanticInfo.Symbol.ToTestDisplayString());
 5181            Assert.Equal(SymbolKind.NamedType, semanticInfo.Symbol.Kind);
 5182            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5183
 5184            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5185
 5186            Assert.False(semanticInfo.IsCompileTimeConstant);
 5187        }
 5188
 5189        [WorkItem(542782, "DevDiv")]
 5190        [Fact]
 5191        public void InaccesibleConstructorsFiltered_AttributeSyntax()
 5192        {
 5193            string sourceCode = @"
 5194using System;
 5195
 5196class Program
 5197{
 5198    [/*<bind>*/Class1(3, 7)/*</bind>*/]
 5199    public static void Main(string[] args)
 5200    {
 5201    }
 5202}
 5203
 5204class Class1 : Attribute
 5205{
 5206    protected Class1() { }
 5207    public Class1(int x) { }
 5208    public Class1(int a, long b) { }
 5209}
 5210";
 5211            var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode);
 5212
 5213            Assert.Equal("Class1", semanticInfo.Type.ToTestDisplayString());
 5214            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 5215            Assert.Equal("Class1", semanticInfo.ConvertedType.ToTestDisplayString());
 5216            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5217            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5218
 5219            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", semanticInfo.Symbol.ToTestDisplayString());
 5220            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 5221            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5222
 5223            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 5224            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5225            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedMethodGroup[0].ToTestDisplayString());
 5226            Assert.Equal("Class1..ctor(System.Int32 x)", sortedMethodGroup[1].ToTestDisplayString());
 5227
 5228            Assert.False(semanticInfo.IsCompileTimeConstant);
 5229        }
 5230
 5231        [WorkItem(542782, "DevDiv")]
 5232        [Fact]
 5233        public void InaccesibleConstructorsFiltered_Attribute_IdentifierNameSyntax()
 5234        {
 5235            string sourceCode = @"
 5236using System;
 5237
 5238class Program
 5239{
 5240    [/*<bind>*/Class1/*</bind>*/(3, 7)]
 5241    public static void Main(string[] args)
 5242    {
 5243    }
 5244}
 5245
 5246class Class1 : Attribute
 5247{
 5248    protected Class1() { }
 5249    public Class1(int x) { }
 5250    public Class1(int a, long b) { }
 5251}
 5252";
 5253            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5254
 5255            Assert.Equal("Class1", semanticInfo.Type.ToTestDisplayString());
 5256            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 5257            Assert.Equal("Class1", semanticInfo.ConvertedType.ToTestDisplayString());
 5258            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5259            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5260
 5261            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", semanticInfo.Symbol.ToTestDisplayString());
 5262            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 5263            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5264
 5265            Assert.Equal(2, semanticInfo.MethodGroup.Length);
 5266            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5267            Assert.Equal("Class1..ctor(System.Int32 a, System.Int64 b)", sortedMethodGroup[0].ToTestDisplayString());
 5268            Assert.Equal("Class1..ctor(System.Int32 x)", sortedMethodGroup[1].ToTestDisplayString());
 5269
 5270            Assert.False(semanticInfo.IsCompileTimeConstant);
 5271        }
 5272
 5273        [WorkItem(528754, "DevDiv")]
 5274        [Fact]
 5275        public void SyntaxErrorInReceiver()
 5276        {
 5277            string sourceCode = @"
 5278public delegate int D(int x);
 5279public class C
 5280{
 5281    public C(int i) { }
 5282    public void M(D d) { }
 5283}
 5284class Main
 5285{
 5286    void Foo(int a)
 5287    {
 5288        new C(a.).M(x => /*<bind>*/x/*</bind>*/);
 5289    }
 5290}";
 5291            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5292            Assert.Equal(SpecialType.System_Int32, semanticInfo.Type.SpecialType);
 5293        }
 5294
 5295        [WorkItem(528754, "DevDiv")]
 5296        [Fact]
 5297        public void SyntaxErrorInReceiverWithExtension()
 5298        {
 5299            string sourceCode = @"
 5300public delegate int D(int x);
 5301public static class CExtensions
 5302{
 5303    public static void M(this C c, D d) { }
 5304}
 5305public class C
 5306{
 5307    public C(int i) { }
 5308}
 5309class Main
 5310{
 5311    void Foo(int a)
 5312    {
 5313        new C(a.).M(x => /*<bind>*/x/*</bind>*/);
 5314    }
 5315}";
 5316            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5317            Assert.Equal(SpecialType.System_Int32, semanticInfo.Type.SpecialType);
 5318        }
 5319
 5320        [WorkItem(541011, "DevDiv")]
 5321        [Fact]
 5322        public void NonStaticInstanceMismatchMethodGroup()
 5323        {
 5324            string sourceCode = @"
 5325class C
 5326{
 5327    public static int P { get; set; }
 5328}
 5329class D
 5330{
 5331    void Foo()
 5332    {
 5333        C./*<bind>*/set_P/*</bind>*/(1);
 5334    }
 5335}
 5336";
 5337            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5338
 5339            Assert.Null(semanticInfo.Type);
 5340            Assert.Null(semanticInfo.ConvertedType);
 5341            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5342
 5343            Assert.Null(semanticInfo.Symbol);
 5344            Assert.Equal(CandidateReason.NotReferencable, semanticInfo.CandidateReason);
 5345            Assert.Equal(1, semanticInfo.CandidateSymbols.Length);
 5346            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5347            Assert.Equal("void C.P.set", sortedCandidates[0].ToTestDisplayString());
 5348            Assert.Equal(SymbolKind.Method, sortedCandidates[0].Kind);
 5349            Assert.Equal(MethodKind.PropertySet, ((MethodSymbol)sortedCandidates[0]).MethodKind);
 5350
 5351            Assert.Equal(1, semanticInfo.MethodGroup.Length);
 5352            var sortedMethodGroup = semanticInfo.MethodGroup.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5353            Assert.Equal("void C.P.set", sortedMethodGroup[0].ToTestDisplayString());
 5354
 5355            Assert.False(semanticInfo.IsCompileTimeConstant);
 5356        }
 5357
 5358        [WorkItem(540360, "DevDiv")]
 5359        [Fact]
 5360        public void DuplicateTypeName()
 5361        {
 5362            string sourceCode = @"
 5363struct C { }
 5364class C
 5365{
 5366    public static void M() { }
 5367}
 5368enum C { A, B }
 5369class D
 5370{
 5371    static void Main()
 5372    {
 5373        /*<bind>*/C/*</bind>*/.M();
 5374    }
 5375}
 5376";
 5377            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5378
 5379            Assert.Equal("C", semanticInfo.Type.ToTestDisplayString());
 5380            Assert.Equal(TypeKind.Error, semanticInfo.Type.TypeKind);
 5381            Assert.Equal("C", semanticInfo.ConvertedType.ToTestDisplayString());
 5382            Assert.Equal(TypeKind.Error, semanticInfo.ConvertedType.TypeKind);
 5383            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5384
 5385            Assert.Null(semanticInfo.Symbol);
 5386            Assert.Equal(CandidateReason.Ambiguous, semanticInfo.CandidateReason);
 5387            Assert.Equal(3, semanticInfo.CandidateSymbols.Length);
 5388            var sortedCandidates = semanticInfo.CandidateSymbols.OrderBy(s => s.ToTestDisplayString()).ToArray();
 5389            Assert.Equal("C", sortedCandidates[0].ToTestDisplayString());
 5390            Assert.Equal(SymbolKind.NamedType, sortedCandidates[0].Kind);
 5391            Assert.Equal("C", sortedCandidates[1].ToTestDisplayString());
 5392            Assert.Equal(SymbolKind.NamedType, sortedCandidates[1].Kind);
 5393            Assert.Equal("C", sortedCandidates[2].ToTestDisplayString());
 5394            Assert.Equal(SymbolKind.NamedType, sortedCandidates[2].Kind);
 5395
 5396            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5397
 5398            Assert.False(semanticInfo.IsCompileTimeConstant);
 5399        }
 5400
 5401        [Fact]
 5402        public void IfCondition()
 5403        {
 5404            string sourceCode = @"
 5405class C 
 5406{
 5407  void M(int x)
 5408  {
 5409    if (/*<bind>*/x == 10/*</bind>*/) {}
 5410  }
 5411}
 5412";
 5413            var semanticInfo = GetSemanticInfoForTest<BinaryExpressionSyntax>(sourceCode);
 5414
 5415            Assert.Equal("System.Boolean", semanticInfo.Type.ToTestDisplayString());
 5416            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5417            Assert.Equal("System.Boolean", semanticInfo.ConvertedType.ToTestDisplayString());
 5418            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5419            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5420
 5421            Assert.Equal("System.Boolean System.Int32.op_Equality(System.Int32 left, System.Int32 right)", semanticInfo.Symbol.ToTestDisplayString());
 5422            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 5423            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5424
 5425            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5426
 5427            Assert.False(semanticInfo.IsCompileTimeConstant);
 5428        }
 5429
 5430        [Fact]
 5431        public void ForCondition()
 5432        {
 5433            string sourceCode = @"
 5434class C 
 5435{
 5436  void M(int x)
 5437  {
 5438    for (int i = 0; /*<bind>*/i < 10/*</bind>*/; i = i + 1) { }
 5439  }
 5440}
 5441";
 5442            var semanticInfo = GetSemanticInfoForTest<BinaryExpressionSyntax>(sourceCode);
 5443
 5444            Assert.Equal("System.Boolean", semanticInfo.Type.ToTestDisplayString());
 5445            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5446            Assert.Equal("System.Boolean", semanticInfo.ConvertedType.ToTestDisplayString());
 5447            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5448            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5449
 5450            Assert.Equal("System.Boolean System.Int32.op_LessThan(System.Int32 left, System.Int32 right)", semanticInfo.Symbol.ToTestDisplayString());
 5451            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 5452            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5453
 5454            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5455
 5456            Assert.False(semanticInfo.IsCompileTimeConstant);
 5457        }
 5458
 5459        [WorkItem(539925, "DevDiv")]
 5460        [Fact]
 5461        public void LocalIsFromSource()
 5462        {
 5463            string sourceCode = @"
 5464
 5465class C
 5466{
 5467    void M()
 5468    {
 5469        int x = 1;
 5470        int y = /*<bind>*/x/*</bind>*/;
 5471    }
 5472}
 5473";
 5474            var compilation = CreateCompilationWithMscorlib(sourceCode);
 5475            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(compilation);
 5476
 5477            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 5478            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5479            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 5480            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5481            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5482
 5483            Assert.Equal("System.Int32 x", semanticInfo.Symbol.ToTestDisplayString());
 5484            Assert.Equal(SymbolKind.Local, semanticInfo.Symbol.Kind);
 5485            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5486
 5487            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5488
 5489            Assert.False(semanticInfo.IsCompileTimeConstant);
 5490            Assert.True(((Symbol)semanticInfo.Symbol).IsFromCompilation(compilation));
 5491        }
 5492
 5493        [WorkItem(540541, "DevDiv")]
 5494        [Fact]
 5495        public void InEnumElementInitializer()
 5496        {
 5497            string sourceCode = @"
 5498class C
 5499{
 5500    public const int x = 1;
 5501}
 5502enum E
 5503{
 5504    q = /*<bind>*/C.x/*</bind>*/,
 5505}
 5506";
 5507            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 5508
 5509            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 5510            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5511            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 5512            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5513            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5514
 5515            Assert.Equal("System.Int32 C.x", semanticInfo.Symbol.ToTestDisplayString());
 5516            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 5517            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5518
 5519            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5520
 5521            Assert.True(semanticInfo.IsCompileTimeConstant);
 5522            Assert.Equal(1, semanticInfo.ConstantValue);
 5523        }
 5524
 5525        [WorkItem(540541, "DevDiv")]
 5526        [Fact]
 5527        public void InEnumOfByteElementInitializer()
 5528        {
 5529            string sourceCode = @"
 5530class C
 5531{
 5532    public const int x = 1;
 5533}
 5534enum E : byte
 5535{
 5536    q = /*<bind>*/C.x/*</bind>*/,
 5537}
 5538";
 5539            var semanticInfo = GetSemanticInfoForTest<MemberAccessExpressionSyntax>(sourceCode);
 5540
 5541            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 5542            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5543            Assert.Equal("System.Byte", semanticInfo.ConvertedType.ToTestDisplayString());
 5544            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5545            Assert.Equal(ConversionKind.ImplicitConstant, semanticInfo.ImplicitConversion.Kind);
 5546
 5547            Assert.Equal("System.Int32 C.x", semanticInfo.Symbol.ToTestDisplayString());
 5548            Assert.Equal(SymbolKind.Field, semanticInfo.Symbol.Kind);
 5549            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5550
 5551            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5552
 5553            Assert.True(semanticInfo.IsCompileTimeConstant);
 5554            Assert.Equal(1, semanticInfo.ConstantValue);
 5555        }
 5556
 5557        [WorkItem(540672, "DevDiv")]
 5558        [Fact]
 5559        public void LambdaExprWithErrorTypeInObjectCreationExpression()
 5560        {
 5561            var text = @"
 5562class Program
 5563{
 5564    static int Main()
 5565    {
 5566       var d = /*<bind>*/() => { if (true) return new X(); else return new Y(); }/*</bind>*/;
 5567    }
 5568}
 5569";
 5570            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(text);
 5571            Assert.NotNull(semanticInfo);
 5572            Assert.Null(semanticInfo.Type);
 5573            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 5574        }
 5575
 5576        [Fact]
 5577        public void LambdaExpression()
 5578        {
 5579            string sourceCode = @"
 5580using System;
 5581
 5582public class TestClass
 5583{
 5584    public static void Main()
 5585    {
 5586        Func<string, int> f = /*<bind>*/str => 10/*</bind>*/ ;
 5587    }
 5588}
 5589";
 5590            var semanticInfo = GetSemanticInfoForTest<ExpressionSyntax>(sourceCode);
 5591
 5592            Assert.Null(semanticInfo.Type);
 5593            Assert.Equal("System.Func<System.String, System.Int32>", semanticInfo.ConvertedType.ToTestDisplayString());
 5594            Assert.Equal(TypeKind.Delegate, semanticInfo.ConvertedType.TypeKind);
 5595            Assert.Equal(ConversionKind.AnonymousFunction, semanticInfo.ImplicitConversion.Kind);
 5596
 5597            Assert.Equal("lambda expression", semanticInfo.Symbol.ToTestDisplayString());
 5598            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 5599            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5600
 5601            MethodSymbol lambdaSym = (MethodSymbol)(semanticInfo.Symbol);
 5602            Assert.Equal(1, lambdaSym.Parameters.Length);
 5603            Assert.Equal("str", lambdaSym.Parameters[0].Name);
 5604            Assert.Equal("System.String", lambdaSym.Parameters[0].Type.ToTestDisplayString());
 5605            Assert.Equal("System.Int32", lambdaSym.ReturnType.ToTestDisplayString());
 5606
 5607            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5608
 5609            Assert.False(semanticInfo.IsCompileTimeConstant);
 5610        }
 5611
 5612        [Fact]
 5613        public void UnboundLambdaExpression()
 5614        {
 5615            string sourceCode = @"
 5616using System;
 5617
 5618public class TestClass
 5619{
 5620    public static void Main()
 5621    {
 5622        object f = /*<bind>*/str => 10/*</bind>*/;
 5623    }
 5624}
 5625";
 5626            var semanticInfo = GetSemanticInfoForTest<SimpleLambdaExpressionSyntax>(sourceCode);
 5627
 5628            Assert.Null(semanticInfo.Type);
 5629            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 5630            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5631            Assert.Equal(ConversionKind.NoConversion, semanticInfo.ImplicitConversion.Kind);
 5632
 5633            Assert.Equal("lambda expression", semanticInfo.Symbol.ToTestDisplayString());
 5634            Assert.Equal(SymbolKind.Method, semanticInfo.Symbol.Kind);
 5635            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5636
 5637            MethodSymbol lambdaSym = (MethodSymbol)(semanticInfo.Symbol);
 5638            Assert.Equal(1, lambdaSym.Parameters.Length);
 5639            Assert.Equal("str", lambdaSym.Parameters[0].Name);
 5640            Assert.Equal(TypeKind.Error, lambdaSym.Parameters[0].Type.TypeKind);
 5641            Assert.Equal("System.Int32", lambdaSym.ReturnType.ToTestDisplayString());
 5642
 5643            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5644
 5645            Assert.False(semanticInfo.IsCompileTimeConstant);
 5646        }
 5647
 5648
 5649        [WorkItem(540650, "DevDiv")]
 5650        [Fact]
 5651        public void TypeOfExpression()
 5652        {
 5653            string sourceCode = @"
 5654class C
 5655{
 5656    static void Main()
 5657    {
 5658        System.Console.WriteLine(/*<bind>*/typeof(C)/*</bind>*/);
 5659    }
 5660}
 5661";
 5662            var semanticInfo = GetSemanticInfoForTest<TypeOfExpressionSyntax>(sourceCode);
 5663
 5664            Assert.Equal("System.Type", semanticInfo.Type.ToTestDisplayString());
 5665            Assert.Equal(TypeKind.Class, semanticInfo.Type.TypeKind);
 5666            Assert.Equal("System.Object", semanticInfo.ConvertedType.ToTestDisplayString());
 5667            Assert.Equal(TypeKind.Class, semanticInfo.ConvertedType.TypeKind);
 5668            Assert.Equal(ConversionKind.ImplicitReference, semanticInfo.ImplicitConversion.Kind);
 5669
 5670            Assert.Null(semanticInfo.Symbol);
 5671            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 5672            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5673
 5674            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5675
 5676            Assert.False(semanticInfo.IsCompileTimeConstant);
 5677        }
 5678
 5679        [WorkItem(540759, "DevDiv")]
 5680        [Fact]
 5681        public void DeclarationEmbeddedStatement_If()
 5682        {
 5683            string sourceCode = @"
 5684class Program
 5685{
 5686    static void Main(string[] args)
 5687    {
 5688        bool c = true;
 5689
 5690        if (c)
 5691            int j = /*<bind>*/43/*</bind>*/;
 5692    }
 5693}
 5694";
 5695            var semanticInfo = GetSemanticInfoForTest<LiteralExpressionSyntax>(sourceCode);
 5696
 5697            Assert.Equal("System.Int32", semanticInfo.Type.ToTestDisplayString());
 5698            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5699            Assert.Equal("System.Int32", semanticInfo.ConvertedType.ToTestDisplayString());
 5700            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5701            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5702
 5703            Assert.Null(semanticInfo.Symbol);
 5704            Assert.Equal(CandidateReason.None, semanticInfo.CandidateReason);
 5705            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5706
 5707            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5708
 5709            Assert.True(semanticInfo.IsCompileTimeConstant);
 5710            Assert.Equal(43, semanticInfo.ConstantValue);
 5711        }
 5712
 5713        [WorkItem(540759, "DevDiv")]
 5714        [Fact]
 5715        public void LabeledEmbeddedStatement_For()
 5716        {
 5717            string sourceCode = @"
 5718class Program
 5719{
 5720    static void Main(string[] args)
 5721    {
 5722        bool c = true;
 5723
 5724        for (; c; c = !c)
 5725            label: /*<bind>*/c/*</bind>*/ = false;
 5726    }
 5727}
 5728";
 5729            var semanticInfo = GetSemanticInfoForTest<IdentifierNameSyntax>(sourceCode);
 5730
 5731            Assert.Equal("System.Boolean", semanticInfo.Type.ToTestDisplayString());
 5732            Assert.Equal(TypeKind.Struct, semanticInfo.Type.TypeKind);
 5733            Assert.Equal("System.Boolean", semanticInfo.ConvertedType.ToTestDisplayString());
 5734            Assert.Equal(TypeKind.Struct, semanticInfo.ConvertedType.TypeKind);
 5735            Assert.Equal(ConversionKind.Identity, semanticInfo.ImplicitConversion.Kind);
 5736
 5737            Assert.Equal("System.Boolean c", semanticInfo.Symbol.ToTestDisplayString());
 5738            Assert.Equal(SymbolKind.Local, semanticInfo.Symbol.Kind);
 5739            Assert.Equal(0, semanticInfo.CandidateSymbols.Length);
 5740
 5741            Assert.Equal(0, semanticInfo.MethodGroup.Length);
 5742
 5743            Assert.False(semanticInfo.IsCompileTimeConstant);
 5744        }
 5745
 5746        [WorkItem(540759, "DevDiv")]
 5747        [Fact]
 5748        public void DeclarationEmbeddedStatement_While()
 5749        {
 5750            string sourceCode = @"
 5751class Program
 5752{
 5753    static void Main(string[] args)
 5754    {
 5755        bool c = true;
 5756
 5757        while (c)
 5758            int j = /*<bind>*/43/*</bind>*/;
 5759    }
 5760}
 5761";
 5762            var semanticInfo = GetSemanticInfoForTest<LiteralExpressionSyntax>(sourceCode);
 5763
 5764            Assert.Equal("System.Int32", semanticInfo.Type