repo_name
stringclasses
6 values
pr_number
int64
512
78.9k
pr_title
stringlengths
3
144
pr_description
stringlengths
0
30.3k
author
stringlengths
2
21
date_created
timestamp[ns, tz=UTC]
date_merged
timestamp[ns, tz=UTC]
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
17
30.4k
filepath
stringlengths
9
210
before_content
stringlengths
0
112M
after_content
stringlengths
0
112M
label
int64
-1
1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_ExtensionMethods.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.Remote.Testing; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AddUsing { public partial class AddUsingTests { [Fact] public async Task TestWhereExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|Where|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.Where } }"); } [Fact] public async Task TestSelectExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|Select|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.Select } }"); } [Fact] public async Task TestGroupByExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|GroupBy|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.GroupBy } }"); } [Fact] public async Task TestJoinExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|Join|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.Join } }"); } [Fact] public async Task RegressionFor8455() { await TestMissingInRegularAndScriptAsync( @"class C { void M() { int dim = (int)Math.[|Min|](); } }"); } [WorkItem(772321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772321")] [Fact] public async Task TestExtensionWithThePresenceOfTheSameNameNonExtensionMethod() { await TestInRegularAndScriptAsync( @"namespace NS1 { class Program { void Main() { [|new C().Goo(4);|] } } class C { public void Goo(string y) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }", @"using NS2; namespace NS1 { class Program { void Main() { new C().Goo(4); } } class C { public void Goo(string y) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }"); } [WorkItem(772321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772321")] [WorkItem(920398, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/920398")] [Fact] public async Task TestExtensionWithThePresenceOfTheSameNameNonExtensionPrivateMethod() { await TestInRegularAndScriptAsync( @"namespace NS1 { class Program { void Main() { [|new C().Goo(4);|] } } class C { private void Goo(int x) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }", @"using NS2; namespace NS1 { class Program { void Main() { new C().Goo(4); } } class C { private void Goo(int x) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }"); } [WorkItem(772321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772321")] [WorkItem(920398, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/920398")] [Fact] public async Task TestExtensionWithThePresenceOfTheSameNameExtensionPrivateMethod() { await TestInRegularAndScriptAsync( @"using NS2; namespace NS1 { class Program { void Main() { [|new C().Goo(4);|] } } class C { } } namespace NS2 { static class CExt { private static void Goo(this NS1.C c, int x) { } } } namespace NS3 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }", @"using NS2; using NS3; namespace NS1 { class Program { void Main() { new C().Goo(4); } } class C { } } namespace NS2 { static class CExt { private static void Goo(this NS1.C c, int x) { } } } namespace NS3 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }"); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|1|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod2() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, 2, [|3|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, 2, 3 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod3() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, [|2|], 3 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, 2, 3 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod4() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, [|{ 4, 5, 6 }|], { 7, 8, 9 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod5() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { 4, 5, 6 }, [|{ 7, 8, 9 }|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod6() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, [|{ '7', '8', '9' }|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod7() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, [|{ ""Four"", ""Five"", ""Six"" }|], { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod8() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|{ 1, 2, 3 }|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod9() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|""This""|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { ""This"" }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod10() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|{ 1, 2, 3 }|], { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod11() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|{ 1, 2, 3 }|], { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", @"using System; using System.Collections; using Ext2; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", index: 1, parseOptions: null); } [WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")] [Fact] public async Task InExtensionMethodUnderConditionalAccessExpression() { var initialText = @"<Workspace> <Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true""> <Document FilePath = ""Program""> namespace Sample { class Program { static void Main(string[] args) { string myString = ""Sample""; var other = myString?[|.StringExtension()|].Substring(0); } } } </Document> <Document FilePath = ""Extensions""> namespace Sample.Extensions { public static class StringExtensions { public static string StringExtension(this string s) { return ""Ok""; } } } </Document> </Project> </Workspace>"; var expectedText = @" using Sample.Extensions; namespace Sample { class Program { static void Main(string[] args) { string myString = ""Sample""; var other = myString?.StringExtension().Substring(0); } } } "; await TestInRegularAndScriptAsync(initialText, expectedText); } [WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")] [Fact] public async Task InExtensionMethodUnderMultipleConditionalAccessExpressions() { var initialText = @"<Workspace> <Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true""> <Document FilePath = ""Program""> public class C { public T F&lt;T&gt;(T x) { return F(new C())?.F(new C())?[|.Extn()|]; } } </Document> <Document FilePath = ""Extensions""> namespace Sample.Extensions { public static class Extensions { public static C Extn(this C obj) { return obj.F(new C()); } } } </Document> </Project> </Workspace>"; var expectedText = @" using Sample.Extensions; public class C { public T F<T>(T x) { return F(new C())?.F(new C())?.Extn(); } } "; await TestInRegularAndScriptAsync(initialText, expectedText); } [WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")] [Fact] public async Task InExtensionMethodUnderMultipleConditionalAccessExpressions2() { var initialText = @"<Workspace> <Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true""> <Document FilePath = ""Program""> public class C { public T F&lt;T&gt;(T x) { return F(new C())?.F(new C())[|.Extn()|]?.F(newC()); } } </Document> <Document FilePath = ""Extensions""> namespace Sample.Extensions { public static class Extensions { public static C Extn(this C obj) { return obj.F(new C()); } } } </Document> </Project> </Workspace>"; var expectedText = @" using Sample.Extensions; public class C { public T F<T>(T x) { return F(new C())?.F(new C()).Extn()?.F(newC()); } } "; await TestInRegularAndScriptAsync(initialText, expectedText); } [Fact] public async Task TestDeconstructExtension() { await TestAsync( @" class Program { void M(Program p) { var (x, y) = [|p|]; } } namespace N { static class E { public static void Deconstruct(this Program p, out int x, out int y) { } } }", @" using N; class Program { void M(Program p) { var (x, y) = [|p|]; } } namespace N { static class E { public static void Deconstruct(this Program p, out int x, out int y) { } } }", parseOptions: null); } [Theory] [CombinatorialData] [WorkItem(16547, "https://github.com/dotnet/roslyn/issues/16547")] public async Task TestAddUsingForAddExtentionMethodWithSameNameAsProperty(TestHost testHost) { await TestAsync( @" namespace A { public class Foo { public void Bar() { var self = this.[|Self()|]; } public Foo Self { get { return this; } } } } namespace A.Extensions { public static class FooExtensions { public static Foo Self(this Foo foo) { return foo; } } }", @" using A.Extensions; namespace A { public class Foo { public void Bar() { var self = this.Self(); } public Foo Self { get { return this; } } } } namespace A.Extensions { public static class FooExtensions { public static Foo Self(this Foo foo) { return foo; } } }", testHost); } [Theory] [CombinatorialData] [WorkItem(39155, "https://github.com/dotnet/roslyn/issues/39155")] public async Task TestExtensionGetAwaiterOverload(TestHost testHost) { await TestAsync( @" using System; using System.Runtime.CompilerServices; namespace A { public class Foo { async void M(Foo foo) { [|await foo|]; } } public static class BarExtensions { public static Extension.FooAwaiter GetAwaiter(this string s) => default; } } namespace A.Extension { public static class FooExtensions { public static FooAwaiter GetAwaiter(this Foo foo) => default; } public struct FooAwaiter : INotifyCompletion { public bool IsCompleted { get; } public void OnCompleted(Action continuation) { } public void GetResult() { } } } ", @" using System; using System.Runtime.CompilerServices; using A.Extension; namespace A { public class Foo { async void M(Foo foo) { await foo; } } public static class BarExtensions { public static Extension.FooAwaiter GetAwaiter(this string s) => default; } } namespace A.Extension { public static class FooExtensions { public static FooAwaiter GetAwaiter(this Foo foo) => default; } public struct FooAwaiter : INotifyCompletion { public bool IsCompleted { get; } public void OnCompleted(Action continuation) { } public void GetResult() { } } } ", testHost); } [Theory] [CombinatorialData] [WorkItem(39155, "https://github.com/dotnet/roslyn/issues/39155")] public async Task TestExtensionSelectOverload(TestHost testHost) { await TestAsync( @" using System; using System.Collections.Generic; namespace A { public class Foo { void M(Foo foo) { _ = [|from x in foo|] select x; } } public static class BarExtensions { public static IEnumerable<int> Select(this string foo, Func<int, int> f) => null; } } namespace A.Extension { public static class FooExtensions { public static IEnumerable<int> Select(this Foo foo, Func<int, int> f) => null; } } ", @" using System; using System.Collections.Generic; using A.Extension; namespace A { public class Foo { void M(Foo foo) { _ = from x in foo select x; } } public static class BarExtensions { public static IEnumerable<int> Select(this string foo, Func<int, int> f) => null; } } namespace A.Extension { public static class FooExtensions { public static IEnumerable<int> Select(this Foo foo, Func<int, int> f) => null; } } ", testHost); } [Fact] public async Task TestExtensionDeconstructOverload() { await TestAsync( @" using System; using System.Collections.Generic; namespace A { public class Foo { void M(Foo foo) { var (x, y) = [|foo|]; } } public static class BarExtensions { public static void Deconstruct(this string foo, out int a, out int b) => throw null; } } namespace A.Extension { public static class FooExtensions { public static void Deconstruct(this Foo foo, out int a, out int b) => throw null; } } ", @" using System; using System.Collections.Generic; using A.Extension; namespace A { public class Foo { void M(Foo foo) { var (x, y) = foo; } } public static class BarExtensions { public static void Deconstruct(this string foo, out int a, out int b) => throw null; } } namespace A.Extension { public static class FooExtensions { public static void Deconstruct(this Foo foo, out int a, out int b) => throw null; } } ", parseOptions: null); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.Remote.Testing; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AddUsing { public partial class AddUsingTests { [Fact] public async Task TestWhereExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|Where|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.Where } }"); } [Fact] public async Task TestSelectExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|Select|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.Select } }"); } [Fact] public async Task TestGroupByExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|GroupBy|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.GroupBy } }"); } [Fact] public async Task TestJoinExtension() { await TestInRegularAndScriptAsync( @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var q = args.[|Join|] } }", @"using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var q = args.Join } }"); } [Fact] public async Task RegressionFor8455() { await TestMissingInRegularAndScriptAsync( @"class C { void M() { int dim = (int)Math.[|Min|](); } }"); } [WorkItem(772321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772321")] [Fact] public async Task TestExtensionWithThePresenceOfTheSameNameNonExtensionMethod() { await TestInRegularAndScriptAsync( @"namespace NS1 { class Program { void Main() { [|new C().Goo(4);|] } } class C { public void Goo(string y) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }", @"using NS2; namespace NS1 { class Program { void Main() { new C().Goo(4); } } class C { public void Goo(string y) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }"); } [WorkItem(772321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772321")] [WorkItem(920398, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/920398")] [Fact] public async Task TestExtensionWithThePresenceOfTheSameNameNonExtensionPrivateMethod() { await TestInRegularAndScriptAsync( @"namespace NS1 { class Program { void Main() { [|new C().Goo(4);|] } } class C { private void Goo(int x) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }", @"using NS2; namespace NS1 { class Program { void Main() { new C().Goo(4); } } class C { private void Goo(int x) { } } } namespace NS2 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }"); } [WorkItem(772321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/772321")] [WorkItem(920398, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/920398")] [Fact] public async Task TestExtensionWithThePresenceOfTheSameNameExtensionPrivateMethod() { await TestInRegularAndScriptAsync( @"using NS2; namespace NS1 { class Program { void Main() { [|new C().Goo(4);|] } } class C { } } namespace NS2 { static class CExt { private static void Goo(this NS1.C c, int x) { } } } namespace NS3 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }", @"using NS2; using NS3; namespace NS1 { class Program { void Main() { new C().Goo(4); } } class C { } } namespace NS2 { static class CExt { private static void Goo(this NS1.C c, int x) { } } } namespace NS3 { static class CExt { public static void Goo(this NS1.C c, int x) { } } }"); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|1|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod2() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, 2, [|3|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, 2, 3 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod3() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, [|2|], 3 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { 1, 2, 3 }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod4() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, [|{ 4, 5, 6 }|], { 7, 8, 9 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod5() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { 4, 5, 6 }, [|{ 7, 8, 9 }|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod6() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, [|{ '7', '8', '9' }|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod7() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, [|{ ""Four"", ""Five"", ""Six"" }|], { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod8() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|{ 1, 2, 3 }|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod9() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|""This""|] }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { ""This"" }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod10() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|{ 1, 2, 3 }|], { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", @"using System; using System.Collections; using Ext; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", parseOptions: null); } [WorkItem(269, "https://github.com/dotnet/roslyn/issues/269")] [Fact] public async Task TestAddUsingForAddExtentionMethod11() { await TestAsync( @"using System; using System.Collections; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { [|{ 1, 2, 3 }|], { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", @"using System; using System.Collections; using Ext2; class X : IEnumerable { public IEnumerator GetEnumerator() { new X { { 1, 2, 3 }, { ""Four"", ""Five"", ""Six"" }, { '7', '8', '9' } }; return null; } } namespace Ext { static class Extensions { public static void Add(this X x, int i) { } } } namespace Ext2 { static class Extensions { public static void Add(this X x, object[] i) { } } }", index: 1, parseOptions: null); } [WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")] [Fact] public async Task InExtensionMethodUnderConditionalAccessExpression() { var initialText = @"<Workspace> <Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true""> <Document FilePath = ""Program""> namespace Sample { class Program { static void Main(string[] args) { string myString = ""Sample""; var other = myString?[|.StringExtension()|].Substring(0); } } } </Document> <Document FilePath = ""Extensions""> namespace Sample.Extensions { public static class StringExtensions { public static string StringExtension(this string s) { return ""Ok""; } } } </Document> </Project> </Workspace>"; var expectedText = @" using Sample.Extensions; namespace Sample { class Program { static void Main(string[] args) { string myString = ""Sample""; var other = myString?.StringExtension().Substring(0); } } } "; await TestInRegularAndScriptAsync(initialText, expectedText); } [WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")] [Fact] public async Task InExtensionMethodUnderMultipleConditionalAccessExpressions() { var initialText = @"<Workspace> <Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true""> <Document FilePath = ""Program""> public class C { public T F&lt;T&gt;(T x) { return F(new C())?.F(new C())?[|.Extn()|]; } } </Document> <Document FilePath = ""Extensions""> namespace Sample.Extensions { public static class Extensions { public static C Extn(this C obj) { return obj.F(new C()); } } } </Document> </Project> </Workspace>"; var expectedText = @" using Sample.Extensions; public class C { public T F<T>(T x) { return F(new C())?.F(new C())?.Extn(); } } "; await TestInRegularAndScriptAsync(initialText, expectedText); } [WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")] [Fact] public async Task InExtensionMethodUnderMultipleConditionalAccessExpressions2() { var initialText = @"<Workspace> <Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true""> <Document FilePath = ""Program""> public class C { public T F&lt;T&gt;(T x) { return F(new C())?.F(new C())[|.Extn()|]?.F(newC()); } } </Document> <Document FilePath = ""Extensions""> namespace Sample.Extensions { public static class Extensions { public static C Extn(this C obj) { return obj.F(new C()); } } } </Document> </Project> </Workspace>"; var expectedText = @" using Sample.Extensions; public class C { public T F<T>(T x) { return F(new C())?.F(new C()).Extn()?.F(newC()); } } "; await TestInRegularAndScriptAsync(initialText, expectedText); } [Fact] public async Task TestDeconstructExtension() { await TestAsync( @" class Program { void M(Program p) { var (x, y) = [|p|]; } } namespace N { static class E { public static void Deconstruct(this Program p, out int x, out int y) { } } }", @" using N; class Program { void M(Program p) { var (x, y) = [|p|]; } } namespace N { static class E { public static void Deconstruct(this Program p, out int x, out int y) { } } }", parseOptions: null); } [Theory] [CombinatorialData] [WorkItem(16547, "https://github.com/dotnet/roslyn/issues/16547")] public async Task TestAddUsingForAddExtentionMethodWithSameNameAsProperty(TestHost testHost) { await TestAsync( @" namespace A { public class Foo { public void Bar() { var self = this.[|Self()|]; } public Foo Self { get { return this; } } } } namespace A.Extensions { public static class FooExtensions { public static Foo Self(this Foo foo) { return foo; } } }", @" using A.Extensions; namespace A { public class Foo { public void Bar() { var self = this.Self(); } public Foo Self { get { return this; } } } } namespace A.Extensions { public static class FooExtensions { public static Foo Self(this Foo foo) { return foo; } } }", testHost); } [Theory] [CombinatorialData] [WorkItem(39155, "https://github.com/dotnet/roslyn/issues/39155")] public async Task TestExtensionGetAwaiterOverload(TestHost testHost) { await TestAsync( @" using System; using System.Runtime.CompilerServices; namespace A { public class Foo { async void M(Foo foo) { [|await foo|]; } } public static class BarExtensions { public static Extension.FooAwaiter GetAwaiter(this string s) => default; } } namespace A.Extension { public static class FooExtensions { public static FooAwaiter GetAwaiter(this Foo foo) => default; } public struct FooAwaiter : INotifyCompletion { public bool IsCompleted { get; } public void OnCompleted(Action continuation) { } public void GetResult() { } } } ", @" using System; using System.Runtime.CompilerServices; using A.Extension; namespace A { public class Foo { async void M(Foo foo) { await foo; } } public static class BarExtensions { public static Extension.FooAwaiter GetAwaiter(this string s) => default; } } namespace A.Extension { public static class FooExtensions { public static FooAwaiter GetAwaiter(this Foo foo) => default; } public struct FooAwaiter : INotifyCompletion { public bool IsCompleted { get; } public void OnCompleted(Action continuation) { } public void GetResult() { } } } ", testHost); } [Theory] [CombinatorialData] [WorkItem(39155, "https://github.com/dotnet/roslyn/issues/39155")] public async Task TestExtensionSelectOverload(TestHost testHost) { await TestAsync( @" using System; using System.Collections.Generic; namespace A { public class Foo { void M(Foo foo) { _ = [|from x in foo|] select x; } } public static class BarExtensions { public static IEnumerable<int> Select(this string foo, Func<int, int> f) => null; } } namespace A.Extension { public static class FooExtensions { public static IEnumerable<int> Select(this Foo foo, Func<int, int> f) => null; } } ", @" using System; using System.Collections.Generic; using A.Extension; namespace A { public class Foo { void M(Foo foo) { _ = from x in foo select x; } } public static class BarExtensions { public static IEnumerable<int> Select(this string foo, Func<int, int> f) => null; } } namespace A.Extension { public static class FooExtensions { public static IEnumerable<int> Select(this Foo foo, Func<int, int> f) => null; } } ", testHost); } [Fact] public async Task TestExtensionDeconstructOverload() { await TestAsync( @" using System; using System.Collections.Generic; namespace A { public class Foo { void M(Foo foo) { var (x, y) = [|foo|]; } } public static class BarExtensions { public static void Deconstruct(this string foo, out int a, out int b) => throw null; } } namespace A.Extension { public static class FooExtensions { public static void Deconstruct(this Foo foo, out int a, out int b) => throw null; } } ", @" using System; using System.Collections.Generic; using A.Extension; namespace A { public class Foo { void M(Foo foo) { var (x, y) = foo; } } public static class BarExtensions { public static void Deconstruct(this string foo, out int a, out int b) => throw null; } } namespace A.Extension { public static class FooExtensions { public static void Deconstruct(this Foo foo, out int a, out int b) => throw null; } } ", parseOptions: null); } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/EditorFeatures/VisualBasicTest/SignatureHelp/RaiseEventStatementSignatureHelpProviderTests.vb
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp Imports Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SignatureHelp Public Class RaiseEventStatementSignatureHelpProviderTests Inherits AbstractVisualBasicSignatureHelpProviderTests Friend Overrides Function GetSignatureHelpProviderType() As Type Return GetType(RaiseEventStatementSignatureHelpProvider) End Function #Region "Regular tests" <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent() As Task Dim markup = <a><![CDATA[ Class C Event E(i As Integer, s As String) Sub M() RaiseEvent [|E($$ |]End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) From { New SignatureHelpTestItem("C.E(i As Integer, s As String)", String.Empty, String.Empty, currentParameterIndex:=0) } Await TestAsync(markup, expectedOrderedItems) End Function <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent_NoDerivedEvents() As Task Dim markup = <a><![CDATA[ Class B Event E1(i As Integer, s As String) End Class Class C Inherits B Event E2(i As Integer, s As String) Sub M() RaiseEvent E1($$ End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) Await TestAsync(markup, expectedOrderedItems) End Function <WorkItem(543558, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543558")> <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent_Shared() As Task Dim markup = <a><![CDATA[ Class C Shared Event E(i As Integer, s As String) Shared Sub M() RaiseEvent E($$ End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) From { New SignatureHelpTestItem("C.E(i As Integer, s As String)", String.Empty, String.Empty, currentParameterIndex:=0) } Await TestAsync(markup, expectedOrderedItems) End Function <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent_NoInstanceInSharedContext() As Task Dim markup = <a><![CDATA[ Class C Event E(i As Integer, s As String) Shared Sub M() RaiseEvent E($$ End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) Await TestAsync(markup, expectedOrderedItems) End Function #End Region End Class End Namespace
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp Imports Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SignatureHelp Public Class RaiseEventStatementSignatureHelpProviderTests Inherits AbstractVisualBasicSignatureHelpProviderTests Friend Overrides Function GetSignatureHelpProviderType() As Type Return GetType(RaiseEventStatementSignatureHelpProvider) End Function #Region "Regular tests" <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent() As Task Dim markup = <a><![CDATA[ Class C Event E(i As Integer, s As String) Sub M() RaiseEvent [|E($$ |]End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) From { New SignatureHelpTestItem("C.E(i As Integer, s As String)", String.Empty, String.Empty, currentParameterIndex:=0) } Await TestAsync(markup, expectedOrderedItems) End Function <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent_NoDerivedEvents() As Task Dim markup = <a><![CDATA[ Class B Event E1(i As Integer, s As String) End Class Class C Inherits B Event E2(i As Integer, s As String) Sub M() RaiseEvent E1($$ End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) Await TestAsync(markup, expectedOrderedItems) End Function <WorkItem(543558, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543558")> <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent_Shared() As Task Dim markup = <a><![CDATA[ Class C Shared Event E(i As Integer, s As String) Shared Sub M() RaiseEvent E($$ End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) From { New SignatureHelpTestItem("C.E(i As Integer, s As String)", String.Empty, String.Empty, currentParameterIndex:=0) } Await TestAsync(markup, expectedOrderedItems) End Function <Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)> Public Async Function TestRaiseEvent_NoInstanceInSharedContext() As Task Dim markup = <a><![CDATA[ Class C Event E(i As Integer, s As String) Shared Sub M() RaiseEvent E($$ End Sub End Class ]]></a>.Value Dim expectedOrderedItems As New List(Of SignatureHelpTestItem) Await TestAsync(markup, expectedOrderedItems) End Function #End Region End Class End Namespace
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/EditorFeatures/Core/Implementation/InlineRename/CommandHandlers/AbstractRenameCommandHandler_MoveSelectedLinesHandler.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.VisualStudio.Commanding; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename { internal abstract partial class AbstractRenameCommandHandler : ICommandHandler<MoveSelectedLinesUpCommandArgs>, ICommandHandler<MoveSelectedLinesDownCommandArgs> { public CommandState GetCommandState(MoveSelectedLinesUpCommandArgs args) => CommandState.Unspecified; public bool ExecuteCommand(MoveSelectedLinesUpCommandArgs args, CommandExecutionContext context) { CommitIfActive(args); return false; } public CommandState GetCommandState(MoveSelectedLinesDownCommandArgs args) => CommandState.Unspecified; public bool ExecuteCommand(MoveSelectedLinesDownCommandArgs args, CommandExecutionContext context) { CommitIfActive(args); return false; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.VisualStudio.Commanding; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename { internal abstract partial class AbstractRenameCommandHandler : ICommandHandler<MoveSelectedLinesUpCommandArgs>, ICommandHandler<MoveSelectedLinesDownCommandArgs> { public CommandState GetCommandState(MoveSelectedLinesUpCommandArgs args) => CommandState.Unspecified; public bool ExecuteCommand(MoveSelectedLinesUpCommandArgs args, CommandExecutionContext context) { CommitIfActive(args); return false; } public CommandState GetCommandState(MoveSelectedLinesDownCommandArgs args) => CommandState.Unspecified; public bool ExecuteCommand(MoveSelectedLinesDownCommandArgs args, CommandExecutionContext context) { CommitIfActive(args); return false; } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Tools/BuildBoss/SharedUtil.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace BuildBoss { internal static class SharedUtil { internal static string MSBuildNamespaceUriRaw => "http://schemas.microsoft.com/developer/msbuild/2003"; internal static Uri MSBuildNamespaceUri { get; } = new Uri(MSBuildNamespaceUriRaw); internal static XNamespace MSBuildNamespace { get; } = XNamespace.Get(MSBuildNamespaceUriRaw); internal static Encoding Encoding { get; } = Encoding.UTF8; internal static bool IsSolutionFile(string path) => Path.GetExtension(path) == ".sln"; internal static bool IsPropsFile(string path) => Path.GetExtension(path) == ".props"; internal static bool IsTargetsFile(string path) => Path.GetExtension(path) == ".targets"; internal static bool IsXslt(string path) => Path.GetExtension(path) == ".xslt"; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace BuildBoss { internal static class SharedUtil { internal static string MSBuildNamespaceUriRaw => "http://schemas.microsoft.com/developer/msbuild/2003"; internal static Uri MSBuildNamespaceUri { get; } = new Uri(MSBuildNamespaceUriRaw); internal static XNamespace MSBuildNamespace { get; } = XNamespace.Get(MSBuildNamespaceUriRaw); internal static Encoding Encoding { get; } = Encoding.UTF8; internal static bool IsSolutionFile(string path) => Path.GetExtension(path) == ".sln"; internal static bool IsPropsFile(string path) => Path.GetExtension(path) == ".props"; internal static bool IsTargetsFile(string path) => Path.GetExtension(path) == ".targets"; internal static bool IsXslt(string path) => Path.GetExtension(path) == ".xslt"; } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/EditorFeatures/TestUtilities/Structure/AbstractSyntaxStructureProviderTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Xunit; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Structure { [UseExportProvider] public abstract class AbstractSyntaxStructureProviderTests { protected abstract string LanguageName { get; } protected virtual string WorkspaceKind => CodeAnalysis.WorkspaceKind.Host; protected virtual OptionSet UpdateOptions(OptionSet options) => options.WithChangedOption(BlockStructureOptions.MaximumBannerLength, LanguageName, 120); private Task<ImmutableArray<BlockSpan>> GetBlockSpansAsync(Document document, int position) => GetBlockSpansWorkerAsync(document, position); internal abstract Task<ImmutableArray<BlockSpan>> GetBlockSpansWorkerAsync(Document document, int position); private protected async Task VerifyBlockSpansAsync(string markupCode, params RegionData[] expectedRegionData) { using (var workspace = TestWorkspace.Create(WorkspaceKind, LanguageName, compilationOptions: null, parseOptions: null, content: markupCode)) { workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(UpdateOptions(workspace.Options))); var hostDocument = workspace.Documents.Single(); Assert.True(hostDocument.CursorPosition.HasValue, "Test must specify a position."); var position = hostDocument.CursorPosition.Value; var expectedRegions = expectedRegionData.Select(data => CreateBlockSpan(data, hostDocument.AnnotatedSpans)).ToArray(); var document = workspace.CurrentSolution.GetDocument(hostDocument.Id); var actualRegions = await GetBlockSpansAsync(document, position); Assert.True(expectedRegions.Length == actualRegions.Length, $"Expected {expectedRegions.Length} regions but there were {actualRegions.Length}"); for (var i = 0; i < expectedRegions.Length; i++) { AssertRegion(expectedRegions[i], actualRegions[i]); } } } protected async Task VerifyNoBlockSpansAsync(string markupCode) { using (var workspace = TestWorkspace.Create(WorkspaceKind, LanguageName, compilationOptions: null, parseOptions: null, content: markupCode)) { workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(UpdateOptions(workspace.Options))); var hostDocument = workspace.Documents.Single(); Assert.True(hostDocument.CursorPosition.HasValue, "Test must specify a position."); var position = hostDocument.CursorPosition.Value; var document = workspace.CurrentSolution.GetDocument(hostDocument.Id); var actualRegions = await GetBlockSpansAsync(document, position); Assert.True(actualRegions.Length == 0, $"Expected no regions but found {actualRegions.Length}."); } } protected static RegionData Region(string textSpanName, string hintSpanName, string bannerText, bool autoCollapse, bool isDefaultCollapsed = false) => new RegionData(textSpanName, hintSpanName, bannerText, autoCollapse, isDefaultCollapsed); protected static RegionData Region(string textSpanName, string bannerText, bool autoCollapse, bool isDefaultCollapsed = false) => new RegionData(textSpanName, textSpanName, bannerText, autoCollapse, isDefaultCollapsed); private static BlockSpan CreateBlockSpan( RegionData regionData, IDictionary<string, ImmutableArray<TextSpan>> spans) { var (textSpanName, hintSpanName, bannerText, autoCollapse, isDefaultCollapsed) = regionData; Assert.True(spans.ContainsKey(textSpanName) && spans[textSpanName].Length == 1, $"Test did not specify '{textSpanName}' span."); Assert.True(spans.ContainsKey(hintSpanName) && spans[hintSpanName].Length == 1, $"Test did not specify '{hintSpanName}' span."); var textSpan = spans[textSpanName][0]; var hintSpan = spans[hintSpanName][0]; return new BlockSpan(isCollapsible: true, textSpan: textSpan, hintSpan: hintSpan, type: BlockTypes.Nonstructural, bannerText: bannerText, autoCollapse: autoCollapse, isDefaultCollapsed: isDefaultCollapsed); } internal static void AssertRegion(BlockSpan expected, BlockSpan actual) { Assert.Equal(expected.TextSpan.Start, actual.TextSpan.Start); Assert.Equal(expected.TextSpan.End, actual.TextSpan.End); Assert.Equal(expected.HintSpan.Start, actual.HintSpan.Start); Assert.Equal(expected.HintSpan.End, actual.HintSpan.End); Assert.Equal(expected.BannerText, actual.BannerText); Assert.Equal(expected.AutoCollapse, actual.AutoCollapse); Assert.Equal(expected.IsDefaultCollapsed, actual.IsDefaultCollapsed); } } public readonly struct RegionData { public readonly string TextSpanName; public readonly string HintSpanName; public readonly string BannerText; public readonly bool AutoCollapse; public readonly bool IsDefaultCollapsed; public RegionData(string textSpanName, string hintSpanName, string bannerText, bool autoCollapse, bool isDefaultCollapsed) { this.TextSpanName = textSpanName; this.HintSpanName = hintSpanName; this.BannerText = bannerText; this.AutoCollapse = autoCollapse; this.IsDefaultCollapsed = isDefaultCollapsed; } public override bool Equals(object obj) { return obj is RegionData other && TextSpanName == other.TextSpanName && HintSpanName == other.HintSpanName && BannerText == other.BannerText && AutoCollapse == other.AutoCollapse && IsDefaultCollapsed == other.IsDefaultCollapsed; } public override int GetHashCode() { var hashCode = -1426774128; hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TextSpanName); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(HintSpanName); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(BannerText); hashCode = hashCode * -1521134295 + AutoCollapse.GetHashCode(); hashCode = hashCode * -1521134295 + IsDefaultCollapsed.GetHashCode(); return hashCode; } public void Deconstruct(out string textSpanName, out string hintSpanName, out string bannerText, out bool autoCollapse, out bool isDefaultCollapsed) { textSpanName = this.TextSpanName; hintSpanName = this.HintSpanName; bannerText = this.BannerText; autoCollapse = this.AutoCollapse; isDefaultCollapsed = this.IsDefaultCollapsed; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Xunit; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Structure { [UseExportProvider] public abstract class AbstractSyntaxStructureProviderTests { protected abstract string LanguageName { get; } protected virtual string WorkspaceKind => CodeAnalysis.WorkspaceKind.Host; protected virtual OptionSet UpdateOptions(OptionSet options) => options.WithChangedOption(BlockStructureOptions.MaximumBannerLength, LanguageName, 120); private Task<ImmutableArray<BlockSpan>> GetBlockSpansAsync(Document document, int position) => GetBlockSpansWorkerAsync(document, position); internal abstract Task<ImmutableArray<BlockSpan>> GetBlockSpansWorkerAsync(Document document, int position); private protected async Task VerifyBlockSpansAsync(string markupCode, params RegionData[] expectedRegionData) { using (var workspace = TestWorkspace.Create(WorkspaceKind, LanguageName, compilationOptions: null, parseOptions: null, content: markupCode)) { workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(UpdateOptions(workspace.Options))); var hostDocument = workspace.Documents.Single(); Assert.True(hostDocument.CursorPosition.HasValue, "Test must specify a position."); var position = hostDocument.CursorPosition.Value; var expectedRegions = expectedRegionData.Select(data => CreateBlockSpan(data, hostDocument.AnnotatedSpans)).ToArray(); var document = workspace.CurrentSolution.GetDocument(hostDocument.Id); var actualRegions = await GetBlockSpansAsync(document, position); Assert.True(expectedRegions.Length == actualRegions.Length, $"Expected {expectedRegions.Length} regions but there were {actualRegions.Length}"); for (var i = 0; i < expectedRegions.Length; i++) { AssertRegion(expectedRegions[i], actualRegions[i]); } } } protected async Task VerifyNoBlockSpansAsync(string markupCode) { using (var workspace = TestWorkspace.Create(WorkspaceKind, LanguageName, compilationOptions: null, parseOptions: null, content: markupCode)) { workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(UpdateOptions(workspace.Options))); var hostDocument = workspace.Documents.Single(); Assert.True(hostDocument.CursorPosition.HasValue, "Test must specify a position."); var position = hostDocument.CursorPosition.Value; var document = workspace.CurrentSolution.GetDocument(hostDocument.Id); var actualRegions = await GetBlockSpansAsync(document, position); Assert.True(actualRegions.Length == 0, $"Expected no regions but found {actualRegions.Length}."); } } protected static RegionData Region(string textSpanName, string hintSpanName, string bannerText, bool autoCollapse, bool isDefaultCollapsed = false) => new RegionData(textSpanName, hintSpanName, bannerText, autoCollapse, isDefaultCollapsed); protected static RegionData Region(string textSpanName, string bannerText, bool autoCollapse, bool isDefaultCollapsed = false) => new RegionData(textSpanName, textSpanName, bannerText, autoCollapse, isDefaultCollapsed); private static BlockSpan CreateBlockSpan( RegionData regionData, IDictionary<string, ImmutableArray<TextSpan>> spans) { var (textSpanName, hintSpanName, bannerText, autoCollapse, isDefaultCollapsed) = regionData; Assert.True(spans.ContainsKey(textSpanName) && spans[textSpanName].Length == 1, $"Test did not specify '{textSpanName}' span."); Assert.True(spans.ContainsKey(hintSpanName) && spans[hintSpanName].Length == 1, $"Test did not specify '{hintSpanName}' span."); var textSpan = spans[textSpanName][0]; var hintSpan = spans[hintSpanName][0]; return new BlockSpan(isCollapsible: true, textSpan: textSpan, hintSpan: hintSpan, type: BlockTypes.Nonstructural, bannerText: bannerText, autoCollapse: autoCollapse, isDefaultCollapsed: isDefaultCollapsed); } internal static void AssertRegion(BlockSpan expected, BlockSpan actual) { Assert.Equal(expected.TextSpan.Start, actual.TextSpan.Start); Assert.Equal(expected.TextSpan.End, actual.TextSpan.End); Assert.Equal(expected.HintSpan.Start, actual.HintSpan.Start); Assert.Equal(expected.HintSpan.End, actual.HintSpan.End); Assert.Equal(expected.BannerText, actual.BannerText); Assert.Equal(expected.AutoCollapse, actual.AutoCollapse); Assert.Equal(expected.IsDefaultCollapsed, actual.IsDefaultCollapsed); } } public readonly struct RegionData { public readonly string TextSpanName; public readonly string HintSpanName; public readonly string BannerText; public readonly bool AutoCollapse; public readonly bool IsDefaultCollapsed; public RegionData(string textSpanName, string hintSpanName, string bannerText, bool autoCollapse, bool isDefaultCollapsed) { this.TextSpanName = textSpanName; this.HintSpanName = hintSpanName; this.BannerText = bannerText; this.AutoCollapse = autoCollapse; this.IsDefaultCollapsed = isDefaultCollapsed; } public override bool Equals(object obj) { return obj is RegionData other && TextSpanName == other.TextSpanName && HintSpanName == other.HintSpanName && BannerText == other.BannerText && AutoCollapse == other.AutoCollapse && IsDefaultCollapsed == other.IsDefaultCollapsed; } public override int GetHashCode() { var hashCode = -1426774128; hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TextSpanName); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(HintSpanName); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(BannerText); hashCode = hashCode * -1521134295 + AutoCollapse.GetHashCode(); hashCode = hashCode * -1521134295 + IsDefaultCollapsed.GetHashCode(); return hashCode; } public void Deconstruct(out string textSpanName, out string hintSpanName, out string bannerText, out bool autoCollapse, out bool isDefaultCollapsed) { textSpanName = this.TextSpanName; hintSpanName = this.HintSpanName; bannerText = this.BannerText; autoCollapse = this.AutoCollapse; isDefaultCollapsed = this.IsDefaultCollapsed; } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Compilers/Core/Portable/Operations/OperationWalker.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.Operations { /// <summary> /// Represents a <see cref="OperationVisitor"/> that descends an entire <see cref="IOperation"/> tree /// visiting each IOperation and its child IOperation nodes in depth-first order. /// </summary> public abstract class OperationWalker : OperationVisitor { private int _recursionDepth; private void VisitChildOperations(IOperation operation) { foreach (var child in ((Operation)operation).ChildOperations) { Visit(child); } } public override void Visit(IOperation? operation) { if (operation != null) { _recursionDepth++; try { StackGuard.EnsureSufficientExecutionStack(_recursionDepth); operation.Accept(this); } finally { _recursionDepth--; } } } public override void DefaultVisit(IOperation operation) { VisitChildOperations(operation); } internal override void VisitNoneOperation(IOperation operation) { VisitChildOperations(operation); } } /// <summary> /// Represents a <see cref="OperationVisitor{TArgument, TResult}"/> that descends an entire <see cref="IOperation"/> tree /// visiting each IOperation and its child IOperation nodes in depth-first order. Returns null. /// </summary> public abstract class OperationWalker<TArgument> : OperationVisitor<TArgument, object?> { private int _recursionDepth; private void VisitChildrenOperations(IOperation operation, TArgument argument) { foreach (var child in ((Operation)operation).ChildOperations) { Visit(child, argument); } } public override object? Visit(IOperation? operation, TArgument argument) { if (operation != null) { _recursionDepth++; try { StackGuard.EnsureSufficientExecutionStack(_recursionDepth); operation.Accept(this, argument); } finally { _recursionDepth--; } } return null; } public override object? DefaultVisit(IOperation operation, TArgument argument) { VisitChildrenOperations(operation, argument); return null; } internal override object? VisitNoneOperation(IOperation operation, TArgument argument) { VisitChildrenOperations(operation, argument); return null; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.Operations { /// <summary> /// Represents a <see cref="OperationVisitor"/> that descends an entire <see cref="IOperation"/> tree /// visiting each IOperation and its child IOperation nodes in depth-first order. /// </summary> public abstract class OperationWalker : OperationVisitor { private int _recursionDepth; private void VisitChildOperations(IOperation operation) { foreach (var child in ((Operation)operation).ChildOperations) { Visit(child); } } public override void Visit(IOperation? operation) { if (operation != null) { _recursionDepth++; try { StackGuard.EnsureSufficientExecutionStack(_recursionDepth); operation.Accept(this); } finally { _recursionDepth--; } } } public override void DefaultVisit(IOperation operation) { VisitChildOperations(operation); } internal override void VisitNoneOperation(IOperation operation) { VisitChildOperations(operation); } } /// <summary> /// Represents a <see cref="OperationVisitor{TArgument, TResult}"/> that descends an entire <see cref="IOperation"/> tree /// visiting each IOperation and its child IOperation nodes in depth-first order. Returns null. /// </summary> public abstract class OperationWalker<TArgument> : OperationVisitor<TArgument, object?> { private int _recursionDepth; private void VisitChildrenOperations(IOperation operation, TArgument argument) { foreach (var child in ((Operation)operation).ChildOperations) { Visit(child, argument); } } public override object? Visit(IOperation? operation, TArgument argument) { if (operation != null) { _recursionDepth++; try { StackGuard.EnsureSufficientExecutionStack(_recursionDepth); operation.Accept(this, argument); } finally { _recursionDepth--; } } return null; } public override object? DefaultVisit(IOperation operation, TArgument argument) { VisitChildrenOperations(operation, argument); return null; } internal override object? VisitNoneOperation(IOperation operation, TArgument argument) { VisitChildrenOperations(operation, argument); return null; } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Features/Core/Portable/Completion/CompletionProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Completion { /// <summary> /// Implement a subtype of this class and export it to provide completions during typing in an editor. /// </summary> public abstract class CompletionProvider { internal string Name { get; } protected CompletionProvider() => Name = GetType().FullName; /// <summary> /// Implement to contribute <see cref="CompletionItem"/>'s and other details to a <see cref="CompletionList"/> /// </summary> public abstract Task ProvideCompletionsAsync(CompletionContext context); /// <summary> /// Returns true if the character recently inserted or deleted in the text should trigger completion. /// </summary> /// <param name="text">The text that completion is occurring within.</param> /// <param name="caretPosition">The position of the caret after the triggering action.</param> /// <param name="trigger">The triggering action.</param> /// <param name="options">The set of options in effect.</param> public virtual bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) => false; /// <summary> /// Returns true if the character recently inserted or deleted in the text should trigger completion. /// </summary> /// <param name="languageServices">The language services available on the text document.</param> /// <param name="text">The text that completion is occurring within.</param> /// <param name="caretPosition">The position of the caret after the triggering action.</param> /// <param name="trigger">The triggering action.</param> /// <param name="options">The set of options in effect.</param> internal virtual bool ShouldTriggerCompletion(HostLanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) => ShouldTriggerCompletion(text, caretPosition, trigger, options); /// <summary> /// This allows Completion Providers that indicated they were triggered textually to use syntax to /// confirm they are really triggered, or decide they are not actually triggered and should become /// an augmenting provider instead. /// </summary> internal virtual async Task<bool> IsSyntacticTriggerCharacterAsync(Document document, int caretPosition, CompletionTrigger trigger, OptionSet options, CancellationToken cancellationToken) => ShouldTriggerCompletion(document.Project.LanguageServices, await document.GetTextAsync(cancellationToken).ConfigureAwait(false), caretPosition, trigger, options); /// <summary> /// Gets the description of the specified item. /// </summary> public virtual Task<CompletionDescription> GetDescriptionAsync(Document document, CompletionItem item, CancellationToken cancellationToken) => Task.FromResult(CompletionDescription.Empty); /// <summary> /// Gets the change to be applied when the specified item is committed. /// </summary> /// <param name="document">The current document.</param> /// <param name="item">The item to be committed.</param> /// <param name="commitKey">The optional key character that caused the commit.</param> /// <param name="cancellationToken"></param> public virtual Task<CompletionChange> GetChangeAsync(Document document, CompletionItem item, char? commitKey, CancellationToken cancellationToken) => Task.FromResult(CompletionChange.Create(new TextChange(item.Span, item.DisplayText))); /// <summary> /// True if the provider produces snippet items. /// </summary> internal virtual bool IsSnippetProvider => false; /// <summary> /// True if the provider produces items show be shown in expanded list only. /// </summary> internal virtual bool IsExpandItemProvider => false; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Completion { /// <summary> /// Implement a subtype of this class and export it to provide completions during typing in an editor. /// </summary> public abstract class CompletionProvider { internal string Name { get; } protected CompletionProvider() => Name = GetType().FullName; /// <summary> /// Implement to contribute <see cref="CompletionItem"/>'s and other details to a <see cref="CompletionList"/> /// </summary> public abstract Task ProvideCompletionsAsync(CompletionContext context); /// <summary> /// Returns true if the character recently inserted or deleted in the text should trigger completion. /// </summary> /// <param name="text">The text that completion is occurring within.</param> /// <param name="caretPosition">The position of the caret after the triggering action.</param> /// <param name="trigger">The triggering action.</param> /// <param name="options">The set of options in effect.</param> public virtual bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) => false; /// <summary> /// Returns true if the character recently inserted or deleted in the text should trigger completion. /// </summary> /// <param name="languageServices">The language services available on the text document.</param> /// <param name="text">The text that completion is occurring within.</param> /// <param name="caretPosition">The position of the caret after the triggering action.</param> /// <param name="trigger">The triggering action.</param> /// <param name="options">The set of options in effect.</param> internal virtual bool ShouldTriggerCompletion(HostLanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) => ShouldTriggerCompletion(text, caretPosition, trigger, options); /// <summary> /// This allows Completion Providers that indicated they were triggered textually to use syntax to /// confirm they are really triggered, or decide they are not actually triggered and should become /// an augmenting provider instead. /// </summary> internal virtual async Task<bool> IsSyntacticTriggerCharacterAsync(Document document, int caretPosition, CompletionTrigger trigger, OptionSet options, CancellationToken cancellationToken) => ShouldTriggerCompletion(document.Project.LanguageServices, await document.GetTextAsync(cancellationToken).ConfigureAwait(false), caretPosition, trigger, options); /// <summary> /// Gets the description of the specified item. /// </summary> public virtual Task<CompletionDescription> GetDescriptionAsync(Document document, CompletionItem item, CancellationToken cancellationToken) => Task.FromResult(CompletionDescription.Empty); /// <summary> /// Gets the change to be applied when the specified item is committed. /// </summary> /// <param name="document">The current document.</param> /// <param name="item">The item to be committed.</param> /// <param name="commitKey">The optional key character that caused the commit.</param> /// <param name="cancellationToken"></param> public virtual Task<CompletionChange> GetChangeAsync(Document document, CompletionItem item, char? commitKey, CancellationToken cancellationToken) => Task.FromResult(CompletionChange.Create(new TextChange(item.Span, item.DisplayText))); /// <summary> /// True if the provider produces snippet items. /// </summary> internal virtual bool IsSnippetProvider => false; /// <summary> /// True if the provider produces items show be shown in expanded list only. /// </summary> internal virtual bool IsExpandItemProvider => false; } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/VisualStudio/Core/Impl/Options/CodeStyleNoticeTextBlock.xaml.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Windows.Controls; using System.Windows.Navigation; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options { internal partial class CodeStyleNoticeTextBlock : TextBlock { private const string UseEditorConfigUrl = "https://go.microsoft.com/fwlink/?linkid=866541"; public CodeStyleNoticeTextBlock() => InitializeComponent(); public static readonly Uri CodeStylePageHeaderLearnMoreUri = new Uri(UseEditorConfigUrl); public static string CodeStylePageHeader => ServicesVSResources.Code_style_header_use_editor_config; public static string CodeStylePageHeaderLearnMoreText => ServicesVSResources.Learn_more; private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) { if (e.Uri == null) { return; } VisualStudioNavigateToLinkService.StartBrowser(e.Uri); e.Handled = true; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Windows.Controls; using System.Windows.Navigation; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options { internal partial class CodeStyleNoticeTextBlock : TextBlock { private const string UseEditorConfigUrl = "https://go.microsoft.com/fwlink/?linkid=866541"; public CodeStyleNoticeTextBlock() => InitializeComponent(); public static readonly Uri CodeStylePageHeaderLearnMoreUri = new Uri(UseEditorConfigUrl); public static string CodeStylePageHeader => ServicesVSResources.Code_style_header_use_editor_config; public static string CodeStylePageHeaderLearnMoreText => ServicesVSResources.Learn_more; private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) { if (e.Uri == null) { return; } VisualStudioNavigateToLinkService.StartBrowser(e.Uri); e.Handled = true; } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/EditorFeatures/CSharpTest/ChangeSignature/ReorderParametersTests.Cascading.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.UnitTests.ChangeSignature; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ChangeSignature { public partial class ChangeSignatureTests : AbstractChangeSignatureTests { [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToImplementedMethod() { var markup = @" interface I { void M(int x, string y); } class C : I { $$public void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" interface I { void M(string y, int x); } class C : I { public void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToImplementedMethod_WithTuples() { var markup = @" interface I { void M((int, int) x, (string a, string b) y); } class C : I { $$public void M((int, int) x, (string a, string b) y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" interface I { void M((string a, string b) y, (int, int) x); } class C : I { public void M((string a, string b) y, (int, int) x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToImplementingMethod() { var markup = @" interface I { $$void M(int x, string y); } class C : I { public void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" interface I { void M(string y, int x); } class C : I { public void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverriddenMethod() { var markup = @" class B { public virtual void M(int x, string y) { } } class D : B { $$public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverridingMethod() { var markup = @" class B { $$public virtual void M(int x, string y) { } } class D : B { public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverriddenMethod_Transitive() { var markup = @" class B { public virtual void M(int x, string y) { } } class D : B { public override void M(int x, string y) { } } class D2 : D { $$public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } } class D2 : D { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverridingMethod_Transitive() { var markup = @" class B { $$public virtual void M(int x, string y) { } } class D : B { public override void M(int x, string y) { } } class D2 : D { public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } } class D2 : D { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToMethods_Complex() { //// B I I2 //// \ / \ / //// D (I3) //// / \ \ //// $$D2 D3 C var markup = @" class B { public virtual void M(int x, string y) { } } class D : B, I { public override void M(int x, string y) { } } class D2 : D { public override void $$M(int x, string y) { } } class D3 : D { public override void M(int x, string y) { } } interface I { void M(int x, string y); } interface I2 { void M(int x, string y); } interface I3 : I, I2 { } class C : I3 { public void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B, I { public override void M(string y, int x) { } } class D2 : D { public override void M(string y, int x) { } } class D3 : D { public override void M(string y, int x) { } } interface I { void M(string y, int x); } interface I2 { void M(string y, int x); } interface I3 : I, I2 { } class C : I3 { public void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToMethods_WithDifferentParameterNames() { var markup = @" public class B { /// <param name=""x""></param> /// <param name=""y""></param> public virtual int M(int x, string y) { return 1; } } public class D : B { /// <param name=""a""></param> /// <param name=""b""></param> public override int M(int a, string b) { return 1; } } public class D2 : D { /// <param name=""y""></param> /// <param name=""x""></param> public override int $$M(int y, string x) { M(1, ""Two""); ((D)this).M(1, ""Two""); ((B)this).M(1, ""Two""); M(1, x: ""Two""); ((D)this).M(1, b: ""Two""); ((B)this).M(1, y: ""Two""); return 1; } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" public class B { /// <param name=""y""></param> /// <param name=""x""></param> public virtual int M(string y, int x) { return 1; } } public class D : B { /// <param name=""b""></param> /// <param name=""a""></param> public override int M(string b, int a) { return 1; } } public class D2 : D { /// <param name=""x""></param> /// <param name=""y""></param> public override int M(string x, int y) { M(""Two"", 1); ((D)this).M(""Two"", 1); ((B)this).M(""Two"", 1); M(x: ""Two"", y: 1); ((D)this).M(b: ""Two"", a: 1); ((B)this).M(y: ""Two"", x: 1); return 1; } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.UnitTests.ChangeSignature; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ChangeSignature { public partial class ChangeSignatureTests : AbstractChangeSignatureTests { [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToImplementedMethod() { var markup = @" interface I { void M(int x, string y); } class C : I { $$public void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" interface I { void M(string y, int x); } class C : I { public void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToImplementedMethod_WithTuples() { var markup = @" interface I { void M((int, int) x, (string a, string b) y); } class C : I { $$public void M((int, int) x, (string a, string b) y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" interface I { void M((string a, string b) y, (int, int) x); } class C : I { public void M((string a, string b) y, (int, int) x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToImplementingMethod() { var markup = @" interface I { $$void M(int x, string y); } class C : I { public void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" interface I { void M(string y, int x); } class C : I { public void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverriddenMethod() { var markup = @" class B { public virtual void M(int x, string y) { } } class D : B { $$public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverridingMethod() { var markup = @" class B { $$public virtual void M(int x, string y) { } } class D : B { public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverriddenMethod_Transitive() { var markup = @" class B { public virtual void M(int x, string y) { } } class D : B { public override void M(int x, string y) { } } class D2 : D { $$public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } } class D2 : D { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToOverridingMethod_Transitive() { var markup = @" class B { $$public virtual void M(int x, string y) { } } class D : B { public override void M(int x, string y) { } } class D2 : D { public override void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B { public override void M(string y, int x) { } } class D2 : D { public override void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToMethods_Complex() { //// B I I2 //// \ / \ / //// D (I3) //// / \ \ //// $$D2 D3 C var markup = @" class B { public virtual void M(int x, string y) { } } class D : B, I { public override void M(int x, string y) { } } class D2 : D { public override void $$M(int x, string y) { } } class D3 : D { public override void M(int x, string y) { } } interface I { void M(int x, string y); } interface I2 { void M(int x, string y); } interface I3 : I, I2 { } class C : I3 { public void M(int x, string y) { } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" class B { public virtual void M(string y, int x) { } } class D : B, I { public override void M(string y, int x) { } } class D2 : D { public override void M(string y, int x) { } } class D3 : D { public override void M(string y, int x) { } } interface I { void M(string y, int x); } interface I2 { void M(string y, int x); } interface I3 : I, I2 { } class C : I3 { public void M(string y, int x) { } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } [Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] public async Task ReorderParameters_Cascade_ToMethods_WithDifferentParameterNames() { var markup = @" public class B { /// <param name=""x""></param> /// <param name=""y""></param> public virtual int M(int x, string y) { return 1; } } public class D : B { /// <param name=""a""></param> /// <param name=""b""></param> public override int M(int a, string b) { return 1; } } public class D2 : D { /// <param name=""y""></param> /// <param name=""x""></param> public override int $$M(int y, string x) { M(1, ""Two""); ((D)this).M(1, ""Two""); ((B)this).M(1, ""Two""); M(1, x: ""Two""); ((D)this).M(1, b: ""Two""); ((B)this).M(1, y: ""Two""); return 1; } }"; var permutation = new[] { 1, 0 }; var updatedCode = @" public class B { /// <param name=""y""></param> /// <param name=""x""></param> public virtual int M(string y, int x) { return 1; } } public class D : B { /// <param name=""b""></param> /// <param name=""a""></param> public override int M(string b, int a) { return 1; } } public class D2 : D { /// <param name=""x""></param> /// <param name=""y""></param> public override int M(string x, int y) { M(""Two"", 1); ((D)this).M(""Two"", 1); ((B)this).M(""Two"", 1); M(x: ""Two"", y: 1); ((D)this).M(b: ""Two"", a: 1); ((B)this).M(y: ""Two"", x: 1); return 1; } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode); } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Features/Core/Portable/QuickInfo/CommonSemanticQuickInfoProvider.TokenInfo.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.QuickInfo { internal abstract partial class CommonSemanticQuickInfoProvider { public struct TokenInformation { public readonly ImmutableArray<ISymbol> Symbols; /// <summary> /// True if this quick info came from hovering over an 'await' keyword, which we show the return /// type of with special text. /// </summary> public readonly bool ShowAwaitReturn; /// <summary> /// The nullable flow state to show in Quick Info; will be <see cref="NullableFlowState.None"/> to show nothing. /// </summary> public readonly NullableFlowState NullableFlowState; public TokenInformation(ImmutableArray<ISymbol> symbols, bool showAwaitReturn = false, NullableFlowState nullableFlowState = NullableFlowState.None) { Symbols = symbols; ShowAwaitReturn = showAwaitReturn; NullableFlowState = nullableFlowState; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.QuickInfo { internal abstract partial class CommonSemanticQuickInfoProvider { public struct TokenInformation { public readonly ImmutableArray<ISymbol> Symbols; /// <summary> /// True if this quick info came from hovering over an 'await' keyword, which we show the return /// type of with special text. /// </summary> public readonly bool ShowAwaitReturn; /// <summary> /// The nullable flow state to show in Quick Info; will be <see cref="NullableFlowState.None"/> to show nothing. /// </summary> public readonly NullableFlowState NullableFlowState; public TokenInformation(ImmutableArray<ISymbol> symbols, bool showAwaitReturn = false, NullableFlowState nullableFlowState = NullableFlowState.None) { Symbols = symbols; ShowAwaitReturn = showAwaitReturn; NullableFlowState = nullableFlowState; } } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Workspaces/Core/Portable/Simplification/AbstractReducer.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.Simplification { internal abstract partial class AbstractReducer { private readonly ObjectPool<IReductionRewriter> _pool; protected AbstractReducer(ObjectPool<IReductionRewriter> pool) => _pool = pool; public IReductionRewriter GetOrCreateRewriter() => _pool.Allocate(); public virtual bool IsApplicable(OptionSet optionSet) => true; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.Simplification { internal abstract partial class AbstractReducer { private readonly ObjectPool<IReductionRewriter> _pool; protected AbstractReducer(ObjectPool<IReductionRewriter> pool) => _pool = pool; public IReductionRewriter GetOrCreateRewriter() => _pool.Allocate(); public virtual bool IsApplicable(OptionSet optionSet) => true; } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Workspaces/Core/Portable/Storage/SQLite/v2/SQLiteConnectionPoolService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Composition; using System.IO; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.SQLite.v2.Interop; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.SQLite.v2 { [Export] [Shared] internal sealed class SQLiteConnectionPoolService : IDisposable { private const string LockFile = "db.lock"; private readonly object _gate = new(); /// <summary> /// Maps from database file path to connection pool. /// </summary> /// <remarks> /// Access to this field is synchronized through <see cref="_gate"/>. /// </remarks> private readonly Dictionary<string, ReferenceCountedDisposable<SQLiteConnectionPool>> _connectionPools = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public SQLiteConnectionPoolService() { } /// <summary> /// Use a <see cref="ConcurrentExclusiveSchedulerPair"/> to simulate a reader-writer lock. /// Read operations are performed on the <see cref="ConcurrentExclusiveSchedulerPair.ConcurrentScheduler"/> /// and writes are performed on the <see cref="ConcurrentExclusiveSchedulerPair.ExclusiveScheduler"/>. /// /// We use this as a condition of using the in-memory shared-cache sqlite DB. This DB /// doesn't busy-wait when attempts are made to lock the tables in it, which can lead to /// deadlocks. Specifically, consider two threads doing the following: /// /// Thread A starts a transaction that starts as a reader, and later attempts to perform a /// write. Thread B is a writer (either started that way, or started as a reader and /// promoted to a writer first). B holds a RESERVED lock, waiting for readers to clear so it /// can start writing. A holds a SHARED lock (it's a reader) and tries to acquire RESERVED /// lock (so it can start writing). The only way to make progress in this situation is for /// one of the transactions to roll back. No amount of waiting will help, so when SQLite /// detects this situation, it doesn't honor the busy timeout. /// /// To prevent this scenario, we control our access to the db explicitly with operations that /// can concurrently read, and operations that exclusively write. /// /// All code that reads or writes from the db should go through this. /// </summary> public ConcurrentExclusiveSchedulerPair Scheduler { get; } = new(); public void Dispose() { lock (_gate) { foreach (var (_, pool) in _connectionPools) pool.Dispose(); _connectionPools.Clear(); } } public ReferenceCountedDisposable<SQLiteConnectionPool>? TryOpenDatabase( string databaseFilePath, IPersistentStorageFaultInjector? faultInjector, Action<SqlConnection, CancellationToken> initializer, CancellationToken cancellationToken) { lock (_gate) { if (_connectionPools.TryGetValue(databaseFilePath, out var pool)) { return pool.TryAddReference() ?? throw ExceptionUtilities.Unreachable; } // try to get db ownership lock. if someone else already has the lock. it will throw var ownershipLock = TryGetDatabaseOwnership(databaseFilePath); if (ownershipLock == null) { return null; } try { pool = new ReferenceCountedDisposable<SQLiteConnectionPool>( new SQLiteConnectionPool(this, faultInjector, databaseFilePath, ownershipLock)); pool.Target.Initialize(initializer, cancellationToken); // Place the initial ownership reference in _connectionPools, and return another _connectionPools.Add(databaseFilePath, pool); return pool.TryAddReference() ?? throw ExceptionUtilities.Unreachable; } catch (Exception ex) when (FatalError.ReportAndCatchUnlessCanceled(ex, cancellationToken)) { if (pool is not null) { // Dispose of the connection pool, releasing the ownership lock. pool.Dispose(); } else { // The storage was not created so nothing owns the lock. // Dispose the lock to allow reuse. ownershipLock.Dispose(); } throw; } } } /// <summary> /// Returns null in the case where an IO exception prevented us from being able to acquire /// the db lock file. /// </summary> private static IDisposable? TryGetDatabaseOwnership(string databaseFilePath) { return IOUtilities.PerformIO<IDisposable?>(() => { // make sure directory exist first. EnsureDirectory(databaseFilePath); var directoryName = Path.GetDirectoryName(databaseFilePath); Contract.ThrowIfNull(directoryName); return File.Open( Path.Combine(directoryName, LockFile), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }, defaultValue: null); } private static void EnsureDirectory(string databaseFilePath) { var directory = Path.GetDirectoryName(databaseFilePath); Contract.ThrowIfNull(directory); if (Directory.Exists(directory)) { return; } Directory.CreateDirectory(directory); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Composition; using System.IO; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.SQLite.v2.Interop; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.SQLite.v2 { [Export] [Shared] internal sealed class SQLiteConnectionPoolService : IDisposable { private const string LockFile = "db.lock"; private readonly object _gate = new(); /// <summary> /// Maps from database file path to connection pool. /// </summary> /// <remarks> /// Access to this field is synchronized through <see cref="_gate"/>. /// </remarks> private readonly Dictionary<string, ReferenceCountedDisposable<SQLiteConnectionPool>> _connectionPools = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public SQLiteConnectionPoolService() { } /// <summary> /// Use a <see cref="ConcurrentExclusiveSchedulerPair"/> to simulate a reader-writer lock. /// Read operations are performed on the <see cref="ConcurrentExclusiveSchedulerPair.ConcurrentScheduler"/> /// and writes are performed on the <see cref="ConcurrentExclusiveSchedulerPair.ExclusiveScheduler"/>. /// /// We use this as a condition of using the in-memory shared-cache sqlite DB. This DB /// doesn't busy-wait when attempts are made to lock the tables in it, which can lead to /// deadlocks. Specifically, consider two threads doing the following: /// /// Thread A starts a transaction that starts as a reader, and later attempts to perform a /// write. Thread B is a writer (either started that way, or started as a reader and /// promoted to a writer first). B holds a RESERVED lock, waiting for readers to clear so it /// can start writing. A holds a SHARED lock (it's a reader) and tries to acquire RESERVED /// lock (so it can start writing). The only way to make progress in this situation is for /// one of the transactions to roll back. No amount of waiting will help, so when SQLite /// detects this situation, it doesn't honor the busy timeout. /// /// To prevent this scenario, we control our access to the db explicitly with operations that /// can concurrently read, and operations that exclusively write. /// /// All code that reads or writes from the db should go through this. /// </summary> public ConcurrentExclusiveSchedulerPair Scheduler { get; } = new(); public void Dispose() { lock (_gate) { foreach (var (_, pool) in _connectionPools) pool.Dispose(); _connectionPools.Clear(); } } public ReferenceCountedDisposable<SQLiteConnectionPool>? TryOpenDatabase( string databaseFilePath, IPersistentStorageFaultInjector? faultInjector, Action<SqlConnection, CancellationToken> initializer, CancellationToken cancellationToken) { lock (_gate) { if (_connectionPools.TryGetValue(databaseFilePath, out var pool)) { return pool.TryAddReference() ?? throw ExceptionUtilities.Unreachable; } // try to get db ownership lock. if someone else already has the lock. it will throw var ownershipLock = TryGetDatabaseOwnership(databaseFilePath); if (ownershipLock == null) { return null; } try { pool = new ReferenceCountedDisposable<SQLiteConnectionPool>( new SQLiteConnectionPool(this, faultInjector, databaseFilePath, ownershipLock)); pool.Target.Initialize(initializer, cancellationToken); // Place the initial ownership reference in _connectionPools, and return another _connectionPools.Add(databaseFilePath, pool); return pool.TryAddReference() ?? throw ExceptionUtilities.Unreachable; } catch (Exception ex) when (FatalError.ReportAndCatchUnlessCanceled(ex, cancellationToken)) { if (pool is not null) { // Dispose of the connection pool, releasing the ownership lock. pool.Dispose(); } else { // The storage was not created so nothing owns the lock. // Dispose the lock to allow reuse. ownershipLock.Dispose(); } throw; } } } /// <summary> /// Returns null in the case where an IO exception prevented us from being able to acquire /// the db lock file. /// </summary> private static IDisposable? TryGetDatabaseOwnership(string databaseFilePath) { return IOUtilities.PerformIO<IDisposable?>(() => { // make sure directory exist first. EnsureDirectory(databaseFilePath); var directoryName = Path.GetDirectoryName(databaseFilePath); Contract.ThrowIfNull(directoryName); return File.Open( Path.Combine(directoryName, LockFile), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }, defaultValue: null); } private static void EnsureDirectory(string databaseFilePath) { var directory = Path.GetDirectoryName(databaseFilePath); Contract.ThrowIfNull(directory); if (Directory.Exists(directory)) { return; } Directory.CreateDirectory(directory); } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/VisualStudio/Core/Test/CodeModel/VisualBasic/ImplementsStatementTests.vb
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Test.Utilities Imports Roslyn.Test.Utilities Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.VisualBasic Public Class ImplementsStatementTests Inherits AbstractCodeElementTests #Region "GetStartPoint() tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestGetStartPoint1() Dim code = <Code> Interface I End Interface Class C Implements $$I End Class </Code> TestGetStartPoint(code, Part(EnvDTE.vsCMPart.vsCMPartAttributes, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartBody, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeader, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartName, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartNavigate, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWhole, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16))) End Sub #End Region #Region "GetEndPoint() tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestGetEndPoint1() Dim code = <Code> Interface I End Interface Class C Implements $$I End Class </Code> TestGetEndPoint(code, Part(EnvDTE.vsCMPart.vsCMPartAttributes, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartBody, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeader, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartName, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartNavigate, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWhole, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16))) End Sub #End Region #Region "Kind tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestKind1() Dim code = <Code> Interface I End Interface Class C Implements I$$ End Class </Code> TestKind(code, EnvDTE.vsCMElement.vsCMElementImplementsStmt) End Sub #End Region #Region "Name tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestName1() Dim code = <Code> Interface I End Interface Class C Implements I$$ End Class </Code> TestName(code, "Implements") End Sub #End Region Protected Overrides ReadOnly Property LanguageName As String Get Return LanguageNames.VisualBasic End Get End Property End Class End Namespace
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Test.Utilities Imports Roslyn.Test.Utilities Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.VisualBasic Public Class ImplementsStatementTests Inherits AbstractCodeElementTests #Region "GetStartPoint() tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestGetStartPoint1() Dim code = <Code> Interface I End Interface Class C Implements $$I End Class </Code> TestGetStartPoint(code, Part(EnvDTE.vsCMPart.vsCMPartAttributes, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartBody, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeader, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartName, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartNavigate, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWhole, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes, TextPoint(line:=5, lineOffset:=5, absoluteOffset:=40, lineLength:=16))) End Sub #End Region #Region "GetEndPoint() tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestGetEndPoint1() Dim code = <Code> Interface I End Interface Class C Implements $$I End Class </Code> TestGetEndPoint(code, Part(EnvDTE.vsCMPart.vsCMPartAttributes, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartBody, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeader, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartName, NullTextPoint), Part(EnvDTE.vsCMPart.vsCMPartNavigate, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWhole, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16)), Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes, TextPoint(line:=5, lineOffset:=17, absoluteOffset:=52, lineLength:=16))) End Sub #End Region #Region "Kind tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestKind1() Dim code = <Code> Interface I End Interface Class C Implements I$$ End Class </Code> TestKind(code, EnvDTE.vsCMElement.vsCMElementImplementsStmt) End Sub #End Region #Region "Name tests" <WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)> Public Sub TestName1() Dim code = <Code> Interface I End Interface Class C Implements I$$ End Class </Code> TestName(code, "Implements") End Sub #End Region Protected Overrides ReadOnly Property LanguageName As String Get Return LanguageNames.VisualBasic End Get End Property End Class End Namespace
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Compilers/Test/Core/Extensions/OperationExtensions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable namespace Microsoft.CodeAnalysis.Test.Utilities { internal static class OperationTestExtensions { public static bool MustHaveNullType(this IOperation operation) { switch (operation.Kind) { // TODO: Expand to cover all operations that must always have null type. case OperationKind.ArrayInitializer: case OperationKind.Argument: return true; default: return false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable namespace Microsoft.CodeAnalysis.Test.Utilities { internal static class OperationTestExtensions { public static bool MustHaveNullType(this IOperation operation) { switch (operation.Kind) { // TODO: Expand to cover all operations that must always have null type. case OperationKind.ArrayInitializer: case OperationKind.Argument: return true; default: return false; } } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./eng/targets/PackageProject.targets
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project> <!-- Include this targets file in projects that build meta-packages. --> <!-- Projects that import this targets file do not produce binaries, they are only used to generate packages. The Build target only needs to build the project's dependencies (via ResolveProjectReferences). --> <Target Name="CoreBuild" DependsOnTargets="ResolveProjectReferences"> <MakeDir Directories="$(IntermediateOutputPath)" ContinueOnError="True"/> </Target> <PropertyGroup> <ProduceReferenceAssembly>false</ProduceReferenceAssembly> <!-- Remove once https://github.com/NuGet/Home/issues/8583 is fixed --> <NoWarn>$(NoWarn);NU5128</NoWarn> </PropertyGroup> </Project>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project> <!-- Include this targets file in projects that build meta-packages. --> <!-- Projects that import this targets file do not produce binaries, they are only used to generate packages. The Build target only needs to build the project's dependencies (via ResolveProjectReferences). --> <Target Name="CoreBuild" DependsOnTargets="ResolveProjectReferences"> <MakeDir Directories="$(IntermediateOutputPath)" ContinueOnError="True"/> </Target> <PropertyGroup> <ProduceReferenceAssembly>false</ProduceReferenceAssembly> <!-- Remove once https://github.com/NuGet/Home/issues/8583 is fixed --> <NoWarn>$(NoWarn);NU5128</NoWarn> </PropertyGroup> </Project>
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./docs/wiki/Getting-Started-C#-Semantic-Analysis.md
## Prerequisites * [Visual Studio 2015](https://www.visualstudio.com/downloads) * [.NET Compiler Platform SDK](https://aka.ms/roslynsdktemplates) * [Getting Started C# Syntax Analysis](https://github.com/dotnet/roslyn/blob/main/docs/wiki/Getting-Started-C%23-Syntax-Analysis.md) ## Introduction Today, the Visual Basic and C# compilers are black boxes - text goes in and bytes come out - with no transparency into the intermediate phases of the compilation pipeline. With the **.NET Compiler Platform** (formerly known as "Roslyn"), tools and developers can leverage the exact same data structures and algorithms the compiler uses to analyze and understand code with confidence that information is accurate and complete. In this walkthrough we'll explore the **Symbol** and **Binding APIs**. The **Syntax API** exposes the parsers, the syntax trees themselves, and utilities for reasoning about and constructing them. ## Understanding Compilations and Symbols The **Syntax API** allows you to look at the _structure_ of a program. However, often you'll want richer information about the semantics or _meaning_ of a program. And while a loose code file or snippet of VB or C# code can be syntactically analyzed in isolation it's not very meaningful to ask questions such as "what's the type of this variable" in a vacuum. The meaning of a type name may be dependent on assembly references, namespace imports, or other code files. That's where the **Compilation** class comes in. A **Compilation** is analogous to a single project as seen by the compiler and represents everything needed to compile a Visual Basic or C# program such as assembly references, compiler options, and the set of source files to be compiled. With this context you can reason about the meaning of code. **Compilations** allow you to find **Symbols** - entities such as types, namespaces, members, and variables which names and other expressions refer to. The process of associating names and expressions with **Symbols** is called **Binding**. Like **SyntaxTree**, **Compilation** is an abstract class with language-specific derivatives. When creating an instance of Compilation you must invoke a factory method on the **CSharpCompilation** (or **VisualBasicCompilation**) class. #### Example - Creating a compilation This example shows how to create a **Compilation** by adding assembly references and source files. Like the syntax trees, everything in the Symbols API and the Binding API is immutable. 1) Create a new C# **Stand-Alone Code Analysis Tool** project. * In Visual Studio, choose **File -> New -> Project...** to display the New Project dialog. * Under **Visual C# -> Extensibility**, choose **Stand-Alone Code Analysis Tool**. * Name your project "**SemanticsCS**" and click OK. 2) Replace the contents of your **Program.cs** with the following: ```C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace SemanticsCS { class Program { static void Main(string[] args) { SyntaxTree tree = CSharpSyntaxTree.ParseText( @"using System; using System.Collections.Generic; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine(""Hello, World!""); } } }"); var root = (CompilationUnitSyntax)tree.GetRoot(); } } } ``` 3) Next, add this code to the end of your **Main** method to construct a **CSharpCompilation** object: ```C# var compilation = CSharpCompilation.Create("HelloWorld") .AddReferences( MetadataReference.CreateFromFile( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree); ``` 4) Move your cursor to the line containing the **closing brace** of your **Main** method and set a breakpoint there. * In Visual Studio, choose **Debug -> Toggle Breakpoint**. 5) Run the program. * In Visual Studio, choose **Debug -> Start Debugging**. 6) Inspect the root variable in the debugger by hovering over it and expanding the datatip. ## The SemanticModel Once you have a **Compilation** you can ask it for a **SemanticModel** for any **SyntaxTree** contained in that **Compilation**. **SemanticModels** can be queried to answer questions like "What names are in scope at this location?" "What members are accessible from this method?" "What variables are used in this block of text?" and "What does this name/expression refer to?" #### Example - Binding a name This example shows how to obtain a **SemanticModel** object for our HelloWorld **SyntaxTree**. Once the model is obtained, the name in the first **using** directive is bound to retrieve a **Symbol** for the **System** namespace. 1) Add this code to the end of your Main method. The code gets a **SemanticModel** for the HelloWorld **SyntaxTree** and stores it in a new variable: ```C# var model = compilation.GetSemanticModel(tree); ``` 2) Set this statement as the next statement to be executed and execute it. * Right-click this line and choose **Set Next Statement**. * In Visual Studio, choose **Debug -> Step Over**, to execute this statement and initialize the new variable. * You will need to repeat this process for each of the following steps as we introduce new variables and inspect them with the debugger. 3) Now add this code to bind the **Name** of the "**using System;**" directive using the **SemanticModel.GetSymbolInfo** method: ```C# var nameInfo = model.GetSymbolInfo(root.Usings[0].Name); ``` 4) Execute this statement and hover over the **nameInfo** variable and expand the datatip to inspect the **SymbolInfo** object returned. * Note the **Symbol** property. This property returns the **Symbol** this expression refers to. For expressions which don't refer to anything (such as numeric literals) this property will be null. * Note that the **Symbol.Kind** property returns the value **SymbolKind.Namespace**. 5) Cast the symbol to a **NamespaceSymbol** instance and store it in a new variable: ```C# var systemSymbol = (INamespaceSymbol)nameInfo.Symbol; ``` 6) Execute this statement and examine the **systemSymbol** variable using the debugger datatips. 7) Stop the program. * In Visual Studio, choose **Debug -> Stop** debugging. 8) Add the following code to enumerate the sub-namespaces of the **System** namespace and print their names to the **Console**: ```C# foreach (var ns in systemSymbol.GetNamespaceMembers()) { Console.WriteLine(ns.Name); } ``` 9) Press **Ctrl+F5** to run the program. You should see the following output: ``` Collections Configuration Deployment Diagnostics Globalization IO Reflection Resources Runtime Security StubHelpers Text Threading Press any key to continue . . . ``` #### Example - Binding an expression The previous example showed how to bind name to find a **Symbol**. However, there are other expressions in a C# program that can be bound that aren't names. This example shows how binding works with other expression types - in this case a simple string literal. 1) Add the following code to locate the "**Hello, World!**" string literal in the **SyntaxTree** and store it in a variable (it should be the only **LiteralExpressionSyntax** in this example): ```C# var helloWorldString = root.DescendantNodes() .OfType<LiteralExpressionSyntax>() .First(); ``` 2) Start debugging the program. 3) Add the following code to get the **TypeInfo** for this expression: ```C# var literalInfo = model.GetTypeInfo(helloWorldString); ``` 4) Execute this statement and examine the **literalInfo**. * Note that its **Type** property is not null and returns the **INamedTypeSymbol** for the **System.String** type because the string literal expression has a compile-time type of **System.String** 5) Stop the program. 6) Add the following code to enumerate the public methods of the **System.String** class which return strings and print their names to the **Console**: ```C# var stringTypeSymbol = (INamedTypeSymbol)literalInfo.Type; Console.Clear(); foreach (var name in (from method in stringTypeSymbol.GetMembers() .OfType<IMethodSymbol>() where method.ReturnType.Equals(stringTypeSymbol) && method.DeclaredAccessibility == Accessibility.Public select method.Name).Distinct()) { Console.WriteLine(name); } ``` 7) Press **Ctrl+F5** to run to run the program without debugging it. You should see the following output: ``` Join Substring Trim TrimStart TrimEnd Normalize PadLeft PadRight ToLower ToLowerInvariant ToUpper ToUpperInvariant ToString Insert Replace Remove Format Copy Concat Intern IsInterned Press any key to continue . . . ``` 8) Your **Program.cs** file should now look like this: ```C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace SemanticsCS { class Program { static void Main(string[] args) { SyntaxTree tree = CSharpSyntaxTree.ParseText( @" using System; using System.Collections.Generic; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine(""Hello, World!""); } } }"); var root = (CompilationUnitSyntax)tree.GetRoot(); var compilation = CSharpCompilation.Create("HelloWorld") .AddReferences( MetadataReference.CreateFromFile( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree); var model = compilation.GetSemanticModel(tree); var nameInfo = model.GetSymbolInfo(root.Usings[0].Name); var systemSymbol = (INamespaceSymbol)nameInfo.Symbol; foreach (var ns in systemSymbol.GetNamespaceMembers()) { Console.WriteLine(ns.Name); } var helloWorldString = root.DescendantNodes() .OfType<LiteralExpressionSyntax>() .First(); var literalInfo = model.GetTypeInfo(helloWorldString); var stringTypeSymbol = (INamedTypeSymbol)literalInfo.Type; Console.Clear(); foreach (var name in (from method in stringTypeSymbol.GetMembers() .OfType<IMethodSymbol>() where method.ReturnType.Equals(stringTypeSymbol) && method.DeclaredAccessibility == Accessibility.Public select method.Name).Distinct()) { Console.WriteLine(name); } } } } ``` 9) Congratulations! You've just used the **Symbol** and **Binding APIs** to analyze the meaning of names and expressions in a C# program.
## Prerequisites * [Visual Studio 2015](https://www.visualstudio.com/downloads) * [.NET Compiler Platform SDK](https://aka.ms/roslynsdktemplates) * [Getting Started C# Syntax Analysis](https://github.com/dotnet/roslyn/blob/main/docs/wiki/Getting-Started-C%23-Syntax-Analysis.md) ## Introduction Today, the Visual Basic and C# compilers are black boxes - text goes in and bytes come out - with no transparency into the intermediate phases of the compilation pipeline. With the **.NET Compiler Platform** (formerly known as "Roslyn"), tools and developers can leverage the exact same data structures and algorithms the compiler uses to analyze and understand code with confidence that information is accurate and complete. In this walkthrough we'll explore the **Symbol** and **Binding APIs**. The **Syntax API** exposes the parsers, the syntax trees themselves, and utilities for reasoning about and constructing them. ## Understanding Compilations and Symbols The **Syntax API** allows you to look at the _structure_ of a program. However, often you'll want richer information about the semantics or _meaning_ of a program. And while a loose code file or snippet of VB or C# code can be syntactically analyzed in isolation it's not very meaningful to ask questions such as "what's the type of this variable" in a vacuum. The meaning of a type name may be dependent on assembly references, namespace imports, or other code files. That's where the **Compilation** class comes in. A **Compilation** is analogous to a single project as seen by the compiler and represents everything needed to compile a Visual Basic or C# program such as assembly references, compiler options, and the set of source files to be compiled. With this context you can reason about the meaning of code. **Compilations** allow you to find **Symbols** - entities such as types, namespaces, members, and variables which names and other expressions refer to. The process of associating names and expressions with **Symbols** is called **Binding**. Like **SyntaxTree**, **Compilation** is an abstract class with language-specific derivatives. When creating an instance of Compilation you must invoke a factory method on the **CSharpCompilation** (or **VisualBasicCompilation**) class. #### Example - Creating a compilation This example shows how to create a **Compilation** by adding assembly references and source files. Like the syntax trees, everything in the Symbols API and the Binding API is immutable. 1) Create a new C# **Stand-Alone Code Analysis Tool** project. * In Visual Studio, choose **File -> New -> Project...** to display the New Project dialog. * Under **Visual C# -> Extensibility**, choose **Stand-Alone Code Analysis Tool**. * Name your project "**SemanticsCS**" and click OK. 2) Replace the contents of your **Program.cs** with the following: ```C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace SemanticsCS { class Program { static void Main(string[] args) { SyntaxTree tree = CSharpSyntaxTree.ParseText( @"using System; using System.Collections.Generic; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine(""Hello, World!""); } } }"); var root = (CompilationUnitSyntax)tree.GetRoot(); } } } ``` 3) Next, add this code to the end of your **Main** method to construct a **CSharpCompilation** object: ```C# var compilation = CSharpCompilation.Create("HelloWorld") .AddReferences( MetadataReference.CreateFromFile( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree); ``` 4) Move your cursor to the line containing the **closing brace** of your **Main** method and set a breakpoint there. * In Visual Studio, choose **Debug -> Toggle Breakpoint**. 5) Run the program. * In Visual Studio, choose **Debug -> Start Debugging**. 6) Inspect the root variable in the debugger by hovering over it and expanding the datatip. ## The SemanticModel Once you have a **Compilation** you can ask it for a **SemanticModel** for any **SyntaxTree** contained in that **Compilation**. **SemanticModels** can be queried to answer questions like "What names are in scope at this location?" "What members are accessible from this method?" "What variables are used in this block of text?" and "What does this name/expression refer to?" #### Example - Binding a name This example shows how to obtain a **SemanticModel** object for our HelloWorld **SyntaxTree**. Once the model is obtained, the name in the first **using** directive is bound to retrieve a **Symbol** for the **System** namespace. 1) Add this code to the end of your Main method. The code gets a **SemanticModel** for the HelloWorld **SyntaxTree** and stores it in a new variable: ```C# var model = compilation.GetSemanticModel(tree); ``` 2) Set this statement as the next statement to be executed and execute it. * Right-click this line and choose **Set Next Statement**. * In Visual Studio, choose **Debug -> Step Over**, to execute this statement and initialize the new variable. * You will need to repeat this process for each of the following steps as we introduce new variables and inspect them with the debugger. 3) Now add this code to bind the **Name** of the "**using System;**" directive using the **SemanticModel.GetSymbolInfo** method: ```C# var nameInfo = model.GetSymbolInfo(root.Usings[0].Name); ``` 4) Execute this statement and hover over the **nameInfo** variable and expand the datatip to inspect the **SymbolInfo** object returned. * Note the **Symbol** property. This property returns the **Symbol** this expression refers to. For expressions which don't refer to anything (such as numeric literals) this property will be null. * Note that the **Symbol.Kind** property returns the value **SymbolKind.Namespace**. 5) Cast the symbol to a **NamespaceSymbol** instance and store it in a new variable: ```C# var systemSymbol = (INamespaceSymbol)nameInfo.Symbol; ``` 6) Execute this statement and examine the **systemSymbol** variable using the debugger datatips. 7) Stop the program. * In Visual Studio, choose **Debug -> Stop** debugging. 8) Add the following code to enumerate the sub-namespaces of the **System** namespace and print their names to the **Console**: ```C# foreach (var ns in systemSymbol.GetNamespaceMembers()) { Console.WriteLine(ns.Name); } ``` 9) Press **Ctrl+F5** to run the program. You should see the following output: ``` Collections Configuration Deployment Diagnostics Globalization IO Reflection Resources Runtime Security StubHelpers Text Threading Press any key to continue . . . ``` #### Example - Binding an expression The previous example showed how to bind name to find a **Symbol**. However, there are other expressions in a C# program that can be bound that aren't names. This example shows how binding works with other expression types - in this case a simple string literal. 1) Add the following code to locate the "**Hello, World!**" string literal in the **SyntaxTree** and store it in a variable (it should be the only **LiteralExpressionSyntax** in this example): ```C# var helloWorldString = root.DescendantNodes() .OfType<LiteralExpressionSyntax>() .First(); ``` 2) Start debugging the program. 3) Add the following code to get the **TypeInfo** for this expression: ```C# var literalInfo = model.GetTypeInfo(helloWorldString); ``` 4) Execute this statement and examine the **literalInfo**. * Note that its **Type** property is not null and returns the **INamedTypeSymbol** for the **System.String** type because the string literal expression has a compile-time type of **System.String** 5) Stop the program. 6) Add the following code to enumerate the public methods of the **System.String** class which return strings and print their names to the **Console**: ```C# var stringTypeSymbol = (INamedTypeSymbol)literalInfo.Type; Console.Clear(); foreach (var name in (from method in stringTypeSymbol.GetMembers() .OfType<IMethodSymbol>() where method.ReturnType.Equals(stringTypeSymbol) && method.DeclaredAccessibility == Accessibility.Public select method.Name).Distinct()) { Console.WriteLine(name); } ``` 7) Press **Ctrl+F5** to run to run the program without debugging it. You should see the following output: ``` Join Substring Trim TrimStart TrimEnd Normalize PadLeft PadRight ToLower ToLowerInvariant ToUpper ToUpperInvariant ToString Insert Replace Remove Format Copy Concat Intern IsInterned Press any key to continue . . . ``` 8) Your **Program.cs** file should now look like this: ```C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace SemanticsCS { class Program { static void Main(string[] args) { SyntaxTree tree = CSharpSyntaxTree.ParseText( @" using System; using System.Collections.Generic; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine(""Hello, World!""); } } }"); var root = (CompilationUnitSyntax)tree.GetRoot(); var compilation = CSharpCompilation.Create("HelloWorld") .AddReferences( MetadataReference.CreateFromFile( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree); var model = compilation.GetSemanticModel(tree); var nameInfo = model.GetSymbolInfo(root.Usings[0].Name); var systemSymbol = (INamespaceSymbol)nameInfo.Symbol; foreach (var ns in systemSymbol.GetNamespaceMembers()) { Console.WriteLine(ns.Name); } var helloWorldString = root.DescendantNodes() .OfType<LiteralExpressionSyntax>() .First(); var literalInfo = model.GetTypeInfo(helloWorldString); var stringTypeSymbol = (INamedTypeSymbol)literalInfo.Type; Console.Clear(); foreach (var name in (from method in stringTypeSymbol.GetMembers() .OfType<IMethodSymbol>() where method.ReturnType.Equals(stringTypeSymbol) && method.DeclaredAccessibility == Accessibility.Public select method.Name).Distinct()) { Console.WriteLine(name); } } } } ``` 9) Congratulations! You've just used the **Symbol** and **Binding APIs** to analyze the meaning of names and expressions in a C# program.
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Compilers/Core/Portable/Syntax/SyntaxNodeOrTokenListBuilder.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Syntax { internal class SyntaxNodeOrTokenListBuilder { private GreenNode?[] _nodes; private int _count; public SyntaxNodeOrTokenListBuilder(int size) { _nodes = new GreenNode?[size]; _count = 0; } public static SyntaxNodeOrTokenListBuilder Create() { return new SyntaxNodeOrTokenListBuilder(8); } public int Count { get { return _count; } } public void Clear() { _count = 0; } public SyntaxNodeOrToken this[int index] { get { var innerNode = _nodes[index]; RoslynDebug.Assert(innerNode is object); if (innerNode.IsToken == true) { // getting internal token so we do not know the position return new SyntaxNodeOrToken(null, innerNode, 0, 0); } else { return innerNode.CreateRed(); } } set { _nodes[index] = value.UnderlyingNode; } } internal void Add(GreenNode item) { if (_count >= _nodes.Length) { this.Grow(_count == 0 ? 8 : _nodes.Length * 2); } _nodes[_count++] = item; } public void Add(SyntaxNode item) { this.Add(item.Green); } public void Add(in SyntaxToken item) { RoslynDebug.Assert(item.Node is object); this.Add(item.Node); } public void Add(in SyntaxNodeOrToken item) { RoslynDebug.Assert(item.UnderlyingNode is object); this.Add(item.UnderlyingNode); } public void Add(SyntaxNodeOrTokenList list) { this.Add(list, 0, list.Count); } public void Add(SyntaxNodeOrTokenList list, int offset, int length) { if (_count + length > _nodes.Length) { this.Grow(_count + length); } list.CopyTo(offset, _nodes, _count, length); _count += length; } public void Add(IEnumerable<SyntaxNodeOrToken> nodeOrTokens) { foreach (var n in nodeOrTokens) { this.Add(n); } } internal void RemoveLast() { _count--; _nodes[_count] = null; } private void Grow(int size) { var tmp = new GreenNode[size]; Array.Copy(_nodes, tmp, _nodes.Length); _nodes = tmp; } public SyntaxNodeOrTokenList ToList() { if (_count > 0) { switch (_count) { case 1: if (_nodes[0]!.IsToken) { return new SyntaxNodeOrTokenList( InternalSyntax.SyntaxList.List(new[] { _nodes[0]! }).CreateRed(), index: 0); } else { return new SyntaxNodeOrTokenList(_nodes[0]!.CreateRed(), index: 0); } case 2: return new SyntaxNodeOrTokenList( InternalSyntax.SyntaxList.List(_nodes[0]!, _nodes[1]!).CreateRed(), index: 0); case 3: return new SyntaxNodeOrTokenList( InternalSyntax.SyntaxList.List(_nodes[0]!, _nodes[1]!, _nodes[2]!).CreateRed(), index: 0); default: var tmp = new ArrayElement<GreenNode>[_count]; for (int i = 0; i < _count; i++) { tmp[i].Value = _nodes[i]!; } return new SyntaxNodeOrTokenList(InternalSyntax.SyntaxList.List(tmp).CreateRed(), index: 0); } } else { return default(SyntaxNodeOrTokenList); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Syntax { internal class SyntaxNodeOrTokenListBuilder { private GreenNode?[] _nodes; private int _count; public SyntaxNodeOrTokenListBuilder(int size) { _nodes = new GreenNode?[size]; _count = 0; } public static SyntaxNodeOrTokenListBuilder Create() { return new SyntaxNodeOrTokenListBuilder(8); } public int Count { get { return _count; } } public void Clear() { _count = 0; } public SyntaxNodeOrToken this[int index] { get { var innerNode = _nodes[index]; RoslynDebug.Assert(innerNode is object); if (innerNode.IsToken == true) { // getting internal token so we do not know the position return new SyntaxNodeOrToken(null, innerNode, 0, 0); } else { return innerNode.CreateRed(); } } set { _nodes[index] = value.UnderlyingNode; } } internal void Add(GreenNode item) { if (_count >= _nodes.Length) { this.Grow(_count == 0 ? 8 : _nodes.Length * 2); } _nodes[_count++] = item; } public void Add(SyntaxNode item) { this.Add(item.Green); } public void Add(in SyntaxToken item) { RoslynDebug.Assert(item.Node is object); this.Add(item.Node); } public void Add(in SyntaxNodeOrToken item) { RoslynDebug.Assert(item.UnderlyingNode is object); this.Add(item.UnderlyingNode); } public void Add(SyntaxNodeOrTokenList list) { this.Add(list, 0, list.Count); } public void Add(SyntaxNodeOrTokenList list, int offset, int length) { if (_count + length > _nodes.Length) { this.Grow(_count + length); } list.CopyTo(offset, _nodes, _count, length); _count += length; } public void Add(IEnumerable<SyntaxNodeOrToken> nodeOrTokens) { foreach (var n in nodeOrTokens) { this.Add(n); } } internal void RemoveLast() { _count--; _nodes[_count] = null; } private void Grow(int size) { var tmp = new GreenNode[size]; Array.Copy(_nodes, tmp, _nodes.Length); _nodes = tmp; } public SyntaxNodeOrTokenList ToList() { if (_count > 0) { switch (_count) { case 1: if (_nodes[0]!.IsToken) { return new SyntaxNodeOrTokenList( InternalSyntax.SyntaxList.List(new[] { _nodes[0]! }).CreateRed(), index: 0); } else { return new SyntaxNodeOrTokenList(_nodes[0]!.CreateRed(), index: 0); } case 2: return new SyntaxNodeOrTokenList( InternalSyntax.SyntaxList.List(_nodes[0]!, _nodes[1]!).CreateRed(), index: 0); case 3: return new SyntaxNodeOrTokenList( InternalSyntax.SyntaxList.List(_nodes[0]!, _nodes[1]!, _nodes[2]!).CreateRed(), index: 0); default: var tmp = new ArrayElement<GreenNode>[_count]; for (int i = 0; i < _count; i++) { tmp[i].Value = _nodes[i]!; } return new SyntaxNodeOrTokenList(InternalSyntax.SyntaxList.List(tmp).CreateRed(), index: 0); } } else { return default(SyntaxNodeOrTokenList); } } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.CodeAnalysis.Host { internal interface ICompilationFactoryService : ILanguageService { Compilation CreateCompilation(string assemblyName, CompilationOptions options); Compilation CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type? hostObjectType); CompilationOptions GetDefaultCompilationOptions(); GeneratorDriver CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray<ISourceGenerator> generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray<AdditionalText> additionalTexts); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.CodeAnalysis.Host { internal interface ICompilationFactoryService : ILanguageService { Compilation CreateCompilation(string assemblyName, CompilationOptions options); Compilation CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type? hostObjectType); CompilationOptions GetDefaultCompilationOptions(); GeneratorDriver CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray<ISourceGenerator> generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray<AdditionalText> additionalTexts); } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenShortCircuitOperatorTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen { public class CodeGenShortCircuitOperatorTests : CSharpTestBase { [Fact] public void TestShortCircuitAnd() { var source = @" class C { public static bool Test(char ch, bool result) { System.Console.WriteLine(ch); return result; } public static void Main() { const bool c1 = true; const bool c2 = false; bool v1 = true; bool v2 = false; System.Console.WriteLine(true && true); System.Console.WriteLine(true && false); System.Console.WriteLine(false && true); System.Console.WriteLine(false && false); System.Console.WriteLine(c1 && c1); System.Console.WriteLine(c1 && c2); System.Console.WriteLine(c2 && c1); System.Console.WriteLine(c2 && c2); System.Console.WriteLine(v1 && v1); System.Console.WriteLine(v1 && v2); System.Console.WriteLine(v2 && v1); System.Console.WriteLine(v2 && v2); System.Console.WriteLine(Test('L', true) && Test('R', true)); System.Console.WriteLine(Test('L', true) && Test('R', false)); System.Console.WriteLine(Test('L', false) && Test('R', true)); System.Console.WriteLine(Test('L', false) && Test('R', false)); } } "; var compilation = CompileAndVerify(source, expectedOutput: @" True False False False True False False False True False False False L R True L R False L False L False "); compilation.VerifyIL("C.Main", @" { // Code size 189 (0xbd) .maxstack 2 .locals init (bool V_0, //v1 bool V_1) //v2 IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: ldc.i4.0 IL_0003: stloc.1 IL_0004: ldc.i4.1 IL_0005: call ""void System.Console.WriteLine(bool)"" IL_000a: ldc.i4.0 IL_000b: call ""void System.Console.WriteLine(bool)"" IL_0010: ldc.i4.0 IL_0011: call ""void System.Console.WriteLine(bool)"" IL_0016: ldc.i4.0 IL_0017: call ""void System.Console.WriteLine(bool)"" IL_001c: ldc.i4.1 IL_001d: call ""void System.Console.WriteLine(bool)"" IL_0022: ldc.i4.0 IL_0023: call ""void System.Console.WriteLine(bool)"" IL_0028: ldc.i4.0 IL_0029: call ""void System.Console.WriteLine(bool)"" IL_002e: ldc.i4.0 IL_002f: call ""void System.Console.WriteLine(bool)"" IL_0034: ldloc.0 IL_0035: ldloc.0 IL_0036: and IL_0037: call ""void System.Console.WriteLine(bool)"" IL_003c: ldloc.0 IL_003d: ldloc.1 IL_003e: and IL_003f: call ""void System.Console.WriteLine(bool)"" IL_0044: ldloc.1 IL_0045: ldloc.0 IL_0046: and IL_0047: call ""void System.Console.WriteLine(bool)"" IL_004c: ldloc.1 IL_004d: ldloc.1 IL_004e: and IL_004f: call ""void System.Console.WriteLine(bool)"" IL_0054: ldc.i4.s 76 IL_0056: ldc.i4.1 IL_0057: call ""bool C.Test(char, bool)"" IL_005c: brfalse.s IL_0068 IL_005e: ldc.i4.s 82 IL_0060: ldc.i4.1 IL_0061: call ""bool C.Test(char, bool)"" IL_0066: br.s IL_0069 IL_0068: ldc.i4.0 IL_0069: call ""void System.Console.WriteLine(bool)"" IL_006e: ldc.i4.s 76 IL_0070: ldc.i4.1 IL_0071: call ""bool C.Test(char, bool)"" IL_0076: brfalse.s IL_0082 IL_0078: ldc.i4.s 82 IL_007a: ldc.i4.0 IL_007b: call ""bool C.Test(char, bool)"" IL_0080: br.s IL_0083 IL_0082: ldc.i4.0 IL_0083: call ""void System.Console.WriteLine(bool)"" IL_0088: ldc.i4.s 76 IL_008a: ldc.i4.0 IL_008b: call ""bool C.Test(char, bool)"" IL_0090: brfalse.s IL_009c IL_0092: ldc.i4.s 82 IL_0094: ldc.i4.1 IL_0095: call ""bool C.Test(char, bool)"" IL_009a: br.s IL_009d IL_009c: ldc.i4.0 IL_009d: call ""void System.Console.WriteLine(bool)"" IL_00a2: ldc.i4.s 76 IL_00a4: ldc.i4.0 IL_00a5: call ""bool C.Test(char, bool)"" IL_00aa: brfalse.s IL_00b6 IL_00ac: ldc.i4.s 82 IL_00ae: ldc.i4.0 IL_00af: call ""bool C.Test(char, bool)"" IL_00b4: br.s IL_00b7 IL_00b6: ldc.i4.0 IL_00b7: call ""void System.Console.WriteLine(bool)"" IL_00bc: ret }"); } [Fact] public void TestShortCircuitOr() { var source = @" class C { public static bool Test(char ch, bool result) { System.Console.WriteLine(ch); return result; } public static void Main() { const bool c1 = true; const bool c2 = false; bool v1 = true; bool v2 = false; System.Console.WriteLine(true || true); System.Console.WriteLine(true || false); System.Console.WriteLine(false || true); System.Console.WriteLine(false || false); System.Console.WriteLine(c1 || c1); System.Console.WriteLine(c1 || c2); System.Console.WriteLine(c2 || c1); System.Console.WriteLine(c2 || c2); System.Console.WriteLine(v1 || v1); System.Console.WriteLine(v1 || v2); System.Console.WriteLine(v2 || v1); System.Console.WriteLine(v2 || v2); System.Console.WriteLine(Test('L', true) || Test('R', true)); System.Console.WriteLine(Test('L', true) || Test('R', false)); System.Console.WriteLine(Test('L', false) || Test('R', true)); System.Console.WriteLine(Test('L', false) || Test('R', false)); } } "; var compilation = CompileAndVerify(source, expectedOutput: @" True True True False True True True False True True True False L True L True L R True L R False "); compilation.VerifyIL("C.Main", @" { // Code size 189 (0xbd) .maxstack 2 .locals init (bool V_0, //v1 bool V_1) //v2 IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: ldc.i4.0 IL_0003: stloc.1 IL_0004: ldc.i4.1 IL_0005: call ""void System.Console.WriteLine(bool)"" IL_000a: ldc.i4.1 IL_000b: call ""void System.Console.WriteLine(bool)"" IL_0010: ldc.i4.1 IL_0011: call ""void System.Console.WriteLine(bool)"" IL_0016: ldc.i4.0 IL_0017: call ""void System.Console.WriteLine(bool)"" IL_001c: ldc.i4.1 IL_001d: call ""void System.Console.WriteLine(bool)"" IL_0022: ldc.i4.1 IL_0023: call ""void System.Console.WriteLine(bool)"" IL_0028: ldc.i4.1 IL_0029: call ""void System.Console.WriteLine(bool)"" IL_002e: ldc.i4.0 IL_002f: call ""void System.Console.WriteLine(bool)"" IL_0034: ldloc.0 IL_0035: ldloc.0 IL_0036: or IL_0037: call ""void System.Console.WriteLine(bool)"" IL_003c: ldloc.0 IL_003d: ldloc.1 IL_003e: or IL_003f: call ""void System.Console.WriteLine(bool)"" IL_0044: ldloc.1 IL_0045: ldloc.0 IL_0046: or IL_0047: call ""void System.Console.WriteLine(bool)"" IL_004c: ldloc.1 IL_004d: ldloc.1 IL_004e: or IL_004f: call ""void System.Console.WriteLine(bool)"" IL_0054: ldc.i4.s 76 IL_0056: ldc.i4.1 IL_0057: call ""bool C.Test(char, bool)"" IL_005c: brtrue.s IL_0068 IL_005e: ldc.i4.s 82 IL_0060: ldc.i4.1 IL_0061: call ""bool C.Test(char, bool)"" IL_0066: br.s IL_0069 IL_0068: ldc.i4.1 IL_0069: call ""void System.Console.WriteLine(bool)"" IL_006e: ldc.i4.s 76 IL_0070: ldc.i4.1 IL_0071: call ""bool C.Test(char, bool)"" IL_0076: brtrue.s IL_0082 IL_0078: ldc.i4.s 82 IL_007a: ldc.i4.0 IL_007b: call ""bool C.Test(char, bool)"" IL_0080: br.s IL_0083 IL_0082: ldc.i4.1 IL_0083: call ""void System.Console.WriteLine(bool)"" IL_0088: ldc.i4.s 76 IL_008a: ldc.i4.0 IL_008b: call ""bool C.Test(char, bool)"" IL_0090: brtrue.s IL_009c IL_0092: ldc.i4.s 82 IL_0094: ldc.i4.1 IL_0095: call ""bool C.Test(char, bool)"" IL_009a: br.s IL_009d IL_009c: ldc.i4.1 IL_009d: call ""void System.Console.WriteLine(bool)"" IL_00a2: ldc.i4.s 76 IL_00a4: ldc.i4.0 IL_00a5: call ""bool C.Test(char, bool)"" IL_00aa: brtrue.s IL_00b6 IL_00ac: ldc.i4.s 82 IL_00ae: ldc.i4.0 IL_00af: call ""bool C.Test(char, bool)"" IL_00b4: br.s IL_00b7 IL_00b6: ldc.i4.1 IL_00b7: call ""void System.Console.WriteLine(bool)"" IL_00bc: ret }"); } [Fact] public void TestChainedShortCircuitOperators() { var source = @" class C { public static bool Test(char ch, bool result) { System.Console.WriteLine(ch); return result; } public static void Main() { // AND AND System.Console.WriteLine(Test('A', true) && Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', true) && Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', false) && Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', false) && Test('C' , false)); // AND OR System.Console.WriteLine(Test('A', true) && Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', true) && Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', false) || Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', false) || Test('C' , false)); // OR AND System.Console.WriteLine(Test('A', true) || Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', true) || Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', false) && Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', false) && Test('C' , false)); // OR OR System.Console.WriteLine(Test('A', true) || Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', true) || Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', false) || Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', false) || Test('C' , false)); } } "; var compilation = CompileAndVerify(source, expectedOutput: @" A B C True A B C False A B False A B False A False A False A False A False A B True A B True A B C True A B C False A C True A C False A C True A C False A True A True A True A True A B C True A B C False A B False A B False A True A True A True A True A B True A B True A B C True A B C False "); compilation.VerifyIL("C.Main", @"{ // Code size 1177 (0x499) .maxstack 2 IL_0000: ldc.i4.s 65 IL_0002: ldc.i4.1 IL_0003: call ""bool C.Test(char, bool)"" IL_0008: brfalse.s IL_001e IL_000a: ldc.i4.s 66 IL_000c: ldc.i4.1 IL_000d: call ""bool C.Test(char, bool)"" IL_0012: brfalse.s IL_001e IL_0014: ldc.i4.s 67 IL_0016: ldc.i4.1 IL_0017: call ""bool C.Test(char, bool)"" IL_001c: br.s IL_001f IL_001e: ldc.i4.0 IL_001f: call ""void System.Console.WriteLine(bool)"" IL_0024: ldc.i4.s 65 IL_0026: ldc.i4.1 IL_0027: call ""bool C.Test(char, bool)"" IL_002c: brfalse.s IL_0042 IL_002e: ldc.i4.s 66 IL_0030: ldc.i4.1 IL_0031: call ""bool C.Test(char, bool)"" IL_0036: brfalse.s IL_0042 IL_0038: ldc.i4.s 67 IL_003a: ldc.i4.0 IL_003b: call ""bool C.Test(char, bool)"" IL_0040: br.s IL_0043 IL_0042: ldc.i4.0 IL_0043: call ""void System.Console.WriteLine(bool)"" IL_0048: ldc.i4.s 65 IL_004a: ldc.i4.1 IL_004b: call ""bool C.Test(char, bool)"" IL_0050: brfalse.s IL_0066 IL_0052: ldc.i4.s 66 IL_0054: ldc.i4.0 IL_0055: call ""bool C.Test(char, bool)"" IL_005a: brfalse.s IL_0066 IL_005c: ldc.i4.s 67 IL_005e: ldc.i4.1 IL_005f: call ""bool C.Test(char, bool)"" IL_0064: br.s IL_0067 IL_0066: ldc.i4.0 IL_0067: call ""void System.Console.WriteLine(bool)"" IL_006c: ldc.i4.s 65 IL_006e: ldc.i4.1 IL_006f: call ""bool C.Test(char, bool)"" IL_0074: brfalse.s IL_008a IL_0076: ldc.i4.s 66 IL_0078: ldc.i4.0 IL_0079: call ""bool C.Test(char, bool)"" IL_007e: brfalse.s IL_008a IL_0080: ldc.i4.s 67 IL_0082: ldc.i4.0 IL_0083: call ""bool C.Test(char, bool)"" IL_0088: br.s IL_008b IL_008a: ldc.i4.0 IL_008b: call ""void System.Console.WriteLine(bool)"" IL_0090: ldc.i4.s 65 IL_0092: ldc.i4.0 IL_0093: call ""bool C.Test(char, bool)"" IL_0098: brfalse.s IL_00ae IL_009a: ldc.i4.s 66 IL_009c: ldc.i4.1 IL_009d: call ""bool C.Test(char, bool)"" IL_00a2: brfalse.s IL_00ae IL_00a4: ldc.i4.s 67 IL_00a6: ldc.i4.1 IL_00a7: call ""bool C.Test(char, bool)"" IL_00ac: br.s IL_00af IL_00ae: ldc.i4.0 IL_00af: call ""void System.Console.WriteLine(bool)"" IL_00b4: ldc.i4.s 65 IL_00b6: ldc.i4.0 IL_00b7: call ""bool C.Test(char, bool)"" IL_00bc: brfalse.s IL_00d2 IL_00be: ldc.i4.s 66 IL_00c0: ldc.i4.1 IL_00c1: call ""bool C.Test(char, bool)"" IL_00c6: brfalse.s IL_00d2 IL_00c8: ldc.i4.s 67 IL_00ca: ldc.i4.0 IL_00cb: call ""bool C.Test(char, bool)"" IL_00d0: br.s IL_00d3 IL_00d2: ldc.i4.0 IL_00d3: call ""void System.Console.WriteLine(bool)"" IL_00d8: ldc.i4.s 65 IL_00da: ldc.i4.0 IL_00db: call ""bool C.Test(char, bool)"" IL_00e0: brfalse.s IL_00f6 IL_00e2: ldc.i4.s 66 IL_00e4: ldc.i4.0 IL_00e5: call ""bool C.Test(char, bool)"" IL_00ea: brfalse.s IL_00f6 IL_00ec: ldc.i4.s 67 IL_00ee: ldc.i4.1 IL_00ef: call ""bool C.Test(char, bool)"" IL_00f4: br.s IL_00f7 IL_00f6: ldc.i4.0 IL_00f7: call ""void System.Console.WriteLine(bool)"" IL_00fc: ldc.i4.s 65 IL_00fe: ldc.i4.0 IL_00ff: call ""bool C.Test(char, bool)"" IL_0104: brfalse.s IL_011a IL_0106: ldc.i4.s 66 IL_0108: ldc.i4.0 IL_0109: call ""bool C.Test(char, bool)"" IL_010e: brfalse.s IL_011a IL_0110: ldc.i4.s 67 IL_0112: ldc.i4.0 IL_0113: call ""bool C.Test(char, bool)"" IL_0118: br.s IL_011b IL_011a: ldc.i4.0 IL_011b: call ""void System.Console.WriteLine(bool)"" IL_0120: ldc.i4.s 65 IL_0122: ldc.i4.1 IL_0123: call ""bool C.Test(char, bool)"" IL_0128: brfalse.s IL_0134 IL_012a: ldc.i4.s 66 IL_012c: ldc.i4.1 IL_012d: call ""bool C.Test(char, bool)"" IL_0132: brtrue.s IL_013e IL_0134: ldc.i4.s 67 IL_0136: ldc.i4.1 IL_0137: call ""bool C.Test(char, bool)"" IL_013c: br.s IL_013f IL_013e: ldc.i4.1 IL_013f: call ""void System.Console.WriteLine(bool)"" IL_0144: ldc.i4.s 65 IL_0146: ldc.i4.1 IL_0147: call ""bool C.Test(char, bool)"" IL_014c: brfalse.s IL_0158 IL_014e: ldc.i4.s 66 IL_0150: ldc.i4.1 IL_0151: call ""bool C.Test(char, bool)"" IL_0156: brtrue.s IL_0162 IL_0158: ldc.i4.s 67 IL_015a: ldc.i4.0 IL_015b: call ""bool C.Test(char, bool)"" IL_0160: br.s IL_0163 IL_0162: ldc.i4.1 IL_0163: call ""void System.Console.WriteLine(bool)"" IL_0168: ldc.i4.s 65 IL_016a: ldc.i4.1 IL_016b: call ""bool C.Test(char, bool)"" IL_0170: brfalse.s IL_017c IL_0172: ldc.i4.s 66 IL_0174: ldc.i4.0 IL_0175: call ""bool C.Test(char, bool)"" IL_017a: brtrue.s IL_0186 IL_017c: ldc.i4.s 67 IL_017e: ldc.i4.1 IL_017f: call ""bool C.Test(char, bool)"" IL_0184: br.s IL_0187 IL_0186: ldc.i4.1 IL_0187: call ""void System.Console.WriteLine(bool)"" IL_018c: ldc.i4.s 65 IL_018e: ldc.i4.1 IL_018f: call ""bool C.Test(char, bool)"" IL_0194: brfalse.s IL_01a0 IL_0196: ldc.i4.s 66 IL_0198: ldc.i4.0 IL_0199: call ""bool C.Test(char, bool)"" IL_019e: brtrue.s IL_01aa IL_01a0: ldc.i4.s 67 IL_01a2: ldc.i4.0 IL_01a3: call ""bool C.Test(char, bool)"" IL_01a8: br.s IL_01ab IL_01aa: ldc.i4.1 IL_01ab: call ""void System.Console.WriteLine(bool)"" IL_01b0: ldc.i4.s 65 IL_01b2: ldc.i4.0 IL_01b3: call ""bool C.Test(char, bool)"" IL_01b8: brfalse.s IL_01c4 IL_01ba: ldc.i4.s 66 IL_01bc: ldc.i4.1 IL_01bd: call ""bool C.Test(char, bool)"" IL_01c2: brtrue.s IL_01ce IL_01c4: ldc.i4.s 67 IL_01c6: ldc.i4.1 IL_01c7: call ""bool C.Test(char, bool)"" IL_01cc: br.s IL_01cf IL_01ce: ldc.i4.1 IL_01cf: call ""void System.Console.WriteLine(bool)"" IL_01d4: ldc.i4.s 65 IL_01d6: ldc.i4.0 IL_01d7: call ""bool C.Test(char, bool)"" IL_01dc: brfalse.s IL_01e8 IL_01de: ldc.i4.s 66 IL_01e0: ldc.i4.1 IL_01e1: call ""bool C.Test(char, bool)"" IL_01e6: brtrue.s IL_01f2 IL_01e8: ldc.i4.s 67 IL_01ea: ldc.i4.0 IL_01eb: call ""bool C.Test(char, bool)"" IL_01f0: br.s IL_01f3 IL_01f2: ldc.i4.1 IL_01f3: call ""void System.Console.WriteLine(bool)"" IL_01f8: ldc.i4.s 65 IL_01fa: ldc.i4.0 IL_01fb: call ""bool C.Test(char, bool)"" IL_0200: brfalse.s IL_020c IL_0202: ldc.i4.s 66 IL_0204: ldc.i4.0 IL_0205: call ""bool C.Test(char, bool)"" IL_020a: brtrue.s IL_0216 IL_020c: ldc.i4.s 67 IL_020e: ldc.i4.1 IL_020f: call ""bool C.Test(char, bool)"" IL_0214: br.s IL_0217 IL_0216: ldc.i4.1 IL_0217: call ""void System.Console.WriteLine(bool)"" IL_021c: ldc.i4.s 65 IL_021e: ldc.i4.0 IL_021f: call ""bool C.Test(char, bool)"" IL_0224: brfalse.s IL_0230 IL_0226: ldc.i4.s 66 IL_0228: ldc.i4.0 IL_0229: call ""bool C.Test(char, bool)"" IL_022e: brtrue.s IL_023a IL_0230: ldc.i4.s 67 IL_0232: ldc.i4.0 IL_0233: call ""bool C.Test(char, bool)"" IL_0238: br.s IL_023b IL_023a: ldc.i4.1 IL_023b: call ""void System.Console.WriteLine(bool)"" IL_0240: ldc.i4.s 65 IL_0242: ldc.i4.1 IL_0243: call ""bool C.Test(char, bool)"" IL_0248: brtrue.s IL_0261 IL_024a: ldc.i4.s 66 IL_024c: ldc.i4.1 IL_024d: call ""bool C.Test(char, bool)"" IL_0252: brfalse.s IL_025e IL_0254: ldc.i4.s 67 IL_0256: ldc.i4.1 IL_0257: call ""bool C.Test(char, bool)"" IL_025c: br.s IL_0262 IL_025e: ldc.i4.0 IL_025f: br.s IL_0262 IL_0261: ldc.i4.1 IL_0262: call ""void System.Console.WriteLine(bool)"" IL_0267: ldc.i4.s 65 IL_0269: ldc.i4.1 IL_026a: call ""bool C.Test(char, bool)"" IL_026f: brtrue.s IL_0288 IL_0271: ldc.i4.s 66 IL_0273: ldc.i4.1 IL_0274: call ""bool C.Test(char, bool)"" IL_0279: brfalse.s IL_0285 IL_027b: ldc.i4.s 67 IL_027d: ldc.i4.0 IL_027e: call ""bool C.Test(char, bool)"" IL_0283: br.s IL_0289 IL_0285: ldc.i4.0 IL_0286: br.s IL_0289 IL_0288: ldc.i4.1 IL_0289: call ""void System.Console.WriteLine(bool)"" IL_028e: ldc.i4.s 65 IL_0290: ldc.i4.1 IL_0291: call ""bool C.Test(char, bool)"" IL_0296: brtrue.s IL_02af IL_0298: ldc.i4.s 66 IL_029a: ldc.i4.0 IL_029b: call ""bool C.Test(char, bool)"" IL_02a0: brfalse.s IL_02ac IL_02a2: ldc.i4.s 67 IL_02a4: ldc.i4.1 IL_02a5: call ""bool C.Test(char, bool)"" IL_02aa: br.s IL_02b0 IL_02ac: ldc.i4.0 IL_02ad: br.s IL_02b0 IL_02af: ldc.i4.1 IL_02b0: call ""void System.Console.WriteLine(bool)"" IL_02b5: ldc.i4.s 65 IL_02b7: ldc.i4.1 IL_02b8: call ""bool C.Test(char, bool)"" IL_02bd: brtrue.s IL_02d6 IL_02bf: ldc.i4.s 66 IL_02c1: ldc.i4.0 IL_02c2: call ""bool C.Test(char, bool)"" IL_02c7: brfalse.s IL_02d3 IL_02c9: ldc.i4.s 67 IL_02cb: ldc.i4.0 IL_02cc: call ""bool C.Test(char, bool)"" IL_02d1: br.s IL_02d7 IL_02d3: ldc.i4.0 IL_02d4: br.s IL_02d7 IL_02d6: ldc.i4.1 IL_02d7: call ""void System.Console.WriteLine(bool)"" IL_02dc: ldc.i4.s 65 IL_02de: ldc.i4.0 IL_02df: call ""bool C.Test(char, bool)"" IL_02e4: brtrue.s IL_02fd IL_02e6: ldc.i4.s 66 IL_02e8: ldc.i4.1 IL_02e9: call ""bool C.Test(char, bool)"" IL_02ee: brfalse.s IL_02fa IL_02f0: ldc.i4.s 67 IL_02f2: ldc.i4.1 IL_02f3: call ""bool C.Test(char, bool)"" IL_02f8: br.s IL_02fe IL_02fa: ldc.i4.0 IL_02fb: br.s IL_02fe IL_02fd: ldc.i4.1 IL_02fe: call ""void System.Console.WriteLine(bool)"" IL_0303: ldc.i4.s 65 IL_0305: ldc.i4.0 IL_0306: call ""bool C.Test(char, bool)"" IL_030b: brtrue.s IL_0324 IL_030d: ldc.i4.s 66 IL_030f: ldc.i4.1 IL_0310: call ""bool C.Test(char, bool)"" IL_0315: brfalse.s IL_0321 IL_0317: ldc.i4.s 67 IL_0319: ldc.i4.0 IL_031a: call ""bool C.Test(char, bool)"" IL_031f: br.s IL_0325 IL_0321: ldc.i4.0 IL_0322: br.s IL_0325 IL_0324: ldc.i4.1 IL_0325: call ""void System.Console.WriteLine(bool)"" IL_032a: ldc.i4.s 65 IL_032c: ldc.i4.0 IL_032d: call ""bool C.Test(char, bool)"" IL_0332: brtrue.s IL_034b IL_0334: ldc.i4.s 66 IL_0336: ldc.i4.0 IL_0337: call ""bool C.Test(char, bool)"" IL_033c: brfalse.s IL_0348 IL_033e: ldc.i4.s 67 IL_0340: ldc.i4.1 IL_0341: call ""bool C.Test(char, bool)"" IL_0346: br.s IL_034c IL_0348: ldc.i4.0 IL_0349: br.s IL_034c IL_034b: ldc.i4.1 IL_034c: call ""void System.Console.WriteLine(bool)"" IL_0351: ldc.i4.s 65 IL_0353: ldc.i4.0 IL_0354: call ""bool C.Test(char, bool)"" IL_0359: brtrue.s IL_0372 IL_035b: ldc.i4.s 66 IL_035d: ldc.i4.0 IL_035e: call ""bool C.Test(char, bool)"" IL_0363: brfalse.s IL_036f IL_0365: ldc.i4.s 67 IL_0367: ldc.i4.0 IL_0368: call ""bool C.Test(char, bool)"" IL_036d: br.s IL_0373 IL_036f: ldc.i4.0 IL_0370: br.s IL_0373 IL_0372: ldc.i4.1 IL_0373: call ""void System.Console.WriteLine(bool)"" IL_0378: ldc.i4.s 65 IL_037a: ldc.i4.1 IL_037b: call ""bool C.Test(char, bool)"" IL_0380: brtrue.s IL_0396 IL_0382: ldc.i4.s 66 IL_0384: ldc.i4.1 IL_0385: call ""bool C.Test(char, bool)"" IL_038a: brtrue.s IL_0396 IL_038c: ldc.i4.s 67 IL_038e: ldc.i4.1 IL_038f: call ""bool C.Test(char, bool)"" IL_0394: br.s IL_0397 IL_0396: ldc.i4.1 IL_0397: call ""void System.Console.WriteLine(bool)"" IL_039c: ldc.i4.s 65 IL_039e: ldc.i4.1 IL_039f: call ""bool C.Test(char, bool)"" IL_03a4: brtrue.s IL_03ba IL_03a6: ldc.i4.s 66 IL_03a8: ldc.i4.1 IL_03a9: call ""bool C.Test(char, bool)"" IL_03ae: brtrue.s IL_03ba IL_03b0: ldc.i4.s 67 IL_03b2: ldc.i4.0 IL_03b3: call ""bool C.Test(char, bool)"" IL_03b8: br.s IL_03bb IL_03ba: ldc.i4.1 IL_03bb: call ""void System.Console.WriteLine(bool)"" IL_03c0: ldc.i4.s 65 IL_03c2: ldc.i4.1 IL_03c3: call ""bool C.Test(char, bool)"" IL_03c8: brtrue.s IL_03de IL_03ca: ldc.i4.s 66 IL_03cc: ldc.i4.0 IL_03cd: call ""bool C.Test(char, bool)"" IL_03d2: brtrue.s IL_03de IL_03d4: ldc.i4.s 67 IL_03d6: ldc.i4.1 IL_03d7: call ""bool C.Test(char, bool)"" IL_03dc: br.s IL_03df IL_03de: ldc.i4.1 IL_03df: call ""void System.Console.WriteLine(bool)"" IL_03e4: ldc.i4.s 65 IL_03e6: ldc.i4.1 IL_03e7: call ""bool C.Test(char, bool)"" IL_03ec: brtrue.s IL_0402 IL_03ee: ldc.i4.s 66 IL_03f0: ldc.i4.0 IL_03f1: call ""bool C.Test(char, bool)"" IL_03f6: brtrue.s IL_0402 IL_03f8: ldc.i4.s 67 IL_03fa: ldc.i4.0 IL_03fb: call ""bool C.Test(char, bool)"" IL_0400: br.s IL_0403 IL_0402: ldc.i4.1 IL_0403: call ""void System.Console.WriteLine(bool)"" IL_0408: ldc.i4.s 65 IL_040a: ldc.i4.0 IL_040b: call ""bool C.Test(char, bool)"" IL_0410: brtrue.s IL_0426 IL_0412: ldc.i4.s 66 IL_0414: ldc.i4.1 IL_0415: call ""bool C.Test(char, bool)"" IL_041a: brtrue.s IL_0426 IL_041c: ldc.i4.s 67 IL_041e: ldc.i4.1 IL_041f: call ""bool C.Test(char, bool)"" IL_0424: br.s IL_0427 IL_0426: ldc.i4.1 IL_0427: call ""void System.Console.WriteLine(bool)"" IL_042c: ldc.i4.s 65 IL_042e: ldc.i4.0 IL_042f: call ""bool C.Test(char, bool)"" IL_0434: brtrue.s IL_044a IL_0436: ldc.i4.s 66 IL_0438: ldc.i4.1 IL_0439: call ""bool C.Test(char, bool)"" IL_043e: brtrue.s IL_044a IL_0440: ldc.i4.s 67 IL_0442: ldc.i4.0 IL_0443: call ""bool C.Test(char, bool)"" IL_0448: br.s IL_044b IL_044a: ldc.i4.1 IL_044b: call ""void System.Console.WriteLine(bool)"" IL_0450: ldc.i4.s 65 IL_0452: ldc.i4.0 IL_0453: call ""bool C.Test(char, bool)"" IL_0458: brtrue.s IL_046e IL_045a: ldc.i4.s 66 IL_045c: ldc.i4.0 IL_045d: call ""bool C.Test(char, bool)"" IL_0462: brtrue.s IL_046e IL_0464: ldc.i4.s 67 IL_0466: ldc.i4.1 IL_0467: call ""bool C.Test(char, bool)"" IL_046c: br.s IL_046f IL_046e: ldc.i4.1 IL_046f: call ""void System.Console.WriteLine(bool)"" IL_0474: ldc.i4.s 65 IL_0476: ldc.i4.0 IL_0477: call ""bool C.Test(char, bool)"" IL_047c: brtrue.s IL_0492 IL_047e: ldc.i4.s 66 IL_0480: ldc.i4.0 IL_0481: call ""bool C.Test(char, bool)"" IL_0486: brtrue.s IL_0492 IL_0488: ldc.i4.s 67 IL_048a: ldc.i4.0 IL_048b: call ""bool C.Test(char, bool)"" IL_0490: br.s IL_0493 IL_0492: ldc.i4.1 IL_0493: call ""void System.Console.WriteLine(bool)"" IL_0498: ret } "); } [Fact] public void TestConditionalMemberAccess001() { var source = @" public class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(int[] x) { System.Console.Write(x?.ToString().ToString().ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, expectedOutput: "NULL#System.Int32[]"); comp.VerifyIL("C.Test", @" { // Code size 37 (0x25) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldnull IL_0004: br.s IL_0016 IL_0006: ldarg.0 IL_0007: callvirt ""string object.ToString()"" IL_000c: callvirt ""string object.ToString()"" IL_0011: callvirt ""string object.ToString()"" IL_0016: dup IL_0017: brtrue.s IL_001f IL_0019: pop IL_001a: ldstr ""NULL"" IL_001f: call ""void System.Console.Write(string)"" IL_0024: ret } "); } [Fact] public void TestConditionalMemberAccess001ext() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(int[] x) { System.Console.Write(x?.ToStr().ToStr().ToStr() ?? ""NULL""); } static string ToStr(this object arg) { return arg.ToString(); } }"; var comp = CompileAndVerify(source, expectedOutput: "NULL#System.Int32[]"); comp.VerifyIL("C.Test", @" { // Code size 37 (0x25) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldnull IL_0004: br.s IL_0016 IL_0006: ldarg.0 IL_0007: call ""string C.ToStr(object)"" IL_000c: call ""string C.ToStr(object)"" IL_0011: call ""string C.ToStr(object)"" IL_0016: dup IL_0017: brtrue.s IL_001f IL_0019: pop IL_001a: ldstr ""NULL"" IL_001f: call ""void System.Console.Write(string)"" IL_0024: ret } "); } [Fact] public void TestConditionalMemberAccess001dyn() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.ToString().ToString()?.ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#System.Int32[]"); comp.VerifyIL("C.Test", @" { // Code size 355 (0x163) .maxstack 14 .locals init (object V_0, object V_1) IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_0005: brtrue.s IL_0046 IL_0007: ldc.i4 0x100 IL_000c: ldstr ""Write"" IL_0011: ldnull IL_0012: ldtoken ""C"" IL_0017: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_001c: ldc.i4.2 IL_001d: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_0022: dup IL_0023: ldc.i4.0 IL_0024: ldc.i4.s 33 IL_0026: ldnull IL_0027: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_002c: stelem.ref IL_002d: dup IL_002e: ldc.i4.1 IL_002f: ldc.i4.0 IL_0030: ldnull IL_0031: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_0036: stelem.ref IL_0037: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_003c: call ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_0041: stsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_0046: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_004b: ldfld ""System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic> System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>>.Target"" IL_0050: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_0055: ldtoken ""System.Console"" IL_005a: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_005f: ldarg.0 IL_0060: stloc.0 IL_0061: ldloc.0 IL_0062: brtrue.s IL_006a IL_0064: ldnull IL_0065: br IL_0154 IL_006a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_006f: brtrue.s IL_00a1 IL_0071: ldc.i4.0 IL_0072: ldstr ""ToString"" IL_0077: ldnull IL_0078: ldtoken ""C"" IL_007d: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0082: ldc.i4.1 IL_0083: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_0088: dup IL_0089: ldc.i4.0 IL_008a: ldc.i4.0 IL_008b: ldnull IL_008c: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_0091: stelem.ref IL_0092: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_0097: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_009c: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_00a1: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_00a6: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target"" IL_00ab: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_00b0: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00b5: brtrue.s IL_00e7 IL_00b7: ldc.i4.0 IL_00b8: ldstr ""ToString"" IL_00bd: ldnull IL_00be: ldtoken ""C"" IL_00c3: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_00c8: ldc.i4.1 IL_00c9: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_00ce: dup IL_00cf: ldc.i4.0 IL_00d0: ldc.i4.0 IL_00d1: ldnull IL_00d2: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_00d7: stelem.ref IL_00d8: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_00dd: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_00e2: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00e7: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00ec: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target"" IL_00f1: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00f6: ldloc.0 IL_00f7: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)"" IL_00fc: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)"" IL_0101: stloc.1 IL_0102: ldloc.1 IL_0103: brtrue.s IL_0108 IL_0105: ldnull IL_0106: br.s IL_0154 IL_0108: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_010d: brtrue.s IL_013f IL_010f: ldc.i4.0 IL_0110: ldstr ""ToString"" IL_0115: ldnull IL_0116: ldtoken ""C"" IL_011b: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0120: ldc.i4.1 IL_0121: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_0126: dup IL_0127: ldc.i4.0 IL_0128: ldc.i4.0 IL_0129: ldnull IL_012a: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_012f: stelem.ref IL_0130: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_0135: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_013a: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_013f: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_0144: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target"" IL_0149: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_014e: ldloc.1 IL_014f: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)"" IL_0154: dup IL_0155: brtrue.s IL_015d IL_0157: pop IL_0158: ldstr ""NULL"" IL_015d: callvirt ""void System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, System.Type, dynamic)"" IL_0162: ret } "); } [Fact] public void TestConditionalMemberAccess001dyn1() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.ToString()?[1].ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); } [Fact] public void TestConditionalMemberAccess001dyn2() { var source = @" public static class C { static void Main() { Test(null, ""aa""); System.Console.Write('#'); Test(""aa"", ""bb""); } static void Test(string s, dynamic ds) { System.Console.Write(s?.CompareTo(ds) ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#-1"); } [Fact] public void TestConditionalMemberAccess001dyn3() { var source = @" public static class C { static void Main() { Test(null, 1); System.Console.Write('#'); int[] a = new int[] { }; Test(a, 1); } static void Test(int[] x, dynamic i) { System.Console.Write(x?.ToString()?[i].ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); } [Fact] public void TestConditionalMemberAccess001dyn4() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] {1,2,3}; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.Length.ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); } [Fact] public void TestConditionalMemberAccess001dyn5() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] {1,2,3}; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.Length?.ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); } [Fact] public void TestConditionalMemberAccessUnused() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString(); var dummy2 = ""qqq""?.ToString(); var dummy3 = 1.ToString()?.ToString(); } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 32 (0x20) .maxstack 2 .locals init (int V_0) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: pop IL_000b: ldc.i4.1 IL_000c: stloc.0 IL_000d: ldloca.s V_0 IL_000f: call ""string int.ToString()"" IL_0014: dup IL_0015: brtrue.s IL_0019 IL_0017: pop IL_0018: ret IL_0019: callvirt ""string object.ToString()"" IL_001e: pop IL_001f: ret } "); } [Fact] public void TestConditionalMemberAccessUsed() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString(); var dummy2 = ""qqq""?.ToString(); var dummy3 = 1.ToString()?.ToString(); dummy1 += dummy2 += dummy3; } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 50 (0x32) .maxstack 3 .locals init (string V_0, //dummy2 string V_1, //dummy3 int V_2) IL_0000: ldnull IL_0001: ldstr ""qqq"" IL_0006: callvirt ""string object.ToString()"" IL_000b: stloc.0 IL_000c: ldc.i4.1 IL_000d: stloc.2 IL_000e: ldloca.s V_2 IL_0010: call ""string int.ToString()"" IL_0015: dup IL_0016: brtrue.s IL_001c IL_0018: pop IL_0019: ldnull IL_001a: br.s IL_0021 IL_001c: callvirt ""string object.ToString()"" IL_0021: stloc.1 IL_0022: ldloc.0 IL_0023: ldloc.1 IL_0024: call ""string string.Concat(string, string)"" IL_0029: dup IL_002a: stloc.0 IL_002b: call ""string string.Concat(string, string)"" IL_0030: pop IL_0031: ret } "); } [Fact] public void TestConditionalMemberAccessUnused1() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().Length; var dummy2 = ""qqq""?.ToString().Length; var dummy3 = 1.ToString()?.ToString().Length; } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 42 (0x2a) .maxstack 2 .locals init (int V_0) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: callvirt ""int string.Length.get"" IL_000f: pop IL_0010: ldc.i4.1 IL_0011: stloc.0 IL_0012: ldloca.s V_0 IL_0014: call ""string int.ToString()"" IL_0019: dup IL_001a: brtrue.s IL_001e IL_001c: pop IL_001d: ret IL_001e: callvirt ""string object.ToString()"" IL_0023: callvirt ""int string.Length.get"" IL_0028: pop IL_0029: ret } "); } [Fact] public void TestConditionalMemberAccessUsed1() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().Length; System.Console.WriteLine(dummy1); var dummy2 = ""qqq""?.ToString().Length; System.Console.WriteLine(dummy2); var dummy3 = 1.ToString()?.ToString().Length; System.Console.WriteLine(dummy3); } }"; var comp = CompileAndVerify(source, expectedOutput: @"3 1"); comp.VerifyIL("C.Main", @" { // Code size 99 (0x63) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldloca.s V_0 IL_0002: initobj ""int?"" IL_0008: ldloc.0 IL_0009: box ""int?"" IL_000e: call ""void System.Console.WriteLine(object)"" IL_0013: ldstr ""qqq"" IL_0018: callvirt ""string object.ToString()"" IL_001d: callvirt ""int string.Length.get"" IL_0022: newobj ""int?..ctor(int)"" IL_0027: box ""int?"" IL_002c: call ""void System.Console.WriteLine(object)"" IL_0031: ldc.i4.1 IL_0032: stloc.1 IL_0033: ldloca.s V_1 IL_0035: call ""string int.ToString()"" IL_003a: dup IL_003b: brtrue.s IL_0049 IL_003d: pop IL_003e: ldloca.s V_0 IL_0040: initobj ""int?"" IL_0046: ldloc.0 IL_0047: br.s IL_0058 IL_0049: callvirt ""string object.ToString()"" IL_004e: callvirt ""int string.Length.get"" IL_0053: newobj ""int?..ctor(int)"" IL_0058: box ""int?"" IL_005d: call ""void System.Console.WriteLine(object)"" IL_0062: ret } "); } [Fact] public void TestConditionalMemberAccessUnused2() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().NullableLength()?.ToString(); var dummy2 = ""qqq""?.ToString().NullableLength().ToString(); var dummy3 = 1.ToString()?.ToString().NullableLength()?.ToString(); } } public static class C1 { public static int? NullableLength(this string self) { return self.Length; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 82 (0x52) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: call ""int? C1.NullableLength(string)"" IL_000f: stloc.0 IL_0010: ldloca.s V_0 IL_0012: constrained. ""int?"" IL_0018: callvirt ""string object.ToString()"" IL_001d: pop IL_001e: ldc.i4.1 IL_001f: stloc.1 IL_0020: ldloca.s V_1 IL_0022: call ""string int.ToString()"" IL_0027: dup IL_0028: brtrue.s IL_002c IL_002a: pop IL_002b: ret IL_002c: callvirt ""string object.ToString()"" IL_0031: call ""int? C1.NullableLength(string)"" IL_0036: stloc.0 IL_0037: ldloca.s V_0 IL_0039: dup IL_003a: call ""bool int?.HasValue.get"" IL_003f: brtrue.s IL_0043 IL_0041: pop IL_0042: ret IL_0043: call ""int int?.GetValueOrDefault()"" IL_0048: stloc.1 IL_0049: ldloca.s V_1 IL_004b: call ""string int.ToString()"" IL_0050: pop IL_0051: ret } "); } [Fact] public void TestConditionalMemberAccessUnused2a() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString()?.Length.ToString(); var dummy2 = ""qqq""?.ToString().Length.ToString(); var dummy3 = 1.ToString()?.ToString().Length.ToString(); } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 58 (0x3a) .maxstack 2 .locals init (int V_0) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: callvirt ""int string.Length.get"" IL_000f: stloc.0 IL_0010: ldloca.s V_0 IL_0012: call ""string int.ToString()"" IL_0017: pop IL_0018: ldc.i4.1 IL_0019: stloc.0 IL_001a: ldloca.s V_0 IL_001c: call ""string int.ToString()"" IL_0021: dup IL_0022: brtrue.s IL_0026 IL_0024: pop IL_0025: ret IL_0026: callvirt ""string object.ToString()"" IL_002b: callvirt ""int string.Length.get"" IL_0030: stloc.0 IL_0031: ldloca.s V_0 IL_0033: call ""string int.ToString()"" IL_0038: pop IL_0039: ret } "); } [Fact] public void TestConditionalMemberAccessUsed2() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().NullableLength()?.ToString(); System.Console.WriteLine(dummy1); var dummy2 = ""qqq""?.ToString().NullableLength()?.ToString(); System.Console.WriteLine(dummy2); var dummy3 = 1.ToString()?.ToString().NullableLength()?.ToString(); System.Console.WriteLine(dummy3); } } public static class C1 { public static int? NullableLength(this string self) { return self.Length; } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @"3 1"); comp.VerifyIL("C.Main", @" { // Code size 114 (0x72) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldnull IL_0001: call ""void System.Console.WriteLine(string)"" IL_0006: ldstr ""qqq"" IL_000b: callvirt ""string object.ToString()"" IL_0010: call ""int? C1.NullableLength(string)"" IL_0015: stloc.0 IL_0016: ldloca.s V_0 IL_0018: dup IL_0019: call ""bool int?.HasValue.get"" IL_001e: brtrue.s IL_0024 IL_0020: pop IL_0021: ldnull IL_0022: br.s IL_0031 IL_0024: call ""int int?.GetValueOrDefault()"" IL_0029: stloc.1 IL_002a: ldloca.s V_1 IL_002c: call ""string int.ToString()"" IL_0031: call ""void System.Console.WriteLine(string)"" IL_0036: ldc.i4.1 IL_0037: stloc.1 IL_0038: ldloca.s V_1 IL_003a: call ""string int.ToString()"" IL_003f: dup IL_0040: brtrue.s IL_0046 IL_0042: pop IL_0043: ldnull IL_0044: br.s IL_006c IL_0046: callvirt ""string object.ToString()"" IL_004b: call ""int? C1.NullableLength(string)"" IL_0050: stloc.0 IL_0051: ldloca.s V_0 IL_0053: dup IL_0054: call ""bool int?.HasValue.get"" IL_0059: brtrue.s IL_005f IL_005b: pop IL_005c: ldnull IL_005d: br.s IL_006c IL_005f: call ""int int?.GetValueOrDefault()"" IL_0064: stloc.1 IL_0065: ldloca.s V_1 IL_0067: call ""string int.ToString()"" IL_006c: call ""void System.Console.WriteLine(string)"" IL_0071: ret } "); } [Fact] public void TestConditionalMemberAccessUsed2a() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString()?.Length.ToString(); System.Console.WriteLine(dummy1); var dummy2 = ""qqq""?.ToString()?.Length.ToString(); System.Console.WriteLine(dummy2); var dummy3 = 1.ToString()?.ToString()?.Length.ToString(); System.Console.WriteLine(dummy3); } }"; var comp = CompileAndVerify(source, expectedOutput: @"3 1"); comp.VerifyIL("C.Main", @" { // Code size 88 (0x58) .maxstack 2 .locals init (int V_0) IL_0000: ldnull IL_0001: call ""void System.Console.WriteLine(string)"" IL_0006: ldstr ""qqq"" IL_000b: callvirt ""string object.ToString()"" IL_0010: dup IL_0011: brtrue.s IL_0017 IL_0013: pop IL_0014: ldnull IL_0015: br.s IL_0024 IL_0017: call ""int string.Length.get"" IL_001c: stloc.0 IL_001d: ldloca.s V_0 IL_001f: call ""string int.ToString()"" IL_0024: call ""void System.Console.WriteLine(string)"" IL_0029: ldc.i4.1 IL_002a: stloc.0 IL_002b: ldloca.s V_0 IL_002d: call ""string int.ToString()"" IL_0032: dup IL_0033: brtrue.s IL_0039 IL_0035: pop IL_0036: ldnull IL_0037: br.s IL_0052 IL_0039: callvirt ""string object.ToString()"" IL_003e: dup IL_003f: brtrue.s IL_0045 IL_0041: pop IL_0042: ldnull IL_0043: br.s IL_0052 IL_0045: call ""int string.Length.get"" IL_004a: stloc.0 IL_004b: ldloca.s V_0 IL_004d: call ""string int.ToString()"" IL_0052: call ""void System.Console.WriteLine(string)"" IL_0057: ret } "); } [Fact] [WorkItem(976765, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/976765")] public void ConditionalMemberAccessConstrained() { var source = @" class Program { static void M<T>(T x) where T: System.Exception { object s = x?.ToString(); System.Console.WriteLine(s); s = x?.GetType(); System.Console.WriteLine(s); } static void Main() { M(new System.Exception(""a"")); } } "; var comp = CompileAndVerify(source, expectedOutput: @"System.Exception: a System.Exception"); comp.VerifyIL("Program.M<T>", @" { // Code size 47 (0x2f) .maxstack 2 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: dup IL_0007: brtrue.s IL_000d IL_0009: pop IL_000a: ldnull IL_000b: br.s IL_0012 IL_000d: callvirt ""string object.ToString()"" IL_0012: call ""void System.Console.WriteLine(object)"" IL_0017: ldarg.0 IL_0018: box ""T"" IL_001d: dup IL_001e: brtrue.s IL_0024 IL_0020: pop IL_0021: ldnull IL_0022: br.s IL_0029 IL_0024: callvirt ""System.Type System.Exception.GetType()"" IL_0029: call ""void System.Console.WriteLine(object)"" IL_002e: ret } "); } [Fact] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement() { var source = @" class Program { class C1 { public void Print0() { System.Console.WriteLine(""print0""); } public int Print1() { System.Console.WriteLine(""print1""); return 1; } public object Print2() { System.Console.WriteLine(""print2""); return 1; } } static void M(C1 x) { x?.Print0(); x?.Print1(); x?.Print2(); } static void Main() { M(null); M(new C1()); } } "; var comp = CompileAndVerify(source, expectedOutput: @"print0 print1 print2"); comp.VerifyIL("Program.M(Program.C1)", @" { // Code size 30 (0x1e) .maxstack 1 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0009 IL_0003: ldarg.0 IL_0004: call ""void Program.C1.Print0()"" IL_0009: ldarg.0 IL_000a: brfalse.s IL_0013 IL_000c: ldarg.0 IL_000d: call ""int Program.C1.Print1()"" IL_0012: pop IL_0013: ldarg.0 IL_0014: brfalse.s IL_001d IL_0016: ldarg.0 IL_0017: call ""object Program.C1.Print2()"" IL_001c: pop IL_001d: ret } "); } [Fact] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement01() { var source = @" class Program { struct S1 { public void Print0() { System.Console.WriteLine(""print0""); } public int Print1() { System.Console.WriteLine(""print1""); return 1; } public object Print2() { System.Console.WriteLine(""print2""); return 1; } } static void M(S1? x) { x?.Print0(); x?.Print1(); x?.Print2()?.ToString().ToString()?.ToString(); } static void Main() { M(null); M(new S1()); } } "; var comp = CompileAndVerify(source, expectedOutput: @"print0 print1 print2"); comp.VerifyIL("Program.M(Program.S1?)", @" { // Code size 100 (0x64) .maxstack 2 .locals init (Program.S1 V_0) IL_0000: ldarga.s V_0 IL_0002: call ""bool Program.S1?.HasValue.get"" IL_0007: brfalse.s IL_0018 IL_0009: ldarga.s V_0 IL_000b: call ""Program.S1 Program.S1?.GetValueOrDefault()"" IL_0010: stloc.0 IL_0011: ldloca.s V_0 IL_0013: call ""void Program.S1.Print0()"" IL_0018: ldarga.s V_0 IL_001a: call ""bool Program.S1?.HasValue.get"" IL_001f: brfalse.s IL_0031 IL_0021: ldarga.s V_0 IL_0023: call ""Program.S1 Program.S1?.GetValueOrDefault()"" IL_0028: stloc.0 IL_0029: ldloca.s V_0 IL_002b: call ""int Program.S1.Print1()"" IL_0030: pop IL_0031: ldarga.s V_0 IL_0033: call ""bool Program.S1?.HasValue.get"" IL_0038: brfalse.s IL_0063 IL_003a: ldarga.s V_0 IL_003c: call ""Program.S1 Program.S1?.GetValueOrDefault()"" IL_0041: stloc.0 IL_0042: ldloca.s V_0 IL_0044: call ""object Program.S1.Print2()"" IL_0049: dup IL_004a: brtrue.s IL_004e IL_004c: pop IL_004d: ret IL_004e: callvirt ""string object.ToString()"" IL_0053: callvirt ""string object.ToString()"" IL_0058: dup IL_0059: brtrue.s IL_005d IL_005b: pop IL_005c: ret IL_005d: callvirt ""string object.ToString()"" IL_0062: pop IL_0063: ret } "); } [ConditionalFact(typeof(DesktopOnly))] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement02() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { class C1 { public void Print0(int i) { System.Console.WriteLine(""print0""); } public int Print1(int i) { System.Console.WriteLine(""print1""); return 1; } public object Print2(int i) { System.Console.WriteLine(""print2""); return 1; } } static async Task<int> Val() { await Task.Yield(); return 1; } static async Task<int> M(C1 x) { x?.Print0(await Val()); x?.Print1(await Val()); x?.Print2(await Val()); return 1; } static void Main() { M(null).Wait(); M(new C1()).Wait(); } } "; var comp = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 print1 print2"); } [ConditionalFact(typeof(DesktopOnly))] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement03() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { struct C1 { public void Print0(int i) { System.Console.WriteLine(""print0""); } public int Print1(int i) { System.Console.WriteLine(""print1""); return 1; } public object Print2(int i) { System.Console.WriteLine(""print2""); return 1; } } static async Task<int> Val() { await Task.Yield(); return 1; } static async Task<int> M(C1? x) { x?.Print0(await Val()); x?.Print1(await Val()); x?.Print2(await Val()); return 1; } static void Main() { M(null).Wait(); M(new C1()).Wait(); } } "; var comp = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 print1 print2"); } [Fact] public void ConditionalMemberAccessUnConstrained() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(ref c, ref c); S1 s = new S1(); Test(ref s, ref s); } static void Test<T>(ref T x, ref T y) where T : IDisposable { x?.Dispose(); y?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False True"); comp.VerifyIL("Program.Test<T>(ref T, ref T)", @" { // Code size 94 (0x5e) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0024 IL_0011: ldobj ""T"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: ldloc.0 IL_001a: box ""T"" IL_001f: brtrue.s IL_0024 IL_0021: pop IL_0022: br.s IL_002f IL_0024: constrained. ""T"" IL_002a: callvirt ""void System.IDisposable.Dispose()"" IL_002f: ldarg.1 IL_0030: ldloca.s V_0 IL_0032: initobj ""T"" IL_0038: ldloc.0 IL_0039: box ""T"" IL_003e: brtrue.s IL_0052 IL_0040: ldobj ""T"" IL_0045: stloc.0 IL_0046: ldloca.s V_0 IL_0048: ldloc.0 IL_0049: box ""T"" IL_004e: brtrue.s IL_0052 IL_0050: pop IL_0051: ret IL_0052: constrained. ""T"" IL_0058: callvirt ""void System.IDisposable.Dispose()"" IL_005d: ret }"); } [Fact] public void ConditionalMemberAccessUnConstrained1() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { var c = new C1[] {new C1()}; Test(c, c); var s = new S1[] {new S1()}; Test(s, s); } static void Test<T>(T[] x, T[] y) where T : IDisposable { x[0]?.Dispose(); y[0]?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False True"); comp.VerifyIL("Program.Test<T>(T[], T[])", @" { // Code size 110 (0x6e) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: readonly. IL_0004: ldelema ""T"" IL_0009: ldloca.s V_0 IL_000b: initobj ""T"" IL_0011: ldloc.0 IL_0012: box ""T"" IL_0017: brtrue.s IL_002c IL_0019: ldobj ""T"" IL_001e: stloc.0 IL_001f: ldloca.s V_0 IL_0021: ldloc.0 IL_0022: box ""T"" IL_0027: brtrue.s IL_002c IL_0029: pop IL_002a: br.s IL_0037 IL_002c: constrained. ""T"" IL_0032: callvirt ""void System.IDisposable.Dispose()"" IL_0037: ldarg.1 IL_0038: ldc.i4.0 IL_0039: readonly. IL_003b: ldelema ""T"" IL_0040: ldloca.s V_0 IL_0042: initobj ""T"" IL_0048: ldloc.0 IL_0049: box ""T"" IL_004e: brtrue.s IL_0062 IL_0050: ldobj ""T"" IL_0055: stloc.0 IL_0056: ldloca.s V_0 IL_0058: ldloc.0 IL_0059: box ""T"" IL_005e: brtrue.s IL_0062 IL_0060: pop IL_0061: ret IL_0062: constrained. ""T"" IL_0068: callvirt ""void System.IDisposable.Dispose()"" IL_006d: ret } "); } [Fact] public void ConditionalMemberAccessConstrained1() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { var c = new C1[] {new C1()}; Test(c, c); } static void Test<T>(T[] x, T[] y) where T : class, IDisposable { x[0]?.Dispose(); y[0]?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True "); comp.VerifyIL("Program.Test<T>(T[], T[])", @" { // Code size 46 (0x2e) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: ldelem ""T"" IL_0007: box ""T"" IL_000c: dup IL_000d: brtrue.s IL_0012 IL_000f: pop IL_0010: br.s IL_0017 IL_0012: callvirt ""void System.IDisposable.Dispose()"" IL_0017: ldarg.1 IL_0018: ldc.i4.0 IL_0019: ldelem ""T"" IL_001e: box ""T"" IL_0023: dup IL_0024: brtrue.s IL_0028 IL_0026: pop IL_0027: ret IL_0028: callvirt ""void System.IDisposable.Dispose()"" IL_002d: ret } "); } [Fact] public void ConditionalMemberAccessUnConstrainedVal() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(c); S1 s = new S1(); Test(s); } static void Test<T>(T x) where T : IDisposable { x?.Dispose(); x?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False True"); comp.VerifyIL("Program.Test<T>(T)", @" { // Code size 43 (0x2b) .maxstack 1 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: brfalse.s IL_0015 IL_0008: ldarga.s V_0 IL_000a: constrained. ""T"" IL_0010: callvirt ""void System.IDisposable.Dispose()"" IL_0015: ldarg.0 IL_0016: box ""T"" IL_001b: brfalse.s IL_002a IL_001d: ldarga.s V_0 IL_001f: constrained. ""T"" IL_0025: callvirt ""void System.IDisposable.Dispose()"" IL_002a: ret } "); } [Fact] public void ConditionalMemberAccessUnConstrainedVal001() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(() => c); S1 s = new S1(); Test(() => s); } static void Test<T>(Func<T> x) where T : IDisposable { x()?.Dispose(); x()?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False False"); comp.VerifyIL("Program.Test<T>(System.Func<T>)", @" { // Code size 72 (0x48) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: callvirt ""T System.Func<T>.Invoke()"" IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: dup IL_000a: ldobj ""T"" IL_000f: box ""T"" IL_0014: brtrue.s IL_0019 IL_0016: pop IL_0017: br.s IL_0024 IL_0019: constrained. ""T"" IL_001f: callvirt ""void System.IDisposable.Dispose()"" IL_0024: ldarg.0 IL_0025: callvirt ""T System.Func<T>.Invoke()"" IL_002a: stloc.0 IL_002b: ldloca.s V_0 IL_002d: dup IL_002e: ldobj ""T"" IL_0033: box ""T"" IL_0038: brtrue.s IL_003c IL_003a: pop IL_003b: ret IL_003c: constrained. ""T"" IL_0042: callvirt ""void System.IDisposable.Dispose()"" IL_0047: ret } "); } [Fact] public void ConditionalMemberAccessConstrainedVal001() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(() => c); } static void Test<T>(Func<T> x) where T : class, IDisposable { x()?.Dispose(); x()?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True"); comp.VerifyIL("Program.Test<T>(System.Func<T>)", @" { // Code size 44 (0x2c) .maxstack 2 IL_0000: ldarg.0 IL_0001: callvirt ""T System.Func<T>.Invoke()"" IL_0006: box ""T"" IL_000b: dup IL_000c: brtrue.s IL_0011 IL_000e: pop IL_000f: br.s IL_0016 IL_0011: callvirt ""void System.IDisposable.Dispose()"" IL_0016: ldarg.0 IL_0017: callvirt ""T System.Func<T>.Invoke()"" IL_001c: box ""T"" IL_0021: dup IL_0022: brtrue.s IL_0026 IL_0024: pop IL_0025: ret IL_0026: callvirt ""void System.IDisposable.Dispose()"" IL_002b: ret } "); } [Fact] public void ConditionalMemberAccessUnConstrainedDyn() { var source = @" using System; using System.Collections.Generic; class Program { interface IDisposable1 { void Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(ref c, ref c); S1 s = new S1(); Test(ref s, ref s); } static void Test<T>(ref T x, ref T y) where T : IDisposable1 { dynamic d = 1; x?.Dispose(d); y?.Dispose(d); } } "; var comp = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedDynVal() { var source = @" using System; using System.Collections.Generic; class Program { interface IDisposable1 { void Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(c, c); S1 s = new S1(); Test(s, s); } static void Test<T>(T x, T y) where T : IDisposable1 { dynamic d = 1; x?.Dispose(d); y?.Dispose(d); } } "; var comp = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsync() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { void Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await Val()); y[0]?.Dispose(await Val()); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncVal() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { int Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } struct S1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } static void Main(string[] args) { C1 c = new C1(); Test(c, c).Wait(); S1 s = new S1(); Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T x, T y) where T : IDisposable1 { x?.Dispose(await Val()); y?.Dispose(await Val()); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncValExt() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; using DE; namespace DE { public static class IDispExt { public static void DisposeExt(this Program.IDisposable1 d, int i) { d.Dispose(i); } } } public class Program { public interface IDisposable1 { int Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } struct S1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } static void Main(string[] args) { C1 c = new C1(); Test(c, c).Wait(); S1 s = new S1(); Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T x, T y) where T : IDisposable1 { x?.DisposeExt(await Val()); y?.DisposeExt(await Val()); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncNested() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { IDisposable1 Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public IDisposable1 Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return this; } } struct S1 : IDisposable1 { private bool disposed; public IDisposable1 Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return this; } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); System.Console.WriteLine(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val()); y[0]?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val()); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True False True False True False True False True True False True False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncNestedArr() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { IDisposable1[] Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public IDisposable1[] Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return new IDisposable1[] { this }; } } struct S1 : IDisposable1 { private bool disposed; public IDisposable1[] Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return new IDisposable1[]{this}; } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); System.Console.WriteLine(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val()); y[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val()); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True False True False True False True False True True False True False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncSuperNested() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { Task<int> Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public Task<int> Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return Task.FromResult(i); } } struct S1 : IDisposable1 { private bool disposed; public Task<int> Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return Task.FromResult(i); } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); System.Console.WriteLine(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await x[0]?.Dispose(await x[0]?.Dispose(await x[0]?.Dispose(await Val())))); y[0]?.Dispose(await y[0]?.Dispose(await y[0]?.Dispose(await y[0]?.Dispose(await Val())))); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True False True False True False True False True False True False True"); } [Fact] public void ConditionalExtensionAccessGeneric001() { var source = @" using System; using System.Collections.Generic; class Test { static void Main() { long? x = 1; Test0(x); return; } static void Test0<T>(T x) { x?.CheckT(); } } static class Ext { public static void CheckT<T>(this T x) { System.Console.WriteLine(typeof(T)); return; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]"); comp.VerifyIL("Test.Test0<T>(T)", @" { // Code size 21 (0x15) .maxstack 1 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: brfalse.s IL_0014 IL_0008: ldarga.s V_0 IL_000a: ldobj ""T"" IL_000f: call ""void Ext.CheckT<T>(T)"" IL_0014: ret } "); } [Fact] public void ConditionalExtensionAccessGeneric002() { var source = @" using System; using System.Collections.Generic; class Test { static void Main() { long? x = 1; Test0(ref x); return; } static void Test0<T>(ref T x) { x?.CheckT(); } } static class Ext { public static void CheckT<T>(this T x) { System.Console.WriteLine(typeof(T)); return; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]"); comp.VerifyIL("Test.Test0<T>(ref T)", @" { // Code size 46 (0x2e) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0023 IL_0011: ldobj ""T"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: ldloc.0 IL_001a: box ""T"" IL_001f: brtrue.s IL_0023 IL_0021: pop IL_0022: ret IL_0023: ldobj ""T"" IL_0028: call ""void Ext.CheckT<T>(T)"" IL_002d: ret } "); } [Fact] public void ConditionalExtensionAccessGeneric003() { var source = @" using System; using System.Linq; using System.Collections.Generic; class Test { static void Main() { Test0(""qqq""); } static void Test0<T>(T x) where T:IEnumerable<char> { x?.Count(); } static void Test1<T>(ref T x) where T:IEnumerable<char> { x?.Count(); } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @""); comp.VerifyIL("Test.Test0<T>(T)", @" { // Code size 27 (0x1b) .maxstack 1 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: brfalse.s IL_001a IL_0008: ldarga.s V_0 IL_000a: ldobj ""T"" IL_000f: box ""T"" IL_0014: call ""int System.Linq.Enumerable.Count<char>(System.Collections.Generic.IEnumerable<char>)"" IL_0019: pop IL_001a: ret } ").VerifyIL("Test.Test1<T>(ref T)", @" { // Code size 52 (0x34) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0023 IL_0011: ldobj ""T"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: ldloc.0 IL_001a: box ""T"" IL_001f: brtrue.s IL_0023 IL_0021: pop IL_0022: ret IL_0023: ldobj ""T"" IL_0028: box ""T"" IL_002d: call ""int System.Linq.Enumerable.Count<char>(System.Collections.Generic.IEnumerable<char>)"" IL_0032: pop IL_0033: ret } "); } [Fact] public void ConditionalExtensionAccessGenericAsync001() { var source = @" using System.Threading.Tasks; class Test { static void Main() { } async Task<int?> TestAsync<T>(T[] x) where T : I1 { return x[0]?.CallAsync(await PassAsync()); } static async Task<int> PassAsync() { await Task.Yield(); return 1; } } interface I1 { int CallAsync(int x); } "; var comp = CreateCompilationWithMscorlib45(source, references: new[] { CSharpRef }); base.CompileAndVerify(comp); } [Fact] public void ConditionalExtensionAccessGenericAsyncNullable001() { var source = @" using System; using System.Threading.Tasks; class Test { static void Main() { var arr = new S1?[] { new S1(), new S1()}; TestAsync(arr).Wait(); System.Console.WriteLine(arr[1].Value.called); } static async Task<int?> TestAsync<T>(T?[] x) where T : struct, I1 { return x[await PassAsync()]?.CallAsync(await PassAsync()); } static async Task<int> PassAsync() { await Task.Yield(); return 1; } } struct S1 : I1 { public int called; public int CallAsync(int x) { called++; System.Console.Write(called + 41); return called; } } interface I1 { int CallAsync(int x); } "; var comp = CreateCompilationWithMscorlib45(source, references: new[] { CSharpRef }, options: TestOptions.ReleaseExe); base.CompileAndVerify(comp, expectedOutput: "420"); } [Fact] public void ConditionalMemberAccessCoalesce001() { var source = @" class Program { class C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); } static int Test1(C1 c) { return c?.x ?? 42; } static int Test2(C1 c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldc.i4.s 42 IL_0005: ret IL_0006: ldarg.0 IL_0007: call ""int Program.C1.x.get"" IL_000c: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 41 (0x29) .maxstack 1 .locals init (int? V_0, int? V_1) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_1 IL_0005: initobj ""int?"" IL_000b: ldloc.1 IL_000c: br.s IL_0014 IL_000e: ldarg.0 IL_000f: call ""int? Program.C1.y.get"" IL_0014: stloc.0 IL_0015: ldloca.s V_0 IL_0017: call ""bool int?.HasValue.get"" IL_001c: brtrue.s IL_0021 IL_001e: ldc.i4.s 42 IL_0020: ret IL_0021: ldloca.s V_0 IL_0023: call ""int int?.GetValueOrDefault()"" IL_0028: ret } "); } [Fact] public void ConditionalMemberAccessCoalesce001n() { var source = @" class Program { class C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); } static int? Test1(C1 c) { return c?.x ?? (int?)42; } static int? Test2(C1 c) { return c?.y ?? (int?)42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 23 (0x17) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_000b IL_0003: ldc.i4.s 42 IL_0005: newobj ""int?..ctor(int)"" IL_000a: ret IL_000b: ldarg.0 IL_000c: call ""int Program.C1.x.get"" IL_0011: newobj ""int?..ctor(int)"" IL_0016: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 40 (0x28) .maxstack 1 .locals init (int? V_0, int? V_1) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_1 IL_0005: initobj ""int?"" IL_000b: ldloc.1 IL_000c: br.s IL_0014 IL_000e: ldarg.0 IL_000f: call ""int? Program.C1.y.get"" IL_0014: stloc.0 IL_0015: ldloca.s V_0 IL_0017: call ""bool int?.HasValue.get"" IL_001c: brtrue.s IL_0026 IL_001e: ldc.i4.s 42 IL_0020: newobj ""int?..ctor(int)"" IL_0025: ret IL_0026: ldloc.0 IL_0027: ret }"); } [Fact] public void ConditionalMemberAccessCoalesce001r() { var source = @" class Program { class C1 { public int x {get; set;} public int? y {get; set;} } static void Main() { var c = new C1(); C1 n = null; System.Console.WriteLine(Test1(ref c)); System.Console.WriteLine(Test1(ref n)); System.Console.WriteLine(Test2(ref c)); System.Console.WriteLine(Test2(ref n)); } static int Test1(ref C1 c) { return c?.x ?? 42; } static int Test2(ref C1 c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(ref Program.C1)", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0009 IL_0005: pop IL_0006: ldc.i4.s 42 IL_0008: ret IL_0009: call ""int Program.C1.x.get"" IL_000e: ret } ").VerifyIL("Program.Test2(ref Program.C1)", @" { // Code size 43 (0x2b) .maxstack 2 .locals init (int? V_0, int? V_1) IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0011 IL_0005: pop IL_0006: ldloca.s V_1 IL_0008: initobj ""int?"" IL_000e: ldloc.1 IL_000f: br.s IL_0016 IL_0011: call ""int? Program.C1.y.get"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: call ""bool int?.HasValue.get"" IL_001e: brtrue.s IL_0023 IL_0020: ldc.i4.s 42 IL_0022: ret IL_0023: ldloca.s V_0 IL_0025: call ""int int?.GetValueOrDefault()"" IL_002a: ret } "); } [Fact] public void ConditionalMemberAccessCoalesce002() { var source = @" class Program { struct C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); } static int Test1(C1? c) { return c?.x ?? 42; } static int Test2(C1? c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(Program.C1?)", @" { // Code size 28 (0x1c) .maxstack 1 .locals init (Program.C1 V_0) IL_0000: ldarga.s V_0 IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_000c IL_0009: ldc.i4.s 42 IL_000b: ret IL_000c: ldarga.s V_0 IL_000e: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_0013: stloc.0 IL_0014: ldloca.s V_0 IL_0016: call ""readonly int Program.C1.x.get"" IL_001b: ret } ").VerifyIL("Program.Test2(Program.C1?)", @" { // Code size 56 (0x38) .maxstack 1 .locals init (int? V_0, int? V_1, Program.C1 V_2) IL_0000: ldarga.s V_0 IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_0014 IL_0009: ldloca.s V_1 IL_000b: initobj ""int?"" IL_0011: ldloc.1 IL_0012: br.s IL_0023 IL_0014: ldarga.s V_0 IL_0016: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_001b: stloc.2 IL_001c: ldloca.s V_2 IL_001e: call ""readonly int? Program.C1.y.get"" IL_0023: stloc.0 IL_0024: ldloca.s V_0 IL_0026: call ""bool int?.HasValue.get"" IL_002b: brtrue.s IL_0030 IL_002d: ldc.i4.s 42 IL_002f: ret IL_0030: ldloca.s V_0 IL_0032: call ""int int?.GetValueOrDefault()"" IL_0037: ret } "); } [Fact] public void ConditionalMemberAccessCoalesce002r() { var source = @" class Program { struct C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { C1? c = new C1(); C1? n = null; System.Console.WriteLine(Test1(ref c)); System.Console.WriteLine(Test1(ref n)); System.Console.WriteLine(Test2(ref c)); System.Console.WriteLine(Test2(ref n)); } static int Test1(ref C1? c) { return c?.x ?? 42; } static int Test2(ref C1? c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(ref Program.C1?)", @" { // Code size 27 (0x1b) .maxstack 2 .locals init (Program.C1 V_0) IL_0000: ldarg.0 IL_0001: dup IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_000d IL_0009: pop IL_000a: ldc.i4.s 42 IL_000c: ret IL_000d: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_0012: stloc.0 IL_0013: ldloca.s V_0 IL_0015: call ""readonly int Program.C1.x.get"" IL_001a: ret } ").VerifyIL("Program.Test2(ref Program.C1?)", @" { // Code size 55 (0x37) .maxstack 2 .locals init (int? V_0, int? V_1, Program.C1 V_2) IL_0000: ldarg.0 IL_0001: dup IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_0015 IL_0009: pop IL_000a: ldloca.s V_1 IL_000c: initobj ""int?"" IL_0012: ldloc.1 IL_0013: br.s IL_0022 IL_0015: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_001a: stloc.2 IL_001b: ldloca.s V_2 IL_001d: call ""readonly int? Program.C1.y.get"" IL_0022: stloc.0 IL_0023: ldloca.s V_0 IL_0025: call ""bool int?.HasValue.get"" IL_002a: brtrue.s IL_002f IL_002c: ldc.i4.s 42 IL_002e: ret IL_002f: ldloca.s V_0 IL_0031: call ""int int?.GetValueOrDefault()"" IL_0036: ret } "); } [Fact] public void ConditionalMemberAccessCoalesceDefault() { var source = @" class Program { class C1 { public int x { get; set; } } static void Main() { var c = new C1() { x = 42 }; System.Console.WriteLine(Test(c)); System.Console.WriteLine(Test(null)); } static int Test(C1 c) { return c?.x ?? 0; } } "; var comp = CompileAndVerify(source, expectedOutput: @" 42 0"); comp.VerifyIL("Program.Test(Program.C1)", @" { // Code size 12 (0xc) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: ret } "); } [Fact] public void ConditionalMemberAccessNullCheck001() { var source = @" class Program { class C1 { public int x{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); System.Console.WriteLine(Test3(c)); System.Console.WriteLine(Test3(null)); } static bool Test1(C1 c) { return c?.x == null; } static bool Test2(C1 c) { return c?.x != null; } static bool Test3(C1 c) { return c?.x > null; } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True True False False False"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: pop IL_000c: ldc.i4.0 IL_000d: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: pop IL_000c: ldc.i4.1 IL_000d: ret } ").VerifyIL("Program.Test3(Program.C1)", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: pop IL_000c: ldc.i4.0 IL_000d: ret } "); } [Fact] public void ConditionalMemberAccessBinary001() { var source = @" public enum N { zero = 0, one = 1, mone = -1 } class Program { class C1 { public N x{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); System.Console.WriteLine(Test3(c)); System.Console.WriteLine(Test3(null)); } static bool Test1(C1 c) { return c?.x == N.zero; } static bool Test2(C1 c) { return c?.x != N.one; } static bool Test3(C1 c) { return c?.x > N.mone; } } "; var comp = CompileAndVerify(source, expectedOutput: @"True False True True True False"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""N Program.C1.x.get"" IL_000b: ldc.i4.0 IL_000c: ceq IL_000e: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""N Program.C1.x.get"" IL_000b: ldc.i4.1 IL_000c: ceq IL_000e: ldc.i4.0 IL_000f: ceq IL_0011: ret } ").VerifyIL("Program.Test3(Program.C1)", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""N Program.C1.x.get"" IL_000b: ldc.i4.m1 IL_000c: cgt IL_000e: ret } "); } [Fact] public void ConditionalMemberAccessBinary002() { var source = @" static class ext { public static Program.C1.S1 y(this Program.C1 self) { return self.x; } } class Program { public class C1 { public struct S1 { public static bool operator <(S1 s1, int s2) { System.Console.WriteLine('<'); return true; } public static bool operator >(S1 s1, int s2) { System.Console.WriteLine('>'); return false; } } public S1 x { get; set; } } static void Main() { C1 c = new C1(); C1 n = null; System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(n)); System.Console.WriteLine(Test2(ref c)); System.Console.WriteLine(Test2(ref n)); System.Console.WriteLine(Test3(c)); System.Console.WriteLine(Test3(n)); System.Console.WriteLine(Test4(ref c)); System.Console.WriteLine(Test4(ref n)); } static bool Test1(C1 c) { return c?.x > -1; } static bool Test2(ref C1 c) { return c?.x < -1; } static bool Test3(C1 c) { return c?.y() > -1; } static bool Test4(ref C1 c) { return c?.y() < -1; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @" > False False < True False > False False < True False"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""Program.C1.S1 Program.C1.x.get"" IL_000b: ldc.i4.m1 IL_000c: call ""bool Program.C1.S1.op_GreaterThan(Program.C1.S1, int)"" IL_0011: ret } ").VerifyIL("Program.Test2(ref Program.C1)", @" { // Code size 20 (0x14) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0008 IL_0005: pop IL_0006: ldc.i4.0 IL_0007: ret IL_0008: call ""Program.C1.S1 Program.C1.x.get"" IL_000d: ldc.i4.m1 IL_000e: call ""bool Program.C1.S1.op_LessThan(Program.C1.S1, int)"" IL_0013: ret } ").VerifyIL("Program.Test3(Program.C1)", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""Program.C1.S1 ext.y(Program.C1)"" IL_000b: ldc.i4.m1 IL_000c: call ""bool Program.C1.S1.op_GreaterThan(Program.C1.S1, int)"" IL_0011: ret } ").VerifyIL("Program.Test4(ref Program.C1)", @" { // Code size 20 (0x14) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0008 IL_0005: pop IL_0006: ldc.i4.0 IL_0007: ret IL_0008: call ""Program.C1.S1 ext.y(Program.C1)"" IL_000d: ldc.i4.m1 IL_000e: call ""bool Program.C1.S1.op_LessThan(Program.C1.S1, int)"" IL_0013: ret } "); } [Fact] public void ConditionalMemberAccessOptimizedLocal001() { var source = @" using System; class Program { class C1 : System.IDisposable { public bool disposed; public void Dispose() { disposed = true; } } static void Main() { Test1(); Test2<C1>(); } static void Test1() { var c = new C1(); c?.Dispose(); } static void Test2<T>() where T : IDisposable, new() { var c = new T(); c?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1()", @" { // Code size 16 (0x10) .maxstack 2 IL_0000: newobj ""Program.C1..ctor()"" IL_0005: dup IL_0006: brtrue.s IL_000a IL_0008: pop IL_0009: ret IL_000a: call ""void Program.C1.Dispose()"" IL_000f: ret } ").VerifyIL("Program.Test2<T>()", @" { // Code size 28 (0x1c) .maxstack 1 .locals init (T V_0) //c IL_0000: call ""T System.Activator.CreateInstance<T>()"" IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: box ""T"" IL_000c: brfalse.s IL_001b IL_000e: ldloca.s V_0 IL_0010: constrained. ""T"" IL_0016: callvirt ""void System.IDisposable.Dispose()"" IL_001b: ret } "); } [Fact] public void ConditionalMemberAccessOptimizedLocal002() { var source = @" using System; class Program { interface I1 { void Goo(I1 arg); } class C1 : I1 { public void Goo(I1 arg) { } } static void Main() { Test1(); Test2<C1>(); } static void Test1() { var c = new C1(); c?.Goo(c); } static void Test2<T>() where T : I1, new() { var c = new T(); c?.Goo(c); } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1()", @" { // Code size 17 (0x11) .maxstack 2 .locals init (Program.C1 V_0) //c IL_0000: newobj ""Program.C1..ctor()"" IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: brfalse.s IL_0010 IL_0009: ldloc.0 IL_000a: ldloc.0 IL_000b: call ""void Program.C1.Goo(Program.I1)"" IL_0010: ret } ").VerifyIL("Program.Test2<T>()", @" { // Code size 34 (0x22) .maxstack 2 .locals init (T V_0) //c IL_0000: call ""T System.Activator.CreateInstance<T>()"" IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: box ""T"" IL_000c: brfalse.s IL_0021 IL_000e: ldloca.s V_0 IL_0010: ldloc.0 IL_0011: box ""T"" IL_0016: constrained. ""T"" IL_001c: callvirt ""void Program.I1.Goo(Program.I1)"" IL_0021: ret } "); } [Fact] public void ConditionalMemberAccessRace001() { var source = @" using System.Threading; using System.Threading.Tasks; class Program { static void Main() { string s = ""hello""; System.Action a = () => { for (int i = 0; i < 1000000; i++) { try { s = s?.Length.ToString(); s = null; Thread.Yield(); } catch (System.Exception ex) { System.Console.WriteLine(ex); } finally { s = s ?? ""hello""; } } }; Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); a(); System.Console.WriteLine(""Success""); } } "; var comp = CompileAndVerify(source, expectedOutput: @"Success"); } [Fact(), WorkItem(836, "GitHub")] public void ConditionalMemberAccessRace002() { var source = @" using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; class Program { static void Main() { string s = ""hello""; Test(s); } private static void Test<T>(T s) where T : IEnumerable<char> { Action a = () => { for (int i = 0; i < 1000000; i++) { var temp = s; try { s?.GetEnumerator(); s = default(T); Thread.Yield(); } catch (System.Exception ex) { System.Console.WriteLine(ex); } finally { s = temp; } } }; var tasks = new List<Task>(); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); a(); // wait for all tasks to exit or we may have // test issues when unloading ApDomain while threads still running in it Task.WaitAll(tasks.ToArray()); System.Console.WriteLine(""Success""); } } "; var comp = CompileAndVerify(source, expectedOutput: @"Success"); } [Fact] public void ConditionalMemberAccessConditional001() { var source = @" using System; class Program { static void Main() { Test1<string>(null); Test2<string>(null); } static string Test1<T>(T[] arr) { if (arr != null && arr.Length > 0) { return arr[0].ToString(); } return ""none""; } static string Test2<T>(T[] arr) { if (arr?.Length > 0) { return arr[0].ToString(); } return ""none""; } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_001c IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brfalse.s IL_001c IL_0007: ldarg.0 IL_0008: ldc.i4.0 IL_0009: readonly. IL_000b: ldelema ""T"" IL_0010: constrained. ""T"" IL_0016: callvirt ""string object.ToString()"" IL_001b: ret IL_001c: ldstr ""none"" IL_0021: ret } ").VerifyIL("Program.Test2<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_001c IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brfalse.s IL_001c IL_0007: ldarg.0 IL_0008: ldc.i4.0 IL_0009: readonly. IL_000b: ldelema ""T"" IL_0010: constrained. ""T"" IL_0016: callvirt ""string object.ToString()"" IL_001b: ret IL_001c: ldstr ""none"" IL_0021: ret } "); } [Fact] public void ConditionalMemberAccessConditional002() { var source = @" using System; class Program { static void Main() { Test1<string>(null); Test2<string>(null); } static string Test1<T>(T[] arr) { if (!(arr != null && arr.Length > 0)) { return ""none""; } return arr[0].ToString(); } static string Test2<T>(T[] arr) { if (!(arr?.Length > 0)) { return ""none""; } return arr[0].ToString(); } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0007 IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brtrue.s IL_000d IL_0007: ldstr ""none"" IL_000c: ret IL_000d: ldarg.0 IL_000e: ldc.i4.0 IL_000f: readonly. IL_0011: ldelema ""T"" IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: ret } ").VerifyIL("Program.Test2<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0007 IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brtrue.s IL_000d IL_0007: ldstr ""none"" IL_000c: ret IL_000d: ldarg.0 IL_000e: ldc.i4.0 IL_000f: readonly. IL_0011: ldelema ""T"" IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: ret } "); } [Fact] public void ConditionalMemberAccessConditional003() { var source = @" using System; class Program { static void Main() { System.Console.WriteLine(Test1<string>(null)); System.Console.WriteLine(Test2<string>(null)); System.Console.WriteLine(Test1<string>(new string[] {})); System.Console.WriteLine(Test2<string>(new string[] {})); System.Console.WriteLine(Test1<string>(new string[] { System.String.Empty })); System.Console.WriteLine(Test2<string>(new string[] { System.String.Empty })); } static string Test1<T>(T[] arr1) { var arr = arr1; if (arr != null && arr.Length == 0) { return ""empty""; } return ""not empty""; } static string Test2<T>(T[] arr1) { var arr = arr1; if (!(arr?.Length != 0)) { return ""empty""; } return ""not empty""; } } "; var comp = CompileAndVerify(source, expectedOutput: @"not empty not empty empty empty not empty not empty"); comp.VerifyIL("Program.Test1<T>(T[])", @" { // Code size 21 (0x15) .maxstack 1 .locals init (T[] V_0) //arr IL_0000: ldarg.0 IL_0001: stloc.0 IL_0002: ldloc.0 IL_0003: brfalse.s IL_000f IL_0005: ldloc.0 IL_0006: ldlen IL_0007: brtrue.s IL_000f IL_0009: ldstr ""empty"" IL_000e: ret IL_000f: ldstr ""not empty"" IL_0014: ret } ").VerifyIL("Program.Test2<T>(T[])", @" { // Code size 26 (0x1a) .maxstack 2 IL_0000: ldarg.0 IL_0001: dup IL_0002: brtrue.s IL_0008 IL_0004: pop IL_0005: ldc.i4.1 IL_0006: br.s IL_000c IL_0008: ldlen IL_0009: ldc.i4.0 IL_000a: cgt.un IL_000c: brtrue.s IL_0014 IL_000e: ldstr ""empty"" IL_0013: ret IL_0014: ldstr ""not empty"" IL_0019: ret } "); } [Fact] public void ConditionalMemberAccessConditional004() { var source = @" using System; class Program { static void Main() { var w = new WeakReference<string>(null); Test0(ref w); Test1(ref w); Test2(ref w); Test3(ref w); } static string Test0(ref WeakReference<string> slot) { string value = null; WeakReference<string> weak = slot; if (weak != null && weak.TryGetTarget(out value)) { return value; } return ""hello""; } static string Test1(ref WeakReference<string> slot) { string value = null; WeakReference<string> weak = slot; if (weak?.TryGetTarget(out value) == true) { return value; } return ""hello""; } static string Test2(ref WeakReference<string> slot) { string value = null; if (slot?.TryGetTarget(out value) == true) { return value; } return ""hello""; } static string Test3(ref WeakReference<string> slot) { string value = null; if (slot?.TryGetTarget(out value) ?? false) { return value; } return ""hello""; } } "; var comp = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: ""). VerifyIL("Program.Test0(ref System.WeakReference<string>)", @" { // Code size 26 (0x1a) .maxstack 2 .locals init (string V_0, //value System.WeakReference<string> V_1) //weak IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: stloc.1 IL_0005: ldloc.1 IL_0006: brfalse.s IL_0014 IL_0008: ldloc.1 IL_0009: ldloca.s V_0 IL_000b: callvirt ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0010: brfalse.s IL_0014 IL_0012: ldloc.0 IL_0013: ret IL_0014: ldstr ""hello"" IL_0019: ret } ").VerifyIL("Program.Test1(ref System.WeakReference<string>)", @" { // Code size 28 (0x1c) .maxstack 2 .locals init (string V_0) //value IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: dup IL_0005: brtrue.s IL_000b IL_0007: pop IL_0008: ldc.i4.0 IL_0009: br.s IL_0012 IL_000b: ldloca.s V_0 IL_000d: call ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0012: brfalse.s IL_0016 IL_0014: ldloc.0 IL_0015: ret IL_0016: ldstr ""hello"" IL_001b: ret } ").VerifyIL("Program.Test2(ref System.WeakReference<string>)", @" { // Code size 28 (0x1c) .maxstack 2 .locals init (string V_0) //value IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: dup IL_0005: brtrue.s IL_000b IL_0007: pop IL_0008: ldc.i4.0 IL_0009: br.s IL_0012 IL_000b: ldloca.s V_0 IL_000d: call ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0012: brfalse.s IL_0016 IL_0014: ldloc.0 IL_0015: ret IL_0016: ldstr ""hello"" IL_001b: ret } ").VerifyIL("Program.Test3(ref System.WeakReference<string>)", @" { // Code size 28 (0x1c) .maxstack 2 .locals init (string V_0) //value IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: dup IL_0005: brtrue.s IL_000b IL_0007: pop IL_0008: ldc.i4.0 IL_0009: br.s IL_0012 IL_000b: ldloca.s V_0 IL_000d: call ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0012: brfalse.s IL_0016 IL_0014: ldloc.0 IL_0015: ret IL_0016: ldstr ""hello"" IL_001b: ret } "); } [WorkItem(1042288, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1042288")] [Fact] public void Bug1042288() { var source = @" using System; class Test { static void Main() { var c1 = new C1(); System.Console.WriteLine(c1?.M1() ?? (long)1000); return; } } class C1 { public int M1() { return 1; } } "; var comp = CompileAndVerify(source, expectedOutput: @"1"); comp.VerifyIL("Test.Main", @" { // Code size 62 (0x3e) .maxstack 2 .locals init (int? V_0, int? V_1) IL_0000: newobj ""C1..ctor()"" IL_0005: dup IL_0006: brtrue.s IL_0014 IL_0008: pop IL_0009: ldloca.s V_1 IL_000b: initobj ""int?"" IL_0011: ldloc.1 IL_0012: br.s IL_001e IL_0014: call ""int C1.M1()"" IL_0019: newobj ""int?..ctor(int)"" IL_001e: stloc.0 IL_001f: ldloca.s V_0 IL_0021: call ""bool int?.HasValue.get"" IL_0026: brtrue.s IL_0030 IL_0028: ldc.i4 0x3e8 IL_002d: conv.i8 IL_002e: br.s IL_0038 IL_0030: ldloca.s V_0 IL_0032: call ""int int?.GetValueOrDefault()"" IL_0037: conv.i8 IL_0038: call ""void System.Console.WriteLine(long)"" IL_003d: ret } "); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_01() { var source = @" class C { public static void Main() { System.Console.WriteLine(MyMethod(null)); System.Console.WriteLine(MyMethod(new MyType())); } public static decimal MyMethod(MyType myObject) { return myObject?.MyField ?? 0m; } } public class MyType { public decimal MyField = 123; } "; var verifier = CompileAndVerify(source, expectedOutput: @"0 123"); verifier.VerifyIL("C.MyMethod", @" { // Code size 16 (0x10) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0009 IL_0003: ldsfld ""decimal decimal.Zero"" IL_0008: ret IL_0009: ldarg.0 IL_000a: ldfld ""decimal MyType.MyField"" IL_000f: ret }"); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_02() { var source = @" class C { public static void Main() { System.Console.WriteLine(MyMethod(null)); System.Console.WriteLine(MyMethod(new MyType())); } public static decimal MyMethod(MyType myObject) { return myObject?.MyField ?? default(decimal); } } public class MyType { public decimal MyField = 123; } "; var verifier = CompileAndVerify(source, expectedOutput: @"0 123"); verifier.VerifyIL("C.MyMethod", @" { // Code size 16 (0x10) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0009 IL_0003: ldsfld ""decimal decimal.Zero"" IL_0008: ret IL_0009: ldarg.0 IL_000a: ldfld ""decimal MyType.MyField"" IL_000f: ret }"); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_03() { var source = @" using System; class C { public static void Main() { System.Console.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, ""{0}"", MyMethod(null))); System.Console.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, ""{0}"", MyMethod(new MyType()))); } public static DateTime MyMethod(MyType myObject) { return myObject?.MyField ?? default(DateTime); } } public class MyType { public DateTime MyField = new DateTime(100000000); } "; var verifier = CompileAndVerify(source, expectedOutput: @"01/01/0001 00:00:00 01/01/0001 00:00:10"); verifier.VerifyIL("C.MyMethod", @" { // Code size 20 (0x14) .maxstack 1 .locals init (System.DateTime V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000d IL_0003: ldloca.s V_0 IL_0005: initobj ""System.DateTime"" IL_000b: ldloc.0 IL_000c: ret IL_000d: ldarg.0 IL_000e: ldfld ""System.DateTime MyType.MyField"" IL_0013: ret }"); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_04() { var source = @" class C { public static void Main() { System.Console.WriteLine(MyMethod(null).F); System.Console.WriteLine(MyMethod(new MyType()).F); } public static MyStruct MyMethod(MyType myObject) { return myObject?.MyField ?? default(MyStruct); } } public class MyType { public MyStruct MyField = new MyStruct() {F = 123}; } public struct MyStruct { public int F; } "; var verifier = CompileAndVerify(source, expectedOutput: @"0 123"); verifier.VerifyIL("C.MyMethod", @" { // Code size 20 (0x14) .maxstack 1 .locals init (MyStruct V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000d IL_0003: ldloca.s V_0 IL_0005: initobj ""MyStruct"" IL_000b: ldloc.0 IL_000c: ret IL_000d: ldarg.0 IL_000e: ldfld ""MyStruct MyType.MyField"" IL_0013: ret }"); } [WorkItem(1103294, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1103294")] [Fact] public void Bug1103294_01() { var source = @" class C { static void Main() { System.Console.WriteLine(""---""); Goo<int>(new C<int>()); System.Console.WriteLine(""---""); Goo<int>(null); System.Console.WriteLine(""---""); } static void Goo<T>(C<T> x) { x?.M(); } } class C<T> { public T M() { System.Console.WriteLine(""M""); return default(T); } }"; var verifier = CompileAndVerify(source, expectedOutput: @"--- M --- ---"); verifier.VerifyIL("C.Goo<T>", @" { // Code size 11 (0xb) .maxstack 1 IL_0000: ldarg.0 IL_0001: brfalse.s IL_000a IL_0003: ldarg.0 IL_0004: call ""T C<T>.M()"" IL_0009: pop IL_000a: ret }"); } [WorkItem(1103294, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1103294")] [Fact] public void Bug1103294_02() { var source = @" unsafe class C { static void Main() { System.Console.WriteLine(""---""); Goo(new C()); System.Console.WriteLine(""---""); Goo(null); System.Console.WriteLine(""---""); } static void Goo(C x) { x?.M(); } public int* M() { System.Console.WriteLine(""M""); return null; } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), verify: Verification.Fails, expectedOutput: @"--- M --- ---"); verifier.VerifyIL("C.Goo", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: nop IL_0001: ldarg.0 IL_0002: brtrue.s IL_0006 IL_0004: br.s IL_000d IL_0006: ldarg.0 IL_0007: call ""int* C.M()"" IL_000c: pop IL_000d: ret }"); } [WorkItem(23422, "https://github.com/dotnet/roslyn/issues/23422")] [Fact] public void ConditionalRefLike() { var source = @" class C { static void Main() { System.Console.WriteLine(""---""); Goo(new C()); System.Console.WriteLine(""---""); Goo(null); System.Console.WriteLine(""---""); } static void Goo(C x) { x?.M(); } public RefLike M() { System.Console.WriteLine(""M""); return default; } public ref struct RefLike{} } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), expectedOutput: @"--- M --- ---"); verifier.VerifyIL("C.Goo", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: nop IL_0001: ldarg.0 IL_0002: brtrue.s IL_0006 IL_0004: br.s IL_000d IL_0006: ldarg.0 IL_0007: call ""C.RefLike C.M()"" IL_000c: pop IL_000d: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_01() { var source = @" using System; class Test { static void Main() { System.Console.WriteLine(""---""); C.F1(null); System.Console.WriteLine(""---""); C.F1(new C()); System.Console.WriteLine(""---""); C.F2(null); System.Console.WriteLine(""---""); C.F2(new C()); System.Console.WriteLine(""---""); } } class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Action a = () => c?.M(); a(); } static public void F2(C c) => c?.M(); void M() => System.Console.WriteLine(""M""); } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- F1 --- F1 M --- --- M ---"); verifier.VerifyIL("C.<>c__DisplayClass0_0.<F1>b__0", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldfld ""C C.<>c__DisplayClass0_0.c"" IL_0006: dup IL_0007: brtrue.s IL_000c IL_0009: pop IL_000a: br.s IL_0012 IL_000c: call ""void C.M()"" IL_0011: nop IL_0012: ret }"); verifier.VerifyIL("C.F2", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: br.s IL_000c IL_0005: ldarg.0 IL_0006: call ""void C.M()"" IL_000b: nop IL_000c: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_02() { var source = @" using System; class Test { static void Main() { } } class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Func<object> a = () => c?.M(); } static public object F2(C c) => c?.M(); static public object P1 => (new C())?.M(); void M() => System.Console.WriteLine(""M""); } "; var compilation = CreateCompilation(source); compilation.VerifyDiagnostics( // (16,32): error CS0029: Cannot implicitly convert type 'void' to 'object' // Func<object> a = () => c?.M(); Diagnostic(ErrorCode.ERR_NoImplicitConv, "c?.M()").WithArguments("void", "object").WithLocation(16, 32), // (16,32): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type // Func<object> a = () => c?.M(); Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "c?.M()").WithArguments("lambda expression").WithLocation(16, 32), // (19,37): error CS0029: Cannot implicitly convert type 'void' to 'object' // static public object F2(C c) => c?.M(); Diagnostic(ErrorCode.ERR_NoImplicitConv, "c?.M()").WithArguments("void", "object").WithLocation(19, 37), // (21,32): error CS0029: Cannot implicitly convert type 'void' to 'object' // static public object P1 => (new C())?.M(); Diagnostic(ErrorCode.ERR_NoImplicitConv, "(new C())?.M()").WithArguments("void", "object").WithLocation(21, 32) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_03() { var source = @" using System; class Test { static void Main() { System.Console.WriteLine(""---""); C<int>.F1(null); System.Console.WriteLine(""---""); C<int>.F1(new C<int>()); System.Console.WriteLine(""---""); C<int>.F2(null); System.Console.WriteLine(""---""); C<int>.F2(new C<int>()); System.Console.WriteLine(""---""); } } class C<T> { static public void F1(C<T> c) { System.Console.WriteLine(""F1""); Action a = () => c?.M(); a(); } static public void F2(C<T> c) => c?.M(); T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- F1 --- F1 M --- --- M ---"); verifier.VerifyIL("C<T>.<>c__DisplayClass0_0.<F1>b__0()", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldfld ""C<T> C<T>.<>c__DisplayClass0_0.c"" IL_0006: dup IL_0007: brtrue.s IL_000c IL_0009: pop IL_000a: br.s IL_0012 IL_000c: call ""T C<T>.M()"" IL_0011: pop IL_0012: ret }"); verifier.VerifyIL("C<T>.F2", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: br.s IL_000c IL_0005: ldarg.0 IL_0006: call ""T C<T>.M()"" IL_000b: pop IL_000c: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_04() { var source = @" using System; class Test { static void Main() { } } class C<T> { static public void F1(C<T> c) { Func<object> a = () => c?.M(); } static public object F2(C<T> c) => c?.M(); static public object P1 => (new C<T>())?.M(); T M() { return default(T); } } "; var compilation = CreateCompilation(source); compilation.VerifyDiagnostics( // (15,33): error CS0023: Operator '?' cannot be applied to operand of type 'T' // Func<object> a = () => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(15, 33), // (18,41): error CS0023: Operator '?' cannot be applied to operand of type 'T' // static public object F2(C<T> c) => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(18, 41), // (20,44): error CS0023: Operator '?' cannot be applied to operand of type 'T' // static public object P1 => (new C<T>())?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(20, 44) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_05() { var source = @" using System; class Test { static void Main() { System.Console.WriteLine(""---""); C.F1(null); System.Console.WriteLine(""---""); C.F1(new C()); System.Console.WriteLine(""---""); C.F2(null); System.Console.WriteLine(""---""); C.F2(new C()); System.Console.WriteLine(""---""); } } unsafe class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Action<object> a = o => c?.M(); a(null); } static public void F2(C c) => c?.M(); void* M() { System.Console.WriteLine(""M""); return null; } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), verify: Verification.Fails, expectedOutput: @"--- F1 --- F1 M --- --- M ---"); verifier.VerifyIL("C.<>c__DisplayClass0_0.<F1>b__0", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldfld ""C C.<>c__DisplayClass0_0.c"" IL_0006: dup IL_0007: brtrue.s IL_000c IL_0009: pop IL_000a: br.s IL_0012 IL_000c: call ""void* C.M()"" IL_0011: pop IL_0012: ret }"); verifier.VerifyIL("C.F2", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: br.s IL_000c IL_0005: ldarg.0 IL_0006: call ""void* C.M()"" IL_000b: pop IL_000c: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_06() { var source = @" using System; class Test { static void Main() { } } unsafe class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Func<object, object> a = o => c?.M(); } static public object F2(C c) => c?.M(); static public object P1 => (new C())?.M(); void* M() { System.Console.WriteLine(""M""); return null; } } "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithAllowUnsafe(true)); compilation.VerifyDiagnostics( // (16,40): error CS0023: Operator '?' cannot be applied to operand of type 'void*' // Func<object, object> a = o => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "void*").WithLocation(16, 40), // (19,38): error CS0023: Operator '?' cannot be applied to operand of type 'void*' // static public object F2(C c) => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "void*").WithLocation(19, 38), // (21,41): error CS0023: Operator '?' cannot be applied to operand of type 'void*' // static public object P1 => (new C())?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "void*").WithLocation(21, 41) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_07() { var source = @" using System; class Test { static void Main() { C<int>.Test(); } } class C<T> { public static void Test() { var x = new [] {null, new C<T>()}; for (int i = 0; i < 2; x[i-1]?.M()) { System.Console.WriteLine(""---""); System.Console.WriteLine(""Loop""); i++; } System.Console.WriteLine(""---""); } public T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @" --- Loop --- Loop M ---"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_08() { var source = @" using System; class Test { static void Main() { C<int>.Test(); } } class C<T> { public static void Test() { var x = new [] {null, new C<T>()}; System.Console.WriteLine(""---""); for (x[0]?.M(); false;) { } System.Console.WriteLine(""---""); for (x[1]?.M(); false;) { } System.Console.WriteLine(""---""); } public T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- --- M ---"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_09() { var source = @" class Test { static void Main() { } } class C<T> { public static void Test() { C<T> x = null; for (; x?.M();) { } } public T M() { return default(T); } } "; var compilation = CreateCompilation(source); compilation.VerifyDiagnostics( // (15,17): error CS0023: Operator '?' cannot be applied to operand of type 'T' // for (; x?.M();) Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(15, 17) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_10() { var source = @" using System; class Test { static void Main() { C<int>.Test(); } } class C<T> { public static void Test() { System.Console.WriteLine(""---""); M1(a => a?.M(), null); System.Console.WriteLine(""---""); M1((a) => a?.M(), new C<T>()); System.Console.WriteLine(""---""); } static void M1(Action<C<T>> x, C<T> y) { System.Console.WriteLine(""M1(Action<C<T>> x)""); x(y); } static void M1(Func<C<T>, object> x, C<T> y) { System.Console.WriteLine(""M1(Func<C<T>, object> x)""); x(y); } public T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- M1(Action<C<T>> x) --- M1(Action<C<T>> x) M ---"); } [WorkItem(74, "https://github.com/dotnet/roslyn/issues/74")] [Fact] public void ConditionalInAsyncTask() { var source = @" #pragma warning disable CS1998 // suppress 'no await in async' warning using System; using System.Threading.Tasks; class Goo<T> { public T Method(int i) { Console.Write(i); return default(T); // returns value of unconstrained type parameter type } public void M1(Goo<T> x) => x?.Method(4); public async void M2(Goo<T> x) => x?.Method(5); public async Task M3(Goo<T> x) => x?.Method(6); public async Task M4() { Goo<T> a = new Goo<T>(); Goo<T> b = null; Action f1 = async () => a?.Method(1); f1(); f1 = async () => b?.Method(0); f1(); Func<Task> f2 = async () => a?.Method(2); await f2(); Func<Task> f3 = async () => b?.Method(3); await f3(); M1(a); M1(b); M2(a); M2(b); await M3(a); await M3(b); } } class Program { public static void Main() { // this will complete synchronously as there are no truly async ops. new Goo<int>().M4(); } }"; var compilation = CreateCompilationWithMscorlib45( source, references: new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, options: TestOptions.DebugExe); CompileAndVerify(compilation, expectedOutput: "12456"); } [WorkItem(825, "https://github.com/dotnet/roslyn/issues/825")] [Fact] public void ConditionalBoolExpr01() { var source = @" class C { public static void Main() { System.Console.WriteLine(HasLength(null, 0)); } static bool HasLength(string s, int len) { return s?.Length == len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False"); verifier.VerifyIL("C.HasLength", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldarg.1 IL_000c: ceq IL_000e: ret }"); } [WorkItem(825, "https://github.com/dotnet/roslyn/issues/825")] [Fact] public void ConditionalBoolExpr01a() { var source = @" class C { public static void Main() { System.Console.WriteLine(HasLength(null, 0)); } static bool HasLength(string s, byte len) { return s?.Length == len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False"); verifier.VerifyIL("C.HasLength", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldarg.1 IL_000c: ceq IL_000e: ret }"); } [WorkItem(825, "https://github.com/dotnet/roslyn/issues/825")] [WorkItem(5662, "https://github.com/dotnet/roslyn/issues/5662")] [Fact] public void ConditionalBoolExpr01b() { var source = @" class C { public static void Main() { System.Console.WriteLine(HasLength(null, long.MaxValue)); try { System.Console.WriteLine(HasLengthChecked(null, long.MaxValue)); } catch (System.Exception ex) { System.Console.WriteLine(ex.GetType().Name); } } static bool HasLength(string s, long len) { return s?.Length == (int)(byte)len; } static bool HasLengthChecked(string s, long len) { checked { return s?.Length == (int)(byte)len; } } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False OverflowException"); verifier.VerifyIL("C.HasLength", @" { // Code size 16 (0x10) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldarg.1 IL_000c: conv.u1 IL_000d: ceq IL_000f: ret }").VerifyIL("C.HasLengthChecked", @" { // Code size 48 (0x30) .maxstack 2 .locals init (int? V_0, int V_1, int? V_2) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_2 IL_0005: initobj ""int?"" IL_000b: ldloc.2 IL_000c: br.s IL_0019 IL_000e: ldarg.0 IL_000f: call ""int string.Length.get"" IL_0014: newobj ""int?..ctor(int)"" IL_0019: stloc.0 IL_001a: ldarg.1 IL_001b: conv.ovf.u1 IL_001c: stloc.1 IL_001d: ldloca.s V_0 IL_001f: call ""int int?.GetValueOrDefault()"" IL_0024: ldloc.1 IL_0025: ceq IL_0027: ldloca.s V_0 IL_0029: call ""bool int?.HasValue.get"" IL_002e: and IL_002f: ret }"); } [Fact] public void ConditionalBoolExpr02() { var source = @" class C { public static void Main() { System.Console.Write(HasLength(null, 0)); System.Console.Write(HasLength(null, 3)); System.Console.Write(HasLength(""q"", 2)); } static bool HasLength(string s, int len) { return (s?.Length ?? 2) + 1 == len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"FalseTrueTrue"); verifier.VerifyIL("C.HasLength", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldc.i4.2 IL_0004: br.s IL_000c IL_0006: ldarg.0 IL_0007: call ""int string.Length.get"" IL_000c: ldc.i4.1 IL_000d: add IL_000e: ldarg.1 IL_000f: ceq IL_0011: ret }"); } [Fact] public void ConditionalBoolExpr02a() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(""q"", 2)); } static bool NotHasLength(string s, int len) { return s?.Length + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 20 (0x14) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldc.i4.1 IL_000c: add IL_000d: ldarg.1 IL_000e: ceq IL_0010: ldc.i4.0 IL_0011: ceq IL_0013: ret }"); } [Fact] public void ConditionalBoolExpr02b() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(""q"", 2)); System.Console.Write(NotHasLength(null, null)); } static bool NotHasLength(string s, int? len) { return s?.Length + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalseFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 42 (0x2a) .maxstack 2 .locals init (int? V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000b IL_0003: ldarga.s V_1 IL_0005: call ""bool int?.HasValue.get"" IL_000a: ret IL_000b: ldarg.0 IL_000c: call ""int string.Length.get"" IL_0011: ldc.i4.1 IL_0012: add IL_0013: ldarg.1 IL_0014: stloc.0 IL_0015: ldloca.s V_0 IL_0017: call ""int int?.GetValueOrDefault()"" IL_001c: ceq IL_001e: ldloca.s V_0 IL_0020: call ""bool int?.HasValue.get"" IL_0025: and IL_0026: ldc.i4.0 IL_0027: ceq IL_0029: ret }"); } [Fact] public void ConditionalBoolExpr03() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength(null, 0).Result); System.Console.Write(HasLength(null, 3).Result); System.Console.Write(HasLength(""q"", 2).Result); } static async Task<bool> HasLength(string s, int len) { return (s?.Goo(await Bar()) ?? await Bar() + await Bar()) + 1 == len; } static int Goo(this string s, int arg) { return s.Length; } static async Task<int> Bar() { await Task.Yield(); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] public void ConditionalBoolExpr04() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength((string)null, 0).Result); System.Console.Write(HasLength((string)null, 3).Result); System.Console.Write(HasLength(""q"", 2).Result); } static async Task<bool> HasLength<T>(T s, int len) { return (s?.Goo(await Bar()) ?? 2) + 1 == len; } static int Goo<T>(this T s, int arg) { return ((string)(object)s).Length; } static async Task<int> Bar() { await Task.Yield(); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] public void ConditionalBoolExpr05() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength((string)null, 0).Result); System.Console.Write(HasLength((string)null, 3).Result); System.Console.Write(HasLength(""q"", 2).Result); } static async Task<bool> HasLength<T>(T s, int len) { return (s?.Goo(await Bar(await Bar())) ?? 2) + 1 == len; } static int Goo<T>(this T s, int arg) { return ((string)(object)s).Length; } static async Task<int> Bar() { await Task.Yield(); return 1; } static async Task<int> Bar(int arg) { await Task.Yield(); return arg; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] public void ConditionalBoolExpr06() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength(null, 0).Result); System.Console.Write(HasLength(null, 7).Result); System.Console.Write(HasLength(""q"", 7).Result); } static async Task<bool> HasLength(string s, int len) { System.Console.WriteLine(s?.Goo(await Bar())?.Goo(await Bar()) + ""#""); return s?.Goo(await Bar())?.Goo(await Bar()).Length == len; } static string Goo(this string s, string arg) { return s + arg; } static async Task<string> Bar() { await Task.Yield(); return ""Bar""; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"# False# FalseqBarBar# True"); } [Fact] public void ConditionalBoolExpr07() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.WriteLine(Test(null).Result); System.Console.WriteLine(Test(""q"").Result); } static async Task<bool> Test(string s) { return (await Bar(s))?.Goo(await Bar())?.ToString()?.Length > 1; } static string Goo(this string s, string arg1) { return s + arg1; } static async Task<string> Bar() { await Task.Yield(); return ""Bar""; } static async Task<string> Bar(string arg) { await Task.Yield(); return arg; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True"); } [Fact] public void ConditionalBoolExpr08() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.WriteLine(Test(null).Result); System.Console.WriteLine(Test(""q"").Result); } static async Task<bool> Test(string s) { return (await Bar(s))?.Insert(0, await Bar())?.ToString()?.Length > 1; } static async Task<string> Bar() { await Task.Yield(); return ""Bar""; } static async Task<dynamic> Bar(string arg) { await Task.Yield(); return arg; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True"); } [Fact] public void ConditionalUserDef01() { var source = @" class C { struct S1 { public static bool operator ==(S1? x, S1?y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1? x, S1? y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); } static bool TestEq(C1 c, S1 arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1 arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"==True ==True !=False !=False"); verifier.VerifyIL("C.TestNeq", @" { // Code size 37 (0x25) .maxstack 2 .locals init (C.S1? V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_0 IL_0005: initobj ""C.S1?"" IL_000b: ldloc.0 IL_000c: br.s IL_0019 IL_000e: ldarg.0 IL_000f: call ""C.S1 C.C1.Goo()"" IL_0014: newobj ""C.S1?..ctor(C.S1)"" IL_0019: ldarg.1 IL_001a: newobj ""C.S1?..ctor(C.S1)"" IL_001f: call ""bool C.S1.op_Inequality(C.S1?, C.S1?)"" IL_0024: ret }"); } [Fact] public void ConditionalUserDef01n() { var source = @" class C { struct S1 { public static bool operator ==(S1? x, S1?y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1? x, S1? y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestEq(new C1(), null)); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); System.Console.WriteLine(TestNeq(new C1(), null)); } static bool TestEq(C1 c, S1? arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1? arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"==True ==True ==True !=False !=False !=False"); verifier.VerifyIL("C.TestNeq", @" { // Code size 32 (0x20) .maxstack 2 .locals init (C.S1? V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_0 IL_0005: initobj ""C.S1?"" IL_000b: ldloc.0 IL_000c: br.s IL_0019 IL_000e: ldarg.0 IL_000f: call ""C.S1 C.C1.Goo()"" IL_0014: newobj ""C.S1?..ctor(C.S1)"" IL_0019: ldarg.1 IL_001a: call ""bool C.S1.op_Inequality(C.S1?, C.S1?)"" IL_001f: ret }"); } [Fact] public void ConditionalUserDef02() { var source = @" class C { struct S1 { public static bool operator ==(S1 x, S1 y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1 x, S1 y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); } static bool TestEq(C1 c, S1 arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1 arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False ==True True !=False"); verifier.VerifyIL("C.TestNeq", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""C.S1 C.C1.Goo()"" IL_000b: ldarg.1 IL_000c: call ""bool C.S1.op_Inequality(C.S1, C.S1)"" IL_0011: ret }"); } [Fact] public void ConditionalUserDef02n() { var source = @" class C { struct S1 { public static bool operator ==(S1 x, S1 y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1 x, S1 y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestEq(new C1(), null)); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); System.Console.WriteLine(TestNeq(new C1(), null)); } static bool TestEq(C1 c, S1? arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1? arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False ==True False True !=False True"); verifier.VerifyIL("C.TestNeq", @" { // Code size 45 (0x2d) .maxstack 2 .locals init (C.S1 V_0, C.S1? V_1) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000b IL_0003: ldarga.s V_1 IL_0005: call ""bool C.S1?.HasValue.get"" IL_000a: ret IL_000b: ldarg.0 IL_000c: call ""C.S1 C.C1.Goo()"" IL_0011: stloc.0 IL_0012: ldarg.1 IL_0013: stloc.1 IL_0014: ldloca.s V_1 IL_0016: call ""bool C.S1?.HasValue.get"" IL_001b: brtrue.s IL_001f IL_001d: ldc.i4.1 IL_001e: ret IL_001f: ldloc.0 IL_0020: ldloca.s V_1 IL_0022: call ""C.S1 C.S1?.GetValueOrDefault()"" IL_0027: call ""bool C.S1.op_Inequality(C.S1, C.S1)"" IL_002c: ret }"); } [Fact] public void Bug1() { var source = @" using System; class Test { static void Main() { var c1 = new C1(); M1(c1); M2(c1); } static void M1(C1 c1) { if (c1?.P == 1) Console.WriteLine(1); } static void M2(C1 c1) { if (c1 != null && c1.P == 1) Console.WriteLine(1); } } class C1 { public int P => 1; } "; var comp = CompileAndVerify(source, expectedOutput: @"1 1"); comp.VerifyIL("Test.M1", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0012 IL_0003: ldarg.0 IL_0004: call ""int C1.P.get"" IL_0009: ldc.i4.1 IL_000a: bne.un.s IL_0012 IL_000c: ldc.i4.1 IL_000d: call ""void System.Console.WriteLine(int)"" IL_0012: ret } "); comp.VerifyIL("Test.M2", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0012 IL_0003: ldarg.0 IL_0004: callvirt ""int C1.P.get"" IL_0009: ldc.i4.1 IL_000a: bne.un.s IL_0012 IL_000c: ldc.i4.1 IL_000d: call ""void System.Console.WriteLine(int)"" IL_0012: ret } "); } [Fact] public void ConditionalBoolExpr02ba() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(1, 2)); } static bool NotHasLength(int? s, int len) { return s?.GetHashCode() + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 35 (0x23) .maxstack 2 .locals init (int V_0) IL_0000: ldarga.s V_0 IL_0002: call ""bool int?.HasValue.get"" IL_0007: brtrue.s IL_000b IL_0009: ldc.i4.1 IL_000a: ret IL_000b: ldarga.s V_0 IL_000d: call ""int int?.GetValueOrDefault()"" IL_0012: stloc.0 IL_0013: ldloca.s V_0 IL_0015: call ""int int.GetHashCode()"" IL_001a: ldc.i4.1 IL_001b: add IL_001c: ldarg.1 IL_001d: ceq IL_001f: ldc.i4.0 IL_0020: ceq IL_0022: ret } "); } [Fact] public void ConditionalBoolExpr02bb() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(1, 2)); System.Console.Write(NotHasLength(null, null)); } static bool NotHasLength(int? s, int? len) { return s?.GetHashCode() + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalseFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 57 (0x39) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldarga.s V_0 IL_0002: call ""bool int?.HasValue.get"" IL_0007: brtrue.s IL_0011 IL_0009: ldarga.s V_1 IL_000b: call ""bool int?.HasValue.get"" IL_0010: ret IL_0011: ldarga.s V_0 IL_0013: call ""int int?.GetValueOrDefault()"" IL_0018: stloc.1 IL_0019: ldloca.s V_1 IL_001b: call ""int int.GetHashCode()"" IL_0020: ldc.i4.1 IL_0021: add IL_0022: ldarg.1 IL_0023: stloc.0 IL_0024: ldloca.s V_0 IL_0026: call ""int int?.GetValueOrDefault()"" IL_002b: ceq IL_002d: ldloca.s V_0 IL_002f: call ""bool int?.HasValue.get"" IL_0034: and IL_0035: ldc.i4.0 IL_0036: ceq IL_0038: ret }"); } [Fact] public void ConditionalUnary() { var source = @" class C { public static void Main() { var x = - - -((string)null)?.Length ?? - - -string.Empty?.Length; System.Console.WriteLine(x); } } "; var verifier = CompileAndVerify(source, expectedOutput: @"0"); verifier.VerifyIL("C.Main", @" { // Code size 44 (0x2c) .maxstack 2 .locals init (int? V_0) IL_0000: ldsfld ""string string.Empty"" IL_0005: dup IL_0006: brtrue.s IL_0014 IL_0008: pop IL_0009: ldloca.s V_0 IL_000b: initobj ""int?"" IL_0011: ldloc.0 IL_0012: br.s IL_0021 IL_0014: call ""int string.Length.get"" IL_0019: neg IL_001a: neg IL_001b: neg IL_001c: newobj ""int?..ctor(int)"" IL_0021: box ""int?"" IL_0026: call ""void System.Console.WriteLine(object)"" IL_002b: ret } "); } [WorkItem(7388, "https://github.com/dotnet/roslyn/issues/7388")] [Fact] public void ConditionalClassConstrained001() { var source = @" using System; namespace ConsoleApplication9 { class Program { static void Main(string[] args) { var v = new A<object>(); System.Console.WriteLine(A<object>.Test(v)); } public class A<T> : object where T : class { public T Value { get { return (T)(object)42; }} public static T Test(A<T> val) { return val?.Value; } } } } "; var verifier = CompileAndVerify(source, expectedOutput: @"42"); verifier.VerifyIL("ConsoleApplication9.Program.A<T>.Test(ConsoleApplication9.Program.A<T>)", @" { // Code size 20 (0x14) .maxstack 1 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000d IL_0003: ldloca.s V_0 IL_0005: initobj ""T"" IL_000b: ldloc.0 IL_000c: ret IL_000d: ldarg.0 IL_000e: call ""T ConsoleApplication9.Program.A<T>.Value.get"" IL_0013: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfUnconstrainedDefault1() { var source = @" using System; public class Test<T> { public string Run() { return default(T)?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 45 (0x2d) .maxstack 2 .locals init (T V_0, string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0028 IL_0014: ldloca.s V_0 IL_0016: dup IL_0017: initobj ""T"" IL_001d: constrained. ""T"" IL_0023: callvirt ""string object.ToString()"" IL_0028: stloc.1 IL_0029: br.s IL_002b IL_002b: ldloc.1 IL_002c: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfUnconstrainedDefault2() { var source = @" using System; public class Test<T> { public string Run() { var v = default(T); return v?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 38 (0x26) .maxstack 1 .locals init (T V_0, //v string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0021 IL_0014: ldloca.s V_0 IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: stloc.1 IL_0022: br.s IL_0024 IL_0024: ldloc.1 IL_0025: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfInterfaceConstrainedDefault1() { var source = @" using System; public class Test<T> where T : IComparable { public string Run() { return default(T)?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 45 (0x2d) .maxstack 2 .locals init (T V_0, string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0028 IL_0014: ldloca.s V_0 IL_0016: dup IL_0017: initobj ""T"" IL_001d: constrained. ""T"" IL_0023: callvirt ""string object.ToString()"" IL_0028: stloc.1 IL_0029: br.s IL_002b IL_002b: ldloc.1 IL_002c: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfInterfaceConstrainedDefault2() { var source = @" using System; public class Test<T> where T : IComparable { public string Run() { var v = default(T); return v?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 38 (0x26) .maxstack 1 .locals init (T V_0, //v string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0021 IL_0014: ldloca.s V_0 IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: stloc.1 IL_0022: br.s IL_0024 IL_0024: ldloc.1 IL_0025: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfClassConstrainedDefault1() { var source = @" using System; public class Test<T> where T : class { public string Run() { return default(T)?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 7 (0x7) .maxstack 1 .locals init (string V_0) IL_0000: nop IL_0001: ldnull IL_0002: stloc.0 IL_0003: br.s IL_0005 IL_0005: ldloc.0 IL_0006: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfClassConstrainedDefault2() { var source = @" using System; public class Test<T> where T : class { public string Run() { var v = default(T); return v?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 32 (0x20) .maxstack 2 .locals init (T V_0, //v string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: dup IL_0010: brtrue.s IL_0016 IL_0012: pop IL_0013: ldnull IL_0014: br.s IL_001b IL_0016: callvirt ""string object.ToString()"" IL_001b: stloc.1 IL_001c: br.s IL_001e IL_001e: ldloc.1 IL_001f: ret }"); } [Fact] [CompilerTrait(CompilerFeature.PEVerifyCompat)] public void ConditionalAccessOffReadOnlyNullable1() { var source = @" using System; class Program { private static readonly Guid? g = null; static void Main() { Console.WriteLine(g?.ToString()); } } "; var comp = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"", verify: Verification.Fails); comp.VerifyIL("Program.Main", @" { // Code size 44 (0x2c) .maxstack 2 .locals init (System.Guid V_0) IL_0000: nop IL_0001: ldsflda ""System.Guid? Program.g"" IL_0006: dup IL_0007: call ""bool System.Guid?.HasValue.get"" IL_000c: brtrue.s IL_0012 IL_000e: pop IL_000f: ldnull IL_0010: br.s IL_0025 IL_0012: call ""System.Guid System.Guid?.GetValueOrDefault()"" IL_0017: stloc.0 IL_0018: ldloca.s V_0 IL_001a: constrained. ""System.Guid"" IL_0020: callvirt ""string object.ToString()"" IL_0025: call ""void System.Console.WriteLine(string)"" IL_002a: nop IL_002b: ret }"); comp = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"", parseOptions: TestOptions.Regular.WithPEVerifyCompatFeature(), verify: Verification.Passes); comp.VerifyIL("Program.Main", @" { // Code size 47 (0x2f) .maxstack 2 .locals init (System.Guid? V_0, System.Guid V_1) IL_0000: nop IL_0001: ldsfld ""System.Guid? Program.g"" IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: dup IL_000a: call ""bool System.Guid?.HasValue.get"" IL_000f: brtrue.s IL_0015 IL_0011: pop IL_0012: ldnull IL_0013: br.s IL_0028 IL_0015: call ""System.Guid System.Guid?.GetValueOrDefault()"" IL_001a: stloc.1 IL_001b: ldloca.s V_1 IL_001d: constrained. ""System.Guid"" IL_0023: callvirt ""string object.ToString()"" IL_0028: call ""void System.Console.WriteLine(string)"" IL_002d: nop IL_002e: ret }"); } [Fact] public void ConditionalAccessOffReadOnlyNullable2() { var source = @" using System; class Program { static void Main() { Console.WriteLine(default(Guid?)?.ToString()); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @""); verifier.VerifyIL("Program.Main", @" { // Code size 55 (0x37) .maxstack 2 .locals init (System.Guid? V_0, System.Guid V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: dup IL_0004: initobj ""System.Guid?"" IL_000a: call ""bool System.Guid?.HasValue.get"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0030 IL_0014: ldloca.s V_0 IL_0016: dup IL_0017: initobj ""System.Guid?"" IL_001d: call ""System.Guid System.Guid?.GetValueOrDefault()"" IL_0022: stloc.1 IL_0023: ldloca.s V_1 IL_0025: constrained. ""System.Guid"" IL_002b: callvirt ""string object.ToString()"" IL_0030: call ""void System.Console.WriteLine(string)"" IL_0035: nop IL_0036: ret }"); } [Fact] [WorkItem(23351, "https://github.com/dotnet/roslyn/issues/23351")] public void ConditionalAccessOffConstrainedTypeParameter_Property() { var source = @" using System; class Program { static void Main(string[] args) { var obj1 = new MyObject1 { MyDate = new DateTime(636461511000000000L) }; var obj2 = new MyObject2<MyObject1>(obj1); System.Console.WriteLine(obj1.MyDate.Ticks); System.Console.WriteLine(obj2.CurrentDate.Value.Ticks); System.Console.WriteLine(new MyObject2<MyObject1>(null).CurrentDate.HasValue); } } abstract class MyBaseObject1 { public DateTime MyDate { get; set; } } class MyObject1 : MyBaseObject1 { } class MyObject2<MyObjectType> where MyObjectType : MyBaseObject1, new() { public MyObject2(MyObjectType obj) { m_CurrentObject1 = obj; } private MyObjectType m_CurrentObject1 = null; public MyObjectType CurrentObject1 => m_CurrentObject1; public DateTime? CurrentDate => CurrentObject1?.MyDate; } "; var expectedOutput = @" 636461511000000000 636461511000000000 False "; CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: expectedOutput); CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: expectedOutput); } [Fact] [WorkItem(23351, "https://github.com/dotnet/roslyn/issues/23351")] public void ConditionalAccessOffConstrainedTypeParameter_Field() { var source = @" using System; class Program { static void Main(string[] args) { var obj1 = new MyObject1 { MyDate = new DateTime(636461511000000000L) }; var obj2 = new MyObject2<MyObject1>(obj1); System.Console.WriteLine(obj1.MyDate.Ticks); System.Console.WriteLine(obj2.CurrentDate.Value.Ticks); System.Console.WriteLine(new MyObject2<MyObject1>(null).CurrentDate.HasValue); } } abstract class MyBaseObject1 { public DateTime MyDate; } class MyObject1 : MyBaseObject1 { } class MyObject2<MyObjectType> where MyObjectType : MyBaseObject1, new() { public MyObject2(MyObjectType obj) { m_CurrentObject1 = obj; } private MyObjectType m_CurrentObject1 = null; public MyObjectType CurrentObject1 => m_CurrentObject1; public DateTime? CurrentDate => CurrentObject1?.MyDate; } "; var expectedOutput = @" 636461511000000000 636461511000000000 False "; CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: expectedOutput); CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: expectedOutput); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen { public class CodeGenShortCircuitOperatorTests : CSharpTestBase { [Fact] public void TestShortCircuitAnd() { var source = @" class C { public static bool Test(char ch, bool result) { System.Console.WriteLine(ch); return result; } public static void Main() { const bool c1 = true; const bool c2 = false; bool v1 = true; bool v2 = false; System.Console.WriteLine(true && true); System.Console.WriteLine(true && false); System.Console.WriteLine(false && true); System.Console.WriteLine(false && false); System.Console.WriteLine(c1 && c1); System.Console.WriteLine(c1 && c2); System.Console.WriteLine(c2 && c1); System.Console.WriteLine(c2 && c2); System.Console.WriteLine(v1 && v1); System.Console.WriteLine(v1 && v2); System.Console.WriteLine(v2 && v1); System.Console.WriteLine(v2 && v2); System.Console.WriteLine(Test('L', true) && Test('R', true)); System.Console.WriteLine(Test('L', true) && Test('R', false)); System.Console.WriteLine(Test('L', false) && Test('R', true)); System.Console.WriteLine(Test('L', false) && Test('R', false)); } } "; var compilation = CompileAndVerify(source, expectedOutput: @" True False False False True False False False True False False False L R True L R False L False L False "); compilation.VerifyIL("C.Main", @" { // Code size 189 (0xbd) .maxstack 2 .locals init (bool V_0, //v1 bool V_1) //v2 IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: ldc.i4.0 IL_0003: stloc.1 IL_0004: ldc.i4.1 IL_0005: call ""void System.Console.WriteLine(bool)"" IL_000a: ldc.i4.0 IL_000b: call ""void System.Console.WriteLine(bool)"" IL_0010: ldc.i4.0 IL_0011: call ""void System.Console.WriteLine(bool)"" IL_0016: ldc.i4.0 IL_0017: call ""void System.Console.WriteLine(bool)"" IL_001c: ldc.i4.1 IL_001d: call ""void System.Console.WriteLine(bool)"" IL_0022: ldc.i4.0 IL_0023: call ""void System.Console.WriteLine(bool)"" IL_0028: ldc.i4.0 IL_0029: call ""void System.Console.WriteLine(bool)"" IL_002e: ldc.i4.0 IL_002f: call ""void System.Console.WriteLine(bool)"" IL_0034: ldloc.0 IL_0035: ldloc.0 IL_0036: and IL_0037: call ""void System.Console.WriteLine(bool)"" IL_003c: ldloc.0 IL_003d: ldloc.1 IL_003e: and IL_003f: call ""void System.Console.WriteLine(bool)"" IL_0044: ldloc.1 IL_0045: ldloc.0 IL_0046: and IL_0047: call ""void System.Console.WriteLine(bool)"" IL_004c: ldloc.1 IL_004d: ldloc.1 IL_004e: and IL_004f: call ""void System.Console.WriteLine(bool)"" IL_0054: ldc.i4.s 76 IL_0056: ldc.i4.1 IL_0057: call ""bool C.Test(char, bool)"" IL_005c: brfalse.s IL_0068 IL_005e: ldc.i4.s 82 IL_0060: ldc.i4.1 IL_0061: call ""bool C.Test(char, bool)"" IL_0066: br.s IL_0069 IL_0068: ldc.i4.0 IL_0069: call ""void System.Console.WriteLine(bool)"" IL_006e: ldc.i4.s 76 IL_0070: ldc.i4.1 IL_0071: call ""bool C.Test(char, bool)"" IL_0076: brfalse.s IL_0082 IL_0078: ldc.i4.s 82 IL_007a: ldc.i4.0 IL_007b: call ""bool C.Test(char, bool)"" IL_0080: br.s IL_0083 IL_0082: ldc.i4.0 IL_0083: call ""void System.Console.WriteLine(bool)"" IL_0088: ldc.i4.s 76 IL_008a: ldc.i4.0 IL_008b: call ""bool C.Test(char, bool)"" IL_0090: brfalse.s IL_009c IL_0092: ldc.i4.s 82 IL_0094: ldc.i4.1 IL_0095: call ""bool C.Test(char, bool)"" IL_009a: br.s IL_009d IL_009c: ldc.i4.0 IL_009d: call ""void System.Console.WriteLine(bool)"" IL_00a2: ldc.i4.s 76 IL_00a4: ldc.i4.0 IL_00a5: call ""bool C.Test(char, bool)"" IL_00aa: brfalse.s IL_00b6 IL_00ac: ldc.i4.s 82 IL_00ae: ldc.i4.0 IL_00af: call ""bool C.Test(char, bool)"" IL_00b4: br.s IL_00b7 IL_00b6: ldc.i4.0 IL_00b7: call ""void System.Console.WriteLine(bool)"" IL_00bc: ret }"); } [Fact] public void TestShortCircuitOr() { var source = @" class C { public static bool Test(char ch, bool result) { System.Console.WriteLine(ch); return result; } public static void Main() { const bool c1 = true; const bool c2 = false; bool v1 = true; bool v2 = false; System.Console.WriteLine(true || true); System.Console.WriteLine(true || false); System.Console.WriteLine(false || true); System.Console.WriteLine(false || false); System.Console.WriteLine(c1 || c1); System.Console.WriteLine(c1 || c2); System.Console.WriteLine(c2 || c1); System.Console.WriteLine(c2 || c2); System.Console.WriteLine(v1 || v1); System.Console.WriteLine(v1 || v2); System.Console.WriteLine(v2 || v1); System.Console.WriteLine(v2 || v2); System.Console.WriteLine(Test('L', true) || Test('R', true)); System.Console.WriteLine(Test('L', true) || Test('R', false)); System.Console.WriteLine(Test('L', false) || Test('R', true)); System.Console.WriteLine(Test('L', false) || Test('R', false)); } } "; var compilation = CompileAndVerify(source, expectedOutput: @" True True True False True True True False True True True False L True L True L R True L R False "); compilation.VerifyIL("C.Main", @" { // Code size 189 (0xbd) .maxstack 2 .locals init (bool V_0, //v1 bool V_1) //v2 IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: ldc.i4.0 IL_0003: stloc.1 IL_0004: ldc.i4.1 IL_0005: call ""void System.Console.WriteLine(bool)"" IL_000a: ldc.i4.1 IL_000b: call ""void System.Console.WriteLine(bool)"" IL_0010: ldc.i4.1 IL_0011: call ""void System.Console.WriteLine(bool)"" IL_0016: ldc.i4.0 IL_0017: call ""void System.Console.WriteLine(bool)"" IL_001c: ldc.i4.1 IL_001d: call ""void System.Console.WriteLine(bool)"" IL_0022: ldc.i4.1 IL_0023: call ""void System.Console.WriteLine(bool)"" IL_0028: ldc.i4.1 IL_0029: call ""void System.Console.WriteLine(bool)"" IL_002e: ldc.i4.0 IL_002f: call ""void System.Console.WriteLine(bool)"" IL_0034: ldloc.0 IL_0035: ldloc.0 IL_0036: or IL_0037: call ""void System.Console.WriteLine(bool)"" IL_003c: ldloc.0 IL_003d: ldloc.1 IL_003e: or IL_003f: call ""void System.Console.WriteLine(bool)"" IL_0044: ldloc.1 IL_0045: ldloc.0 IL_0046: or IL_0047: call ""void System.Console.WriteLine(bool)"" IL_004c: ldloc.1 IL_004d: ldloc.1 IL_004e: or IL_004f: call ""void System.Console.WriteLine(bool)"" IL_0054: ldc.i4.s 76 IL_0056: ldc.i4.1 IL_0057: call ""bool C.Test(char, bool)"" IL_005c: brtrue.s IL_0068 IL_005e: ldc.i4.s 82 IL_0060: ldc.i4.1 IL_0061: call ""bool C.Test(char, bool)"" IL_0066: br.s IL_0069 IL_0068: ldc.i4.1 IL_0069: call ""void System.Console.WriteLine(bool)"" IL_006e: ldc.i4.s 76 IL_0070: ldc.i4.1 IL_0071: call ""bool C.Test(char, bool)"" IL_0076: brtrue.s IL_0082 IL_0078: ldc.i4.s 82 IL_007a: ldc.i4.0 IL_007b: call ""bool C.Test(char, bool)"" IL_0080: br.s IL_0083 IL_0082: ldc.i4.1 IL_0083: call ""void System.Console.WriteLine(bool)"" IL_0088: ldc.i4.s 76 IL_008a: ldc.i4.0 IL_008b: call ""bool C.Test(char, bool)"" IL_0090: brtrue.s IL_009c IL_0092: ldc.i4.s 82 IL_0094: ldc.i4.1 IL_0095: call ""bool C.Test(char, bool)"" IL_009a: br.s IL_009d IL_009c: ldc.i4.1 IL_009d: call ""void System.Console.WriteLine(bool)"" IL_00a2: ldc.i4.s 76 IL_00a4: ldc.i4.0 IL_00a5: call ""bool C.Test(char, bool)"" IL_00aa: brtrue.s IL_00b6 IL_00ac: ldc.i4.s 82 IL_00ae: ldc.i4.0 IL_00af: call ""bool C.Test(char, bool)"" IL_00b4: br.s IL_00b7 IL_00b6: ldc.i4.1 IL_00b7: call ""void System.Console.WriteLine(bool)"" IL_00bc: ret }"); } [Fact] public void TestChainedShortCircuitOperators() { var source = @" class C { public static bool Test(char ch, bool result) { System.Console.WriteLine(ch); return result; } public static void Main() { // AND AND System.Console.WriteLine(Test('A', true) && Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', true) && Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', false) && Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', false) && Test('C' , false)); // AND OR System.Console.WriteLine(Test('A', true) && Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', true) && Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', true) && Test('B', false) || Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', false) && Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', false) && Test('B', false) || Test('C' , false)); // OR AND System.Console.WriteLine(Test('A', true) || Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', true) || Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', false) && Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', true) && Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', true) && Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', false) && Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', false) && Test('C' , false)); // OR OR System.Console.WriteLine(Test('A', true) || Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', true) || Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', true) || Test('B', false) || Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', true) || Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', true) || Test('C' , false)); System.Console.WriteLine(Test('A', false) || Test('B', false) || Test('C' , true)); System.Console.WriteLine(Test('A', false) || Test('B', false) || Test('C' , false)); } } "; var compilation = CompileAndVerify(source, expectedOutput: @" A B C True A B C False A B False A B False A False A False A False A False A B True A B True A B C True A B C False A C True A C False A C True A C False A True A True A True A True A B C True A B C False A B False A B False A True A True A True A True A B True A B True A B C True A B C False "); compilation.VerifyIL("C.Main", @"{ // Code size 1177 (0x499) .maxstack 2 IL_0000: ldc.i4.s 65 IL_0002: ldc.i4.1 IL_0003: call ""bool C.Test(char, bool)"" IL_0008: brfalse.s IL_001e IL_000a: ldc.i4.s 66 IL_000c: ldc.i4.1 IL_000d: call ""bool C.Test(char, bool)"" IL_0012: brfalse.s IL_001e IL_0014: ldc.i4.s 67 IL_0016: ldc.i4.1 IL_0017: call ""bool C.Test(char, bool)"" IL_001c: br.s IL_001f IL_001e: ldc.i4.0 IL_001f: call ""void System.Console.WriteLine(bool)"" IL_0024: ldc.i4.s 65 IL_0026: ldc.i4.1 IL_0027: call ""bool C.Test(char, bool)"" IL_002c: brfalse.s IL_0042 IL_002e: ldc.i4.s 66 IL_0030: ldc.i4.1 IL_0031: call ""bool C.Test(char, bool)"" IL_0036: brfalse.s IL_0042 IL_0038: ldc.i4.s 67 IL_003a: ldc.i4.0 IL_003b: call ""bool C.Test(char, bool)"" IL_0040: br.s IL_0043 IL_0042: ldc.i4.0 IL_0043: call ""void System.Console.WriteLine(bool)"" IL_0048: ldc.i4.s 65 IL_004a: ldc.i4.1 IL_004b: call ""bool C.Test(char, bool)"" IL_0050: brfalse.s IL_0066 IL_0052: ldc.i4.s 66 IL_0054: ldc.i4.0 IL_0055: call ""bool C.Test(char, bool)"" IL_005a: brfalse.s IL_0066 IL_005c: ldc.i4.s 67 IL_005e: ldc.i4.1 IL_005f: call ""bool C.Test(char, bool)"" IL_0064: br.s IL_0067 IL_0066: ldc.i4.0 IL_0067: call ""void System.Console.WriteLine(bool)"" IL_006c: ldc.i4.s 65 IL_006e: ldc.i4.1 IL_006f: call ""bool C.Test(char, bool)"" IL_0074: brfalse.s IL_008a IL_0076: ldc.i4.s 66 IL_0078: ldc.i4.0 IL_0079: call ""bool C.Test(char, bool)"" IL_007e: brfalse.s IL_008a IL_0080: ldc.i4.s 67 IL_0082: ldc.i4.0 IL_0083: call ""bool C.Test(char, bool)"" IL_0088: br.s IL_008b IL_008a: ldc.i4.0 IL_008b: call ""void System.Console.WriteLine(bool)"" IL_0090: ldc.i4.s 65 IL_0092: ldc.i4.0 IL_0093: call ""bool C.Test(char, bool)"" IL_0098: brfalse.s IL_00ae IL_009a: ldc.i4.s 66 IL_009c: ldc.i4.1 IL_009d: call ""bool C.Test(char, bool)"" IL_00a2: brfalse.s IL_00ae IL_00a4: ldc.i4.s 67 IL_00a6: ldc.i4.1 IL_00a7: call ""bool C.Test(char, bool)"" IL_00ac: br.s IL_00af IL_00ae: ldc.i4.0 IL_00af: call ""void System.Console.WriteLine(bool)"" IL_00b4: ldc.i4.s 65 IL_00b6: ldc.i4.0 IL_00b7: call ""bool C.Test(char, bool)"" IL_00bc: brfalse.s IL_00d2 IL_00be: ldc.i4.s 66 IL_00c0: ldc.i4.1 IL_00c1: call ""bool C.Test(char, bool)"" IL_00c6: brfalse.s IL_00d2 IL_00c8: ldc.i4.s 67 IL_00ca: ldc.i4.0 IL_00cb: call ""bool C.Test(char, bool)"" IL_00d0: br.s IL_00d3 IL_00d2: ldc.i4.0 IL_00d3: call ""void System.Console.WriteLine(bool)"" IL_00d8: ldc.i4.s 65 IL_00da: ldc.i4.0 IL_00db: call ""bool C.Test(char, bool)"" IL_00e0: brfalse.s IL_00f6 IL_00e2: ldc.i4.s 66 IL_00e4: ldc.i4.0 IL_00e5: call ""bool C.Test(char, bool)"" IL_00ea: brfalse.s IL_00f6 IL_00ec: ldc.i4.s 67 IL_00ee: ldc.i4.1 IL_00ef: call ""bool C.Test(char, bool)"" IL_00f4: br.s IL_00f7 IL_00f6: ldc.i4.0 IL_00f7: call ""void System.Console.WriteLine(bool)"" IL_00fc: ldc.i4.s 65 IL_00fe: ldc.i4.0 IL_00ff: call ""bool C.Test(char, bool)"" IL_0104: brfalse.s IL_011a IL_0106: ldc.i4.s 66 IL_0108: ldc.i4.0 IL_0109: call ""bool C.Test(char, bool)"" IL_010e: brfalse.s IL_011a IL_0110: ldc.i4.s 67 IL_0112: ldc.i4.0 IL_0113: call ""bool C.Test(char, bool)"" IL_0118: br.s IL_011b IL_011a: ldc.i4.0 IL_011b: call ""void System.Console.WriteLine(bool)"" IL_0120: ldc.i4.s 65 IL_0122: ldc.i4.1 IL_0123: call ""bool C.Test(char, bool)"" IL_0128: brfalse.s IL_0134 IL_012a: ldc.i4.s 66 IL_012c: ldc.i4.1 IL_012d: call ""bool C.Test(char, bool)"" IL_0132: brtrue.s IL_013e IL_0134: ldc.i4.s 67 IL_0136: ldc.i4.1 IL_0137: call ""bool C.Test(char, bool)"" IL_013c: br.s IL_013f IL_013e: ldc.i4.1 IL_013f: call ""void System.Console.WriteLine(bool)"" IL_0144: ldc.i4.s 65 IL_0146: ldc.i4.1 IL_0147: call ""bool C.Test(char, bool)"" IL_014c: brfalse.s IL_0158 IL_014e: ldc.i4.s 66 IL_0150: ldc.i4.1 IL_0151: call ""bool C.Test(char, bool)"" IL_0156: brtrue.s IL_0162 IL_0158: ldc.i4.s 67 IL_015a: ldc.i4.0 IL_015b: call ""bool C.Test(char, bool)"" IL_0160: br.s IL_0163 IL_0162: ldc.i4.1 IL_0163: call ""void System.Console.WriteLine(bool)"" IL_0168: ldc.i4.s 65 IL_016a: ldc.i4.1 IL_016b: call ""bool C.Test(char, bool)"" IL_0170: brfalse.s IL_017c IL_0172: ldc.i4.s 66 IL_0174: ldc.i4.0 IL_0175: call ""bool C.Test(char, bool)"" IL_017a: brtrue.s IL_0186 IL_017c: ldc.i4.s 67 IL_017e: ldc.i4.1 IL_017f: call ""bool C.Test(char, bool)"" IL_0184: br.s IL_0187 IL_0186: ldc.i4.1 IL_0187: call ""void System.Console.WriteLine(bool)"" IL_018c: ldc.i4.s 65 IL_018e: ldc.i4.1 IL_018f: call ""bool C.Test(char, bool)"" IL_0194: brfalse.s IL_01a0 IL_0196: ldc.i4.s 66 IL_0198: ldc.i4.0 IL_0199: call ""bool C.Test(char, bool)"" IL_019e: brtrue.s IL_01aa IL_01a0: ldc.i4.s 67 IL_01a2: ldc.i4.0 IL_01a3: call ""bool C.Test(char, bool)"" IL_01a8: br.s IL_01ab IL_01aa: ldc.i4.1 IL_01ab: call ""void System.Console.WriteLine(bool)"" IL_01b0: ldc.i4.s 65 IL_01b2: ldc.i4.0 IL_01b3: call ""bool C.Test(char, bool)"" IL_01b8: brfalse.s IL_01c4 IL_01ba: ldc.i4.s 66 IL_01bc: ldc.i4.1 IL_01bd: call ""bool C.Test(char, bool)"" IL_01c2: brtrue.s IL_01ce IL_01c4: ldc.i4.s 67 IL_01c6: ldc.i4.1 IL_01c7: call ""bool C.Test(char, bool)"" IL_01cc: br.s IL_01cf IL_01ce: ldc.i4.1 IL_01cf: call ""void System.Console.WriteLine(bool)"" IL_01d4: ldc.i4.s 65 IL_01d6: ldc.i4.0 IL_01d7: call ""bool C.Test(char, bool)"" IL_01dc: brfalse.s IL_01e8 IL_01de: ldc.i4.s 66 IL_01e0: ldc.i4.1 IL_01e1: call ""bool C.Test(char, bool)"" IL_01e6: brtrue.s IL_01f2 IL_01e8: ldc.i4.s 67 IL_01ea: ldc.i4.0 IL_01eb: call ""bool C.Test(char, bool)"" IL_01f0: br.s IL_01f3 IL_01f2: ldc.i4.1 IL_01f3: call ""void System.Console.WriteLine(bool)"" IL_01f8: ldc.i4.s 65 IL_01fa: ldc.i4.0 IL_01fb: call ""bool C.Test(char, bool)"" IL_0200: brfalse.s IL_020c IL_0202: ldc.i4.s 66 IL_0204: ldc.i4.0 IL_0205: call ""bool C.Test(char, bool)"" IL_020a: brtrue.s IL_0216 IL_020c: ldc.i4.s 67 IL_020e: ldc.i4.1 IL_020f: call ""bool C.Test(char, bool)"" IL_0214: br.s IL_0217 IL_0216: ldc.i4.1 IL_0217: call ""void System.Console.WriteLine(bool)"" IL_021c: ldc.i4.s 65 IL_021e: ldc.i4.0 IL_021f: call ""bool C.Test(char, bool)"" IL_0224: brfalse.s IL_0230 IL_0226: ldc.i4.s 66 IL_0228: ldc.i4.0 IL_0229: call ""bool C.Test(char, bool)"" IL_022e: brtrue.s IL_023a IL_0230: ldc.i4.s 67 IL_0232: ldc.i4.0 IL_0233: call ""bool C.Test(char, bool)"" IL_0238: br.s IL_023b IL_023a: ldc.i4.1 IL_023b: call ""void System.Console.WriteLine(bool)"" IL_0240: ldc.i4.s 65 IL_0242: ldc.i4.1 IL_0243: call ""bool C.Test(char, bool)"" IL_0248: brtrue.s IL_0261 IL_024a: ldc.i4.s 66 IL_024c: ldc.i4.1 IL_024d: call ""bool C.Test(char, bool)"" IL_0252: brfalse.s IL_025e IL_0254: ldc.i4.s 67 IL_0256: ldc.i4.1 IL_0257: call ""bool C.Test(char, bool)"" IL_025c: br.s IL_0262 IL_025e: ldc.i4.0 IL_025f: br.s IL_0262 IL_0261: ldc.i4.1 IL_0262: call ""void System.Console.WriteLine(bool)"" IL_0267: ldc.i4.s 65 IL_0269: ldc.i4.1 IL_026a: call ""bool C.Test(char, bool)"" IL_026f: brtrue.s IL_0288 IL_0271: ldc.i4.s 66 IL_0273: ldc.i4.1 IL_0274: call ""bool C.Test(char, bool)"" IL_0279: brfalse.s IL_0285 IL_027b: ldc.i4.s 67 IL_027d: ldc.i4.0 IL_027e: call ""bool C.Test(char, bool)"" IL_0283: br.s IL_0289 IL_0285: ldc.i4.0 IL_0286: br.s IL_0289 IL_0288: ldc.i4.1 IL_0289: call ""void System.Console.WriteLine(bool)"" IL_028e: ldc.i4.s 65 IL_0290: ldc.i4.1 IL_0291: call ""bool C.Test(char, bool)"" IL_0296: brtrue.s IL_02af IL_0298: ldc.i4.s 66 IL_029a: ldc.i4.0 IL_029b: call ""bool C.Test(char, bool)"" IL_02a0: brfalse.s IL_02ac IL_02a2: ldc.i4.s 67 IL_02a4: ldc.i4.1 IL_02a5: call ""bool C.Test(char, bool)"" IL_02aa: br.s IL_02b0 IL_02ac: ldc.i4.0 IL_02ad: br.s IL_02b0 IL_02af: ldc.i4.1 IL_02b0: call ""void System.Console.WriteLine(bool)"" IL_02b5: ldc.i4.s 65 IL_02b7: ldc.i4.1 IL_02b8: call ""bool C.Test(char, bool)"" IL_02bd: brtrue.s IL_02d6 IL_02bf: ldc.i4.s 66 IL_02c1: ldc.i4.0 IL_02c2: call ""bool C.Test(char, bool)"" IL_02c7: brfalse.s IL_02d3 IL_02c9: ldc.i4.s 67 IL_02cb: ldc.i4.0 IL_02cc: call ""bool C.Test(char, bool)"" IL_02d1: br.s IL_02d7 IL_02d3: ldc.i4.0 IL_02d4: br.s IL_02d7 IL_02d6: ldc.i4.1 IL_02d7: call ""void System.Console.WriteLine(bool)"" IL_02dc: ldc.i4.s 65 IL_02de: ldc.i4.0 IL_02df: call ""bool C.Test(char, bool)"" IL_02e4: brtrue.s IL_02fd IL_02e6: ldc.i4.s 66 IL_02e8: ldc.i4.1 IL_02e9: call ""bool C.Test(char, bool)"" IL_02ee: brfalse.s IL_02fa IL_02f0: ldc.i4.s 67 IL_02f2: ldc.i4.1 IL_02f3: call ""bool C.Test(char, bool)"" IL_02f8: br.s IL_02fe IL_02fa: ldc.i4.0 IL_02fb: br.s IL_02fe IL_02fd: ldc.i4.1 IL_02fe: call ""void System.Console.WriteLine(bool)"" IL_0303: ldc.i4.s 65 IL_0305: ldc.i4.0 IL_0306: call ""bool C.Test(char, bool)"" IL_030b: brtrue.s IL_0324 IL_030d: ldc.i4.s 66 IL_030f: ldc.i4.1 IL_0310: call ""bool C.Test(char, bool)"" IL_0315: brfalse.s IL_0321 IL_0317: ldc.i4.s 67 IL_0319: ldc.i4.0 IL_031a: call ""bool C.Test(char, bool)"" IL_031f: br.s IL_0325 IL_0321: ldc.i4.0 IL_0322: br.s IL_0325 IL_0324: ldc.i4.1 IL_0325: call ""void System.Console.WriteLine(bool)"" IL_032a: ldc.i4.s 65 IL_032c: ldc.i4.0 IL_032d: call ""bool C.Test(char, bool)"" IL_0332: brtrue.s IL_034b IL_0334: ldc.i4.s 66 IL_0336: ldc.i4.0 IL_0337: call ""bool C.Test(char, bool)"" IL_033c: brfalse.s IL_0348 IL_033e: ldc.i4.s 67 IL_0340: ldc.i4.1 IL_0341: call ""bool C.Test(char, bool)"" IL_0346: br.s IL_034c IL_0348: ldc.i4.0 IL_0349: br.s IL_034c IL_034b: ldc.i4.1 IL_034c: call ""void System.Console.WriteLine(bool)"" IL_0351: ldc.i4.s 65 IL_0353: ldc.i4.0 IL_0354: call ""bool C.Test(char, bool)"" IL_0359: brtrue.s IL_0372 IL_035b: ldc.i4.s 66 IL_035d: ldc.i4.0 IL_035e: call ""bool C.Test(char, bool)"" IL_0363: brfalse.s IL_036f IL_0365: ldc.i4.s 67 IL_0367: ldc.i4.0 IL_0368: call ""bool C.Test(char, bool)"" IL_036d: br.s IL_0373 IL_036f: ldc.i4.0 IL_0370: br.s IL_0373 IL_0372: ldc.i4.1 IL_0373: call ""void System.Console.WriteLine(bool)"" IL_0378: ldc.i4.s 65 IL_037a: ldc.i4.1 IL_037b: call ""bool C.Test(char, bool)"" IL_0380: brtrue.s IL_0396 IL_0382: ldc.i4.s 66 IL_0384: ldc.i4.1 IL_0385: call ""bool C.Test(char, bool)"" IL_038a: brtrue.s IL_0396 IL_038c: ldc.i4.s 67 IL_038e: ldc.i4.1 IL_038f: call ""bool C.Test(char, bool)"" IL_0394: br.s IL_0397 IL_0396: ldc.i4.1 IL_0397: call ""void System.Console.WriteLine(bool)"" IL_039c: ldc.i4.s 65 IL_039e: ldc.i4.1 IL_039f: call ""bool C.Test(char, bool)"" IL_03a4: brtrue.s IL_03ba IL_03a6: ldc.i4.s 66 IL_03a8: ldc.i4.1 IL_03a9: call ""bool C.Test(char, bool)"" IL_03ae: brtrue.s IL_03ba IL_03b0: ldc.i4.s 67 IL_03b2: ldc.i4.0 IL_03b3: call ""bool C.Test(char, bool)"" IL_03b8: br.s IL_03bb IL_03ba: ldc.i4.1 IL_03bb: call ""void System.Console.WriteLine(bool)"" IL_03c0: ldc.i4.s 65 IL_03c2: ldc.i4.1 IL_03c3: call ""bool C.Test(char, bool)"" IL_03c8: brtrue.s IL_03de IL_03ca: ldc.i4.s 66 IL_03cc: ldc.i4.0 IL_03cd: call ""bool C.Test(char, bool)"" IL_03d2: brtrue.s IL_03de IL_03d4: ldc.i4.s 67 IL_03d6: ldc.i4.1 IL_03d7: call ""bool C.Test(char, bool)"" IL_03dc: br.s IL_03df IL_03de: ldc.i4.1 IL_03df: call ""void System.Console.WriteLine(bool)"" IL_03e4: ldc.i4.s 65 IL_03e6: ldc.i4.1 IL_03e7: call ""bool C.Test(char, bool)"" IL_03ec: brtrue.s IL_0402 IL_03ee: ldc.i4.s 66 IL_03f0: ldc.i4.0 IL_03f1: call ""bool C.Test(char, bool)"" IL_03f6: brtrue.s IL_0402 IL_03f8: ldc.i4.s 67 IL_03fa: ldc.i4.0 IL_03fb: call ""bool C.Test(char, bool)"" IL_0400: br.s IL_0403 IL_0402: ldc.i4.1 IL_0403: call ""void System.Console.WriteLine(bool)"" IL_0408: ldc.i4.s 65 IL_040a: ldc.i4.0 IL_040b: call ""bool C.Test(char, bool)"" IL_0410: brtrue.s IL_0426 IL_0412: ldc.i4.s 66 IL_0414: ldc.i4.1 IL_0415: call ""bool C.Test(char, bool)"" IL_041a: brtrue.s IL_0426 IL_041c: ldc.i4.s 67 IL_041e: ldc.i4.1 IL_041f: call ""bool C.Test(char, bool)"" IL_0424: br.s IL_0427 IL_0426: ldc.i4.1 IL_0427: call ""void System.Console.WriteLine(bool)"" IL_042c: ldc.i4.s 65 IL_042e: ldc.i4.0 IL_042f: call ""bool C.Test(char, bool)"" IL_0434: brtrue.s IL_044a IL_0436: ldc.i4.s 66 IL_0438: ldc.i4.1 IL_0439: call ""bool C.Test(char, bool)"" IL_043e: brtrue.s IL_044a IL_0440: ldc.i4.s 67 IL_0442: ldc.i4.0 IL_0443: call ""bool C.Test(char, bool)"" IL_0448: br.s IL_044b IL_044a: ldc.i4.1 IL_044b: call ""void System.Console.WriteLine(bool)"" IL_0450: ldc.i4.s 65 IL_0452: ldc.i4.0 IL_0453: call ""bool C.Test(char, bool)"" IL_0458: brtrue.s IL_046e IL_045a: ldc.i4.s 66 IL_045c: ldc.i4.0 IL_045d: call ""bool C.Test(char, bool)"" IL_0462: brtrue.s IL_046e IL_0464: ldc.i4.s 67 IL_0466: ldc.i4.1 IL_0467: call ""bool C.Test(char, bool)"" IL_046c: br.s IL_046f IL_046e: ldc.i4.1 IL_046f: call ""void System.Console.WriteLine(bool)"" IL_0474: ldc.i4.s 65 IL_0476: ldc.i4.0 IL_0477: call ""bool C.Test(char, bool)"" IL_047c: brtrue.s IL_0492 IL_047e: ldc.i4.s 66 IL_0480: ldc.i4.0 IL_0481: call ""bool C.Test(char, bool)"" IL_0486: brtrue.s IL_0492 IL_0488: ldc.i4.s 67 IL_048a: ldc.i4.0 IL_048b: call ""bool C.Test(char, bool)"" IL_0490: br.s IL_0493 IL_0492: ldc.i4.1 IL_0493: call ""void System.Console.WriteLine(bool)"" IL_0498: ret } "); } [Fact] public void TestConditionalMemberAccess001() { var source = @" public class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(int[] x) { System.Console.Write(x?.ToString().ToString().ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, expectedOutput: "NULL#System.Int32[]"); comp.VerifyIL("C.Test", @" { // Code size 37 (0x25) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldnull IL_0004: br.s IL_0016 IL_0006: ldarg.0 IL_0007: callvirt ""string object.ToString()"" IL_000c: callvirt ""string object.ToString()"" IL_0011: callvirt ""string object.ToString()"" IL_0016: dup IL_0017: brtrue.s IL_001f IL_0019: pop IL_001a: ldstr ""NULL"" IL_001f: call ""void System.Console.Write(string)"" IL_0024: ret } "); } [Fact] public void TestConditionalMemberAccess001ext() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(int[] x) { System.Console.Write(x?.ToStr().ToStr().ToStr() ?? ""NULL""); } static string ToStr(this object arg) { return arg.ToString(); } }"; var comp = CompileAndVerify(source, expectedOutput: "NULL#System.Int32[]"); comp.VerifyIL("C.Test", @" { // Code size 37 (0x25) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldnull IL_0004: br.s IL_0016 IL_0006: ldarg.0 IL_0007: call ""string C.ToStr(object)"" IL_000c: call ""string C.ToStr(object)"" IL_0011: call ""string C.ToStr(object)"" IL_0016: dup IL_0017: brtrue.s IL_001f IL_0019: pop IL_001a: ldstr ""NULL"" IL_001f: call ""void System.Console.Write(string)"" IL_0024: ret } "); } [Fact] public void TestConditionalMemberAccess001dyn() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.ToString().ToString()?.ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#System.Int32[]"); comp.VerifyIL("C.Test", @" { // Code size 355 (0x163) .maxstack 14 .locals init (object V_0, object V_1) IL_0000: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_0005: brtrue.s IL_0046 IL_0007: ldc.i4 0x100 IL_000c: ldstr ""Write"" IL_0011: ldnull IL_0012: ldtoken ""C"" IL_0017: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_001c: ldc.i4.2 IL_001d: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_0022: dup IL_0023: ldc.i4.0 IL_0024: ldc.i4.s 33 IL_0026: ldnull IL_0027: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_002c: stelem.ref IL_002d: dup IL_002e: ldc.i4.1 IL_002f: ldc.i4.0 IL_0030: ldnull IL_0031: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_0036: stelem.ref IL_0037: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_003c: call ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_0041: stsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_0046: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_004b: ldfld ""System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic> System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>>.Target"" IL_0050: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>> C.<>o__1.<>p__3"" IL_0055: ldtoken ""System.Console"" IL_005a: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_005f: ldarg.0 IL_0060: stloc.0 IL_0061: ldloc.0 IL_0062: brtrue.s IL_006a IL_0064: ldnull IL_0065: br IL_0154 IL_006a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_006f: brtrue.s IL_00a1 IL_0071: ldc.i4.0 IL_0072: ldstr ""ToString"" IL_0077: ldnull IL_0078: ldtoken ""C"" IL_007d: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0082: ldc.i4.1 IL_0083: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_0088: dup IL_0089: ldc.i4.0 IL_008a: ldc.i4.0 IL_008b: ldnull IL_008c: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_0091: stelem.ref IL_0092: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_0097: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_009c: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_00a1: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_00a6: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target"" IL_00ab: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__1"" IL_00b0: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00b5: brtrue.s IL_00e7 IL_00b7: ldc.i4.0 IL_00b8: ldstr ""ToString"" IL_00bd: ldnull IL_00be: ldtoken ""C"" IL_00c3: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_00c8: ldc.i4.1 IL_00c9: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_00ce: dup IL_00cf: ldc.i4.0 IL_00d0: ldc.i4.0 IL_00d1: ldnull IL_00d2: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_00d7: stelem.ref IL_00d8: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_00dd: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_00e2: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00e7: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00ec: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target"" IL_00f1: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__0"" IL_00f6: ldloc.0 IL_00f7: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)"" IL_00fc: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)"" IL_0101: stloc.1 IL_0102: ldloc.1 IL_0103: brtrue.s IL_0108 IL_0105: ldnull IL_0106: br.s IL_0154 IL_0108: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_010d: brtrue.s IL_013f IL_010f: ldc.i4.0 IL_0110: ldstr ""ToString"" IL_0115: ldnull IL_0116: ldtoken ""C"" IL_011b: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0120: ldc.i4.1 IL_0121: newarr ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"" IL_0126: dup IL_0127: ldc.i4.0 IL_0128: ldc.i4.0 IL_0129: ldnull IL_012a: call ""Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags, string)"" IL_012f: stelem.ref IL_0130: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)"" IL_0135: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Create(System.Runtime.CompilerServices.CallSiteBinder)"" IL_013a: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_013f: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_0144: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>>.Target"" IL_0149: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> C.<>o__1.<>p__2"" IL_014e: ldloc.1 IL_014f: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)"" IL_0154: dup IL_0155: brtrue.s IL_015d IL_0157: pop IL_0158: ldstr ""NULL"" IL_015d: callvirt ""void System.Action<System.Runtime.CompilerServices.CallSite, System.Type, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, System.Type, dynamic)"" IL_0162: ret } "); } [Fact] public void TestConditionalMemberAccess001dyn1() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] { }; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.ToString()?[1].ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); } [Fact] public void TestConditionalMemberAccess001dyn2() { var source = @" public static class C { static void Main() { Test(null, ""aa""); System.Console.Write('#'); Test(""aa"", ""bb""); } static void Test(string s, dynamic ds) { System.Console.Write(s?.CompareTo(ds) ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#-1"); } [Fact] public void TestConditionalMemberAccess001dyn3() { var source = @" public static class C { static void Main() { Test(null, 1); System.Console.Write('#'); int[] a = new int[] { }; Test(a, 1); } static void Test(int[] x, dynamic i) { System.Console.Write(x?.ToString()?[i].ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#y"); } [Fact] public void TestConditionalMemberAccess001dyn4() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] {1,2,3}; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.Length.ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); } [Fact] public void TestConditionalMemberAccess001dyn5() { var source = @" public static class C { static void Main() { Test(null); System.Console.Write('#'); int[] a = new int[] {1,2,3}; Test(a); } static void Test(dynamic x) { System.Console.Write(x?.Length?.ToString() ?? ""NULL""); } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: "NULL#3"); } [Fact] public void TestConditionalMemberAccessUnused() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString(); var dummy2 = ""qqq""?.ToString(); var dummy3 = 1.ToString()?.ToString(); } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 32 (0x20) .maxstack 2 .locals init (int V_0) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: pop IL_000b: ldc.i4.1 IL_000c: stloc.0 IL_000d: ldloca.s V_0 IL_000f: call ""string int.ToString()"" IL_0014: dup IL_0015: brtrue.s IL_0019 IL_0017: pop IL_0018: ret IL_0019: callvirt ""string object.ToString()"" IL_001e: pop IL_001f: ret } "); } [Fact] public void TestConditionalMemberAccessUsed() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString(); var dummy2 = ""qqq""?.ToString(); var dummy3 = 1.ToString()?.ToString(); dummy1 += dummy2 += dummy3; } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 50 (0x32) .maxstack 3 .locals init (string V_0, //dummy2 string V_1, //dummy3 int V_2) IL_0000: ldnull IL_0001: ldstr ""qqq"" IL_0006: callvirt ""string object.ToString()"" IL_000b: stloc.0 IL_000c: ldc.i4.1 IL_000d: stloc.2 IL_000e: ldloca.s V_2 IL_0010: call ""string int.ToString()"" IL_0015: dup IL_0016: brtrue.s IL_001c IL_0018: pop IL_0019: ldnull IL_001a: br.s IL_0021 IL_001c: callvirt ""string object.ToString()"" IL_0021: stloc.1 IL_0022: ldloc.0 IL_0023: ldloc.1 IL_0024: call ""string string.Concat(string, string)"" IL_0029: dup IL_002a: stloc.0 IL_002b: call ""string string.Concat(string, string)"" IL_0030: pop IL_0031: ret } "); } [Fact] public void TestConditionalMemberAccessUnused1() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().Length; var dummy2 = ""qqq""?.ToString().Length; var dummy3 = 1.ToString()?.ToString().Length; } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 42 (0x2a) .maxstack 2 .locals init (int V_0) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: callvirt ""int string.Length.get"" IL_000f: pop IL_0010: ldc.i4.1 IL_0011: stloc.0 IL_0012: ldloca.s V_0 IL_0014: call ""string int.ToString()"" IL_0019: dup IL_001a: brtrue.s IL_001e IL_001c: pop IL_001d: ret IL_001e: callvirt ""string object.ToString()"" IL_0023: callvirt ""int string.Length.get"" IL_0028: pop IL_0029: ret } "); } [Fact] public void TestConditionalMemberAccessUsed1() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().Length; System.Console.WriteLine(dummy1); var dummy2 = ""qqq""?.ToString().Length; System.Console.WriteLine(dummy2); var dummy3 = 1.ToString()?.ToString().Length; System.Console.WriteLine(dummy3); } }"; var comp = CompileAndVerify(source, expectedOutput: @"3 1"); comp.VerifyIL("C.Main", @" { // Code size 99 (0x63) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldloca.s V_0 IL_0002: initobj ""int?"" IL_0008: ldloc.0 IL_0009: box ""int?"" IL_000e: call ""void System.Console.WriteLine(object)"" IL_0013: ldstr ""qqq"" IL_0018: callvirt ""string object.ToString()"" IL_001d: callvirt ""int string.Length.get"" IL_0022: newobj ""int?..ctor(int)"" IL_0027: box ""int?"" IL_002c: call ""void System.Console.WriteLine(object)"" IL_0031: ldc.i4.1 IL_0032: stloc.1 IL_0033: ldloca.s V_1 IL_0035: call ""string int.ToString()"" IL_003a: dup IL_003b: brtrue.s IL_0049 IL_003d: pop IL_003e: ldloca.s V_0 IL_0040: initobj ""int?"" IL_0046: ldloc.0 IL_0047: br.s IL_0058 IL_0049: callvirt ""string object.ToString()"" IL_004e: callvirt ""int string.Length.get"" IL_0053: newobj ""int?..ctor(int)"" IL_0058: box ""int?"" IL_005d: call ""void System.Console.WriteLine(object)"" IL_0062: ret } "); } [Fact] public void TestConditionalMemberAccessUnused2() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().NullableLength()?.ToString(); var dummy2 = ""qqq""?.ToString().NullableLength().ToString(); var dummy3 = 1.ToString()?.ToString().NullableLength()?.ToString(); } } public static class C1 { public static int? NullableLength(this string self) { return self.Length; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 82 (0x52) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: call ""int? C1.NullableLength(string)"" IL_000f: stloc.0 IL_0010: ldloca.s V_0 IL_0012: constrained. ""int?"" IL_0018: callvirt ""string object.ToString()"" IL_001d: pop IL_001e: ldc.i4.1 IL_001f: stloc.1 IL_0020: ldloca.s V_1 IL_0022: call ""string int.ToString()"" IL_0027: dup IL_0028: brtrue.s IL_002c IL_002a: pop IL_002b: ret IL_002c: callvirt ""string object.ToString()"" IL_0031: call ""int? C1.NullableLength(string)"" IL_0036: stloc.0 IL_0037: ldloca.s V_0 IL_0039: dup IL_003a: call ""bool int?.HasValue.get"" IL_003f: brtrue.s IL_0043 IL_0041: pop IL_0042: ret IL_0043: call ""int int?.GetValueOrDefault()"" IL_0048: stloc.1 IL_0049: ldloca.s V_1 IL_004b: call ""string int.ToString()"" IL_0050: pop IL_0051: ret } "); } [Fact] public void TestConditionalMemberAccessUnused2a() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString()?.Length.ToString(); var dummy2 = ""qqq""?.ToString().Length.ToString(); var dummy3 = 1.ToString()?.ToString().Length.ToString(); } }"; var comp = CompileAndVerify(source, expectedOutput: ""); comp.VerifyIL("C.Main", @" { // Code size 58 (0x3a) .maxstack 2 .locals init (int V_0) IL_0000: ldstr ""qqq"" IL_0005: callvirt ""string object.ToString()"" IL_000a: callvirt ""int string.Length.get"" IL_000f: stloc.0 IL_0010: ldloca.s V_0 IL_0012: call ""string int.ToString()"" IL_0017: pop IL_0018: ldc.i4.1 IL_0019: stloc.0 IL_001a: ldloca.s V_0 IL_001c: call ""string int.ToString()"" IL_0021: dup IL_0022: brtrue.s IL_0026 IL_0024: pop IL_0025: ret IL_0026: callvirt ""string object.ToString()"" IL_002b: callvirt ""int string.Length.get"" IL_0030: stloc.0 IL_0031: ldloca.s V_0 IL_0033: call ""string int.ToString()"" IL_0038: pop IL_0039: ret } "); } [Fact] public void TestConditionalMemberAccessUsed2() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString().NullableLength()?.ToString(); System.Console.WriteLine(dummy1); var dummy2 = ""qqq""?.ToString().NullableLength()?.ToString(); System.Console.WriteLine(dummy2); var dummy3 = 1.ToString()?.ToString().NullableLength()?.ToString(); System.Console.WriteLine(dummy3); } } public static class C1 { public static int? NullableLength(this string self) { return self.Length; } }"; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @"3 1"); comp.VerifyIL("C.Main", @" { // Code size 114 (0x72) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldnull IL_0001: call ""void System.Console.WriteLine(string)"" IL_0006: ldstr ""qqq"" IL_000b: callvirt ""string object.ToString()"" IL_0010: call ""int? C1.NullableLength(string)"" IL_0015: stloc.0 IL_0016: ldloca.s V_0 IL_0018: dup IL_0019: call ""bool int?.HasValue.get"" IL_001e: brtrue.s IL_0024 IL_0020: pop IL_0021: ldnull IL_0022: br.s IL_0031 IL_0024: call ""int int?.GetValueOrDefault()"" IL_0029: stloc.1 IL_002a: ldloca.s V_1 IL_002c: call ""string int.ToString()"" IL_0031: call ""void System.Console.WriteLine(string)"" IL_0036: ldc.i4.1 IL_0037: stloc.1 IL_0038: ldloca.s V_1 IL_003a: call ""string int.ToString()"" IL_003f: dup IL_0040: brtrue.s IL_0046 IL_0042: pop IL_0043: ldnull IL_0044: br.s IL_006c IL_0046: callvirt ""string object.ToString()"" IL_004b: call ""int? C1.NullableLength(string)"" IL_0050: stloc.0 IL_0051: ldloca.s V_0 IL_0053: dup IL_0054: call ""bool int?.HasValue.get"" IL_0059: brtrue.s IL_005f IL_005b: pop IL_005c: ldnull IL_005d: br.s IL_006c IL_005f: call ""int int?.GetValueOrDefault()"" IL_0064: stloc.1 IL_0065: ldloca.s V_1 IL_0067: call ""string int.ToString()"" IL_006c: call ""void System.Console.WriteLine(string)"" IL_0071: ret } "); } [Fact] public void TestConditionalMemberAccessUsed2a() { var source = @" public class C { static void Main() { var dummy1 = ((string)null)?.ToString()?.Length.ToString(); System.Console.WriteLine(dummy1); var dummy2 = ""qqq""?.ToString()?.Length.ToString(); System.Console.WriteLine(dummy2); var dummy3 = 1.ToString()?.ToString()?.Length.ToString(); System.Console.WriteLine(dummy3); } }"; var comp = CompileAndVerify(source, expectedOutput: @"3 1"); comp.VerifyIL("C.Main", @" { // Code size 88 (0x58) .maxstack 2 .locals init (int V_0) IL_0000: ldnull IL_0001: call ""void System.Console.WriteLine(string)"" IL_0006: ldstr ""qqq"" IL_000b: callvirt ""string object.ToString()"" IL_0010: dup IL_0011: brtrue.s IL_0017 IL_0013: pop IL_0014: ldnull IL_0015: br.s IL_0024 IL_0017: call ""int string.Length.get"" IL_001c: stloc.0 IL_001d: ldloca.s V_0 IL_001f: call ""string int.ToString()"" IL_0024: call ""void System.Console.WriteLine(string)"" IL_0029: ldc.i4.1 IL_002a: stloc.0 IL_002b: ldloca.s V_0 IL_002d: call ""string int.ToString()"" IL_0032: dup IL_0033: brtrue.s IL_0039 IL_0035: pop IL_0036: ldnull IL_0037: br.s IL_0052 IL_0039: callvirt ""string object.ToString()"" IL_003e: dup IL_003f: brtrue.s IL_0045 IL_0041: pop IL_0042: ldnull IL_0043: br.s IL_0052 IL_0045: call ""int string.Length.get"" IL_004a: stloc.0 IL_004b: ldloca.s V_0 IL_004d: call ""string int.ToString()"" IL_0052: call ""void System.Console.WriteLine(string)"" IL_0057: ret } "); } [Fact] [WorkItem(976765, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/976765")] public void ConditionalMemberAccessConstrained() { var source = @" class Program { static void M<T>(T x) where T: System.Exception { object s = x?.ToString(); System.Console.WriteLine(s); s = x?.GetType(); System.Console.WriteLine(s); } static void Main() { M(new System.Exception(""a"")); } } "; var comp = CompileAndVerify(source, expectedOutput: @"System.Exception: a System.Exception"); comp.VerifyIL("Program.M<T>", @" { // Code size 47 (0x2f) .maxstack 2 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: dup IL_0007: brtrue.s IL_000d IL_0009: pop IL_000a: ldnull IL_000b: br.s IL_0012 IL_000d: callvirt ""string object.ToString()"" IL_0012: call ""void System.Console.WriteLine(object)"" IL_0017: ldarg.0 IL_0018: box ""T"" IL_001d: dup IL_001e: brtrue.s IL_0024 IL_0020: pop IL_0021: ldnull IL_0022: br.s IL_0029 IL_0024: callvirt ""System.Type System.Exception.GetType()"" IL_0029: call ""void System.Console.WriteLine(object)"" IL_002e: ret } "); } [Fact] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement() { var source = @" class Program { class C1 { public void Print0() { System.Console.WriteLine(""print0""); } public int Print1() { System.Console.WriteLine(""print1""); return 1; } public object Print2() { System.Console.WriteLine(""print2""); return 1; } } static void M(C1 x) { x?.Print0(); x?.Print1(); x?.Print2(); } static void Main() { M(null); M(new C1()); } } "; var comp = CompileAndVerify(source, expectedOutput: @"print0 print1 print2"); comp.VerifyIL("Program.M(Program.C1)", @" { // Code size 30 (0x1e) .maxstack 1 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0009 IL_0003: ldarg.0 IL_0004: call ""void Program.C1.Print0()"" IL_0009: ldarg.0 IL_000a: brfalse.s IL_0013 IL_000c: ldarg.0 IL_000d: call ""int Program.C1.Print1()"" IL_0012: pop IL_0013: ldarg.0 IL_0014: brfalse.s IL_001d IL_0016: ldarg.0 IL_0017: call ""object Program.C1.Print2()"" IL_001c: pop IL_001d: ret } "); } [Fact] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement01() { var source = @" class Program { struct S1 { public void Print0() { System.Console.WriteLine(""print0""); } public int Print1() { System.Console.WriteLine(""print1""); return 1; } public object Print2() { System.Console.WriteLine(""print2""); return 1; } } static void M(S1? x) { x?.Print0(); x?.Print1(); x?.Print2()?.ToString().ToString()?.ToString(); } static void Main() { M(null); M(new S1()); } } "; var comp = CompileAndVerify(source, expectedOutput: @"print0 print1 print2"); comp.VerifyIL("Program.M(Program.S1?)", @" { // Code size 100 (0x64) .maxstack 2 .locals init (Program.S1 V_0) IL_0000: ldarga.s V_0 IL_0002: call ""bool Program.S1?.HasValue.get"" IL_0007: brfalse.s IL_0018 IL_0009: ldarga.s V_0 IL_000b: call ""Program.S1 Program.S1?.GetValueOrDefault()"" IL_0010: stloc.0 IL_0011: ldloca.s V_0 IL_0013: call ""void Program.S1.Print0()"" IL_0018: ldarga.s V_0 IL_001a: call ""bool Program.S1?.HasValue.get"" IL_001f: brfalse.s IL_0031 IL_0021: ldarga.s V_0 IL_0023: call ""Program.S1 Program.S1?.GetValueOrDefault()"" IL_0028: stloc.0 IL_0029: ldloca.s V_0 IL_002b: call ""int Program.S1.Print1()"" IL_0030: pop IL_0031: ldarga.s V_0 IL_0033: call ""bool Program.S1?.HasValue.get"" IL_0038: brfalse.s IL_0063 IL_003a: ldarga.s V_0 IL_003c: call ""Program.S1 Program.S1?.GetValueOrDefault()"" IL_0041: stloc.0 IL_0042: ldloca.s V_0 IL_0044: call ""object Program.S1.Print2()"" IL_0049: dup IL_004a: brtrue.s IL_004e IL_004c: pop IL_004d: ret IL_004e: callvirt ""string object.ToString()"" IL_0053: callvirt ""string object.ToString()"" IL_0058: dup IL_0059: brtrue.s IL_005d IL_005b: pop IL_005c: ret IL_005d: callvirt ""string object.ToString()"" IL_0062: pop IL_0063: ret } "); } [ConditionalFact(typeof(DesktopOnly))] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement02() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { class C1 { public void Print0(int i) { System.Console.WriteLine(""print0""); } public int Print1(int i) { System.Console.WriteLine(""print1""); return 1; } public object Print2(int i) { System.Console.WriteLine(""print2""); return 1; } } static async Task<int> Val() { await Task.Yield(); return 1; } static async Task<int> M(C1 x) { x?.Print0(await Val()); x?.Print1(await Val()); x?.Print2(await Val()); return 1; } static void Main() { M(null).Wait(); M(new C1()).Wait(); } } "; var comp = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 print1 print2"); } [ConditionalFact(typeof(DesktopOnly))] [WorkItem(991400, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991400")] public void ConditionalMemberAccessStatement03() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { struct C1 { public void Print0(int i) { System.Console.WriteLine(""print0""); } public int Print1(int i) { System.Console.WriteLine(""print1""); return 1; } public object Print2(int i) { System.Console.WriteLine(""print2""); return 1; } } static async Task<int> Val() { await Task.Yield(); return 1; } static async Task<int> M(C1? x) { x?.Print0(await Val()); x?.Print1(await Val()); x?.Print2(await Val()); return 1; } static void Main() { M(null).Wait(); M(new C1()).Wait(); } } "; var comp = CompileAndVerify(source, targetFramework: TargetFramework.Empty, references: new[] { MscorlibRef_v4_0_30316_17626 }, expectedOutput: @"print0 print1 print2"); } [Fact] public void ConditionalMemberAccessUnConstrained() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(ref c, ref c); S1 s = new S1(); Test(ref s, ref s); } static void Test<T>(ref T x, ref T y) where T : IDisposable { x?.Dispose(); y?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False True"); comp.VerifyIL("Program.Test<T>(ref T, ref T)", @" { // Code size 94 (0x5e) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0024 IL_0011: ldobj ""T"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: ldloc.0 IL_001a: box ""T"" IL_001f: brtrue.s IL_0024 IL_0021: pop IL_0022: br.s IL_002f IL_0024: constrained. ""T"" IL_002a: callvirt ""void System.IDisposable.Dispose()"" IL_002f: ldarg.1 IL_0030: ldloca.s V_0 IL_0032: initobj ""T"" IL_0038: ldloc.0 IL_0039: box ""T"" IL_003e: brtrue.s IL_0052 IL_0040: ldobj ""T"" IL_0045: stloc.0 IL_0046: ldloca.s V_0 IL_0048: ldloc.0 IL_0049: box ""T"" IL_004e: brtrue.s IL_0052 IL_0050: pop IL_0051: ret IL_0052: constrained. ""T"" IL_0058: callvirt ""void System.IDisposable.Dispose()"" IL_005d: ret }"); } [Fact] public void ConditionalMemberAccessUnConstrained1() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { var c = new C1[] {new C1()}; Test(c, c); var s = new S1[] {new S1()}; Test(s, s); } static void Test<T>(T[] x, T[] y) where T : IDisposable { x[0]?.Dispose(); y[0]?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False True"); comp.VerifyIL("Program.Test<T>(T[], T[])", @" { // Code size 110 (0x6e) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: readonly. IL_0004: ldelema ""T"" IL_0009: ldloca.s V_0 IL_000b: initobj ""T"" IL_0011: ldloc.0 IL_0012: box ""T"" IL_0017: brtrue.s IL_002c IL_0019: ldobj ""T"" IL_001e: stloc.0 IL_001f: ldloca.s V_0 IL_0021: ldloc.0 IL_0022: box ""T"" IL_0027: brtrue.s IL_002c IL_0029: pop IL_002a: br.s IL_0037 IL_002c: constrained. ""T"" IL_0032: callvirt ""void System.IDisposable.Dispose()"" IL_0037: ldarg.1 IL_0038: ldc.i4.0 IL_0039: readonly. IL_003b: ldelema ""T"" IL_0040: ldloca.s V_0 IL_0042: initobj ""T"" IL_0048: ldloc.0 IL_0049: box ""T"" IL_004e: brtrue.s IL_0062 IL_0050: ldobj ""T"" IL_0055: stloc.0 IL_0056: ldloca.s V_0 IL_0058: ldloc.0 IL_0059: box ""T"" IL_005e: brtrue.s IL_0062 IL_0060: pop IL_0061: ret IL_0062: constrained. ""T"" IL_0068: callvirt ""void System.IDisposable.Dispose()"" IL_006d: ret } "); } [Fact] public void ConditionalMemberAccessConstrained1() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { var c = new C1[] {new C1()}; Test(c, c); } static void Test<T>(T[] x, T[] y) where T : class, IDisposable { x[0]?.Dispose(); y[0]?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True "); comp.VerifyIL("Program.Test<T>(T[], T[])", @" { // Code size 46 (0x2e) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: ldelem ""T"" IL_0007: box ""T"" IL_000c: dup IL_000d: brtrue.s IL_0012 IL_000f: pop IL_0010: br.s IL_0017 IL_0012: callvirt ""void System.IDisposable.Dispose()"" IL_0017: ldarg.1 IL_0018: ldc.i4.0 IL_0019: ldelem ""T"" IL_001e: box ""T"" IL_0023: dup IL_0024: brtrue.s IL_0028 IL_0026: pop IL_0027: ret IL_0028: callvirt ""void System.IDisposable.Dispose()"" IL_002d: ret } "); } [Fact] public void ConditionalMemberAccessUnConstrainedVal() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(c); S1 s = new S1(); Test(s); } static void Test<T>(T x) where T : IDisposable { x?.Dispose(); x?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False True"); comp.VerifyIL("Program.Test<T>(T)", @" { // Code size 43 (0x2b) .maxstack 1 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: brfalse.s IL_0015 IL_0008: ldarga.s V_0 IL_000a: constrained. ""T"" IL_0010: callvirt ""void System.IDisposable.Dispose()"" IL_0015: ldarg.0 IL_0016: box ""T"" IL_001b: brfalse.s IL_002a IL_001d: ldarga.s V_0 IL_001f: constrained. ""T"" IL_0025: callvirt ""void System.IDisposable.Dispose()"" IL_002a: ret } "); } [Fact] public void ConditionalMemberAccessUnConstrainedVal001() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(() => c); S1 s = new S1(); Test(() => s); } static void Test<T>(Func<T> x) where T : IDisposable { x()?.Dispose(); x()?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True False False"); comp.VerifyIL("Program.Test<T>(System.Func<T>)", @" { // Code size 72 (0x48) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: callvirt ""T System.Func<T>.Invoke()"" IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: dup IL_000a: ldobj ""T"" IL_000f: box ""T"" IL_0014: brtrue.s IL_0019 IL_0016: pop IL_0017: br.s IL_0024 IL_0019: constrained. ""T"" IL_001f: callvirt ""void System.IDisposable.Dispose()"" IL_0024: ldarg.0 IL_0025: callvirt ""T System.Func<T>.Invoke()"" IL_002a: stloc.0 IL_002b: ldloca.s V_0 IL_002d: dup IL_002e: ldobj ""T"" IL_0033: box ""T"" IL_0038: brtrue.s IL_003c IL_003a: pop IL_003b: ret IL_003c: constrained. ""T"" IL_0042: callvirt ""void System.IDisposable.Dispose()"" IL_0047: ret } "); } [Fact] public void ConditionalMemberAccessConstrainedVal001() { var source = @" using System; using System.Collections.Generic; class Program { class C1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable { private bool disposed; public void Dispose() { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(() => c); } static void Test<T>(Func<T> x) where T : class, IDisposable { x()?.Dispose(); x()?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True"); comp.VerifyIL("Program.Test<T>(System.Func<T>)", @" { // Code size 44 (0x2c) .maxstack 2 IL_0000: ldarg.0 IL_0001: callvirt ""T System.Func<T>.Invoke()"" IL_0006: box ""T"" IL_000b: dup IL_000c: brtrue.s IL_0011 IL_000e: pop IL_000f: br.s IL_0016 IL_0011: callvirt ""void System.IDisposable.Dispose()"" IL_0016: ldarg.0 IL_0017: callvirt ""T System.Func<T>.Invoke()"" IL_001c: box ""T"" IL_0021: dup IL_0022: brtrue.s IL_0026 IL_0024: pop IL_0025: ret IL_0026: callvirt ""void System.IDisposable.Dispose()"" IL_002b: ret } "); } [Fact] public void ConditionalMemberAccessUnConstrainedDyn() { var source = @" using System; using System.Collections.Generic; class Program { interface IDisposable1 { void Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(ref c, ref c); S1 s = new S1(); Test(ref s, ref s); } static void Test<T>(ref T x, ref T y) where T : IDisposable1 { dynamic d = 1; x?.Dispose(d); y?.Dispose(d); } } "; var comp = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedDynVal() { var source = @" using System; using System.Collections.Generic; class Program { interface IDisposable1 { void Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1 c = new C1(); Test(c, c); S1 s = new S1(); Test(s, s); } static void Test<T>(T x, T y) where T : IDisposable1 { dynamic d = 1; x?.Dispose(d); y?.Dispose(d); } } "; var comp = CompileAndVerify(source, references: new MetadataReference[] { CSharpRef }, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsync() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { void Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } struct S1 : IDisposable1 { private bool disposed; public void Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await Val()); y[0]?.Dispose(await Val()); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncVal() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { int Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } struct S1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } static void Main(string[] args) { C1 c = new C1(); Test(c, c).Wait(); S1 s = new S1(); Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T x, T y) where T : IDisposable1 { x?.Dispose(await Val()); y?.Dispose(await Val()); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncValExt() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; using DE; namespace DE { public static class IDispExt { public static void DisposeExt(this Program.IDisposable1 d, int i) { d.Dispose(i); } } } public class Program { public interface IDisposable1 { int Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } struct S1 : IDisposable1 { private bool disposed; public int Dispose(int i) { System.Console.WriteLine(disposed); disposed = true; return 1; } } static void Main(string[] args) { C1 c = new C1(); Test(c, c).Wait(); S1 s = new S1(); Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T x, T y) where T : IDisposable1 { x?.DisposeExt(await Val()); y?.DisposeExt(await Val()); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncNested() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { IDisposable1 Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public IDisposable1 Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return this; } } struct S1 : IDisposable1 { private bool disposed; public IDisposable1 Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return this; } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); System.Console.WriteLine(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val()); y[0]?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val())?.Dispose(await Val()); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True False True False True False True False True True False True False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncNestedArr() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { IDisposable1[] Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public IDisposable1[] Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return new IDisposable1[] { this }; } } struct S1 : IDisposable1 { private bool disposed; public IDisposable1[] Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return new IDisposable1[]{this}; } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); System.Console.WriteLine(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val()); y[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val())[0]?.Dispose(await Val()); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True False True False True False True False True True False True False"); } [Fact] public void ConditionalMemberAccessUnConstrainedAsyncSuperNested() { var source = @" using System; using System.Collections.Generic; using System.Threading.Tasks; class Program { interface IDisposable1 { Task<int> Dispose(int i); } class C1 : IDisposable1 { private bool disposed; public Task<int> Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return Task.FromResult(i); } } struct S1 : IDisposable1 { private bool disposed; public Task<int> Dispose(int i) { System.Console.WriteLine(disposed); disposed ^= true; return Task.FromResult(i); } } static void Main(string[] args) { C1[] c = new C1[] { new C1() }; Test(c, c).Wait(); System.Console.WriteLine(); S1[] s = new S1[] { new S1() }; Test(s, s).Wait(); } static async Task<int> Val() { await Task.Yield(); return 0; } static async Task<int> Test<T>(T[] x, T[] y) where T : IDisposable1 { x[0]?.Dispose(await x[0]?.Dispose(await x[0]?.Dispose(await x[0]?.Dispose(await Val())))); y[0]?.Dispose(await y[0]?.Dispose(await y[0]?.Dispose(await y[0]?.Dispose(await Val())))); return 1; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True False True False True False True False True False True False True False True"); } [Fact] public void ConditionalExtensionAccessGeneric001() { var source = @" using System; using System.Collections.Generic; class Test { static void Main() { long? x = 1; Test0(x); return; } static void Test0<T>(T x) { x?.CheckT(); } } static class Ext { public static void CheckT<T>(this T x) { System.Console.WriteLine(typeof(T)); return; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]"); comp.VerifyIL("Test.Test0<T>(T)", @" { // Code size 21 (0x15) .maxstack 1 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: brfalse.s IL_0014 IL_0008: ldarga.s V_0 IL_000a: ldobj ""T"" IL_000f: call ""void Ext.CheckT<T>(T)"" IL_0014: ret } "); } [Fact] public void ConditionalExtensionAccessGeneric002() { var source = @" using System; using System.Collections.Generic; class Test { static void Main() { long? x = 1; Test0(ref x); return; } static void Test0<T>(ref T x) { x?.CheckT(); } } static class Ext { public static void CheckT<T>(this T x) { System.Console.WriteLine(typeof(T)); return; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]"); comp.VerifyIL("Test.Test0<T>(ref T)", @" { // Code size 46 (0x2e) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0023 IL_0011: ldobj ""T"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: ldloc.0 IL_001a: box ""T"" IL_001f: brtrue.s IL_0023 IL_0021: pop IL_0022: ret IL_0023: ldobj ""T"" IL_0028: call ""void Ext.CheckT<T>(T)"" IL_002d: ret } "); } [Fact] public void ConditionalExtensionAccessGeneric003() { var source = @" using System; using System.Linq; using System.Collections.Generic; class Test { static void Main() { Test0(""qqq""); } static void Test0<T>(T x) where T:IEnumerable<char> { x?.Count(); } static void Test1<T>(ref T x) where T:IEnumerable<char> { x?.Count(); } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @""); comp.VerifyIL("Test.Test0<T>(T)", @" { // Code size 27 (0x1b) .maxstack 1 IL_0000: ldarg.0 IL_0001: box ""T"" IL_0006: brfalse.s IL_001a IL_0008: ldarga.s V_0 IL_000a: ldobj ""T"" IL_000f: box ""T"" IL_0014: call ""int System.Linq.Enumerable.Count<char>(System.Collections.Generic.IEnumerable<char>)"" IL_0019: pop IL_001a: ret } ").VerifyIL("Test.Test1<T>(ref T)", @" { // Code size 52 (0x34) .maxstack 2 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0023 IL_0011: ldobj ""T"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: ldloc.0 IL_001a: box ""T"" IL_001f: brtrue.s IL_0023 IL_0021: pop IL_0022: ret IL_0023: ldobj ""T"" IL_0028: box ""T"" IL_002d: call ""int System.Linq.Enumerable.Count<char>(System.Collections.Generic.IEnumerable<char>)"" IL_0032: pop IL_0033: ret } "); } [Fact] public void ConditionalExtensionAccessGenericAsync001() { var source = @" using System.Threading.Tasks; class Test { static void Main() { } async Task<int?> TestAsync<T>(T[] x) where T : I1 { return x[0]?.CallAsync(await PassAsync()); } static async Task<int> PassAsync() { await Task.Yield(); return 1; } } interface I1 { int CallAsync(int x); } "; var comp = CreateCompilationWithMscorlib45(source, references: new[] { CSharpRef }); base.CompileAndVerify(comp); } [Fact] public void ConditionalExtensionAccessGenericAsyncNullable001() { var source = @" using System; using System.Threading.Tasks; class Test { static void Main() { var arr = new S1?[] { new S1(), new S1()}; TestAsync(arr).Wait(); System.Console.WriteLine(arr[1].Value.called); } static async Task<int?> TestAsync<T>(T?[] x) where T : struct, I1 { return x[await PassAsync()]?.CallAsync(await PassAsync()); } static async Task<int> PassAsync() { await Task.Yield(); return 1; } } struct S1 : I1 { public int called; public int CallAsync(int x) { called++; System.Console.Write(called + 41); return called; } } interface I1 { int CallAsync(int x); } "; var comp = CreateCompilationWithMscorlib45(source, references: new[] { CSharpRef }, options: TestOptions.ReleaseExe); base.CompileAndVerify(comp, expectedOutput: "420"); } [Fact] public void ConditionalMemberAccessCoalesce001() { var source = @" class Program { class C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); } static int Test1(C1 c) { return c?.x ?? 42; } static int Test2(C1 c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldc.i4.s 42 IL_0005: ret IL_0006: ldarg.0 IL_0007: call ""int Program.C1.x.get"" IL_000c: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 41 (0x29) .maxstack 1 .locals init (int? V_0, int? V_1) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_1 IL_0005: initobj ""int?"" IL_000b: ldloc.1 IL_000c: br.s IL_0014 IL_000e: ldarg.0 IL_000f: call ""int? Program.C1.y.get"" IL_0014: stloc.0 IL_0015: ldloca.s V_0 IL_0017: call ""bool int?.HasValue.get"" IL_001c: brtrue.s IL_0021 IL_001e: ldc.i4.s 42 IL_0020: ret IL_0021: ldloca.s V_0 IL_0023: call ""int int?.GetValueOrDefault()"" IL_0028: ret } "); } [Fact] public void ConditionalMemberAccessCoalesce001n() { var source = @" class Program { class C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); } static int? Test1(C1 c) { return c?.x ?? (int?)42; } static int? Test2(C1 c) { return c?.y ?? (int?)42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 23 (0x17) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_000b IL_0003: ldc.i4.s 42 IL_0005: newobj ""int?..ctor(int)"" IL_000a: ret IL_000b: ldarg.0 IL_000c: call ""int Program.C1.x.get"" IL_0011: newobj ""int?..ctor(int)"" IL_0016: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 40 (0x28) .maxstack 1 .locals init (int? V_0, int? V_1) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_1 IL_0005: initobj ""int?"" IL_000b: ldloc.1 IL_000c: br.s IL_0014 IL_000e: ldarg.0 IL_000f: call ""int? Program.C1.y.get"" IL_0014: stloc.0 IL_0015: ldloca.s V_0 IL_0017: call ""bool int?.HasValue.get"" IL_001c: brtrue.s IL_0026 IL_001e: ldc.i4.s 42 IL_0020: newobj ""int?..ctor(int)"" IL_0025: ret IL_0026: ldloc.0 IL_0027: ret }"); } [Fact] public void ConditionalMemberAccessCoalesce001r() { var source = @" class Program { class C1 { public int x {get; set;} public int? y {get; set;} } static void Main() { var c = new C1(); C1 n = null; System.Console.WriteLine(Test1(ref c)); System.Console.WriteLine(Test1(ref n)); System.Console.WriteLine(Test2(ref c)); System.Console.WriteLine(Test2(ref n)); } static int Test1(ref C1 c) { return c?.x ?? 42; } static int Test2(ref C1 c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(ref Program.C1)", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0009 IL_0005: pop IL_0006: ldc.i4.s 42 IL_0008: ret IL_0009: call ""int Program.C1.x.get"" IL_000e: ret } ").VerifyIL("Program.Test2(ref Program.C1)", @" { // Code size 43 (0x2b) .maxstack 2 .locals init (int? V_0, int? V_1) IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0011 IL_0005: pop IL_0006: ldloca.s V_1 IL_0008: initobj ""int?"" IL_000e: ldloc.1 IL_000f: br.s IL_0016 IL_0011: call ""int? Program.C1.y.get"" IL_0016: stloc.0 IL_0017: ldloca.s V_0 IL_0019: call ""bool int?.HasValue.get"" IL_001e: brtrue.s IL_0023 IL_0020: ldc.i4.s 42 IL_0022: ret IL_0023: ldloca.s V_0 IL_0025: call ""int int?.GetValueOrDefault()"" IL_002a: ret } "); } [Fact] public void ConditionalMemberAccessCoalesce002() { var source = @" class Program { struct C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); } static int Test1(C1? c) { return c?.x ?? 42; } static int Test2(C1? c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(Program.C1?)", @" { // Code size 28 (0x1c) .maxstack 1 .locals init (Program.C1 V_0) IL_0000: ldarga.s V_0 IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_000c IL_0009: ldc.i4.s 42 IL_000b: ret IL_000c: ldarga.s V_0 IL_000e: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_0013: stloc.0 IL_0014: ldloca.s V_0 IL_0016: call ""readonly int Program.C1.x.get"" IL_001b: ret } ").VerifyIL("Program.Test2(Program.C1?)", @" { // Code size 56 (0x38) .maxstack 1 .locals init (int? V_0, int? V_1, Program.C1 V_2) IL_0000: ldarga.s V_0 IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_0014 IL_0009: ldloca.s V_1 IL_000b: initobj ""int?"" IL_0011: ldloc.1 IL_0012: br.s IL_0023 IL_0014: ldarga.s V_0 IL_0016: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_001b: stloc.2 IL_001c: ldloca.s V_2 IL_001e: call ""readonly int? Program.C1.y.get"" IL_0023: stloc.0 IL_0024: ldloca.s V_0 IL_0026: call ""bool int?.HasValue.get"" IL_002b: brtrue.s IL_0030 IL_002d: ldc.i4.s 42 IL_002f: ret IL_0030: ldloca.s V_0 IL_0032: call ""int int?.GetValueOrDefault()"" IL_0037: ret } "); } [Fact] public void ConditionalMemberAccessCoalesce002r() { var source = @" class Program { struct C1 { public int x{get; set;} public int? y{get; set;} } static void Main() { C1? c = new C1(); C1? n = null; System.Console.WriteLine(Test1(ref c)); System.Console.WriteLine(Test1(ref n)); System.Console.WriteLine(Test2(ref c)); System.Console.WriteLine(Test2(ref n)); } static int Test1(ref C1? c) { return c?.x ?? 42; } static int Test2(ref C1? c) { return c?.y ?? 42; } } "; var comp = CompileAndVerify(source, expectedOutput: @"0 42 42 42"); comp.VerifyIL("Program.Test1(ref Program.C1?)", @" { // Code size 27 (0x1b) .maxstack 2 .locals init (Program.C1 V_0) IL_0000: ldarg.0 IL_0001: dup IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_000d IL_0009: pop IL_000a: ldc.i4.s 42 IL_000c: ret IL_000d: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_0012: stloc.0 IL_0013: ldloca.s V_0 IL_0015: call ""readonly int Program.C1.x.get"" IL_001a: ret } ").VerifyIL("Program.Test2(ref Program.C1?)", @" { // Code size 55 (0x37) .maxstack 2 .locals init (int? V_0, int? V_1, Program.C1 V_2) IL_0000: ldarg.0 IL_0001: dup IL_0002: call ""bool Program.C1?.HasValue.get"" IL_0007: brtrue.s IL_0015 IL_0009: pop IL_000a: ldloca.s V_1 IL_000c: initobj ""int?"" IL_0012: ldloc.1 IL_0013: br.s IL_0022 IL_0015: call ""Program.C1 Program.C1?.GetValueOrDefault()"" IL_001a: stloc.2 IL_001b: ldloca.s V_2 IL_001d: call ""readonly int? Program.C1.y.get"" IL_0022: stloc.0 IL_0023: ldloca.s V_0 IL_0025: call ""bool int?.HasValue.get"" IL_002a: brtrue.s IL_002f IL_002c: ldc.i4.s 42 IL_002e: ret IL_002f: ldloca.s V_0 IL_0031: call ""int int?.GetValueOrDefault()"" IL_0036: ret } "); } [Fact] public void ConditionalMemberAccessCoalesceDefault() { var source = @" class Program { class C1 { public int x { get; set; } } static void Main() { var c = new C1() { x = 42 }; System.Console.WriteLine(Test(c)); System.Console.WriteLine(Test(null)); } static int Test(C1 c) { return c?.x ?? 0; } } "; var comp = CompileAndVerify(source, expectedOutput: @" 42 0"); comp.VerifyIL("Program.Test(Program.C1)", @" { // Code size 12 (0xc) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: ret } "); } [Fact] public void ConditionalMemberAccessNullCheck001() { var source = @" class Program { class C1 { public int x{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); System.Console.WriteLine(Test3(c)); System.Console.WriteLine(Test3(null)); } static bool Test1(C1 c) { return c?.x == null; } static bool Test2(C1 c) { return c?.x != null; } static bool Test3(C1 c) { return c?.x > null; } } "; var comp = CompileAndVerify(source, expectedOutput: @"False True True False False False"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: pop IL_000c: ldc.i4.0 IL_000d: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: pop IL_000c: ldc.i4.1 IL_000d: ret } ").VerifyIL("Program.Test3(Program.C1)", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int Program.C1.x.get"" IL_000b: pop IL_000c: ldc.i4.0 IL_000d: ret } "); } [Fact] public void ConditionalMemberAccessBinary001() { var source = @" public enum N { zero = 0, one = 1, mone = -1 } class Program { class C1 { public N x{get; set;} } static void Main() { var c = new C1(); System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(null)); System.Console.WriteLine(Test2(c)); System.Console.WriteLine(Test2(null)); System.Console.WriteLine(Test3(c)); System.Console.WriteLine(Test3(null)); } static bool Test1(C1 c) { return c?.x == N.zero; } static bool Test2(C1 c) { return c?.x != N.one; } static bool Test3(C1 c) { return c?.x > N.mone; } } "; var comp = CompileAndVerify(source, expectedOutput: @"True False True True True False"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""N Program.C1.x.get"" IL_000b: ldc.i4.0 IL_000c: ceq IL_000e: ret } ").VerifyIL("Program.Test2(Program.C1)", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""N Program.C1.x.get"" IL_000b: ldc.i4.1 IL_000c: ceq IL_000e: ldc.i4.0 IL_000f: ceq IL_0011: ret } ").VerifyIL("Program.Test3(Program.C1)", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""N Program.C1.x.get"" IL_000b: ldc.i4.m1 IL_000c: cgt IL_000e: ret } "); } [Fact] public void ConditionalMemberAccessBinary002() { var source = @" static class ext { public static Program.C1.S1 y(this Program.C1 self) { return self.x; } } class Program { public class C1 { public struct S1 { public static bool operator <(S1 s1, int s2) { System.Console.WriteLine('<'); return true; } public static bool operator >(S1 s1, int s2) { System.Console.WriteLine('>'); return false; } } public S1 x { get; set; } } static void Main() { C1 c = new C1(); C1 n = null; System.Console.WriteLine(Test1(c)); System.Console.WriteLine(Test1(n)); System.Console.WriteLine(Test2(ref c)); System.Console.WriteLine(Test2(ref n)); System.Console.WriteLine(Test3(c)); System.Console.WriteLine(Test3(n)); System.Console.WriteLine(Test4(ref c)); System.Console.WriteLine(Test4(ref n)); } static bool Test1(C1 c) { return c?.x > -1; } static bool Test2(ref C1 c) { return c?.x < -1; } static bool Test3(C1 c) { return c?.y() > -1; } static bool Test4(ref C1 c) { return c?.y() < -1; } } "; var comp = CompileAndVerify(source, references: new[] { CSharpRef }, expectedOutput: @" > False False < True False > False False < True False"); comp.VerifyIL("Program.Test1(Program.C1)", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""Program.C1.S1 Program.C1.x.get"" IL_000b: ldc.i4.m1 IL_000c: call ""bool Program.C1.S1.op_GreaterThan(Program.C1.S1, int)"" IL_0011: ret } ").VerifyIL("Program.Test2(ref Program.C1)", @" { // Code size 20 (0x14) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0008 IL_0005: pop IL_0006: ldc.i4.0 IL_0007: ret IL_0008: call ""Program.C1.S1 Program.C1.x.get"" IL_000d: ldc.i4.m1 IL_000e: call ""bool Program.C1.S1.op_LessThan(Program.C1.S1, int)"" IL_0013: ret } ").VerifyIL("Program.Test3(Program.C1)", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""Program.C1.S1 ext.y(Program.C1)"" IL_000b: ldc.i4.m1 IL_000c: call ""bool Program.C1.S1.op_GreaterThan(Program.C1.S1, int)"" IL_0011: ret } ").VerifyIL("Program.Test4(ref Program.C1)", @" { // Code size 20 (0x14) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldind.ref IL_0002: dup IL_0003: brtrue.s IL_0008 IL_0005: pop IL_0006: ldc.i4.0 IL_0007: ret IL_0008: call ""Program.C1.S1 ext.y(Program.C1)"" IL_000d: ldc.i4.m1 IL_000e: call ""bool Program.C1.S1.op_LessThan(Program.C1.S1, int)"" IL_0013: ret } "); } [Fact] public void ConditionalMemberAccessOptimizedLocal001() { var source = @" using System; class Program { class C1 : System.IDisposable { public bool disposed; public void Dispose() { disposed = true; } } static void Main() { Test1(); Test2<C1>(); } static void Test1() { var c = new C1(); c?.Dispose(); } static void Test2<T>() where T : IDisposable, new() { var c = new T(); c?.Dispose(); } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1()", @" { // Code size 16 (0x10) .maxstack 2 IL_0000: newobj ""Program.C1..ctor()"" IL_0005: dup IL_0006: brtrue.s IL_000a IL_0008: pop IL_0009: ret IL_000a: call ""void Program.C1.Dispose()"" IL_000f: ret } ").VerifyIL("Program.Test2<T>()", @" { // Code size 28 (0x1c) .maxstack 1 .locals init (T V_0) //c IL_0000: call ""T System.Activator.CreateInstance<T>()"" IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: box ""T"" IL_000c: brfalse.s IL_001b IL_000e: ldloca.s V_0 IL_0010: constrained. ""T"" IL_0016: callvirt ""void System.IDisposable.Dispose()"" IL_001b: ret } "); } [Fact] public void ConditionalMemberAccessOptimizedLocal002() { var source = @" using System; class Program { interface I1 { void Goo(I1 arg); } class C1 : I1 { public void Goo(I1 arg) { } } static void Main() { Test1(); Test2<C1>(); } static void Test1() { var c = new C1(); c?.Goo(c); } static void Test2<T>() where T : I1, new() { var c = new T(); c?.Goo(c); } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1()", @" { // Code size 17 (0x11) .maxstack 2 .locals init (Program.C1 V_0) //c IL_0000: newobj ""Program.C1..ctor()"" IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: brfalse.s IL_0010 IL_0009: ldloc.0 IL_000a: ldloc.0 IL_000b: call ""void Program.C1.Goo(Program.I1)"" IL_0010: ret } ").VerifyIL("Program.Test2<T>()", @" { // Code size 34 (0x22) .maxstack 2 .locals init (T V_0) //c IL_0000: call ""T System.Activator.CreateInstance<T>()"" IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: box ""T"" IL_000c: brfalse.s IL_0021 IL_000e: ldloca.s V_0 IL_0010: ldloc.0 IL_0011: box ""T"" IL_0016: constrained. ""T"" IL_001c: callvirt ""void Program.I1.Goo(Program.I1)"" IL_0021: ret } "); } [Fact] public void ConditionalMemberAccessRace001() { var source = @" using System.Threading; using System.Threading.Tasks; class Program { static void Main() { string s = ""hello""; System.Action a = () => { for (int i = 0; i < 1000000; i++) { try { s = s?.Length.ToString(); s = null; Thread.Yield(); } catch (System.Exception ex) { System.Console.WriteLine(ex); } finally { s = s ?? ""hello""; } } }; Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); Task.Factory.StartNew(a); a(); System.Console.WriteLine(""Success""); } } "; var comp = CompileAndVerify(source, expectedOutput: @"Success"); } [Fact(), WorkItem(836, "GitHub")] public void ConditionalMemberAccessRace002() { var source = @" using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; class Program { static void Main() { string s = ""hello""; Test(s); } private static void Test<T>(T s) where T : IEnumerable<char> { Action a = () => { for (int i = 0; i < 1000000; i++) { var temp = s; try { s?.GetEnumerator(); s = default(T); Thread.Yield(); } catch (System.Exception ex) { System.Console.WriteLine(ex); } finally { s = temp; } } }; var tasks = new List<Task>(); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); tasks.Add(Task.Factory.StartNew(a)); a(); // wait for all tasks to exit or we may have // test issues when unloading ApDomain while threads still running in it Task.WaitAll(tasks.ToArray()); System.Console.WriteLine(""Success""); } } "; var comp = CompileAndVerify(source, expectedOutput: @"Success"); } [Fact] public void ConditionalMemberAccessConditional001() { var source = @" using System; class Program { static void Main() { Test1<string>(null); Test2<string>(null); } static string Test1<T>(T[] arr) { if (arr != null && arr.Length > 0) { return arr[0].ToString(); } return ""none""; } static string Test2<T>(T[] arr) { if (arr?.Length > 0) { return arr[0].ToString(); } return ""none""; } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_001c IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brfalse.s IL_001c IL_0007: ldarg.0 IL_0008: ldc.i4.0 IL_0009: readonly. IL_000b: ldelema ""T"" IL_0010: constrained. ""T"" IL_0016: callvirt ""string object.ToString()"" IL_001b: ret IL_001c: ldstr ""none"" IL_0021: ret } ").VerifyIL("Program.Test2<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_001c IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brfalse.s IL_001c IL_0007: ldarg.0 IL_0008: ldc.i4.0 IL_0009: readonly. IL_000b: ldelema ""T"" IL_0010: constrained. ""T"" IL_0016: callvirt ""string object.ToString()"" IL_001b: ret IL_001c: ldstr ""none"" IL_0021: ret } "); } [Fact] public void ConditionalMemberAccessConditional002() { var source = @" using System; class Program { static void Main() { Test1<string>(null); Test2<string>(null); } static string Test1<T>(T[] arr) { if (!(arr != null && arr.Length > 0)) { return ""none""; } return arr[0].ToString(); } static string Test2<T>(T[] arr) { if (!(arr?.Length > 0)) { return ""none""; } return arr[0].ToString(); } } "; var comp = CompileAndVerify(source, expectedOutput: @""); comp.VerifyIL("Program.Test1<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0007 IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brtrue.s IL_000d IL_0007: ldstr ""none"" IL_000c: ret IL_000d: ldarg.0 IL_000e: ldc.i4.0 IL_000f: readonly. IL_0011: ldelema ""T"" IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: ret } ").VerifyIL("Program.Test2<T>(T[])", @" { // Code size 34 (0x22) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0007 IL_0003: ldarg.0 IL_0004: ldlen IL_0005: brtrue.s IL_000d IL_0007: ldstr ""none"" IL_000c: ret IL_000d: ldarg.0 IL_000e: ldc.i4.0 IL_000f: readonly. IL_0011: ldelema ""T"" IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: ret } "); } [Fact] public void ConditionalMemberAccessConditional003() { var source = @" using System; class Program { static void Main() { System.Console.WriteLine(Test1<string>(null)); System.Console.WriteLine(Test2<string>(null)); System.Console.WriteLine(Test1<string>(new string[] {})); System.Console.WriteLine(Test2<string>(new string[] {})); System.Console.WriteLine(Test1<string>(new string[] { System.String.Empty })); System.Console.WriteLine(Test2<string>(new string[] { System.String.Empty })); } static string Test1<T>(T[] arr1) { var arr = arr1; if (arr != null && arr.Length == 0) { return ""empty""; } return ""not empty""; } static string Test2<T>(T[] arr1) { var arr = arr1; if (!(arr?.Length != 0)) { return ""empty""; } return ""not empty""; } } "; var comp = CompileAndVerify(source, expectedOutput: @"not empty not empty empty empty not empty not empty"); comp.VerifyIL("Program.Test1<T>(T[])", @" { // Code size 21 (0x15) .maxstack 1 .locals init (T[] V_0) //arr IL_0000: ldarg.0 IL_0001: stloc.0 IL_0002: ldloc.0 IL_0003: brfalse.s IL_000f IL_0005: ldloc.0 IL_0006: ldlen IL_0007: brtrue.s IL_000f IL_0009: ldstr ""empty"" IL_000e: ret IL_000f: ldstr ""not empty"" IL_0014: ret } ").VerifyIL("Program.Test2<T>(T[])", @" { // Code size 26 (0x1a) .maxstack 2 IL_0000: ldarg.0 IL_0001: dup IL_0002: brtrue.s IL_0008 IL_0004: pop IL_0005: ldc.i4.1 IL_0006: br.s IL_000c IL_0008: ldlen IL_0009: ldc.i4.0 IL_000a: cgt.un IL_000c: brtrue.s IL_0014 IL_000e: ldstr ""empty"" IL_0013: ret IL_0014: ldstr ""not empty"" IL_0019: ret } "); } [Fact] public void ConditionalMemberAccessConditional004() { var source = @" using System; class Program { static void Main() { var w = new WeakReference<string>(null); Test0(ref w); Test1(ref w); Test2(ref w); Test3(ref w); } static string Test0(ref WeakReference<string> slot) { string value = null; WeakReference<string> weak = slot; if (weak != null && weak.TryGetTarget(out value)) { return value; } return ""hello""; } static string Test1(ref WeakReference<string> slot) { string value = null; WeakReference<string> weak = slot; if (weak?.TryGetTarget(out value) == true) { return value; } return ""hello""; } static string Test2(ref WeakReference<string> slot) { string value = null; if (slot?.TryGetTarget(out value) == true) { return value; } return ""hello""; } static string Test3(ref WeakReference<string> slot) { string value = null; if (slot?.TryGetTarget(out value) ?? false) { return value; } return ""hello""; } } "; var comp = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: ""). VerifyIL("Program.Test0(ref System.WeakReference<string>)", @" { // Code size 26 (0x1a) .maxstack 2 .locals init (string V_0, //value System.WeakReference<string> V_1) //weak IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: stloc.1 IL_0005: ldloc.1 IL_0006: brfalse.s IL_0014 IL_0008: ldloc.1 IL_0009: ldloca.s V_0 IL_000b: callvirt ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0010: brfalse.s IL_0014 IL_0012: ldloc.0 IL_0013: ret IL_0014: ldstr ""hello"" IL_0019: ret } ").VerifyIL("Program.Test1(ref System.WeakReference<string>)", @" { // Code size 28 (0x1c) .maxstack 2 .locals init (string V_0) //value IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: dup IL_0005: brtrue.s IL_000b IL_0007: pop IL_0008: ldc.i4.0 IL_0009: br.s IL_0012 IL_000b: ldloca.s V_0 IL_000d: call ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0012: brfalse.s IL_0016 IL_0014: ldloc.0 IL_0015: ret IL_0016: ldstr ""hello"" IL_001b: ret } ").VerifyIL("Program.Test2(ref System.WeakReference<string>)", @" { // Code size 28 (0x1c) .maxstack 2 .locals init (string V_0) //value IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: dup IL_0005: brtrue.s IL_000b IL_0007: pop IL_0008: ldc.i4.0 IL_0009: br.s IL_0012 IL_000b: ldloca.s V_0 IL_000d: call ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0012: brfalse.s IL_0016 IL_0014: ldloc.0 IL_0015: ret IL_0016: ldstr ""hello"" IL_001b: ret } ").VerifyIL("Program.Test3(ref System.WeakReference<string>)", @" { // Code size 28 (0x1c) .maxstack 2 .locals init (string V_0) //value IL_0000: ldnull IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldind.ref IL_0004: dup IL_0005: brtrue.s IL_000b IL_0007: pop IL_0008: ldc.i4.0 IL_0009: br.s IL_0012 IL_000b: ldloca.s V_0 IL_000d: call ""bool System.WeakReference<string>.TryGetTarget(out string)"" IL_0012: brfalse.s IL_0016 IL_0014: ldloc.0 IL_0015: ret IL_0016: ldstr ""hello"" IL_001b: ret } "); } [WorkItem(1042288, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1042288")] [Fact] public void Bug1042288() { var source = @" using System; class Test { static void Main() { var c1 = new C1(); System.Console.WriteLine(c1?.M1() ?? (long)1000); return; } } class C1 { public int M1() { return 1; } } "; var comp = CompileAndVerify(source, expectedOutput: @"1"); comp.VerifyIL("Test.Main", @" { // Code size 62 (0x3e) .maxstack 2 .locals init (int? V_0, int? V_1) IL_0000: newobj ""C1..ctor()"" IL_0005: dup IL_0006: brtrue.s IL_0014 IL_0008: pop IL_0009: ldloca.s V_1 IL_000b: initobj ""int?"" IL_0011: ldloc.1 IL_0012: br.s IL_001e IL_0014: call ""int C1.M1()"" IL_0019: newobj ""int?..ctor(int)"" IL_001e: stloc.0 IL_001f: ldloca.s V_0 IL_0021: call ""bool int?.HasValue.get"" IL_0026: brtrue.s IL_0030 IL_0028: ldc.i4 0x3e8 IL_002d: conv.i8 IL_002e: br.s IL_0038 IL_0030: ldloca.s V_0 IL_0032: call ""int int?.GetValueOrDefault()"" IL_0037: conv.i8 IL_0038: call ""void System.Console.WriteLine(long)"" IL_003d: ret } "); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_01() { var source = @" class C { public static void Main() { System.Console.WriteLine(MyMethod(null)); System.Console.WriteLine(MyMethod(new MyType())); } public static decimal MyMethod(MyType myObject) { return myObject?.MyField ?? 0m; } } public class MyType { public decimal MyField = 123; } "; var verifier = CompileAndVerify(source, expectedOutput: @"0 123"); verifier.VerifyIL("C.MyMethod", @" { // Code size 16 (0x10) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0009 IL_0003: ldsfld ""decimal decimal.Zero"" IL_0008: ret IL_0009: ldarg.0 IL_000a: ldfld ""decimal MyType.MyField"" IL_000f: ret }"); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_02() { var source = @" class C { public static void Main() { System.Console.WriteLine(MyMethod(null)); System.Console.WriteLine(MyMethod(new MyType())); } public static decimal MyMethod(MyType myObject) { return myObject?.MyField ?? default(decimal); } } public class MyType { public decimal MyField = 123; } "; var verifier = CompileAndVerify(source, expectedOutput: @"0 123"); verifier.VerifyIL("C.MyMethod", @" { // Code size 16 (0x10) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0009 IL_0003: ldsfld ""decimal decimal.Zero"" IL_0008: ret IL_0009: ldarg.0 IL_000a: ldfld ""decimal MyType.MyField"" IL_000f: ret }"); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_03() { var source = @" using System; class C { public static void Main() { System.Console.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, ""{0}"", MyMethod(null))); System.Console.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, ""{0}"", MyMethod(new MyType()))); } public static DateTime MyMethod(MyType myObject) { return myObject?.MyField ?? default(DateTime); } } public class MyType { public DateTime MyField = new DateTime(100000000); } "; var verifier = CompileAndVerify(source, expectedOutput: @"01/01/0001 00:00:00 01/01/0001 00:00:10"); verifier.VerifyIL("C.MyMethod", @" { // Code size 20 (0x14) .maxstack 1 .locals init (System.DateTime V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000d IL_0003: ldloca.s V_0 IL_0005: initobj ""System.DateTime"" IL_000b: ldloc.0 IL_000c: ret IL_000d: ldarg.0 IL_000e: ldfld ""System.DateTime MyType.MyField"" IL_0013: ret }"); } [WorkItem(470, "CodPlex")] [Fact] public void CodPlexBug470_04() { var source = @" class C { public static void Main() { System.Console.WriteLine(MyMethod(null).F); System.Console.WriteLine(MyMethod(new MyType()).F); } public static MyStruct MyMethod(MyType myObject) { return myObject?.MyField ?? default(MyStruct); } } public class MyType { public MyStruct MyField = new MyStruct() {F = 123}; } public struct MyStruct { public int F; } "; var verifier = CompileAndVerify(source, expectedOutput: @"0 123"); verifier.VerifyIL("C.MyMethod", @" { // Code size 20 (0x14) .maxstack 1 .locals init (MyStruct V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000d IL_0003: ldloca.s V_0 IL_0005: initobj ""MyStruct"" IL_000b: ldloc.0 IL_000c: ret IL_000d: ldarg.0 IL_000e: ldfld ""MyStruct MyType.MyField"" IL_0013: ret }"); } [WorkItem(1103294, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1103294")] [Fact] public void Bug1103294_01() { var source = @" class C { static void Main() { System.Console.WriteLine(""---""); Goo<int>(new C<int>()); System.Console.WriteLine(""---""); Goo<int>(null); System.Console.WriteLine(""---""); } static void Goo<T>(C<T> x) { x?.M(); } } class C<T> { public T M() { System.Console.WriteLine(""M""); return default(T); } }"; var verifier = CompileAndVerify(source, expectedOutput: @"--- M --- ---"); verifier.VerifyIL("C.Goo<T>", @" { // Code size 11 (0xb) .maxstack 1 IL_0000: ldarg.0 IL_0001: brfalse.s IL_000a IL_0003: ldarg.0 IL_0004: call ""T C<T>.M()"" IL_0009: pop IL_000a: ret }"); } [WorkItem(1103294, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1103294")] [Fact] public void Bug1103294_02() { var source = @" unsafe class C { static void Main() { System.Console.WriteLine(""---""); Goo(new C()); System.Console.WriteLine(""---""); Goo(null); System.Console.WriteLine(""---""); } static void Goo(C x) { x?.M(); } public int* M() { System.Console.WriteLine(""M""); return null; } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), verify: Verification.Fails, expectedOutput: @"--- M --- ---"); verifier.VerifyIL("C.Goo", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: nop IL_0001: ldarg.0 IL_0002: brtrue.s IL_0006 IL_0004: br.s IL_000d IL_0006: ldarg.0 IL_0007: call ""int* C.M()"" IL_000c: pop IL_000d: ret }"); } [WorkItem(23422, "https://github.com/dotnet/roslyn/issues/23422")] [Fact] public void ConditionalRefLike() { var source = @" class C { static void Main() { System.Console.WriteLine(""---""); Goo(new C()); System.Console.WriteLine(""---""); Goo(null); System.Console.WriteLine(""---""); } static void Goo(C x) { x?.M(); } public RefLike M() { System.Console.WriteLine(""M""); return default; } public ref struct RefLike{} } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), expectedOutput: @"--- M --- ---"); verifier.VerifyIL("C.Goo", @" { // Code size 14 (0xe) .maxstack 1 IL_0000: nop IL_0001: ldarg.0 IL_0002: brtrue.s IL_0006 IL_0004: br.s IL_000d IL_0006: ldarg.0 IL_0007: call ""C.RefLike C.M()"" IL_000c: pop IL_000d: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_01() { var source = @" using System; class Test { static void Main() { System.Console.WriteLine(""---""); C.F1(null); System.Console.WriteLine(""---""); C.F1(new C()); System.Console.WriteLine(""---""); C.F2(null); System.Console.WriteLine(""---""); C.F2(new C()); System.Console.WriteLine(""---""); } } class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Action a = () => c?.M(); a(); } static public void F2(C c) => c?.M(); void M() => System.Console.WriteLine(""M""); } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- F1 --- F1 M --- --- M ---"); verifier.VerifyIL("C.<>c__DisplayClass0_0.<F1>b__0", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldfld ""C C.<>c__DisplayClass0_0.c"" IL_0006: dup IL_0007: brtrue.s IL_000c IL_0009: pop IL_000a: br.s IL_0012 IL_000c: call ""void C.M()"" IL_0011: nop IL_0012: ret }"); verifier.VerifyIL("C.F2", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: br.s IL_000c IL_0005: ldarg.0 IL_0006: call ""void C.M()"" IL_000b: nop IL_000c: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_02() { var source = @" using System; class Test { static void Main() { } } class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Func<object> a = () => c?.M(); } static public object F2(C c) => c?.M(); static public object P1 => (new C())?.M(); void M() => System.Console.WriteLine(""M""); } "; var compilation = CreateCompilation(source); compilation.VerifyDiagnostics( // (16,32): error CS0029: Cannot implicitly convert type 'void' to 'object' // Func<object> a = () => c?.M(); Diagnostic(ErrorCode.ERR_NoImplicitConv, "c?.M()").WithArguments("void", "object").WithLocation(16, 32), // (16,32): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type // Func<object> a = () => c?.M(); Diagnostic(ErrorCode.ERR_CantConvAnonMethReturns, "c?.M()").WithArguments("lambda expression").WithLocation(16, 32), // (19,37): error CS0029: Cannot implicitly convert type 'void' to 'object' // static public object F2(C c) => c?.M(); Diagnostic(ErrorCode.ERR_NoImplicitConv, "c?.M()").WithArguments("void", "object").WithLocation(19, 37), // (21,32): error CS0029: Cannot implicitly convert type 'void' to 'object' // static public object P1 => (new C())?.M(); Diagnostic(ErrorCode.ERR_NoImplicitConv, "(new C())?.M()").WithArguments("void", "object").WithLocation(21, 32) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_03() { var source = @" using System; class Test { static void Main() { System.Console.WriteLine(""---""); C<int>.F1(null); System.Console.WriteLine(""---""); C<int>.F1(new C<int>()); System.Console.WriteLine(""---""); C<int>.F2(null); System.Console.WriteLine(""---""); C<int>.F2(new C<int>()); System.Console.WriteLine(""---""); } } class C<T> { static public void F1(C<T> c) { System.Console.WriteLine(""F1""); Action a = () => c?.M(); a(); } static public void F2(C<T> c) => c?.M(); T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- F1 --- F1 M --- --- M ---"); verifier.VerifyIL("C<T>.<>c__DisplayClass0_0.<F1>b__0()", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldfld ""C<T> C<T>.<>c__DisplayClass0_0.c"" IL_0006: dup IL_0007: brtrue.s IL_000c IL_0009: pop IL_000a: br.s IL_0012 IL_000c: call ""T C<T>.M()"" IL_0011: pop IL_0012: ret }"); verifier.VerifyIL("C<T>.F2", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: br.s IL_000c IL_0005: ldarg.0 IL_0006: call ""T C<T>.M()"" IL_000b: pop IL_000c: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_04() { var source = @" using System; class Test { static void Main() { } } class C<T> { static public void F1(C<T> c) { Func<object> a = () => c?.M(); } static public object F2(C<T> c) => c?.M(); static public object P1 => (new C<T>())?.M(); T M() { return default(T); } } "; var compilation = CreateCompilation(source); compilation.VerifyDiagnostics( // (15,33): error CS0023: Operator '?' cannot be applied to operand of type 'T' // Func<object> a = () => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(15, 33), // (18,41): error CS0023: Operator '?' cannot be applied to operand of type 'T' // static public object F2(C<T> c) => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(18, 41), // (20,44): error CS0023: Operator '?' cannot be applied to operand of type 'T' // static public object P1 => (new C<T>())?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(20, 44) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_05() { var source = @" using System; class Test { static void Main() { System.Console.WriteLine(""---""); C.F1(null); System.Console.WriteLine(""---""); C.F1(new C()); System.Console.WriteLine(""---""); C.F2(null); System.Console.WriteLine(""---""); C.F2(new C()); System.Console.WriteLine(""---""); } } unsafe class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Action<object> a = o => c?.M(); a(null); } static public void F2(C c) => c?.M(); void* M() { System.Console.WriteLine(""M""); return null; } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe.WithAllowUnsafe(true), verify: Verification.Fails, expectedOutput: @"--- F1 --- F1 M --- --- M ---"); verifier.VerifyIL("C.<>c__DisplayClass0_0.<F1>b__0", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: ldfld ""C C.<>c__DisplayClass0_0.c"" IL_0006: dup IL_0007: brtrue.s IL_000c IL_0009: pop IL_000a: br.s IL_0012 IL_000c: call ""void* C.M()"" IL_0011: pop IL_0012: ret }"); verifier.VerifyIL("C.F2", @" { // Code size 13 (0xd) .maxstack 1 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: br.s IL_000c IL_0005: ldarg.0 IL_0006: call ""void* C.M()"" IL_000b: pop IL_000c: ret }"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_06() { var source = @" using System; class Test { static void Main() { } } unsafe class C { static public void F1(C c) { System.Console.WriteLine(""F1""); Func<object, object> a = o => c?.M(); } static public object F2(C c) => c?.M(); static public object P1 => (new C())?.M(); void* M() { System.Console.WriteLine(""M""); return null; } } "; var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithAllowUnsafe(true)); compilation.VerifyDiagnostics( // (16,40): error CS0023: Operator '?' cannot be applied to operand of type 'void*' // Func<object, object> a = o => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "void*").WithLocation(16, 40), // (19,38): error CS0023: Operator '?' cannot be applied to operand of type 'void*' // static public object F2(C c) => c?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "void*").WithLocation(19, 38), // (21,41): error CS0023: Operator '?' cannot be applied to operand of type 'void*' // static public object P1 => (new C())?.M(); Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "void*").WithLocation(21, 41) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_07() { var source = @" using System; class Test { static void Main() { C<int>.Test(); } } class C<T> { public static void Test() { var x = new [] {null, new C<T>()}; for (int i = 0; i < 2; x[i-1]?.M()) { System.Console.WriteLine(""---""); System.Console.WriteLine(""Loop""); i++; } System.Console.WriteLine(""---""); } public T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @" --- Loop --- Loop M ---"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_08() { var source = @" using System; class Test { static void Main() { C<int>.Test(); } } class C<T> { public static void Test() { var x = new [] {null, new C<T>()}; System.Console.WriteLine(""---""); for (x[0]?.M(); false;) { } System.Console.WriteLine(""---""); for (x[1]?.M(); false;) { } System.Console.WriteLine(""---""); } public T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- --- M ---"); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_09() { var source = @" class Test { static void Main() { } } class C<T> { public static void Test() { C<T> x = null; for (; x?.M();) { } } public T M() { return default(T); } } "; var compilation = CreateCompilation(source); compilation.VerifyDiagnostics( // (15,17): error CS0023: Operator '?' cannot be applied to operand of type 'T' // for (; x?.M();) Diagnostic(ErrorCode.ERR_BadUnaryOp, "?").WithArguments("?", "T").WithLocation(15, 17) ); } [WorkItem(1109164, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1109164")] [Fact] public void Bug1109164_10() { var source = @" using System; class Test { static void Main() { C<int>.Test(); } } class C<T> { public static void Test() { System.Console.WriteLine(""---""); M1(a => a?.M(), null); System.Console.WriteLine(""---""); M1((a) => a?.M(), new C<T>()); System.Console.WriteLine(""---""); } static void M1(Action<C<T>> x, C<T> y) { System.Console.WriteLine(""M1(Action<C<T>> x)""); x(y); } static void M1(Func<C<T>, object> x, C<T> y) { System.Console.WriteLine(""M1(Func<C<T>, object> x)""); x(y); } public T M() { System.Console.WriteLine(""M""); return default(T); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"--- M1(Action<C<T>> x) --- M1(Action<C<T>> x) M ---"); } [WorkItem(74, "https://github.com/dotnet/roslyn/issues/74")] [Fact] public void ConditionalInAsyncTask() { var source = @" #pragma warning disable CS1998 // suppress 'no await in async' warning using System; using System.Threading.Tasks; class Goo<T> { public T Method(int i) { Console.Write(i); return default(T); // returns value of unconstrained type parameter type } public void M1(Goo<T> x) => x?.Method(4); public async void M2(Goo<T> x) => x?.Method(5); public async Task M3(Goo<T> x) => x?.Method(6); public async Task M4() { Goo<T> a = new Goo<T>(); Goo<T> b = null; Action f1 = async () => a?.Method(1); f1(); f1 = async () => b?.Method(0); f1(); Func<Task> f2 = async () => a?.Method(2); await f2(); Func<Task> f3 = async () => b?.Method(3); await f3(); M1(a); M1(b); M2(a); M2(b); await M3(a); await M3(b); } } class Program { public static void Main() { // this will complete synchronously as there are no truly async ops. new Goo<int>().M4(); } }"; var compilation = CreateCompilationWithMscorlib45( source, references: new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, options: TestOptions.DebugExe); CompileAndVerify(compilation, expectedOutput: "12456"); } [WorkItem(825, "https://github.com/dotnet/roslyn/issues/825")] [Fact] public void ConditionalBoolExpr01() { var source = @" class C { public static void Main() { System.Console.WriteLine(HasLength(null, 0)); } static bool HasLength(string s, int len) { return s?.Length == len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False"); verifier.VerifyIL("C.HasLength", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldarg.1 IL_000c: ceq IL_000e: ret }"); } [WorkItem(825, "https://github.com/dotnet/roslyn/issues/825")] [Fact] public void ConditionalBoolExpr01a() { var source = @" class C { public static void Main() { System.Console.WriteLine(HasLength(null, 0)); } static bool HasLength(string s, byte len) { return s?.Length == len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False"); verifier.VerifyIL("C.HasLength", @" { // Code size 15 (0xf) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldarg.1 IL_000c: ceq IL_000e: ret }"); } [WorkItem(825, "https://github.com/dotnet/roslyn/issues/825")] [WorkItem(5662, "https://github.com/dotnet/roslyn/issues/5662")] [Fact] public void ConditionalBoolExpr01b() { var source = @" class C { public static void Main() { System.Console.WriteLine(HasLength(null, long.MaxValue)); try { System.Console.WriteLine(HasLengthChecked(null, long.MaxValue)); } catch (System.Exception ex) { System.Console.WriteLine(ex.GetType().Name); } } static bool HasLength(string s, long len) { return s?.Length == (int)(byte)len; } static bool HasLengthChecked(string s, long len) { checked { return s?.Length == (int)(byte)len; } } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False OverflowException"); verifier.VerifyIL("C.HasLength", @" { // Code size 16 (0x10) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.0 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldarg.1 IL_000c: conv.u1 IL_000d: ceq IL_000f: ret }").VerifyIL("C.HasLengthChecked", @" { // Code size 48 (0x30) .maxstack 2 .locals init (int? V_0, int V_1, int? V_2) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_2 IL_0005: initobj ""int?"" IL_000b: ldloc.2 IL_000c: br.s IL_0019 IL_000e: ldarg.0 IL_000f: call ""int string.Length.get"" IL_0014: newobj ""int?..ctor(int)"" IL_0019: stloc.0 IL_001a: ldarg.1 IL_001b: conv.ovf.u1 IL_001c: stloc.1 IL_001d: ldloca.s V_0 IL_001f: call ""int int?.GetValueOrDefault()"" IL_0024: ldloc.1 IL_0025: ceq IL_0027: ldloca.s V_0 IL_0029: call ""bool int?.HasValue.get"" IL_002e: and IL_002f: ret }"); } [Fact] public void ConditionalBoolExpr02() { var source = @" class C { public static void Main() { System.Console.Write(HasLength(null, 0)); System.Console.Write(HasLength(null, 3)); System.Console.Write(HasLength(""q"", 2)); } static bool HasLength(string s, int len) { return (s?.Length ?? 2) + 1 == len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"FalseTrueTrue"); verifier.VerifyIL("C.HasLength", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldc.i4.2 IL_0004: br.s IL_000c IL_0006: ldarg.0 IL_0007: call ""int string.Length.get"" IL_000c: ldc.i4.1 IL_000d: add IL_000e: ldarg.1 IL_000f: ceq IL_0011: ret }"); } [Fact] public void ConditionalBoolExpr02a() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(""q"", 2)); } static bool NotHasLength(string s, int len) { return s?.Length + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 20 (0x14) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""int string.Length.get"" IL_000b: ldc.i4.1 IL_000c: add IL_000d: ldarg.1 IL_000e: ceq IL_0010: ldc.i4.0 IL_0011: ceq IL_0013: ret }"); } [Fact] public void ConditionalBoolExpr02b() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(""q"", 2)); System.Console.Write(NotHasLength(null, null)); } static bool NotHasLength(string s, int? len) { return s?.Length + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalseFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 42 (0x2a) .maxstack 2 .locals init (int? V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000b IL_0003: ldarga.s V_1 IL_0005: call ""bool int?.HasValue.get"" IL_000a: ret IL_000b: ldarg.0 IL_000c: call ""int string.Length.get"" IL_0011: ldc.i4.1 IL_0012: add IL_0013: ldarg.1 IL_0014: stloc.0 IL_0015: ldloca.s V_0 IL_0017: call ""int int?.GetValueOrDefault()"" IL_001c: ceq IL_001e: ldloca.s V_0 IL_0020: call ""bool int?.HasValue.get"" IL_0025: and IL_0026: ldc.i4.0 IL_0027: ceq IL_0029: ret }"); } [Fact] public void ConditionalBoolExpr03() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength(null, 0).Result); System.Console.Write(HasLength(null, 3).Result); System.Console.Write(HasLength(""q"", 2).Result); } static async Task<bool> HasLength(string s, int len) { return (s?.Goo(await Bar()) ?? await Bar() + await Bar()) + 1 == len; } static int Goo(this string s, int arg) { return s.Length; } static async Task<int> Bar() { await Task.Yield(); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] public void ConditionalBoolExpr04() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength((string)null, 0).Result); System.Console.Write(HasLength((string)null, 3).Result); System.Console.Write(HasLength(""q"", 2).Result); } static async Task<bool> HasLength<T>(T s, int len) { return (s?.Goo(await Bar()) ?? 2) + 1 == len; } static int Goo<T>(this T s, int arg) { return ((string)(object)s).Length; } static async Task<int> Bar() { await Task.Yield(); return 1; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] public void ConditionalBoolExpr05() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength((string)null, 0).Result); System.Console.Write(HasLength((string)null, 3).Result); System.Console.Write(HasLength(""q"", 2).Result); } static async Task<bool> HasLength<T>(T s, int len) { return (s?.Goo(await Bar(await Bar())) ?? 2) + 1 == len; } static int Goo<T>(this T s, int arg) { return ((string)(object)s).Length; } static async Task<int> Bar() { await Task.Yield(); return 1; } static async Task<int> Bar(int arg) { await Task.Yield(); return arg; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"FalseTrueTrue"); } [Fact] public void ConditionalBoolExpr06() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.Write(HasLength(null, 0).Result); System.Console.Write(HasLength(null, 7).Result); System.Console.Write(HasLength(""q"", 7).Result); } static async Task<bool> HasLength(string s, int len) { System.Console.WriteLine(s?.Goo(await Bar())?.Goo(await Bar()) + ""#""); return s?.Goo(await Bar())?.Goo(await Bar()).Length == len; } static string Goo(this string s, string arg) { return s + arg; } static async Task<string> Bar() { await Task.Yield(); return ""Bar""; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"# False# FalseqBarBar# True"); } [Fact] public void ConditionalBoolExpr07() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.WriteLine(Test(null).Result); System.Console.WriteLine(Test(""q"").Result); } static async Task<bool> Test(string s) { return (await Bar(s))?.Goo(await Bar())?.ToString()?.Length > 1; } static string Goo(this string s, string arg1) { return s + arg1; } static async Task<string> Bar() { await Task.Yield(); return ""Bar""; } static async Task<string> Bar(string arg) { await Task.Yield(); return arg; } } "; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True"); } [Fact] public void ConditionalBoolExpr08() { var source = @" using System.Threading.Tasks; static class C { public static void Main() { System.Console.WriteLine(Test(null).Result); System.Console.WriteLine(Test(""q"").Result); } static async Task<bool> Test(string s) { return (await Bar(s))?.Insert(0, await Bar())?.ToString()?.Length > 1; } static async Task<string> Bar() { await Task.Yield(); return ""Bar""; } static async Task<dynamic> Bar(string arg) { await Task.Yield(); return arg; } }"; var c = CreateCompilationWithMscorlib45(source, new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929, CSharpRef }, TestOptions.ReleaseExe); var comp = CompileAndVerify(c, expectedOutput: @"False True"); } [Fact] public void ConditionalUserDef01() { var source = @" class C { struct S1 { public static bool operator ==(S1? x, S1?y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1? x, S1? y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); } static bool TestEq(C1 c, S1 arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1 arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"==True ==True !=False !=False"); verifier.VerifyIL("C.TestNeq", @" { // Code size 37 (0x25) .maxstack 2 .locals init (C.S1? V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_0 IL_0005: initobj ""C.S1?"" IL_000b: ldloc.0 IL_000c: br.s IL_0019 IL_000e: ldarg.0 IL_000f: call ""C.S1 C.C1.Goo()"" IL_0014: newobj ""C.S1?..ctor(C.S1)"" IL_0019: ldarg.1 IL_001a: newobj ""C.S1?..ctor(C.S1)"" IL_001f: call ""bool C.S1.op_Inequality(C.S1?, C.S1?)"" IL_0024: ret }"); } [Fact] public void ConditionalUserDef01n() { var source = @" class C { struct S1 { public static bool operator ==(S1? x, S1?y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1? x, S1? y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestEq(new C1(), null)); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); System.Console.WriteLine(TestNeq(new C1(), null)); } static bool TestEq(C1 c, S1? arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1? arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"==True ==True ==True !=False !=False !=False"); verifier.VerifyIL("C.TestNeq", @" { // Code size 32 (0x20) .maxstack 2 .locals init (C.S1? V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000e IL_0003: ldloca.s V_0 IL_0005: initobj ""C.S1?"" IL_000b: ldloc.0 IL_000c: br.s IL_0019 IL_000e: ldarg.0 IL_000f: call ""C.S1 C.C1.Goo()"" IL_0014: newobj ""C.S1?..ctor(C.S1)"" IL_0019: ldarg.1 IL_001a: call ""bool C.S1.op_Inequality(C.S1?, C.S1?)"" IL_001f: ret }"); } [Fact] public void ConditionalUserDef02() { var source = @" class C { struct S1 { public static bool operator ==(S1 x, S1 y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1 x, S1 y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); } static bool TestEq(C1 c, S1 arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1 arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False ==True True !=False"); verifier.VerifyIL("C.TestNeq", @" { // Code size 18 (0x12) .maxstack 2 IL_0000: ldarg.0 IL_0001: brtrue.s IL_0005 IL_0003: ldc.i4.1 IL_0004: ret IL_0005: ldarg.0 IL_0006: call ""C.S1 C.C1.Goo()"" IL_000b: ldarg.1 IL_000c: call ""bool C.S1.op_Inequality(C.S1, C.S1)"" IL_0011: ret }"); } [Fact] public void ConditionalUserDef02n() { var source = @" class C { struct S1 { public static bool operator ==(S1 x, S1 y) { System.Console.Write(""==""); return true; } public static bool operator !=(S1 x, S1 y) { System.Console.Write(""!=""); return false; } } class C1 { public S1 Goo() { return new S1(); } } public static void Main() { System.Console.WriteLine(TestEq(null, new S1())); System.Console.WriteLine(TestEq(new C1(), new S1())); System.Console.WriteLine(TestEq(new C1(), null)); System.Console.WriteLine(TestNeq(null, new S1())); System.Console.WriteLine(TestNeq(new C1(), new S1())); System.Console.WriteLine(TestNeq(new C1(), null)); } static bool TestEq(C1 c, S1? arg) { return c?.Goo() == arg; } static bool TestNeq(C1 c, S1? arg) { return c?.Goo() != arg; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"False ==True False True !=False True"); verifier.VerifyIL("C.TestNeq", @" { // Code size 45 (0x2d) .maxstack 2 .locals init (C.S1 V_0, C.S1? V_1) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000b IL_0003: ldarga.s V_1 IL_0005: call ""bool C.S1?.HasValue.get"" IL_000a: ret IL_000b: ldarg.0 IL_000c: call ""C.S1 C.C1.Goo()"" IL_0011: stloc.0 IL_0012: ldarg.1 IL_0013: stloc.1 IL_0014: ldloca.s V_1 IL_0016: call ""bool C.S1?.HasValue.get"" IL_001b: brtrue.s IL_001f IL_001d: ldc.i4.1 IL_001e: ret IL_001f: ldloc.0 IL_0020: ldloca.s V_1 IL_0022: call ""C.S1 C.S1?.GetValueOrDefault()"" IL_0027: call ""bool C.S1.op_Inequality(C.S1, C.S1)"" IL_002c: ret }"); } [Fact] public void Bug1() { var source = @" using System; class Test { static void Main() { var c1 = new C1(); M1(c1); M2(c1); } static void M1(C1 c1) { if (c1?.P == 1) Console.WriteLine(1); } static void M2(C1 c1) { if (c1 != null && c1.P == 1) Console.WriteLine(1); } } class C1 { public int P => 1; } "; var comp = CompileAndVerify(source, expectedOutput: @"1 1"); comp.VerifyIL("Test.M1", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0012 IL_0003: ldarg.0 IL_0004: call ""int C1.P.get"" IL_0009: ldc.i4.1 IL_000a: bne.un.s IL_0012 IL_000c: ldc.i4.1 IL_000d: call ""void System.Console.WriteLine(int)"" IL_0012: ret } "); comp.VerifyIL("Test.M2", @" { // Code size 19 (0x13) .maxstack 2 IL_0000: ldarg.0 IL_0001: brfalse.s IL_0012 IL_0003: ldarg.0 IL_0004: callvirt ""int C1.P.get"" IL_0009: ldc.i4.1 IL_000a: bne.un.s IL_0012 IL_000c: ldc.i4.1 IL_000d: call ""void System.Console.WriteLine(int)"" IL_0012: ret } "); } [Fact] public void ConditionalBoolExpr02ba() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(1, 2)); } static bool NotHasLength(int? s, int len) { return s?.GetHashCode() + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 35 (0x23) .maxstack 2 .locals init (int V_0) IL_0000: ldarga.s V_0 IL_0002: call ""bool int?.HasValue.get"" IL_0007: brtrue.s IL_000b IL_0009: ldc.i4.1 IL_000a: ret IL_000b: ldarga.s V_0 IL_000d: call ""int int?.GetValueOrDefault()"" IL_0012: stloc.0 IL_0013: ldloca.s V_0 IL_0015: call ""int int.GetHashCode()"" IL_001a: ldc.i4.1 IL_001b: add IL_001c: ldarg.1 IL_001d: ceq IL_001f: ldc.i4.0 IL_0020: ceq IL_0022: ret } "); } [Fact] public void ConditionalBoolExpr02bb() { var source = @" class C { public static void Main() { System.Console.Write(NotHasLength(null, 0)); System.Console.Write(NotHasLength(null, 3)); System.Console.Write(NotHasLength(1, 2)); System.Console.Write(NotHasLength(null, null)); } static bool NotHasLength(int? s, int? len) { return s?.GetHashCode() + 1 != len; } } "; var verifier = CompileAndVerify(source, expectedOutput: @"TrueTrueFalseFalse"); verifier.VerifyIL("C.NotHasLength", @" { // Code size 57 (0x39) .maxstack 2 .locals init (int? V_0, int V_1) IL_0000: ldarga.s V_0 IL_0002: call ""bool int?.HasValue.get"" IL_0007: brtrue.s IL_0011 IL_0009: ldarga.s V_1 IL_000b: call ""bool int?.HasValue.get"" IL_0010: ret IL_0011: ldarga.s V_0 IL_0013: call ""int int?.GetValueOrDefault()"" IL_0018: stloc.1 IL_0019: ldloca.s V_1 IL_001b: call ""int int.GetHashCode()"" IL_0020: ldc.i4.1 IL_0021: add IL_0022: ldarg.1 IL_0023: stloc.0 IL_0024: ldloca.s V_0 IL_0026: call ""int int?.GetValueOrDefault()"" IL_002b: ceq IL_002d: ldloca.s V_0 IL_002f: call ""bool int?.HasValue.get"" IL_0034: and IL_0035: ldc.i4.0 IL_0036: ceq IL_0038: ret }"); } [Fact] public void ConditionalUnary() { var source = @" class C { public static void Main() { var x = - - -((string)null)?.Length ?? - - -string.Empty?.Length; System.Console.WriteLine(x); } } "; var verifier = CompileAndVerify(source, expectedOutput: @"0"); verifier.VerifyIL("C.Main", @" { // Code size 44 (0x2c) .maxstack 2 .locals init (int? V_0) IL_0000: ldsfld ""string string.Empty"" IL_0005: dup IL_0006: brtrue.s IL_0014 IL_0008: pop IL_0009: ldloca.s V_0 IL_000b: initobj ""int?"" IL_0011: ldloc.0 IL_0012: br.s IL_0021 IL_0014: call ""int string.Length.get"" IL_0019: neg IL_001a: neg IL_001b: neg IL_001c: newobj ""int?..ctor(int)"" IL_0021: box ""int?"" IL_0026: call ""void System.Console.WriteLine(object)"" IL_002b: ret } "); } [WorkItem(7388, "https://github.com/dotnet/roslyn/issues/7388")] [Fact] public void ConditionalClassConstrained001() { var source = @" using System; namespace ConsoleApplication9 { class Program { static void Main(string[] args) { var v = new A<object>(); System.Console.WriteLine(A<object>.Test(v)); } public class A<T> : object where T : class { public T Value { get { return (T)(object)42; }} public static T Test(A<T> val) { return val?.Value; } } } } "; var verifier = CompileAndVerify(source, expectedOutput: @"42"); verifier.VerifyIL("ConsoleApplication9.Program.A<T>.Test(ConsoleApplication9.Program.A<T>)", @" { // Code size 20 (0x14) .maxstack 1 .locals init (T V_0) IL_0000: ldarg.0 IL_0001: brtrue.s IL_000d IL_0003: ldloca.s V_0 IL_0005: initobj ""T"" IL_000b: ldloc.0 IL_000c: ret IL_000d: ldarg.0 IL_000e: call ""T ConsoleApplication9.Program.A<T>.Value.get"" IL_0013: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfUnconstrainedDefault1() { var source = @" using System; public class Test<T> { public string Run() { return default(T)?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 45 (0x2d) .maxstack 2 .locals init (T V_0, string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0028 IL_0014: ldloca.s V_0 IL_0016: dup IL_0017: initobj ""T"" IL_001d: constrained. ""T"" IL_0023: callvirt ""string object.ToString()"" IL_0028: stloc.1 IL_0029: br.s IL_002b IL_002b: ldloc.1 IL_002c: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfUnconstrainedDefault2() { var source = @" using System; public class Test<T> { public string Run() { var v = default(T); return v?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 38 (0x26) .maxstack 1 .locals init (T V_0, //v string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0021 IL_0014: ldloca.s V_0 IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: stloc.1 IL_0022: br.s IL_0024 IL_0024: ldloc.1 IL_0025: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfInterfaceConstrainedDefault1() { var source = @" using System; public class Test<T> where T : IComparable { public string Run() { return default(T)?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 45 (0x2d) .maxstack 2 .locals init (T V_0, string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0028 IL_0014: ldloca.s V_0 IL_0016: dup IL_0017: initobj ""T"" IL_001d: constrained. ""T"" IL_0023: callvirt ""string object.ToString()"" IL_0028: stloc.1 IL_0029: br.s IL_002b IL_002b: ldloc.1 IL_002c: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfInterfaceConstrainedDefault2() { var source = @" using System; public class Test<T> where T : IComparable { public string Run() { var v = default(T); return v?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); Console.WriteLine(new Test<int>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- -- 0 --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 38 (0x26) .maxstack 1 .locals init (T V_0, //v string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0021 IL_0014: ldloca.s V_0 IL_0016: constrained. ""T"" IL_001c: callvirt ""string object.ToString()"" IL_0021: stloc.1 IL_0022: br.s IL_0024 IL_0024: ldloc.1 IL_0025: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfClassConstrainedDefault1() { var source = @" using System; public class Test<T> where T : class { public string Run() { return default(T)?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 7 (0x7) .maxstack 1 .locals init (string V_0) IL_0000: nop IL_0001: ldnull IL_0002: stloc.0 IL_0003: br.s IL_0005 IL_0005: ldloc.0 IL_0006: ret }"); } [Fact, WorkItem(15670, "https://github.com/dotnet/roslyn/issues/15670")] public void ConditionalAccessOffOfClassConstrainedDefault2() { var source = @" using System; public class Test<T> where T : class { public string Run() { var v = default(T); return v?.ToString(); } } class Program { static void Main() { Console.WriteLine(""--""); Console.WriteLine(new Test<string>().Run()); Console.WriteLine(""--""); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"-- --"); verifier.VerifyIL("Test<T>.Run", @" { // Code size 32 (0x20) .maxstack 2 .locals init (T V_0, //v string V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: initobj ""T"" IL_0009: ldloc.0 IL_000a: box ""T"" IL_000f: dup IL_0010: brtrue.s IL_0016 IL_0012: pop IL_0013: ldnull IL_0014: br.s IL_001b IL_0016: callvirt ""string object.ToString()"" IL_001b: stloc.1 IL_001c: br.s IL_001e IL_001e: ldloc.1 IL_001f: ret }"); } [Fact] [CompilerTrait(CompilerFeature.PEVerifyCompat)] public void ConditionalAccessOffReadOnlyNullable1() { var source = @" using System; class Program { private static readonly Guid? g = null; static void Main() { Console.WriteLine(g?.ToString()); } } "; var comp = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"", verify: Verification.Fails); comp.VerifyIL("Program.Main", @" { // Code size 44 (0x2c) .maxstack 2 .locals init (System.Guid V_0) IL_0000: nop IL_0001: ldsflda ""System.Guid? Program.g"" IL_0006: dup IL_0007: call ""bool System.Guid?.HasValue.get"" IL_000c: brtrue.s IL_0012 IL_000e: pop IL_000f: ldnull IL_0010: br.s IL_0025 IL_0012: call ""System.Guid System.Guid?.GetValueOrDefault()"" IL_0017: stloc.0 IL_0018: ldloca.s V_0 IL_001a: constrained. ""System.Guid"" IL_0020: callvirt ""string object.ToString()"" IL_0025: call ""void System.Console.WriteLine(string)"" IL_002a: nop IL_002b: ret }"); comp = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @"", parseOptions: TestOptions.Regular.WithPEVerifyCompatFeature(), verify: Verification.Passes); comp.VerifyIL("Program.Main", @" { // Code size 47 (0x2f) .maxstack 2 .locals init (System.Guid? V_0, System.Guid V_1) IL_0000: nop IL_0001: ldsfld ""System.Guid? Program.g"" IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: dup IL_000a: call ""bool System.Guid?.HasValue.get"" IL_000f: brtrue.s IL_0015 IL_0011: pop IL_0012: ldnull IL_0013: br.s IL_0028 IL_0015: call ""System.Guid System.Guid?.GetValueOrDefault()"" IL_001a: stloc.1 IL_001b: ldloca.s V_1 IL_001d: constrained. ""System.Guid"" IL_0023: callvirt ""string object.ToString()"" IL_0028: call ""void System.Console.WriteLine(string)"" IL_002d: nop IL_002e: ret }"); } [Fact] public void ConditionalAccessOffReadOnlyNullable2() { var source = @" using System; class Program { static void Main() { Console.WriteLine(default(Guid?)?.ToString()); } } "; var verifier = CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: @""); verifier.VerifyIL("Program.Main", @" { // Code size 55 (0x37) .maxstack 2 .locals init (System.Guid? V_0, System.Guid V_1) IL_0000: nop IL_0001: ldloca.s V_0 IL_0003: dup IL_0004: initobj ""System.Guid?"" IL_000a: call ""bool System.Guid?.HasValue.get"" IL_000f: brtrue.s IL_0014 IL_0011: ldnull IL_0012: br.s IL_0030 IL_0014: ldloca.s V_0 IL_0016: dup IL_0017: initobj ""System.Guid?"" IL_001d: call ""System.Guid System.Guid?.GetValueOrDefault()"" IL_0022: stloc.1 IL_0023: ldloca.s V_1 IL_0025: constrained. ""System.Guid"" IL_002b: callvirt ""string object.ToString()"" IL_0030: call ""void System.Console.WriteLine(string)"" IL_0035: nop IL_0036: ret }"); } [Fact] [WorkItem(23351, "https://github.com/dotnet/roslyn/issues/23351")] public void ConditionalAccessOffConstrainedTypeParameter_Property() { var source = @" using System; class Program { static void Main(string[] args) { var obj1 = new MyObject1 { MyDate = new DateTime(636461511000000000L) }; var obj2 = new MyObject2<MyObject1>(obj1); System.Console.WriteLine(obj1.MyDate.Ticks); System.Console.WriteLine(obj2.CurrentDate.Value.Ticks); System.Console.WriteLine(new MyObject2<MyObject1>(null).CurrentDate.HasValue); } } abstract class MyBaseObject1 { public DateTime MyDate { get; set; } } class MyObject1 : MyBaseObject1 { } class MyObject2<MyObjectType> where MyObjectType : MyBaseObject1, new() { public MyObject2(MyObjectType obj) { m_CurrentObject1 = obj; } private MyObjectType m_CurrentObject1 = null; public MyObjectType CurrentObject1 => m_CurrentObject1; public DateTime? CurrentDate => CurrentObject1?.MyDate; } "; var expectedOutput = @" 636461511000000000 636461511000000000 False "; CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: expectedOutput); CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: expectedOutput); } [Fact] [WorkItem(23351, "https://github.com/dotnet/roslyn/issues/23351")] public void ConditionalAccessOffConstrainedTypeParameter_Field() { var source = @" using System; class Program { static void Main(string[] args) { var obj1 = new MyObject1 { MyDate = new DateTime(636461511000000000L) }; var obj2 = new MyObject2<MyObject1>(obj1); System.Console.WriteLine(obj1.MyDate.Ticks); System.Console.WriteLine(obj2.CurrentDate.Value.Ticks); System.Console.WriteLine(new MyObject2<MyObject1>(null).CurrentDate.HasValue); } } abstract class MyBaseObject1 { public DateTime MyDate; } class MyObject1 : MyBaseObject1 { } class MyObject2<MyObjectType> where MyObjectType : MyBaseObject1, new() { public MyObject2(MyObjectType obj) { m_CurrentObject1 = obj; } private MyObjectType m_CurrentObject1 = null; public MyObjectType CurrentObject1 => m_CurrentObject1; public DateTime? CurrentDate => CurrentObject1?.MyDate; } "; var expectedOutput = @" 636461511000000000 636461511000000000 False "; CompileAndVerify(source, options: TestOptions.DebugExe, expectedOutput: expectedOutput); CompileAndVerify(source, options: TestOptions.ReleaseExe, expectedOutput: expectedOutput); } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./THIRD-PARTY-NOTICES.txt
Roslyn uses third-party libraries or other resources that may be distributed under licenses different than the Roslyn software. In the event that we accidentally failed to list a required notice, please bring it to our attention. Post an issue or email us: [email protected] The attached notices are provided for information only. License notice for .NET Core Libraries (CoreFX) ------------------------------------- https://github.com/dotnet/corefx Copyright (c) 2018 .NET Foundation and Contributors This software is licensed subject to the MIT license, available at https://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License notice for DotNetTools ------------------------------------- https://github.com/aspnet/DotNetTools Copyright (c) .NET Foundation and Contributors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. License notice for DocFX ------------------------------------- https://github.com/dotnet/docfx Copyright (c) Microsoft Corporation This software is licensed subject to the MIT license, available at https://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License notice for MSBuild Locator ------------------------------------- https://github.com/Microsoft/MSBuildLocator Copyright (c) Microsoft Corporation. All rights reserved. This software is licensed subject to the MIT license, available at https://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Roslyn uses third-party libraries or other resources that may be distributed under licenses different than the Roslyn software. In the event that we accidentally failed to list a required notice, please bring it to our attention. Post an issue or email us: [email protected] The attached notices are provided for information only. License notice for .NET Core Libraries (CoreFX) ------------------------------------- https://github.com/dotnet/corefx Copyright (c) 2018 .NET Foundation and Contributors This software is licensed subject to the MIT license, available at https://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License notice for DotNetTools ------------------------------------- https://github.com/aspnet/DotNetTools Copyright (c) .NET Foundation and Contributors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. License notice for DocFX ------------------------------------- https://github.com/dotnet/docfx Copyright (c) Microsoft Corporation This software is licensed subject to the MIT license, available at https://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License notice for MSBuild Locator ------------------------------------- https://github.com/Microsoft/MSBuildLocator Copyright (c) Microsoft Corporation. All rights reserved. This software is licensed subject to the MIT license, available at https://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/Compilers/CSharp/Portable/Syntax/SwitchStatementSyntax.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.CodeAnalysis.CSharp.Syntax { public partial class SwitchStatementSyntax { public SwitchStatementSyntax Update(SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) => Update(AttributeLists, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, sections, closeBraceToken); } } namespace Microsoft.CodeAnalysis.CSharp { public partial class SyntaxFactory { public static SwitchStatementSyntax SwitchStatement(SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) => SwitchStatement(attributeLists: default, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, sections, closeBraceToken); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.CodeAnalysis.CSharp.Syntax { public partial class SwitchStatementSyntax { public SwitchStatementSyntax Update(SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) => Update(AttributeLists, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, sections, closeBraceToken); } } namespace Microsoft.CodeAnalysis.CSharp { public partial class SyntaxFactory { public static SwitchStatementSyntax SwitchStatement(SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) => SwitchStatement(attributeLists: default, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, sections, closeBraceToken); } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/EditorFeatures/CSharp/BraceMatching/OpenCloseBracketBraceMatcher.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.ComponentModel.Composition; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.Editor.CSharp.BraceMatching { [ExportBraceMatcher(LanguageNames.CSharp)] internal class OpenCloseBracketBraceMatcher : AbstractCSharpBraceMatcher { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public OpenCloseBracketBraceMatcher() : base(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken) { } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.ComponentModel.Composition; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.Editor.CSharp.BraceMatching { [ExportBraceMatcher(LanguageNames.CSharp)] internal class OpenCloseBracketBraceMatcher : AbstractCSharpBraceMatcher { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public OpenCloseBracketBraceMatcher() : base(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken) { } } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/VisualStudio/Core/Def/Implementation/CommandBindings.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.ComponentModel.Composition; using Microsoft.CodeAnalysis.Editor.Commanding.Commands; using Microsoft.VisualStudio.Editor.Commanding; using Microsoft.VisualStudio.LanguageServices; using Microsoft.VisualStudio.LanguageServices.ValueTracking; namespace Microsoft.VisualStudio.Editor.Implementation { internal sealed class CommandBindings { [Export] [CommandBinding(Guids.RoslynGroupIdString, ID.RoslynCommands.GoToImplementation, typeof(GoToImplementationCommandArgs))] internal CommandBindingDefinition gotoImplementationCommandBinding; [Export] [CommandBinding(Guids.CSharpGroupIdString, ID.CSharpCommands.OrganizeSortUsings, typeof(SortImportsCommandArgs))] internal CommandBindingDefinition organizeSortCommandBinding; [Export] [CommandBinding(Guids.CSharpGroupIdString, ID.CSharpCommands.OrganizeRemoveAndSort, typeof(SortAndRemoveUnnecessaryImportsCommandArgs))] internal CommandBindingDefinition organizeRemoveAndSortCommandBinding; [Export] [CommandBinding(Guids.CSharpGroupIdString, ID.CSharpCommands.ContextOrganizeRemoveAndSort, typeof(SortAndRemoveUnnecessaryImportsCommandArgs))] internal CommandBindingDefinition contextOrganizeRemoveAndSortCommandBinding; [Export] [CommandBinding(Guids.RoslynGroupIdString, ID.RoslynCommands.GoToValueTrackingWindow, typeof(ValueTrackingEditorCommandArgs))] internal CommandBindingDefinition gotoDataFlowToolCommandBinding; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.ComponentModel.Composition; using Microsoft.CodeAnalysis.Editor.Commanding.Commands; using Microsoft.VisualStudio.Editor.Commanding; using Microsoft.VisualStudio.LanguageServices; using Microsoft.VisualStudio.LanguageServices.ValueTracking; namespace Microsoft.VisualStudio.Editor.Implementation { internal sealed class CommandBindings { [Export] [CommandBinding(Guids.RoslynGroupIdString, ID.RoslynCommands.GoToImplementation, typeof(GoToImplementationCommandArgs))] internal CommandBindingDefinition gotoImplementationCommandBinding; [Export] [CommandBinding(Guids.CSharpGroupIdString, ID.CSharpCommands.OrganizeSortUsings, typeof(SortImportsCommandArgs))] internal CommandBindingDefinition organizeSortCommandBinding; [Export] [CommandBinding(Guids.CSharpGroupIdString, ID.CSharpCommands.OrganizeRemoveAndSort, typeof(SortAndRemoveUnnecessaryImportsCommandArgs))] internal CommandBindingDefinition organizeRemoveAndSortCommandBinding; [Export] [CommandBinding(Guids.CSharpGroupIdString, ID.CSharpCommands.ContextOrganizeRemoveAndSort, typeof(SortAndRemoveUnnecessaryImportsCommandArgs))] internal CommandBindingDefinition contextOrganizeRemoveAndSortCommandBinding; [Export] [CommandBinding(Guids.RoslynGroupIdString, ID.RoslynCommands.GoToValueTrackingWindow, typeof(ValueTrackingEditorCommandArgs))] internal CommandBindingDefinition gotoDataFlowToolCommandBinding; } }
-1
dotnet/roslyn
55,504
Format new document namespace declarations
Fixes https://github.com/dotnet/roslyn/issues/55417
davidwengier
2021-08-09T07:51:27Z
2021-08-10T11:42:04Z
06495a2bf3813e13cff59d2cdf30c24c99966d8e
782f71d3ada7ae95e42af182405824aeff12daeb
Format new document namespace declarations. Fixes https://github.com/dotnet/roslyn/issues/55417
./src/ExpressionEvaluator/Core/Test/FunctionResolver/ParsingTestBase.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Roslyn.Test.Utilities; using System.Collections.Immutable; using System.Linq; using Xunit; namespace Microsoft.CodeAnalysis.ExpressionEvaluator.UnitTests { public abstract class ParsingTestBase : CSharpTestBase { internal static RequestSignature SignatureNameOnly(Name name) { return new RequestSignature(name, default(ImmutableArray<ParameterSignature>)); } internal static RequestSignature Signature(Name name) { return new RequestSignature(name, ImmutableArray<ParameterSignature>.Empty); } internal static RequestSignature Signature(Name name, params TypeSignature[] parameterTypes) { return Signature(name, parameterTypes.Select(t => new ParameterSignature(t, isByRef: false)).ToArray()); } internal static RequestSignature Signature(Name name, params ParameterSignature[] parameters) { return new RequestSignature(name, ImmutableArray.CreateRange(parameters)); } internal static QualifiedName Name(string name) { return new QualifiedName(null, name); } internal static GenericName Generic(QualifiedName name, params string[] typeArguments) { Assert.True(typeArguments.Length > 0); return new GenericName(name, ImmutableArray.CreateRange(typeArguments)); } internal static QualifiedName Qualified(Name left, string right) { return new QualifiedName(left, right); } internal static QualifiedTypeSignature Identifier(string name) { return new QualifiedTypeSignature(null, name); } internal static GenericTypeSignature Generic(QualifiedTypeSignature name, params TypeSignature[] typeArguments) { Assert.True(typeArguments.Length > 0); return new GenericTypeSignature(name, ImmutableArray.CreateRange(typeArguments)); } internal static QualifiedTypeSignature Qualified(TypeSignature left, string right) { return new QualifiedTypeSignature(left, right); } internal static QualifiedTypeSignature Qualified(params string[] names) { QualifiedTypeSignature signature = null; foreach (var name in names) { signature = new QualifiedTypeSignature(signature, name); } return signature; } internal static ArrayTypeSignature Array(TypeSignature elementType, int rank) { return new ArrayTypeSignature(elementType, rank); } internal static PointerTypeSignature Pointer(TypeSignature pointedAtType) { return new PointerTypeSignature(pointedAtType); } internal static void VerifySignature(RequestSignature actualSignature, RequestSignature expectedSignature) { if (expectedSignature == null) { Assert.Null(actualSignature); } else { Assert.NotNull(actualSignature); Assert.Equal(expectedSignature.MemberName, actualSignature.MemberName, NameComparer.Instance); if (expectedSignature.Parameters.IsDefault) { Assert.True(actualSignature.Parameters.IsDefault); } else { AssertEx.Equal( expectedSignature.Parameters, actualSignature.Parameters, comparer: ParameterComparer.Instance, itemInspector: p => p.Type.GetDebuggerDisplay()); } } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Roslyn.Test.Utilities; using System.Collections.Immutable; using System.Linq; using Xunit; namespace Microsoft.CodeAnalysis.ExpressionEvaluator.UnitTests { public abstract class ParsingTestBase : CSharpTestBase { internal static RequestSignature SignatureNameOnly(Name name) { return new RequestSignature(name, default(ImmutableArray<ParameterSignature>)); } internal static RequestSignature Signature(Name name) { return new RequestSignature(name, ImmutableArray<ParameterSignature>.Empty); } internal static RequestSignature Signature(Name name, params TypeSignature[] parameterTypes) { return Signature(name, parameterTypes.Select(t => new ParameterSignature(t, isByRef: false)).ToArray()); } internal static RequestSignature Signature(Name name, params ParameterSignature[] parameters) { return new RequestSignature(name, ImmutableArray.CreateRange(parameters)); } internal static QualifiedName Name(string name) { return new QualifiedName(null, name); } internal static GenericName Generic(QualifiedName name, params string[] typeArguments) { Assert.True(typeArguments.Length > 0); return new GenericName(name, ImmutableArray.CreateRange(typeArguments)); } internal static QualifiedName Qualified(Name left, string right) { return new QualifiedName(left, right); } internal static QualifiedTypeSignature Identifier(string name) { return new QualifiedTypeSignature(null, name); } internal static GenericTypeSignature Generic(QualifiedTypeSignature name, params TypeSignature[] typeArguments) { Assert.True(typeArguments.Length > 0); return new GenericTypeSignature(name, ImmutableArray.CreateRange(typeArguments)); } internal static QualifiedTypeSignature Qualified(TypeSignature left, string right) { return new QualifiedTypeSignature(left, right); } internal static QualifiedTypeSignature Qualified(params string[] names) { QualifiedTypeSignature signature = null; foreach (var name in names) { signature = new QualifiedTypeSignature(signature, name); } return signature; } internal static ArrayTypeSignature Array(TypeSignature elementType, int rank) { return new ArrayTypeSignature(elementType, rank); } internal static PointerTypeSignature Pointer(TypeSignature pointedAtType) { return new PointerTypeSignature(pointedAtType); } internal static void VerifySignature(RequestSignature actualSignature, RequestSignature expectedSignature) { if (expectedSignature == null) { Assert.Null(actualSignature); } else { Assert.NotNull(actualSignature); Assert.Equal(expectedSignature.MemberName, actualSignature.MemberName, NameComparer.Instance); if (expectedSignature.Parameters.IsDefault) { Assert.True(actualSignature.Parameters.IsDefault); } else { AssertEx.Equal( expectedSignature.Parameters, actualSignature.Parameters, comparer: ParameterComparer.Instance, itemInspector: p => p.Type.GetDebuggerDisplay()); } } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./Roslyn.sln
Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31319.15 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoslynDeployment", "src\Deployment\RoslynDeployment.csproj", "{600AF682-E097-407B-AD85-EE3CED37E680}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{A41D1B99-F489-4C43-BBDF-96D61B19A6B9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compilers", "Compilers", "{3F40F71B-7DCF-44A1-B15C-38CA34824143}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{32A48625-F0AD-419D-828B-A50BDABA38EA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{C65C6143-BED3-46E6-869E-9F0BE6E84C37}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspaces", "Workspaces", "{55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EditorFeatures", "EditorFeatures", "{EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExpressionEvaluator", "ExpressionEvaluator", "{235A3418-A3B0-4844-BCEB-F1CF45069232}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Features", "Features", "{3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Interactive", "Interactive", "{999FBDA2-33DA-4F74-B957-03AC72CCE5EC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripting", "Scripting", "{38940C5F-97FD-4B2A-B2CD-C4E4EF601B05}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualStudio", "VisualStudio", "{8DBA5174-B0AA-4561-82B1-A46607697753}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{913A4C08-898E-49C7-9692-0EF9DC56CF6E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{151F6994-AEB3-4B12-B746-2ACFF26C7BBB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{4C81EBB2-82E1-4C81-80C4-84CC40FA281B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{998CAFE8-06E4-4683-A151-0F6AA4BFF6C6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{19148439-436F-4CDA-B493-70AF4FFC13E9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hosts", "Hosts", "{5CA5F70E-0FDB-467B-B22C-3CD5994F0087}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{7E907718-0B33-45C8-851F-396CEFDC1AB6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CAD2965A-19AB-489F-BE2E-7649957F914A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTest", "IntegrationTest", "{CC126D03-7EAC-493F-B187-DCDEE1EF6A70}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{C2D1346B-9665-4150-B644-075CF1636BAA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Perf", "Perf", "{DD13507E-D5AF-4B61-B11A-D55D6F4A73A5}" ProjectSection(SolutionItems) = preProject src\Test\Perf\readme.md = src\Test\Perf\readme.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeStyle", "CodeStyle", "{DC014586-8D07-4DE6-B28E-C0540C59C085}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.UnitTests", "src\Compilers\Core\CodeAnalysisTest\Microsoft.CodeAnalysis.UnitTests.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis", "src\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj", "{1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VBCSCompiler", "src\Compilers\Server\VBCSCompiler\VBCSCompiler.csproj", "{9508F118-F62E-4C16-A6F4-7C3B56E166AD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VBCSCompiler.UnitTests", "src\Compilers\Server\VBCSCompilerTests\VBCSCompiler.UnitTests.csproj", "{F5CE416E-B906-41D2-80B9-0078E887A3F6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csc", "src\Compilers\CSharp\csc\csc.csproj", "{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp", "src\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj", "{B501A547-C911-4A05-AC6E-274A50DFF30E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests", "src\Compilers\CSharp\Test\CommandLine\Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests.csproj", "{50D26304-0961-4A51-ABF6-6CAD1A56D203}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Emit.UnitTests", "src\Compilers\CSharp\Test\Emit\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj", "{4462B57A-7245-4146-B504-D46FDE762948}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests", "src\Compilers\CSharp\Test\IOperation\Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests.csproj", "{1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests", "src\Compilers\CSharp\Test\Semantic\Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests.csproj", "{B2C33A93-DB30-4099-903E-77D75C4C3F45}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests", "src\Compilers\CSharp\Test\Symbol\Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests.csproj", "{28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests", "src\Compilers\CSharp\Test\Syntax\Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests.csproj", "{50D26304-0961-4A51-ABF6-6CAD1A56D202}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compiler.Test.Resources", "src\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj", "{7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Test.Utilities", "src\Compilers\Test\Utilities\CSharp\Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj", "{4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Test.Utilities", "src\Compilers\Test\Utilities\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Test.Utilities.vbproj", "{4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic", "src\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj", "{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests", "src\Compilers\VisualBasic\Test\CommandLine\Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests.vbproj", "{E3B32027-3362-41DF-9172-4D3B623F42A5}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests", "src\Compilers\VisualBasic\Test\Emit\Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests.vbproj", "{190CE348-596E-435A-9E5B-12A689F9FC29}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Roslyn.Compilers.VisualBasic.IOperation.UnitTests", "src\Compilers\VisualBasic\Test\IOperation\Roslyn.Compilers.VisualBasic.IOperation.UnitTests.vbproj", "{9C9DABA4-0E72-4469-ADF1-4991F3CA572A}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests", "src\Compilers\VisualBasic\Test\Semantic\Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests.vbproj", "{BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests", "src\Compilers\VisualBasic\Test\Symbol\Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests.vbproj", "{BDA5D613-596D-4B61-837C-63554151C8F5}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests", "src\Compilers\VisualBasic\Test\Syntax\Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests.vbproj", "{91F6F646-4F6E-449A-9AB4-2986348F329D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Test.PdbUtilities", "src\Test\PdbUtilities\Roslyn.Test.PdbUtilities.csproj", "{AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces", "src\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj", "{5F8D2414-064A-4B3A-9B42-8E2A04246BE5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilersBoundTreeGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\BoundTreeGenerator\CompilersBoundTreeGenerator.csproj", "{02459936-CD2C-4F61-B671-5C518F2A3DDC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpErrorFactsGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\CSharpErrorFactsGenerator\CSharpErrorFactsGenerator.csproj", "{288089C5-8721-458E-BE3E-78990DAB5E2E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpSyntaxGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\CSharpSyntaxGenerator\CSharpSyntaxGenerator.csproj", "{288089C5-8721-458E-BE3E-78990DAB5E2D}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VisualBasicSyntaxGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\VisualBasicSyntaxGenerator\VisualBasicSyntaxGenerator.vbproj", "{6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.UnitTests", "src\Workspaces\CoreTest\Microsoft.CodeAnalysis.Workspaces.UnitTests.csproj", "{C50166F1-BABC-40A9-95EB-8200080CD701}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests", "src\Workspaces\CSharpTest\Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests.csproj", "{E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests", "src\Workspaces\VisualBasicTest\Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests.vbproj", "{E3FDC65F-568D-4E2D-A093-5132FD3793B7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VisualBasicErrorFactsGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\VisualBasicErrorFactsGenerator\VisualBasicErrorFactsGenerator.vbproj", "{909B656F-6095-4AC2-A5AB-C3F032315C45}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.Desktop", "src\Workspaces\Core\Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.csproj", "{2E87FA96-50BB-4607-8676-46521599F998}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.MSBuild", "src\Workspaces\Core\MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj", "{96EB2D3B-F694-48C6-A284-67382841E086}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Workspaces", "src\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj", "{21B239D0-D144-430F-A394-C066D58EE267}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Workspaces", "src\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj", "{57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RunTests", "src\Tools\Source\RunTests\RunTests.csproj", "{1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Features", "src\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj", "{A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Features", "src\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj", "{3973B09A-4FBF-44A5-8359-3D22CEB71F71}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Features", "src\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj", "{EDC68A0E-C68D-4A74-91B7-BF38EC909888}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Text", "src\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj", "{18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.EditorFeatures", "src\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj", "{49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.EditorFeatures", "src\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj", "{B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures", "src\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj", "{3CDEEAB7-2256-418A-BEB2-620B5CB16302}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests", "src\EditorFeatures\VisualBasicTest\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj", "{0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Scripting", "src\Scripting\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Scripting.vbproj", "{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting", "src\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj", "{12A68549-4E8C-42D6-8703-A09335F97997}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.UnitTests", "src\Scripting\CoreTest\Microsoft.CodeAnalysis.Scripting.UnitTests.csproj", "{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Scripting", "src\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj", "{066F0DBD-C46C-4C20-AFEC-99829A172625}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests", "src\Scripting\CSharpTest\Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests.csproj", "{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.InteractiveHost", "src\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj", "{8E2A252E-A140-45A6-A81A-2652996EA589}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests", "src\EditorFeatures\CSharpTest\Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj", "{AC2BCEFB-9298-4621-AC48-1FF5E639E48D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests", "src\EditorFeatures\CSharpTest2\Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj", "{16E93074-4252-466C-89A3-3B905ABAF779}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.UnitTests", "src\EditorFeatures\Test\Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj", "{8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.EditorFeatures2.UnitTests", "src\EditorFeatures\Test2\Microsoft.CodeAnalysis.EditorFeatures2.UnitTests.vbproj", "{3CEA0D69-00D3-40E5-A661-DC41EA07269B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities", "src\EditorFeatures\TestUtilities\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj", "{76C6F005-C89D-4348-BB4A-39189DDBEB52}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveHost32", "src\Interactive\HostProcess\InteractiveHost32.csproj", "{EBA4DFA1-6DED-418F-A485-A3B608978906}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveHost.UnitTests", "src\Interactive\HostTest\InteractiveHost.UnitTests.csproj", "{8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csi", "src\Interactive\csi\csi.csproj", "{14118347-ED06-4608-9C45-18228273C712}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "vbi", "src\Interactive\vbi\vbi.vbproj", "{6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices", "src\VisualStudio\Core\Def\Microsoft.VisualStudio.LanguageServices.csproj", "{86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.Implementation", "src\VisualStudio\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation.csproj", "{C0E80510-4FBE-4B0C-AF2C-4F473787722C}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.VisualStudio.LanguageServices.VisualBasic", "src\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj", "{D49439D7-56D2-450F-A4F0-74CB95D620E6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CSharp", "src\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj", "{5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests", "src\VisualStudio\CSharp\Test\Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.csproj", "{91C574AD-0352-47E9-A019-EE02CC32A396}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.VisualStudio.LanguageServices.UnitTests", "src\VisualStudio\Core\Test\Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj", "{A1455D30-55FC-45EF-8759-3AEBDB13D940}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup", "src\VisualStudio\Setup\Roslyn.VisualStudio.Setup.csproj", "{201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.DiagnosticsWindow", "src\VisualStudio\VisualStudioDiagnosticsToolWindow\Roslyn.VisualStudio.DiagnosticsWindow.csproj", "{A486D7DE-F614-409D-BB41-0FFDF582E35C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluatorPackage", "src\ExpressionEvaluator\Package\ExpressionEvaluatorPackage.csproj", "{B617717C-7881-4F01-AB6D-B1B6CC0483A0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ExpressionCompiler", "src\ExpressionEvaluator\CSharp\Source\ExpressionCompiler\Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.csproj", "{FD6BA96C-7905-4876-8BCC-E38E2CA64F31}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.UnitTests", "src\ExpressionEvaluator\CSharp\Test\ExpressionCompiler\Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.UnitTests.csproj", "{AE297965-4D56-4BA9-85EB-655AC4FC95A0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ResultProvider.UnitTests", "src\ExpressionEvaluator\CSharp\Test\ResultProvider\Microsoft.CodeAnalysis.CSharp.ResultProvider.UnitTests.csproj", "{60DB272A-21C9-4E8D-9803-FF4E132392C8}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler", "src\ExpressionEvaluator\VisualBasic\Source\ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.vbproj", "{73242A2D-6300-499D-8C15-FADF7ECB185C}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.UnitTests", "src\ExpressionEvaluator\VisualBasic\Test\ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.UnitTests.vbproj", "{AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExpressionCompiler", "src\ExpressionEvaluator\Core\Source\ExpressionCompiler\Microsoft.CodeAnalysis.ExpressionCompiler.csproj", "{B8DA3A90-A60C-42E3-9D8E-6C67B800C395}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ResultProvider.UnitTests", "src\ExpressionEvaluator\VisualBasic\Test\ResultProvider\Microsoft.CodeAnalysis.VisualBasic.ResultProvider.UnitTests.vbproj", "{ACE53515-482C-4C6A-E2D2-4242A687DFEE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExpressionCompiler.Utilities", "src\ExpressionEvaluator\Core\Test\ExpressionCompiler\Microsoft.CodeAnalysis.ExpressionCompiler.Utilities.csproj", "{21B80A31-8FF9-4E3A-8403-AABD635AEED9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResultProvider.Utilities", "src\ExpressionEvaluator\Core\Test\ResultProvider\Microsoft.CodeAnalysis.ResultProvider.Utilities.csproj", "{ABDBAC1E-350E-4DC3-BB45-3504404545EE}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AnalyzerDriver", "src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.shproj", "{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests", "src\Compilers\CSharp\Test\WinRT\Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests.csproj", "{FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Tasks.CodeAnalysis.UnitTests", "src\Compilers\Core\MSBuildTaskTests\Microsoft.Build.Tasks.CodeAnalysis.UnitTests.csproj", "{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicResultProvider", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.shproj", "{3140FE61-0856-4367-9AA3-8081B9A80E35}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "BasicResultProvider.NetFX20", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\NetFX20\BasicResultProvider.NetFX20.vbproj", "{76242A2D-2600-49DD-8C15-FEA07ECB1842}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ResultProvider", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.VisualBasic.ResultProvider.vbproj", "{76242A2D-2600-49DD-8C15-FEA07ECB1843}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpResultProvider", "src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.shproj", "{3140FE61-0856-4367-9AA3-8081B9A80E36}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpResultProvider.NetFX20", "src\ExpressionEvaluator\CSharp\Source\ResultProvider\NetFX20\CSharpResultProvider.NetFX20.csproj", "{BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ResultProvider", "src\ExpressionEvaluator\CSharp\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.CSharp.ResultProvider.csproj", "{BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ResultProvider", "src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.shproj", "{BB3CA047-5D00-48D4-B7D3-233C1265C065}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResultProvider.NetFX20", "src\ExpressionEvaluator\Core\Source\ResultProvider\NetFX20\ResultProvider.NetFX20.csproj", "{BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResultProvider", "src\ExpressionEvaluator\Core\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.ResultProvider.csproj", "{FA0E905D-EC46-466D-B7B2-3B5557F9428C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbc", "src\Compilers\VisualBasic\vbc\vbc.csproj", "{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests", "src\Scripting\CoreTest.Desktop\Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests.csproj", "{6FD1CC3E-6A99-4736-9B8D-757992DDE75D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests", "src\Scripting\CSharpTest.Desktop\Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests.csproj", "{286B01F3-811A-40A7-8C1F-10C9BB0597F7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Scripting.Desktop.UnitTests", "src\Scripting\VisualBasicTest.Desktop\Microsoft.CodeAnalysis.VisualBasic.Scripting.Desktop.UnitTests.vbproj", "{24973B4C-FD09-4EE1-97F4-EA03E6B12040}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests", "src\Scripting\VisualBasicTest\Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests.vbproj", "{ABC7262E-1053-49F3-B846-E3091BB92E8C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Hosting.Diagnostics", "src\Test\Diagnostics\Roslyn.Hosting.Diagnostics.csproj", "{E2E889A5-2489-4546-9194-47C63E49EAEB}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicAnalyzerDriver", "src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.shproj", "{E8F0BAA5-7327-43D1-9A51-644E81AE55F1}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzerDriver", "src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.shproj", "{54E08BF5-F819-404F-A18D-0AB9EA81EA04}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CommandLine", "src\Compilers\Core\CommandLine\CommandLine.shproj", "{AD6F474E-E6D4-4217-91F3-B7AF1BE31CCC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Compilers.Extension", "src\Compilers\Extension\Roslyn.Compilers.Extension.csproj", "{43026D51-3083-4850-928D-07E1883D5B1A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.Setup", "src\VisualStudio\IntegrationTest\TestSetup\Microsoft.VisualStudio.IntegrationTest.Setup.csproj", "{A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}" ProjectSection(ProjectDependencies) = postProject {600AF682-E097-407B-AD85-EE3CED37E680} = {600AF682-E097-407B-AD85-EE3CED37E680} {A486D7DE-F614-409D-BB41-0FFDF582E35C} = {A486D7DE-F614-409D-BB41-0FFDF582E35C} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.IntegrationTests", "src\VisualStudio\IntegrationTest\IntegrationTests\Microsoft.VisualStudio.LanguageServices.IntegrationTests.csproj", "{E5A55C16-A5B9-4874-9043-A5266DC02F58}" ProjectSection(ProjectDependencies) = postProject {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2} = {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.Utilities", "src\VisualStudio\IntegrationTest\TestUtilities\Microsoft.VisualStudio.IntegrationTest.Utilities.csproj", "{3BED15FD-D608-4573-B432-1569C1026F6D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.PerformanceTests", "src\Test\Perf\tests\Roslyn.PerformanceTests.csproj", "{DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.Xaml", "src\VisualStudio\Xaml\Impl\Microsoft.VisualStudio.LanguageServices.Xaml.csproj", "{971E832B-7471-48B5-833E-5913188EC0E4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Test.Performance.Utilities", "src\Test\Perf\Utilities\Roslyn.Test.Performance.Utilities.csproj", "{59AD474E-2A35-4E8A-A74D-E33479977FBF}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Debugging", "src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.shproj", "{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.PooledObjects", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.shproj", "{C1930979-C824-496B-A630-70F5369A636F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Workspaces", "src\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj", "{F822F72A-CC87-4E31-B57D-853F65CBEBF3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.ServiceHub", "src\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj", "{80FDDD00-9393-47F7-8BAF-7E87CE011068}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Tasks.CodeAnalysis", "src\Compilers\Core\MSBuildTask\Microsoft.Build.Tasks.CodeAnalysis.csproj", "{7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Next.UnitTests", "src\VisualStudio\Core\Test.Next\Roslyn.VisualStudio.Next.UnitTests.csproj", "{2E1658E2-5045-4F85-A64C-C0ECCD39F719}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildBoss", "src\Tools\BuildBoss\BuildBoss.csproj", "{9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.TestUtilities", "src\Scripting\CoreTestUtilities\Microsoft.CodeAnalysis.Scripting.TestUtilities.csproj", "{21A01C2D-2501-4619-8144-48977DD22D9C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.Test.Utilities", "src\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj", "{3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2", "src\EditorFeatures\TestUtilities2\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj", "{3DFB4701-E3D6-4435-9F70-A6E35822C4F2}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.VisualStudio.LanguageServices.Test.Utilities2", "src\VisualStudio\TestUtilities2\Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj", "{69F853E5-BD04-4842-984F-FC68CC51F402}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.FunctionResolver", "src\ExpressionEvaluator\Core\Source\FunctionResolver\Microsoft.CodeAnalysis.FunctionResolver.csproj", "{6FC8E6F5-659C-424D-AEB5-331B95883E29}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.FunctionResolver.UnitTests", "src\ExpressionEvaluator\Core\Test\FunctionResolver\Microsoft.CodeAnalysis.FunctionResolver.UnitTests.csproj", "{DD317BE1-42A1-4795-B1D4-F370C40D649A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Razor.ServiceHub", "src\Workspaces\Remote\Razor\Microsoft.CodeAnalysis.Remote.Razor.ServiceHub.csproj", "{B6FC05F2-0E49-4BE2-8030-ACBB82B7F431}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup.Dependencies", "src\VisualStudio\Setup.Dependencies\Roslyn.VisualStudio.Setup.Dependencies.csproj", "{1688E1E5-D510-4E06-86F3-F8DB10B1393D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackDepthTest", "src\Test\Perf\StackDepthTest\StackDepthTest.csproj", "{F040CEC5-5E11-4DBD-9F6A-250478E28177}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle", "src\CodeStyle\Core\Analyzers\Microsoft.CodeAnalysis.CodeStyle.csproj", "{275812EE-DEDB-4232-9439-91C9757D2AE4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.Fixes", "src\CodeStyle\Core\CodeFixes\Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj", "{5FF1E493-69CC-4D0B-83F2-039F469A04E1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle", "src\CodeStyle\CSharp\Analyzers\Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj", "{AA87BFED-089A-4096-B8D5-690BDC7D5B24}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes", "src\CodeStyle\CSharp\CodeFixes\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj", "{A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}" ProjectSection(ProjectDependencies) = postProject {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} = {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} EndProjectSection EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle", "src\CodeStyle\VisualBasic\Analyzers\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj", "{2531A8C4-97DD-47BC-A79C-B7846051E137}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes", "src\CodeStyle\VisualBasic\CodeFixes\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj", "{0141285D-8F6C-42C7-BAF3-3C0CCD61C716}" ProjectSection(ProjectDependencies) = postProject {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} = {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj", "{9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests", "src\CodeStyle\CSharp\Tests\Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj", "{5018D049-5870-465A-889B-C742CE1E31CB}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests", "src\CodeStyle\VisualBasic\Tests\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj", "{E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Wpf", "src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj", "{FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnalyzerRunner", "src\Tools\AnalyzerRunner\AnalyzerRunner.csproj", "{60166C60-813C-46C4-911D-2411B4ABBC0F}" ProjectSection(ProjectDependencies) = postProject {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2} = {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2} {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD} = {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD} {3CDEEAB7-2256-418A-BEB2-620B5CB16302} = {3CDEEAB7-2256-418A-BEB2-620B5CB16302} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Debugging.Package", "src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.Package.csproj", "{FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PooledObjects.Package", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.Package.csproj", "{49E7C367-181B-499C-AC2E-8E17C81418D6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests", "src\Workspaces\MSBuildTest\Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj", "{037F06F0-3BE8-42D0-801E-2F74FC380AB8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveHost64", "src\Interactive\HostProcess\InteractiveHost64.csproj", "{2F11618A-9251-4609-B3D5-CE4D2B3D3E49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.IntegrationService", "src\VisualStudio\IntegrationTest\IntegrationService\Microsoft.VisualStudio.IntegrationTest.IntegrationService.csproj", "{764D2C19-0187-4837-A2A3-96DDC6EF4CE2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Net.Compilers.Package", "src\NuGet\Microsoft.Net.Compilers\Microsoft.Net.Compilers.Package.csproj", "{9102ECF3-5CD1-4107-B8B7-F3795A52D790}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NETCore.Compilers.Package", "src\NuGet\Microsoft.NETCore.Compilers\Microsoft.NETCore.Compilers.Package.csproj", "{50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compilers.Package", "src\NuGet\Microsoft.CodeAnalysis.Compilers.Package.csproj", "{CFA94A39-4805-456D-A369-FC35CCC170E9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{C52D8057-43AF-40E6-A01B-6CDBB7301985}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.Package", "src\NuGet\Microsoft.CodeAnalysis.Scripting.Package.csproj", "{4A490CBC-37F4-4859-AFDB-4B0833D144AF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Package", "src\NuGet\Microsoft.CodeAnalysis.EditorFeatures.Package.csproj", "{34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{BE25E872-1667-4649-9D19-96B83E75A44E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VS.ExternalAPIs.Roslyn.Package", "src\NuGet\VisualStudio\VS.ExternalAPIs.Roslyn.Package.csproj", "{0EB22BD1-B8B1-417D-8276-F475C2E190FF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VS.Tools.Roslyn.Package", "src\NuGet\VisualStudio\VS.Tools.Roslyn.Package.csproj", "{3636D3E2-E3EF-4815-B020-819F382204CD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Package", "src\NuGet\Microsoft.CodeAnalysis.Package.csproj", "{B9843F65-262E-4F40-A0BC-2CBEF7563A44}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compilers.Setup", "src\Setup\DevDivVsix\CompilersPackage\Microsoft.CodeAnalysis.Compilers.Setup.csproj", "{03607817-6800-40B6-BEAA-D6F437CD62B7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Installer.Package", "src\Setup\Installer\Installer.Package.csproj", "{6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.Desktop.UnitTests", "src\Workspaces\DesktopTest\Microsoft.CodeAnalysis.Workspaces.Desktop.UnitTests.csproj", "{23405307-7EFF-4774-8B11-8F5885439761}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Insertion", "Insertion", "{AFA5F921-0650-45E8-B293-51A0BB89DEA0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevDivInsertionFiles", "src\Setup\DevDivInsertionFiles\DevDivInsertionFiles.csproj", "{6362616E-6A47-48F0-9EE0-27800B306ACB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExternalAccess", "ExternalAccess", "{8977A560-45C2-4EC2-A849-97335B382C74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp", "src\Tools\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj", "{BD8CE303-5F04-45EC-8DCF-73C9164CD614}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor", "src\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj", "{2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CodeLens", "src\VisualStudio\CodeLens\Microsoft.VisualStudio.LanguageServices.CodeLens.csproj", "{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Net.Compilers.Toolset.Package", "src\NuGet\Microsoft.Net.Compilers.Toolset\Microsoft.Net.Compilers.Toolset.Package.csproj", "{A74C7D2E-92FA-490A-B80A-28BEF56B56FC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServer.Protocol", "src\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj", "{686BF57E-A6FF-467B-AAB3-44DE916A9772}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests", "src\Features\LanguageServer\ProtocolUnitTests\Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests.csproj", "{1DDE89EE-5819-441F-A060-2FF4A986F372}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Debugger", "src\Tools\ExternalAccess\Debugger\Microsoft.CodeAnalysis.ExternalAccess.Debugger.csproj", "{655A5B07-39B8-48CD-8590-8AC0C2B708D8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote", "src\Tools\ExternalAccess\Xamarin.Remote\Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote.csproj", "{DE53934B-7FC1-48A0-85AB-C519FBBD02CF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup.ServiceHub", "src\Setup\DevDivVsix\ServiceHubConfig\Roslyn.VisualStudio.Setup.ServiceHub.csproj", "{3D33BBFD-EC63-4E8C-A714-0A48A3809A87}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests", "src\Tools\ExternalAccess\FSharpTest\Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj", "{BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Apex", "src\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj", "{FC32EF16-31B1-47B3-B625-A80933CB3F29}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.LiveShare", "src\VisualStudio\LiveShare\Impl\Microsoft.VisualStudio.LanguageServices.LiveShare.csproj", "{453C8E28-81D4-431E-BFB0-F3D413346E51}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests", "src\VisualStudio\LiveShare\Test\Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests.csproj", "{CE7F7553-DB2D-4839-92E3-F042E4261B4E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdeBenchmarks", "src\Tools\IdeBenchmarks\IdeBenchmarks.csproj", "{FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{157EA250-2F28-4948-A8F2-D58EAEA05DC8}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .vsconfig = .vsconfig EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilersIOperationGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\IOperationGenerator\CompilersIOperationGenerator.csproj", "{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator", "src\Features\Lsif\Generator\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.csproj", "{B9899CF1-E0EB-4599-9E24-6939A04B4979}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests", "src\Features\Lsif\GeneratorTest\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.vbproj", "{D15BF03E-04ED-4BEE-A72B-7620F541F4E2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{4A49D526-1644-4819-AA4F-95B348D447D4}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.shproj", "{EC946164-1E17-410B-B7D9-7DE7E6268D63}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.shproj", "{99F594B1-3916-471D-A761-A6731FC50E9A}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.shproj", "{699FEA05-AEA7-403D-827E-53CF4E826955}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.shproj", "{438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzers.UnitTests", "src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.shproj", "{58969243-7F59-4236-93D0-C93B81F569B3}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.shproj", "{CEC0DCE7-8D52-45C3-9295-FC7B16BD2451}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.shproj", "{E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicAnalyzers.UnitTests", "src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.shproj", "{7B7F4153-AE93-4908-B8F0-430871589F83}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzers", "src\Analyzers\Core\Analyzers\Analyzers.shproj", "{76E96966-4780-4040-8197-BDE2879516F4}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CodeFixes", "src\Analyzers\Core\CodeFixes\CodeFixes.shproj", "{1B6C4A1A-413B-41FB-9F85-5C09118E541B}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzers", "src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.shproj", "{EAFFCA55-335B-4860-BB99-EFCEAD123199}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCodeFixes", "src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.shproj", "{DA973826-C985-4128-9948-0B445E638BDB}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicAnalyzers", "src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.shproj", "{94FAF461-2E74-4DBB-9813-6B2CDE6F1880}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicCodeFixes", "src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.shproj", "{9F9CCC78-7487-4127-9D46-DB23E501F001}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedUtilitiesAndExtensions", "SharedUtilitiesAndExtensions", "{DF17AF27-AA02-482B-8946-5CA8A50D5A2B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler", "Compiler", "{7A69EA65-4411-4CD0-B439-035E720C1BD3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspace", "Workspace", "{9C1BE25C-5926-4E56-84AE-D2242CB0627E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities", "src\EditorFeatures\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj", "{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities.csproj", "{2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdeCoreBenchmarks", "src\Tools\IdeCoreBenchmarks\IdeCoreBenchmarks.csproj", "{CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildValidator", "src\Tools\BuildValidator\BuildValidator.csproj", "{8D22FC91-BDFE-4342-999B-D695E1C57E85}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildActionTelemetryTable", "src\Tools\BuildActionTelemetryTable\BuildActionTelemetryTable.csproj", "{2801F82B-78CE-4BAE-B06F-537574751E2E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrepareTests", "src\Tools\PrepareTests\PrepareTests.csproj", "{9B25E472-DF94-4E24-9F5D-E487CE5A91FB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Cocoa", "src\EditorFeatures\Core.Cocoa\Microsoft.CodeAnalysis.EditorFeatures.Cocoa.csproj", "{67F44564-759B-4643-BD86-407B010B0B74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Test.Utilities", "src\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj", "{5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.TestSourceGenerator", "src\Workspaces\TestSourceGenerator\Microsoft.CodeAnalysis.TestSourceGenerator.csproj", "{21B50E65-D601-4D82-B98A-FFE6DE3B25DC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.XunitHook", "src\EditorFeatures\XunitHook\Microsoft.CodeAnalysis.XunitHook.csproj", "{967A8F5E-7D18-436C-97ED-1DB303FE5DE0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeStyleConfigFileGenerator", "src\CodeStyle\Tools\CodeStyleConfigFileGenerator.csproj", "{41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Collections", "src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.shproj", "{E919DD77-34F8-4F57-8058-4D3FF4C2B241}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Collections.Package", "src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.Package.csproj", "{0C2E1633-1462-4712-88F4-A0C945BAD3A8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Rebuild", "src\Compilers\Core\Rebuild\Microsoft.CodeAnalysis.Rebuild.csproj", "{B7D29559-4360-434A-B9B9-2C0612287999}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Rebuild.UnitTests", "src\Compilers\Core\RebuildTest\Microsoft.CodeAnalysis.Rebuild.UnitTests.csproj", "{21B49277-E55A-45EF-8818-744BCD6CB732}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests", "src\Tools\ExternalAccess\RazorTest\Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests.csproj", "{BB987FFC-B758-4F73-96A3-923DE8DCFF1A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp", "src\Tools\ExternalAccess\OmniSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj", "{1B73FB08-9A17-497E-97C5-FA312867D51B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp", "src\Tools\ExternalAccess\OmniSharp.CSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj", "{AE976DE9-811D-4C86-AEBB-DCDC1226D754}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests", "src\Tools\ExternalAccess\OmniSharpTest\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj", "{3829F774-33F2-41E9-B568-AE555004FC62}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{0be66736-cdaa-4989-88b1-b3f46ebdca4a}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{1b6c4a1a-413b-41fb-9f85-5c09118e541b}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5 src\Analyzers\Core\Analyzers\Analyzers.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e35}*SharedItemsImports = 13 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e36}*SharedItemsImports = 13 src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{438db8af-f3f0-4ed9-80b5-13fddd5b8787}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{5018d049-5870-465a-889b-c742ce1e31cb}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{58969243-7f59-4236-93d0-c93b81f569b3}*SharedItemsImports = 13 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{60db272a-21c9-4e8d-9803-ff4e132392c8}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{699fea05-aea7-403d-827e-53cf4e826955}*SharedItemsImports = 13 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1842}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1843}*SharedItemsImports = 5 src\Analyzers\Core\Analyzers\Analyzers.projitems*{76e96966-4780-4040-8197-bde2879516f4}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{94faf461-2e74-4dbb-9813-6b2cde6f1880}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{99f594b1-3916-471d-a761-a6731fc50e9a}*SharedItemsImports = 13 src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{9f9ccc78-7487-4127-9d46-db23e501f001}*SharedItemsImports = 13 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{abdbac1e-350e-4dc3-bb45-3504404545ee}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{ac2bcefb-9298-4621-ac48-1ff5e639e48d}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{ace53515-482c-4c6a-e2d2-4242a687dfee}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bb3ca047-5d00-48d4-b7d3-233c1265c065}*SharedItemsImports = 13 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bedc5a4a-809e-4017-9cfd-6c8d4e1847f0}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d3}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d4}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{cec0dce7-8d52-45c3-9295-fc7b16bd2451}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{da973826-c985-4128-9948-0b445e638bdb}*SharedItemsImports = 13 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{e512c6c1-f085-4ad7-b0d9-e8f1a0a2a510}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{e8f0baa5-7327-43d1-9a51-644e81ae55f1}*SharedItemsImports = 13 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{e919dd77-34f8-4f57-8058-4d3ff4c2b241}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{e9dbfa41-7a9c-49be-bd36-fd71b31aa9fe}*SharedItemsImports = 13 src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{eaffca55-335b-4860-bb99-efcead123199}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{ec946164-1e17-410b-b7d9-7de7e6268d63}*SharedItemsImports = 13 src\Analyzers\Core\Analyzers\Analyzers.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {600AF682-E097-407B-AD85-EE3CED37E680}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600AF682-E097-407B-AD85-EE3CED37E680}.Debug|Any CPU.Build.0 = Debug|Any CPU {600AF682-E097-407B-AD85-EE3CED37E680}.Release|Any CPU.ActiveCfg = Release|Any CPU {600AF682-E097-407B-AD85-EE3CED37E680}.Release|Any CPU.Build.0 = Release|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Release|Any CPU.Build.0 = Release|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Release|Any CPU.Build.0 = Release|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Release|Any CPU.ActiveCfg = Release|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Release|Any CPU.Build.0 = Release|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Release|Any CPU.Build.0 = Release|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Release|Any CPU.Build.0 = Release|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Release|Any CPU.Build.0 = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Debug|Any CPU.Build.0 = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Release|Any CPU.ActiveCfg = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Release|Any CPU.Build.0 = Release|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Debug|Any CPU.Build.0 = Debug|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Release|Any CPU.ActiveCfg = Release|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Release|Any CPU.Build.0 = Release|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Release|Any CPU.Build.0 = Release|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Debug|Any CPU.Build.0 = Debug|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Release|Any CPU.ActiveCfg = Release|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Release|Any CPU.Build.0 = Release|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Release|Any CPU.Build.0 = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Debug|Any CPU.Build.0 = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Release|Any CPU.ActiveCfg = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Release|Any CPU.Build.0 = Release|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Release|Any CPU.Build.0 = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Release|Any CPU.Build.0 = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Release|Any CPU.Build.0 = Release|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Release|Any CPU.ActiveCfg = Release|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Release|Any CPU.Build.0 = Release|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Release|Any CPU.Build.0 = Release|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Debug|Any CPU.Build.0 = Debug|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Release|Any CPU.ActiveCfg = Release|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Release|Any CPU.Build.0 = Release|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Release|Any CPU.Build.0 = Release|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Release|Any CPU.Build.0 = Release|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Release|Any CPU.ActiveCfg = Release|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Release|Any CPU.Build.0 = Release|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Debug|Any CPU.Build.0 = Debug|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Release|Any CPU.ActiveCfg = Release|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Release|Any CPU.Build.0 = Release|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Release|Any CPU.Build.0 = Release|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Debug|Any CPU.Build.0 = Debug|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Release|Any CPU.Build.0 = Release|Any CPU {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Debug|Any CPU.ActiveCfg = Debug|x64 {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Debug|Any CPU.Build.0 = Debug|x64 {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Release|Any CPU.ActiveCfg = Release|x64 {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Release|Any CPU.Build.0 = Release|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Debug|Any CPU.ActiveCfg = Debug|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Debug|Any CPU.Build.0 = Debug|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Release|Any CPU.ActiveCfg = Release|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Release|Any CPU.Build.0 = Release|x64 {288089C5-8721-458E-BE3E-78990DAB5E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {288089C5-8721-458E-BE3E-78990DAB5E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU {288089C5-8721-458E-BE3E-78990DAB5E2D}.Release|Any CPU.ActiveCfg = Release|Any CPU {288089C5-8721-458E-BE3E-78990DAB5E2D}.Release|Any CPU.Build.0 = Release|Any CPU {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Debug|Any CPU.ActiveCfg = Debug|x64 {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Debug|Any CPU.Build.0 = Debug|x64 {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Release|Any CPU.ActiveCfg = Release|x64 {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Release|Any CPU.Build.0 = Release|x64 {C50166F1-BABC-40A9-95EB-8200080CD701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C50166F1-BABC-40A9-95EB-8200080CD701}.Debug|Any CPU.Build.0 = Debug|Any CPU {C50166F1-BABC-40A9-95EB-8200080CD701}.Release|Any CPU.ActiveCfg = Release|Any CPU {C50166F1-BABC-40A9-95EB-8200080CD701}.Release|Any CPU.Build.0 = Release|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Release|Any CPU.Build.0 = Release|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Release|Any CPU.Build.0 = Release|Any CPU {909B656F-6095-4AC2-A5AB-C3F032315C45}.Debug|Any CPU.ActiveCfg = Debug|x64 {909B656F-6095-4AC2-A5AB-C3F032315C45}.Debug|Any CPU.Build.0 = Debug|x64 {909B656F-6095-4AC2-A5AB-C3F032315C45}.Release|Any CPU.ActiveCfg = Release|x64 {909B656F-6095-4AC2-A5AB-C3F032315C45}.Release|Any CPU.Build.0 = Release|x64 {2E87FA96-50BB-4607-8676-46521599F998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E87FA96-50BB-4607-8676-46521599F998}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E87FA96-50BB-4607-8676-46521599F998}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E87FA96-50BB-4607-8676-46521599F998}.Release|Any CPU.Build.0 = Release|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Debug|Any CPU.Build.0 = Debug|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Release|Any CPU.ActiveCfg = Release|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Release|Any CPU.Build.0 = Release|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Release|Any CPU.Build.0 = Release|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Release|Any CPU.ActiveCfg = Release|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Release|Any CPU.Build.0 = Release|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Release|Any CPU.Build.0 = Release|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Release|Any CPU.Build.0 = Release|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Debug|Any CPU.Build.0 = Debug|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Release|Any CPU.ActiveCfg = Release|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Release|Any CPU.Build.0 = Release|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Release|Any CPU.Build.0 = Release|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Release|Any CPU.Build.0 = Release|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Debug|Any CPU.Build.0 = Debug|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Release|Any CPU.ActiveCfg = Release|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Release|Any CPU.Build.0 = Release|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Release|Any CPU.Build.0 = Release|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|Any CPU.ActiveCfg = Release|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|Any CPU.Build.0 = Release|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Debug|Any CPU.Build.0 = Debug|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Release|Any CPU.ActiveCfg = Release|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Release|Any CPU.Build.0 = Release|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|Any CPU.Build.0 = Release|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Debug|Any CPU.Build.0 = Debug|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Release|Any CPU.ActiveCfg = Release|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Release|Any CPU.Build.0 = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|Any CPU.Build.0 = Release|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|Any CPU.Build.0 = Debug|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|Any CPU.ActiveCfg = Release|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|Any CPU.Build.0 = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|Any CPU.Build.0 = Release|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Release|Any CPU.Build.0 = Release|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Release|Any CPU.Build.0 = Release|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Debug|Any CPU.Build.0 = Debug|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Release|Any CPU.ActiveCfg = Release|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Release|Any CPU.Build.0 = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Release|Any CPU.Build.0 = Release|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Release|Any CPU.ActiveCfg = Release|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Release|Any CPU.Build.0 = Release|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Debug|Any CPU.Build.0 = Debug|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Release|Any CPU.ActiveCfg = Release|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Release|Any CPU.Build.0 = Release|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Release|Any CPU.ActiveCfg = Release|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Release|Any CPU.Build.0 = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Release|Any CPU.Build.0 = Release|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Debug|Any CPU.Build.0 = Debug|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Release|Any CPU.ActiveCfg = Release|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Release|Any CPU.Build.0 = Release|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|Any CPU.Build.0 = Release|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Debug|Any CPU.Build.0 = Debug|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Release|Any CPU.ActiveCfg = Release|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Release|Any CPU.Build.0 = Release|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Release|Any CPU.Build.0 = Release|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Release|Any CPU.Build.0 = Release|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Release|Any CPU.Build.0 = Release|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Debug|Any CPU.Build.0 = Debug|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Release|Any CPU.ActiveCfg = Release|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Release|Any CPU.Build.0 = Release|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Release|Any CPU.Build.0 = Release|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Release|Any CPU.Build.0 = Release|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Debug|Any CPU.Build.0 = Debug|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Release|Any CPU.ActiveCfg = Release|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Release|Any CPU.Build.0 = Release|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Release|Any CPU.Build.0 = Release|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Debug|Any CPU.Build.0 = Debug|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Release|Any CPU.ActiveCfg = Release|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Release|Any CPU.Build.0 = Release|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Release|Any CPU.Build.0 = Release|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Release|Any CPU.Build.0 = Release|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Debug|Any CPU.Build.0 = Debug|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Release|Any CPU.ActiveCfg = Release|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Release|Any CPU.Build.0 = Release|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Release|Any CPU.Build.0 = Release|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Release|Any CPU.Build.0 = Release|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Release|Any CPU.Build.0 = Release|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Release|Any CPU.Build.0 = Release|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Release|Any CPU.Build.0 = Release|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Debug|Any CPU.Build.0 = Debug|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Release|Any CPU.Build.0 = Release|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.Build.0 = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|Any CPU.Build.0 = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Release|Any CPU.ActiveCfg = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Release|Any CPU.Build.0 = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Debug|Any CPU.Build.0 = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Release|Any CPU.ActiveCfg = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Release|Any CPU.Build.0 = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Release|Any CPU.Build.0 = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Release|Any CPU.Build.0 = Release|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Release|Any CPU.Build.0 = Release|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Debug|Any CPU.Build.0 = Debug|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Release|Any CPU.ActiveCfg = Release|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Release|Any CPU.Build.0 = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.Build.0 = Release|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Release|Any CPU.Build.0 = Release|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Release|Any CPU.Build.0 = Release|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Debug|Any CPU.Build.0 = Debug|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Release|Any CPU.ActiveCfg = Release|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Release|Any CPU.Build.0 = Release|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|Any CPU.Build.0 = Debug|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|Any CPU.ActiveCfg = Release|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|Any CPU.Build.0 = Release|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Release|Any CPU.Build.0 = Release|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Release|Any CPU.Build.0 = Release|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Debug|Any CPU.Build.0 = Debug|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Release|Any CPU.ActiveCfg = Release|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Release|Any CPU.Build.0 = Release|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Release|Any CPU.Build.0 = Release|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Release|Any CPU.Build.0 = Release|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Release|Any CPU.Build.0 = Release|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Release|Any CPU.Build.0 = Release|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Debug|Any CPU.Build.0 = Debug|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Release|Any CPU.ActiveCfg = Release|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Release|Any CPU.Build.0 = Release|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Release|Any CPU.Build.0 = Release|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Debug|Any CPU.Build.0 = Debug|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Release|Any CPU.ActiveCfg = Release|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Release|Any CPU.Build.0 = Release|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Release|Any CPU.Build.0 = Release|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Release|Any CPU.Build.0 = Release|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Release|Any CPU.Build.0 = Release|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Debug|Any CPU.Build.0 = Debug|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Release|Any CPU.ActiveCfg = Release|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Release|Any CPU.Build.0 = Release|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Release|Any CPU.ActiveCfg = Release|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Release|Any CPU.Build.0 = Release|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Release|Any CPU.Build.0 = Release|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Debug|Any CPU.Build.0 = Debug|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Release|Any CPU.ActiveCfg = Release|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Release|Any CPU.Build.0 = Release|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Release|Any CPU.Build.0 = Release|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Release|Any CPU.Build.0 = Release|Any CPU {B6FC05F2-0E49-4BE2-8030-ACBB82B7F431}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B6FC05F2-0E49-4BE2-8030-ACBB82B7F431}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6FC05F2-0E49-4BE2-8030-ACBB82B7F431}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6FC05F2-0E49-4BE2-8030-ACBB82B7F431}.Release|Any CPU.Build.0 = Release|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Debug|Any CPU.Build.0 = Debug|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Release|Any CPU.ActiveCfg = Release|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Release|Any CPU.Build.0 = Release|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Debug|Any CPU.Build.0 = Debug|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Release|Any CPU.ActiveCfg = Release|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Release|Any CPU.Build.0 = Release|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Release|Any CPU.Build.0 = Release|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Release|Any CPU.Build.0 = Release|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Release|Any CPU.Build.0 = Release|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Debug|Any CPU.Build.0 = Debug|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Release|Any CPU.ActiveCfg = Release|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Release|Any CPU.Build.0 = Release|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Debug|Any CPU.Build.0 = Debug|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Release|Any CPU.ActiveCfg = Release|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Release|Any CPU.Build.0 = Release|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Debug|Any CPU.Build.0 = Debug|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Release|Any CPU.ActiveCfg = Release|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Release|Any CPU.Build.0 = Release|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Release|Any CPU.ActiveCfg = Release|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Release|Any CPU.Build.0 = Release|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Release|Any CPU.Build.0 = Release|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Debug|Any CPU.Build.0 = Debug|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Release|Any CPU.ActiveCfg = Release|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Release|Any CPU.Build.0 = Release|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Release|Any CPU.Build.0 = Release|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Release|Any CPU.Build.0 = Release|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Release|Any CPU.Build.0 = Release|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Release|Any CPU.Build.0 = Release|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Release|Any CPU.Build.0 = Release|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Release|Any CPU.Build.0 = Release|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Release|Any CPU.Build.0 = Release|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Debug|Any CPU.Build.0 = Debug|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Release|Any CPU.ActiveCfg = Release|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Release|Any CPU.Build.0 = Release|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Debug|Any CPU.Build.0 = Debug|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Release|Any CPU.ActiveCfg = Release|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Release|Any CPU.Build.0 = Release|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Release|Any CPU.Build.0 = Release|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Release|Any CPU.Build.0 = Release|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Release|Any CPU.ActiveCfg = Release|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Release|Any CPU.Build.0 = Release|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Release|Any CPU.Build.0 = Release|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Release|Any CPU.Build.0 = Release|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Debug|Any CPU.Build.0 = Debug|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Release|Any CPU.Build.0 = Release|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Release|Any CPU.Build.0 = Release|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Release|Any CPU.Build.0 = Release|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Debug|Any CPU.Build.0 = Debug|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Release|Any CPU.ActiveCfg = Release|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Release|Any CPU.Build.0 = Release|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Release|Any CPU.Build.0 = Release|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Release|Any CPU.Build.0 = Release|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Release|Any CPU.Build.0 = Release|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Release|Any CPU.Build.0 = Release|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Release|Any CPU.Build.0 = Release|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Debug|Any CPU.Build.0 = Debug|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Release|Any CPU.ActiveCfg = Release|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Release|Any CPU.Build.0 = Release|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Debug|Any CPU.Build.0 = Debug|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Release|Any CPU.ActiveCfg = Release|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Release|Any CPU.Build.0 = Release|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Release|Any CPU.Build.0 = Release|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Release|Any CPU.Build.0 = Release|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Release|Any CPU.Build.0 = Release|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Release|Any CPU.Build.0 = Release|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Release|Any CPU.Build.0 = Release|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Debug|Any CPU.Build.0 = Debug|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Release|Any CPU.ActiveCfg = Release|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Release|Any CPU.Build.0 = Release|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Release|Any CPU.Build.0 = Release|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Release|Any CPU.Build.0 = Release|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.Build.0 = Release|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Debug|Any CPU.Build.0 = Debug|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Release|Any CPU.Build.0 = Release|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Debug|Any CPU.Build.0 = Debug|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Release|Any CPU.ActiveCfg = Release|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Release|Any CPU.Build.0 = Release|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.Build.0 = Release|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Release|Any CPU.Build.0 = Release|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Release|Any CPU.Build.0 = Release|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Release|Any CPU.Build.0 = Release|Any CPU {2801F82B-78CE-4BAE-B06F-537574751E2E}.Debug|Any CPU.ActiveCfg = Debug|x86 {2801F82B-78CE-4BAE-B06F-537574751E2E}.Debug|Any CPU.Build.0 = Debug|x86 {2801F82B-78CE-4BAE-B06F-537574751E2E}.Release|Any CPU.ActiveCfg = Release|x86 {2801F82B-78CE-4BAE-B06F-537574751E2E}.Release|Any CPU.Build.0 = Release|x86 {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Debug|Any CPU.Build.0 = Debug|Any CPU {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Release|Any CPU.Build.0 = Release|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Debug|Any CPU.Build.0 = Debug|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Release|Any CPU.ActiveCfg = Release|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Release|Any CPU.Build.0 = Release|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Release|Any CPU.ActiveCfg = Release|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Release|Any CPU.Build.0 = Release|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Release|Any CPU.Build.0 = Release|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Release|Any CPU.Build.0 = Release|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Debug|Any CPU.Build.0 = Debug|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Release|Any CPU.ActiveCfg = Release|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Release|Any CPU.Build.0 = Release|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Debug|Any CPU.Build.0 = Debug|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Release|Any CPU.ActiveCfg = Release|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Release|Any CPU.Build.0 = Release|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Release|Any CPU.Build.0 = Release|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Release|Any CPU.Build.0 = Release|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Release|Any CPU.Build.0 = Release|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Release|Any CPU.Build.0 = Release|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.Build.0 = Release|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Debug|Any CPU.Build.0 = Debug|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Release|Any CPU.ActiveCfg = Release|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {32A48625-F0AD-419D-828B-A50BDABA38EA} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {C65C6143-BED3-46E6-869E-9F0BE6E84C37} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {913A4C08-898E-49C7-9692-0EF9DC56CF6E} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {4C81EBB2-82E1-4C81-80C4-84CC40FA281B} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {19148439-436F-4CDA-B493-70AF4FFC13E9} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} {7E907718-0B33-45C8-851F-396CEFDC1AB6} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} = {8DBA5174-B0AA-4561-82B1-A46607697753} {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} = {CAD2965A-19AB-489F-BE2E-7649957F914A} {DC014586-8D07-4DE6-B28E-C0540C59C085} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {A4C99B85-765C-4C65-9C2A-BB609AAB09E6} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {9508F118-F62E-4C16-A6F4-7C3B56E166AD} = {7E907718-0B33-45C8-851F-396CEFDC1AB6} {F5CE416E-B906-41D2-80B9-0078E887A3F6} = {7E907718-0B33-45C8-851F-396CEFDC1AB6} {4B45CA0C-03A0-400F-B454-3D4BCB16AF38} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {B501A547-C911-4A05-AC6E-274A50DFF30E} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {50D26304-0961-4A51-ABF6-6CAD1A56D203} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {4462B57A-7245-4146-B504-D46FDE762948} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {B2C33A93-DB30-4099-903E-77D75C4C3F45} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {50D26304-0961-4A51-ABF6-6CAD1A56D202} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {E3B32027-3362-41DF-9172-4D3B623F42A5} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {190CE348-596E-435A-9E5B-12A689F9FC29} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {9C9DABA4-0E72-4469-ADF1-4991F3CA572A} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {BDA5D613-596D-4B61-837C-63554151C8F5} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {91F6F646-4F6E-449A-9AB4-2986348F329D} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {5F8D2414-064A-4B3A-9B42-8E2A04246BE5} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {02459936-CD2C-4F61-B671-5C518F2A3DDC} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {288089C5-8721-458E-BE3E-78990DAB5E2E} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {288089C5-8721-458E-BE3E-78990DAB5E2D} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {C50166F1-BABC-40A9-95EB-8200080CD701} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {E3FDC65F-568D-4E2D-A093-5132FD3793B7} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {909B656F-6095-4AC2-A5AB-C3F032315C45} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {2E87FA96-50BB-4607-8676-46521599F998} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {96EB2D3B-F694-48C6-A284-67382841E086} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {21B239D0-D144-430F-A394-C066D58EE267} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {3973B09A-4FBF-44A5-8359-3D22CEB71F71} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {EDC68A0E-C68D-4A74-91B7-BF38EC909888} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {3CDEEAB7-2256-418A-BEB2-620B5CB16302} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {3E7DEA65-317B-4F43-A25D-62F18D96CFD7} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {12A68549-4E8C-42D6-8703-A09335F97997} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {066F0DBD-C46C-4C20-AFEC-99829A172625} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {8E2A252E-A140-45A6-A81A-2652996EA589} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {AC2BCEFB-9298-4621-AC48-1FF5E639E48D} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {16E93074-4252-466C-89A3-3B905ABAF779} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {3CEA0D69-00D3-40E5-A661-DC41EA07269B} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {76C6F005-C89D-4348-BB4A-39189DDBEB52} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {EBA4DFA1-6DED-418F-A485-A3B608978906} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {14118347-ED06-4608-9C45-18228273C712} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C} = {8DBA5174-B0AA-4561-82B1-A46607697753} {C0E80510-4FBE-4B0C-AF2C-4F473787722C} = {8DBA5174-B0AA-4561-82B1-A46607697753} {D49439D7-56D2-450F-A4F0-74CB95D620E6} = {8DBA5174-B0AA-4561-82B1-A46607697753} {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9} = {8DBA5174-B0AA-4561-82B1-A46607697753} {91C574AD-0352-47E9-A019-EE02CC32A396} = {8DBA5174-B0AA-4561-82B1-A46607697753} {A1455D30-55FC-45EF-8759-3AEBDB13D940} = {8DBA5174-B0AA-4561-82B1-A46607697753} {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC} = {8DBA5174-B0AA-4561-82B1-A46607697753} {A486D7DE-F614-409D-BB41-0FFDF582E35C} = {8DBA5174-B0AA-4561-82B1-A46607697753} {B617717C-7881-4F01-AB6D-B1B6CC0483A0} = {4C81EBB2-82E1-4C81-80C4-84CC40FA281B} {FD6BA96C-7905-4876-8BCC-E38E2CA64F31} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {AE297965-4D56-4BA9-85EB-655AC4FC95A0} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {60DB272A-21C9-4E8D-9803-FF4E132392C8} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {73242A2D-6300-499D-8C15-FADF7ECB185C} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {B8DA3A90-A60C-42E3-9D8E-6C67B800C395} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {ACE53515-482C-4C6A-E2D2-4242A687DFEE} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {21B80A31-8FF9-4E3A-8403-AABD635AEED9} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {ABDBAC1E-350E-4DC3-BB45-3504404545EE} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {3140FE61-0856-4367-9AA3-8081B9A80E35} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {76242A2D-2600-49DD-8C15-FEA07ECB1842} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {76242A2D-2600-49DD-8C15-FEA07ECB1843} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {3140FE61-0856-4367-9AA3-8081B9A80E36} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {BB3CA047-5D00-48D4-B7D3-233C1265C065} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {FA0E905D-EC46-466D-B7B2-3B5557F9428C} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {6FD1CC3E-6A99-4736-9B8D-757992DDE75D} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {286B01F3-811A-40A7-8C1F-10C9BB0597F7} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {24973B4C-FD09-4EE1-97F4-EA03E6B12040} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {ABC7262E-1053-49F3-B846-E3091BB92E8C} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {E2E889A5-2489-4546-9194-47C63E49EAEB} = {8DBA5174-B0AA-4561-82B1-A46607697753} {E8F0BAA5-7327-43D1-9A51-644E81AE55F1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {54E08BF5-F819-404F-A18D-0AB9EA81EA04} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {AD6F474E-E6D4-4217-91F3-B7AF1BE31CCC} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {43026D51-3083-4850-928D-07E1883D5B1A} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {E5A55C16-A5B9-4874-9043-A5266DC02F58} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {3BED15FD-D608-4573-B432-1569C1026F6D} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} {971E832B-7471-48B5-833E-5913188EC0E4} = {8DBA5174-B0AA-4561-82B1-A46607697753} {59AD474E-2A35-4E8A-A74D-E33479977FBF} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} {D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71} = {C2D1346B-9665-4150-B644-075CF1636BAA} {C1930979-C824-496B-A630-70F5369A636F} = {C2D1346B-9665-4150-B644-075CF1636BAA} {F822F72A-CC87-4E31-B57D-853F65CBEBF3} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {80FDDD00-9393-47F7-8BAF-7E87CE011068} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {2E1658E2-5045-4F85-A64C-C0ECCD39F719} = {8DBA5174-B0AA-4561-82B1-A46607697753} {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {21A01C2D-2501-4619-8144-48977DD22D9C} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {3DFB4701-E3D6-4435-9F70-A6E35822C4F2} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {69F853E5-BD04-4842-984F-FC68CC51F402} = {8DBA5174-B0AA-4561-82B1-A46607697753} {6FC8E6F5-659C-424D-AEB5-331B95883E29} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {DD317BE1-42A1-4795-B1D4-F370C40D649A} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {B6FC05F2-0E49-4BE2-8030-ACBB82B7F431} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {1688E1E5-D510-4E06-86F3-F8DB10B1393D} = {8DBA5174-B0AA-4561-82B1-A46607697753} {F040CEC5-5E11-4DBD-9F6A-250478E28177} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} {275812EE-DEDB-4232-9439-91C9757D2AE4} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {5FF1E493-69CC-4D0B-83F2-039F469A04E1} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {AA87BFED-089A-4096-B8D5-690BDC7D5B24} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {2531A8C4-97DD-47BC-A79C-B7846051E137} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {5018D049-5870-465A-889B-C742CE1E31CB} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {60166C60-813C-46C4-911D-2411B4ABBC0F} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89} = {C2D1346B-9665-4150-B644-075CF1636BAA} {49E7C367-181B-499C-AC2E-8E17C81418D6} = {C2D1346B-9665-4150-B644-075CF1636BAA} {037F06F0-3BE8-42D0-801E-2F74FC380AB8} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {2F11618A-9251-4609-B3D5-CE4D2B3D3E49} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {764D2C19-0187-4837-A2A3-96DDC6EF4CE2} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {9102ECF3-5CD1-4107-B8B7-F3795A52D790} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {CFA94A39-4805-456D-A369-FC35CCC170E9} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {C52D8057-43AF-40E6-A01B-6CDBB7301985} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {4A490CBC-37F4-4859-AFDB-4B0833D144AF} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {BE25E872-1667-4649-9D19-96B83E75A44E} = {8DBA5174-B0AA-4561-82B1-A46607697753} {0EB22BD1-B8B1-417D-8276-F475C2E190FF} = {BE25E872-1667-4649-9D19-96B83E75A44E} {3636D3E2-E3EF-4815-B020-819F382204CD} = {BE25E872-1667-4649-9D19-96B83E75A44E} {B9843F65-262E-4F40-A0BC-2CBEF7563A44} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {03607817-6800-40B6-BEAA-D6F437CD62B7} = {BE25E872-1667-4649-9D19-96B83E75A44E} {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5} = {BE25E872-1667-4649-9D19-96B83E75A44E} {23405307-7EFF-4774-8B11-8F5885439761} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {AFA5F921-0650-45E8-B293-51A0BB89DEA0} = {8DBA5174-B0AA-4561-82B1-A46607697753} {6362616E-6A47-48F0-9EE0-27800B306ACB} = {AFA5F921-0650-45E8-B293-51A0BB89DEA0} {8977A560-45C2-4EC2-A849-97335B382C74} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {BD8CE303-5F04-45EC-8DCF-73C9164CD614} = {8977A560-45C2-4EC2-A849-97335B382C74} {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC} = {8977A560-45C2-4EC2-A849-97335B382C74} {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE} = {8DBA5174-B0AA-4561-82B1-A46607697753} {A74C7D2E-92FA-490A-B80A-28BEF56B56FC} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {686BF57E-A6FF-467B-AAB3-44DE916A9772} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {1DDE89EE-5819-441F-A060-2FF4A986F372} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {655A5B07-39B8-48CD-8590-8AC0C2B708D8} = {8977A560-45C2-4EC2-A849-97335B382C74} {DE53934B-7FC1-48A0-85AB-C519FBBD02CF} = {8977A560-45C2-4EC2-A849-97335B382C74} {3D33BBFD-EC63-4E8C-A714-0A48A3809A87} = {BE25E872-1667-4649-9D19-96B83E75A44E} {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5} = {8977A560-45C2-4EC2-A849-97335B382C74} {FC32EF16-31B1-47B3-B625-A80933CB3F29} = {8977A560-45C2-4EC2-A849-97335B382C74} {453C8E28-81D4-431E-BFB0-F3D413346E51} = {8DBA5174-B0AA-4561-82B1-A46607697753} {CE7F7553-DB2D-4839-92E3-F042E4261B4E} = {8DBA5174-B0AA-4561-82B1-A46607697753} {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {D55FB2BD-CC9E-454B-9654-94AF5D910BF7} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {B9899CF1-E0EB-4599-9E24-6939A04B4979} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {D15BF03E-04ED-4BEE-A72B-7620F541F4E2} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {4A49D526-1644-4819-AA4F-95B348D447D4} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {EC946164-1E17-410B-B7D9-7DE7E6268D63} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {99F594B1-3916-471D-A761-A6731FC50E9A} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {699FEA05-AEA7-403D-827E-53CF4E826955} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {58969243-7F59-4236-93D0-C93B81F569B3} = {4A49D526-1644-4819-AA4F-95B348D447D4} {CEC0DCE7-8D52-45C3-9295-FC7B16BD2451} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {7B7F4153-AE93-4908-B8F0-430871589F83} = {4A49D526-1644-4819-AA4F-95B348D447D4} {76E96966-4780-4040-8197-BDE2879516F4} = {4A49D526-1644-4819-AA4F-95B348D447D4} {1B6C4A1A-413B-41FB-9F85-5C09118E541B} = {4A49D526-1644-4819-AA4F-95B348D447D4} {EAFFCA55-335B-4860-BB99-EFCEAD123199} = {4A49D526-1644-4819-AA4F-95B348D447D4} {DA973826-C985-4128-9948-0B445E638BDB} = {4A49D526-1644-4819-AA4F-95B348D447D4} {94FAF461-2E74-4DBB-9813-6B2CDE6F1880} = {4A49D526-1644-4819-AA4F-95B348D447D4} {9F9CCC78-7487-4127-9D46-DB23E501F001} = {4A49D526-1644-4819-AA4F-95B348D447D4} {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {7A69EA65-4411-4CD0-B439-035E720C1BD3} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} {9C1BE25C-5926-4E56-84AE-D2242CB0627E} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {8D22FC91-BDFE-4342-999B-D695E1C57E85} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {2801F82B-78CE-4BAE-B06F-537574751E2E} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {9B25E472-DF94-4E24-9F5D-E487CE5A91FB} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {67F44564-759B-4643-BD86-407B010B0B74} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {21B50E65-D601-4D82-B98A-FFE6DE3B25DC} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {967A8F5E-7D18-436C-97ED-1DB303FE5DE0} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {E919DD77-34F8-4F57-8058-4D3FF4C2B241} = {C2D1346B-9665-4150-B644-075CF1636BAA} {0C2E1633-1462-4712-88F4-A0C945BAD3A8} = {C2D1346B-9665-4150-B644-075CF1636BAA} {B7D29559-4360-434A-B9B9-2C0612287999} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {21B49277-E55A-45EF-8818-744BCD6CB732} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {BB987FFC-B758-4F73-96A3-923DE8DCFF1A} = {8977A560-45C2-4EC2-A849-97335B382C74} {1B73FB08-9A17-497E-97C5-FA312867D51B} = {8977A560-45C2-4EC2-A849-97335B382C74} {AE976DE9-811D-4C86-AEBB-DCDC1226D754} = {8977A560-45C2-4EC2-A849-97335B382C74} {3829F774-33F2-41E9-B568-AE555004FC62} = {8977A560-45C2-4EC2-A849-97335B382C74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} EndGlobalSection EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31319.15 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoslynDeployment", "src\Deployment\RoslynDeployment.csproj", "{600AF682-E097-407B-AD85-EE3CED37E680}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{A41D1B99-F489-4C43-BBDF-96D61B19A6B9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compilers", "Compilers", "{3F40F71B-7DCF-44A1-B15C-38CA34824143}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{32A48625-F0AD-419D-828B-A50BDABA38EA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{C65C6143-BED3-46E6-869E-9F0BE6E84C37}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspaces", "Workspaces", "{55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EditorFeatures", "EditorFeatures", "{EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExpressionEvaluator", "ExpressionEvaluator", "{235A3418-A3B0-4844-BCEB-F1CF45069232}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Features", "Features", "{3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Interactive", "Interactive", "{999FBDA2-33DA-4F74-B957-03AC72CCE5EC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripting", "Scripting", "{38940C5F-97FD-4B2A-B2CD-C4E4EF601B05}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualStudio", "VisualStudio", "{8DBA5174-B0AA-4561-82B1-A46607697753}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{913A4C08-898E-49C7-9692-0EF9DC56CF6E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{151F6994-AEB3-4B12-B746-2ACFF26C7BBB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{4C81EBB2-82E1-4C81-80C4-84CC40FA281B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{998CAFE8-06E4-4683-A151-0F6AA4BFF6C6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{19148439-436F-4CDA-B493-70AF4FFC13E9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hosts", "Hosts", "{5CA5F70E-0FDB-467B-B22C-3CD5994F0087}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{7E907718-0B33-45C8-851F-396CEFDC1AB6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CAD2965A-19AB-489F-BE2E-7649957F914A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTest", "IntegrationTest", "{CC126D03-7EAC-493F-B187-DCDEE1EF6A70}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{C2D1346B-9665-4150-B644-075CF1636BAA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Perf", "Perf", "{DD13507E-D5AF-4B61-B11A-D55D6F4A73A5}" ProjectSection(SolutionItems) = preProject src\Test\Perf\readme.md = src\Test\Perf\readme.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeStyle", "CodeStyle", "{DC014586-8D07-4DE6-B28E-C0540C59C085}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.UnitTests", "src\Compilers\Core\CodeAnalysisTest\Microsoft.CodeAnalysis.UnitTests.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis", "src\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj", "{1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VBCSCompiler", "src\Compilers\Server\VBCSCompiler\VBCSCompiler.csproj", "{9508F118-F62E-4C16-A6F4-7C3B56E166AD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VBCSCompiler.UnitTests", "src\Compilers\Server\VBCSCompilerTests\VBCSCompiler.UnitTests.csproj", "{F5CE416E-B906-41D2-80B9-0078E887A3F6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csc", "src\Compilers\CSharp\csc\csc.csproj", "{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp", "src\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj", "{B501A547-C911-4A05-AC6E-274A50DFF30E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests", "src\Compilers\CSharp\Test\CommandLine\Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests.csproj", "{50D26304-0961-4A51-ABF6-6CAD1A56D203}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Emit.UnitTests", "src\Compilers\CSharp\Test\Emit\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj", "{4462B57A-7245-4146-B504-D46FDE762948}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests", "src\Compilers\CSharp\Test\IOperation\Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests.csproj", "{1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests", "src\Compilers\CSharp\Test\Semantic\Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests.csproj", "{B2C33A93-DB30-4099-903E-77D75C4C3F45}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests", "src\Compilers\CSharp\Test\Symbol\Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests.csproj", "{28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests", "src\Compilers\CSharp\Test\Syntax\Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests.csproj", "{50D26304-0961-4A51-ABF6-6CAD1A56D202}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compiler.Test.Resources", "src\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj", "{7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Test.Utilities", "src\Compilers\Test\Utilities\CSharp\Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj", "{4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Test.Utilities", "src\Compilers\Test\Utilities\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Test.Utilities.vbproj", "{4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic", "src\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj", "{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests", "src\Compilers\VisualBasic\Test\CommandLine\Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests.vbproj", "{E3B32027-3362-41DF-9172-4D3B623F42A5}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests", "src\Compilers\VisualBasic\Test\Emit\Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests.vbproj", "{190CE348-596E-435A-9E5B-12A689F9FC29}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Roslyn.Compilers.VisualBasic.IOperation.UnitTests", "src\Compilers\VisualBasic\Test\IOperation\Roslyn.Compilers.VisualBasic.IOperation.UnitTests.vbproj", "{9C9DABA4-0E72-4469-ADF1-4991F3CA572A}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests", "src\Compilers\VisualBasic\Test\Semantic\Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests.vbproj", "{BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests", "src\Compilers\VisualBasic\Test\Symbol\Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests.vbproj", "{BDA5D613-596D-4B61-837C-63554151C8F5}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests", "src\Compilers\VisualBasic\Test\Syntax\Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests.vbproj", "{91F6F646-4F6E-449A-9AB4-2986348F329D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Test.PdbUtilities", "src\Test\PdbUtilities\Roslyn.Test.PdbUtilities.csproj", "{AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces", "src\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj", "{5F8D2414-064A-4B3A-9B42-8E2A04246BE5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilersBoundTreeGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\BoundTreeGenerator\CompilersBoundTreeGenerator.csproj", "{02459936-CD2C-4F61-B671-5C518F2A3DDC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpErrorFactsGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\CSharpErrorFactsGenerator\CSharpErrorFactsGenerator.csproj", "{288089C5-8721-458E-BE3E-78990DAB5E2E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpSyntaxGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\CSharpSyntaxGenerator\CSharpSyntaxGenerator.csproj", "{288089C5-8721-458E-BE3E-78990DAB5E2D}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VisualBasicSyntaxGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\VisualBasicSyntaxGenerator\VisualBasicSyntaxGenerator.vbproj", "{6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.UnitTests", "src\Workspaces\CoreTest\Microsoft.CodeAnalysis.Workspaces.UnitTests.csproj", "{C50166F1-BABC-40A9-95EB-8200080CD701}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests", "src\Workspaces\CSharpTest\Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests.csproj", "{E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests", "src\Workspaces\VisualBasicTest\Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests.vbproj", "{E3FDC65F-568D-4E2D-A093-5132FD3793B7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VisualBasicErrorFactsGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\VisualBasicErrorFactsGenerator\VisualBasicErrorFactsGenerator.vbproj", "{909B656F-6095-4AC2-A5AB-C3F032315C45}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.Desktop", "src\Workspaces\Core\Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.csproj", "{2E87FA96-50BB-4607-8676-46521599F998}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.MSBuild", "src\Workspaces\Core\MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj", "{96EB2D3B-F694-48C6-A284-67382841E086}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Workspaces", "src\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj", "{21B239D0-D144-430F-A394-C066D58EE267}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Workspaces", "src\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj", "{57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RunTests", "src\Tools\Source\RunTests\RunTests.csproj", "{1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Features", "src\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj", "{A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Features", "src\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj", "{3973B09A-4FBF-44A5-8359-3D22CEB71F71}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Features", "src\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj", "{EDC68A0E-C68D-4A74-91B7-BF38EC909888}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Text", "src\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj", "{18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.EditorFeatures", "src\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj", "{49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.EditorFeatures", "src\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj", "{B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures", "src\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj", "{3CDEEAB7-2256-418A-BEB2-620B5CB16302}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests", "src\EditorFeatures\VisualBasicTest\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj", "{0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Scripting", "src\Scripting\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Scripting.vbproj", "{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting", "src\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj", "{12A68549-4E8C-42D6-8703-A09335F97997}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.UnitTests", "src\Scripting\CoreTest\Microsoft.CodeAnalysis.Scripting.UnitTests.csproj", "{2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Scripting", "src\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj", "{066F0DBD-C46C-4C20-AFEC-99829A172625}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests", "src\Scripting\CSharpTest\Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests.csproj", "{2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.InteractiveHost", "src\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj", "{8E2A252E-A140-45A6-A81A-2652996EA589}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests", "src\EditorFeatures\CSharpTest\Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj", "{AC2BCEFB-9298-4621-AC48-1FF5E639E48D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests", "src\EditorFeatures\CSharpTest2\Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj", "{16E93074-4252-466C-89A3-3B905ABAF779}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.UnitTests", "src\EditorFeatures\Test\Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj", "{8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.EditorFeatures2.UnitTests", "src\EditorFeatures\Test2\Microsoft.CodeAnalysis.EditorFeatures2.UnitTests.vbproj", "{3CEA0D69-00D3-40E5-A661-DC41EA07269B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities", "src\EditorFeatures\TestUtilities\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj", "{76C6F005-C89D-4348-BB4A-39189DDBEB52}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveHost32", "src\Interactive\HostProcess\InteractiveHost32.csproj", "{EBA4DFA1-6DED-418F-A485-A3B608978906}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveHost.UnitTests", "src\Interactive\HostTest\InteractiveHost.UnitTests.csproj", "{8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csi", "src\Interactive\csi\csi.csproj", "{14118347-ED06-4608-9C45-18228273C712}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "vbi", "src\Interactive\vbi\vbi.vbproj", "{6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices", "src\VisualStudio\Core\Def\Microsoft.VisualStudio.LanguageServices.csproj", "{86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.Implementation", "src\VisualStudio\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation.csproj", "{C0E80510-4FBE-4B0C-AF2C-4F473787722C}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.VisualStudio.LanguageServices.VisualBasic", "src\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj", "{D49439D7-56D2-450F-A4F0-74CB95D620E6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CSharp", "src\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj", "{5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests", "src\VisualStudio\CSharp\Test\Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.csproj", "{91C574AD-0352-47E9-A019-EE02CC32A396}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.VisualStudio.LanguageServices.UnitTests", "src\VisualStudio\Core\Test\Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj", "{A1455D30-55FC-45EF-8759-3AEBDB13D940}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup", "src\VisualStudio\Setup\Roslyn.VisualStudio.Setup.csproj", "{201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.DiagnosticsWindow", "src\VisualStudio\VisualStudioDiagnosticsToolWindow\Roslyn.VisualStudio.DiagnosticsWindow.csproj", "{A486D7DE-F614-409D-BB41-0FFDF582E35C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluatorPackage", "src\ExpressionEvaluator\Package\ExpressionEvaluatorPackage.csproj", "{B617717C-7881-4F01-AB6D-B1B6CC0483A0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ExpressionCompiler", "src\ExpressionEvaluator\CSharp\Source\ExpressionCompiler\Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.csproj", "{FD6BA96C-7905-4876-8BCC-E38E2CA64F31}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.UnitTests", "src\ExpressionEvaluator\CSharp\Test\ExpressionCompiler\Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.UnitTests.csproj", "{AE297965-4D56-4BA9-85EB-655AC4FC95A0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ResultProvider.UnitTests", "src\ExpressionEvaluator\CSharp\Test\ResultProvider\Microsoft.CodeAnalysis.CSharp.ResultProvider.UnitTests.csproj", "{60DB272A-21C9-4E8D-9803-FF4E132392C8}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler", "src\ExpressionEvaluator\VisualBasic\Source\ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.vbproj", "{73242A2D-6300-499D-8C15-FADF7ECB185C}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.UnitTests", "src\ExpressionEvaluator\VisualBasic\Test\ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.UnitTests.vbproj", "{AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExpressionCompiler", "src\ExpressionEvaluator\Core\Source\ExpressionCompiler\Microsoft.CodeAnalysis.ExpressionCompiler.csproj", "{B8DA3A90-A60C-42E3-9D8E-6C67B800C395}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ResultProvider.UnitTests", "src\ExpressionEvaluator\VisualBasic\Test\ResultProvider\Microsoft.CodeAnalysis.VisualBasic.ResultProvider.UnitTests.vbproj", "{ACE53515-482C-4C6A-E2D2-4242A687DFEE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExpressionCompiler.Utilities", "src\ExpressionEvaluator\Core\Test\ExpressionCompiler\Microsoft.CodeAnalysis.ExpressionCompiler.Utilities.csproj", "{21B80A31-8FF9-4E3A-8403-AABD635AEED9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResultProvider.Utilities", "src\ExpressionEvaluator\Core\Test\ResultProvider\Microsoft.CodeAnalysis.ResultProvider.Utilities.csproj", "{ABDBAC1E-350E-4DC3-BB45-3504404545EE}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AnalyzerDriver", "src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.shproj", "{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests", "src\Compilers\CSharp\Test\WinRT\Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests.csproj", "{FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Tasks.CodeAnalysis.UnitTests", "src\Compilers\Core\MSBuildTaskTests\Microsoft.Build.Tasks.CodeAnalysis.UnitTests.csproj", "{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicResultProvider", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.shproj", "{3140FE61-0856-4367-9AA3-8081B9A80E35}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "BasicResultProvider.NetFX20", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\NetFX20\BasicResultProvider.NetFX20.vbproj", "{76242A2D-2600-49DD-8C15-FEA07ECB1842}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.ResultProvider", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.VisualBasic.ResultProvider.vbproj", "{76242A2D-2600-49DD-8C15-FEA07ECB1843}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpResultProvider", "src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.shproj", "{3140FE61-0856-4367-9AA3-8081B9A80E36}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpResultProvider.NetFX20", "src\ExpressionEvaluator\CSharp\Source\ResultProvider\NetFX20\CSharpResultProvider.NetFX20.csproj", "{BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.ResultProvider", "src\ExpressionEvaluator\CSharp\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.CSharp.ResultProvider.csproj", "{BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ResultProvider", "src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.shproj", "{BB3CA047-5D00-48D4-B7D3-233C1265C065}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResultProvider.NetFX20", "src\ExpressionEvaluator\Core\Source\ResultProvider\NetFX20\ResultProvider.NetFX20.csproj", "{BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResultProvider", "src\ExpressionEvaluator\Core\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.ResultProvider.csproj", "{FA0E905D-EC46-466D-B7B2-3B5557F9428C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbc", "src\Compilers\VisualBasic\vbc\vbc.csproj", "{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests", "src\Scripting\CoreTest.Desktop\Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests.csproj", "{6FD1CC3E-6A99-4736-9B8D-757992DDE75D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests", "src\Scripting\CSharpTest.Desktop\Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests.csproj", "{286B01F3-811A-40A7-8C1F-10C9BB0597F7}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Scripting.Desktop.UnitTests", "src\Scripting\VisualBasicTest.Desktop\Microsoft.CodeAnalysis.VisualBasic.Scripting.Desktop.UnitTests.vbproj", "{24973B4C-FD09-4EE1-97F4-EA03E6B12040}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests", "src\Scripting\VisualBasicTest\Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests.vbproj", "{ABC7262E-1053-49F3-B846-E3091BB92E8C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Hosting.Diagnostics", "src\Test\Diagnostics\Roslyn.Hosting.Diagnostics.csproj", "{E2E889A5-2489-4546-9194-47C63E49EAEB}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicAnalyzerDriver", "src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.shproj", "{E8F0BAA5-7327-43D1-9A51-644E81AE55F1}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzerDriver", "src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.shproj", "{54E08BF5-F819-404F-A18D-0AB9EA81EA04}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CommandLine", "src\Compilers\Core\CommandLine\CommandLine.shproj", "{AD6F474E-E6D4-4217-91F3-B7AF1BE31CCC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Compilers.Extension", "src\Compilers\Extension\Roslyn.Compilers.Extension.csproj", "{43026D51-3083-4850-928D-07E1883D5B1A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.Setup", "src\VisualStudio\IntegrationTest\TestSetup\Microsoft.VisualStudio.IntegrationTest.Setup.csproj", "{A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}" ProjectSection(ProjectDependencies) = postProject {600AF682-E097-407B-AD85-EE3CED37E680} = {600AF682-E097-407B-AD85-EE3CED37E680} {A486D7DE-F614-409D-BB41-0FFDF582E35C} = {A486D7DE-F614-409D-BB41-0FFDF582E35C} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.IntegrationTests", "src\VisualStudio\IntegrationTest\IntegrationTests\Microsoft.VisualStudio.LanguageServices.IntegrationTests.csproj", "{E5A55C16-A5B9-4874-9043-A5266DC02F58}" ProjectSection(ProjectDependencies) = postProject {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2} = {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.Utilities", "src\VisualStudio\IntegrationTest\TestUtilities\Microsoft.VisualStudio.IntegrationTest.Utilities.csproj", "{3BED15FD-D608-4573-B432-1569C1026F6D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.PerformanceTests", "src\Test\Perf\tests\Roslyn.PerformanceTests.csproj", "{DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.Xaml", "src\VisualStudio\Xaml\Impl\Microsoft.VisualStudio.LanguageServices.Xaml.csproj", "{971E832B-7471-48B5-833E-5913188EC0E4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Test.Performance.Utilities", "src\Test\Perf\Utilities\Roslyn.Test.Performance.Utilities.csproj", "{59AD474E-2A35-4E8A-A74D-E33479977FBF}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Debugging", "src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.shproj", "{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.PooledObjects", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.shproj", "{C1930979-C824-496B-A630-70F5369A636F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Workspaces", "src\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj", "{F822F72A-CC87-4E31-B57D-853F65CBEBF3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.ServiceHub", "src\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj", "{80FDDD00-9393-47F7-8BAF-7E87CE011068}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Tasks.CodeAnalysis", "src\Compilers\Core\MSBuildTask\Microsoft.Build.Tasks.CodeAnalysis.csproj", "{7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Next.UnitTests", "src\VisualStudio\Core\Test.Next\Roslyn.VisualStudio.Next.UnitTests.csproj", "{2E1658E2-5045-4F85-A64C-C0ECCD39F719}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildBoss", "src\Tools\BuildBoss\BuildBoss.csproj", "{9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.TestUtilities", "src\Scripting\CoreTestUtilities\Microsoft.CodeAnalysis.Scripting.TestUtilities.csproj", "{21A01C2D-2501-4619-8144-48977DD22D9C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.Test.Utilities", "src\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj", "{3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2", "src\EditorFeatures\TestUtilities2\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj", "{3DFB4701-E3D6-4435-9F70-A6E35822C4F2}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.VisualStudio.LanguageServices.Test.Utilities2", "src\VisualStudio\TestUtilities2\Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj", "{69F853E5-BD04-4842-984F-FC68CC51F402}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.FunctionResolver", "src\ExpressionEvaluator\Core\Source\FunctionResolver\Microsoft.CodeAnalysis.FunctionResolver.csproj", "{6FC8E6F5-659C-424D-AEB5-331B95883E29}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.FunctionResolver.UnitTests", "src\ExpressionEvaluator\Core\Test\FunctionResolver\Microsoft.CodeAnalysis.FunctionResolver.UnitTests.csproj", "{DD317BE1-42A1-4795-B1D4-F370C40D649A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup.Dependencies", "src\VisualStudio\Setup.Dependencies\Roslyn.VisualStudio.Setup.Dependencies.csproj", "{1688E1E5-D510-4E06-86F3-F8DB10B1393D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackDepthTest", "src\Test\Perf\StackDepthTest\StackDepthTest.csproj", "{F040CEC5-5E11-4DBD-9F6A-250478E28177}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle", "src\CodeStyle\Core\Analyzers\Microsoft.CodeAnalysis.CodeStyle.csproj", "{275812EE-DEDB-4232-9439-91C9757D2AE4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.Fixes", "src\CodeStyle\Core\CodeFixes\Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj", "{5FF1E493-69CC-4D0B-83F2-039F469A04E1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle", "src\CodeStyle\CSharp\Analyzers\Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj", "{AA87BFED-089A-4096-B8D5-690BDC7D5B24}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes", "src\CodeStyle\CSharp\CodeFixes\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj", "{A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}" ProjectSection(ProjectDependencies) = postProject {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} = {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} EndProjectSection EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle", "src\CodeStyle\VisualBasic\Analyzers\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj", "{2531A8C4-97DD-47BC-A79C-B7846051E137}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes", "src\CodeStyle\VisualBasic\CodeFixes\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj", "{0141285D-8F6C-42C7-BAF3-3C0CCD61C716}" ProjectSection(ProjectDependencies) = postProject {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} = {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj", "{9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests", "src\CodeStyle\CSharp\Tests\Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj", "{5018D049-5870-465A-889B-C742CE1E31CB}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests", "src\CodeStyle\VisualBasic\Tests\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj", "{E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Wpf", "src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj", "{FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnalyzerRunner", "src\Tools\AnalyzerRunner\AnalyzerRunner.csproj", "{60166C60-813C-46C4-911D-2411B4ABBC0F}" ProjectSection(ProjectDependencies) = postProject {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2} = {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2} {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD} = {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD} {3CDEEAB7-2256-418A-BEB2-620B5CB16302} = {3CDEEAB7-2256-418A-BEB2-620B5CB16302} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Debugging.Package", "src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.Package.csproj", "{FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PooledObjects.Package", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.Package.csproj", "{49E7C367-181B-499C-AC2E-8E17C81418D6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests", "src\Workspaces\MSBuildTest\Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj", "{037F06F0-3BE8-42D0-801E-2F74FC380AB8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveHost64", "src\Interactive\HostProcess\InteractiveHost64.csproj", "{2F11618A-9251-4609-B3D5-CE4D2B3D3E49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.IntegrationService", "src\VisualStudio\IntegrationTest\IntegrationService\Microsoft.VisualStudio.IntegrationTest.IntegrationService.csproj", "{764D2C19-0187-4837-A2A3-96DDC6EF4CE2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Net.Compilers.Package", "src\NuGet\Microsoft.Net.Compilers\Microsoft.Net.Compilers.Package.csproj", "{9102ECF3-5CD1-4107-B8B7-F3795A52D790}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NETCore.Compilers.Package", "src\NuGet\Microsoft.NETCore.Compilers\Microsoft.NETCore.Compilers.Package.csproj", "{50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compilers.Package", "src\NuGet\Microsoft.CodeAnalysis.Compilers.Package.csproj", "{CFA94A39-4805-456D-A369-FC35CCC170E9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{C52D8057-43AF-40E6-A01B-6CDBB7301985}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Scripting.Package", "src\NuGet\Microsoft.CodeAnalysis.Scripting.Package.csproj", "{4A490CBC-37F4-4859-AFDB-4B0833D144AF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Package", "src\NuGet\Microsoft.CodeAnalysis.EditorFeatures.Package.csproj", "{34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{BE25E872-1667-4649-9D19-96B83E75A44E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VS.ExternalAPIs.Roslyn.Package", "src\NuGet\VisualStudio\VS.ExternalAPIs.Roslyn.Package.csproj", "{0EB22BD1-B8B1-417D-8276-F475C2E190FF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VS.Tools.Roslyn.Package", "src\NuGet\VisualStudio\VS.Tools.Roslyn.Package.csproj", "{3636D3E2-E3EF-4815-B020-819F382204CD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Package", "src\NuGet\Microsoft.CodeAnalysis.Package.csproj", "{B9843F65-262E-4F40-A0BC-2CBEF7563A44}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compilers.Setup", "src\Setup\DevDivVsix\CompilersPackage\Microsoft.CodeAnalysis.Compilers.Setup.csproj", "{03607817-6800-40B6-BEAA-D6F437CD62B7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Installer.Package", "src\Setup\Installer\Installer.Package.csproj", "{6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Workspaces.Desktop.UnitTests", "src\Workspaces\DesktopTest\Microsoft.CodeAnalysis.Workspaces.Desktop.UnitTests.csproj", "{23405307-7EFF-4774-8B11-8F5885439761}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Insertion", "Insertion", "{AFA5F921-0650-45E8-B293-51A0BB89DEA0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevDivInsertionFiles", "src\Setup\DevDivInsertionFiles\DevDivInsertionFiles.csproj", "{6362616E-6A47-48F0-9EE0-27800B306ACB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExternalAccess", "ExternalAccess", "{8977A560-45C2-4EC2-A849-97335B382C74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp", "src\Tools\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj", "{BD8CE303-5F04-45EC-8DCF-73C9164CD614}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor", "src\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj", "{2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CodeLens", "src\VisualStudio\CodeLens\Microsoft.VisualStudio.LanguageServices.CodeLens.csproj", "{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Net.Compilers.Toolset.Package", "src\NuGet\Microsoft.Net.Compilers.Toolset\Microsoft.Net.Compilers.Toolset.Package.csproj", "{A74C7D2E-92FA-490A-B80A-28BEF56B56FC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServer.Protocol", "src\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj", "{686BF57E-A6FF-467B-AAB3-44DE916A9772}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests", "src\Features\LanguageServer\ProtocolUnitTests\Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests.csproj", "{1DDE89EE-5819-441F-A060-2FF4A986F372}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Debugger", "src\Tools\ExternalAccess\Debugger\Microsoft.CodeAnalysis.ExternalAccess.Debugger.csproj", "{655A5B07-39B8-48CD-8590-8AC0C2B708D8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote", "src\Tools\ExternalAccess\Xamarin.Remote\Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote.csproj", "{DE53934B-7FC1-48A0-85AB-C519FBBD02CF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup.ServiceHub", "src\Setup\DevDivVsix\ServiceHubConfig\Roslyn.VisualStudio.Setup.ServiceHub.csproj", "{3D33BBFD-EC63-4E8C-A714-0A48A3809A87}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests", "src\Tools\ExternalAccess\FSharpTest\Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj", "{BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Apex", "src\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj", "{FC32EF16-31B1-47B3-B625-A80933CB3F29}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.LiveShare", "src\VisualStudio\LiveShare\Impl\Microsoft.VisualStudio.LanguageServices.LiveShare.csproj", "{453C8E28-81D4-431E-BFB0-F3D413346E51}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests", "src\VisualStudio\LiveShare\Test\Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests.csproj", "{CE7F7553-DB2D-4839-92E3-F042E4261B4E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdeBenchmarks", "src\Tools\IdeBenchmarks\IdeBenchmarks.csproj", "{FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{157EA250-2F28-4948-A8F2-D58EAEA05DC8}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .vsconfig = .vsconfig EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilersIOperationGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\IOperationGenerator\CompilersIOperationGenerator.csproj", "{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator", "src\Features\Lsif\Generator\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.csproj", "{B9899CF1-E0EB-4599-9E24-6939A04B4979}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests", "src\Features\Lsif\GeneratorTest\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.vbproj", "{D15BF03E-04ED-4BEE-A72B-7620F541F4E2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{4A49D526-1644-4819-AA4F-95B348D447D4}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.shproj", "{EC946164-1E17-410B-B7D9-7DE7E6268D63}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.shproj", "{99F594B1-3916-471D-A761-A6731FC50E9A}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.shproj", "{699FEA05-AEA7-403D-827E-53CF4E826955}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.shproj", "{438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzers.UnitTests", "src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.shproj", "{58969243-7F59-4236-93D0-C93B81F569B3}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.shproj", "{CEC0DCE7-8D52-45C3-9295-FC7B16BD2451}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.shproj", "{E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicAnalyzers.UnitTests", "src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.shproj", "{7B7F4153-AE93-4908-B8F0-430871589F83}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzers", "src\Analyzers\Core\Analyzers\Analyzers.shproj", "{76E96966-4780-4040-8197-BDE2879516F4}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CodeFixes", "src\Analyzers\Core\CodeFixes\CodeFixes.shproj", "{1B6C4A1A-413B-41FB-9F85-5C09118E541B}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzers", "src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.shproj", "{EAFFCA55-335B-4860-BB99-EFCEAD123199}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCodeFixes", "src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.shproj", "{DA973826-C985-4128-9948-0B445E638BDB}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicAnalyzers", "src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.shproj", "{94FAF461-2E74-4DBB-9813-6B2CDE6F1880}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicCodeFixes", "src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.shproj", "{9F9CCC78-7487-4127-9D46-DB23E501F001}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedUtilitiesAndExtensions", "SharedUtilitiesAndExtensions", "{DF17AF27-AA02-482B-8946-5CA8A50D5A2B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler", "Compiler", "{7A69EA65-4411-4CD0-B439-035E720C1BD3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspace", "Workspace", "{9C1BE25C-5926-4E56-84AE-D2242CB0627E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities", "src\EditorFeatures\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj", "{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities.csproj", "{2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdeCoreBenchmarks", "src\Tools\IdeCoreBenchmarks\IdeCoreBenchmarks.csproj", "{CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildValidator", "src\Tools\BuildValidator\BuildValidator.csproj", "{8D22FC91-BDFE-4342-999B-D695E1C57E85}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildActionTelemetryTable", "src\Tools\BuildActionTelemetryTable\BuildActionTelemetryTable.csproj", "{2801F82B-78CE-4BAE-B06F-537574751E2E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrepareTests", "src\Tools\PrepareTests\PrepareTests.csproj", "{9B25E472-DF94-4E24-9F5D-E487CE5A91FB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.Cocoa", "src\EditorFeatures\Core.Cocoa\Microsoft.CodeAnalysis.EditorFeatures.Cocoa.csproj", "{67F44564-759B-4643-BD86-407B010B0B74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Test.Utilities", "src\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj", "{5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.TestSourceGenerator", "src\Workspaces\TestSourceGenerator\Microsoft.CodeAnalysis.TestSourceGenerator.csproj", "{21B50E65-D601-4D82-B98A-FFE6DE3B25DC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.XunitHook", "src\EditorFeatures\XunitHook\Microsoft.CodeAnalysis.XunitHook.csproj", "{967A8F5E-7D18-436C-97ED-1DB303FE5DE0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeStyleConfigFileGenerator", "src\CodeStyle\Tools\CodeStyleConfigFileGenerator.csproj", "{41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Collections", "src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.shproj", "{E919DD77-34F8-4F57-8058-4D3FF4C2B241}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Collections.Package", "src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.Package.csproj", "{0C2E1633-1462-4712-88F4-A0C945BAD3A8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Rebuild", "src\Compilers\Core\Rebuild\Microsoft.CodeAnalysis.Rebuild.csproj", "{B7D29559-4360-434A-B9B9-2C0612287999}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Rebuild.UnitTests", "src\Compilers\Core\RebuildTest\Microsoft.CodeAnalysis.Rebuild.UnitTests.csproj", "{21B49277-E55A-45EF-8818-744BCD6CB732}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests", "src\Tools\ExternalAccess\RazorTest\Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests.csproj", "{BB987FFC-B758-4F73-96A3-923DE8DCFF1A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp", "src\Tools\ExternalAccess\OmniSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.csproj", "{1B73FB08-9A17-497E-97C5-FA312867D51B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp", "src\Tools\ExternalAccess\OmniSharp.CSharp\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.csproj", "{AE976DE9-811D-4C86-AEBB-DCDC1226D754}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests", "src\Tools\ExternalAccess\OmniSharpTest\Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests.csproj", "{3829F774-33F2-41E9-B568-AE555004FC62}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{0be66736-cdaa-4989-88b1-b3f46ebdca4a}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{1b6c4a1a-413b-41fb-9f85-5c09118e541b}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5 src\Analyzers\Core\Analyzers\Analyzers.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e35}*SharedItemsImports = 13 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e36}*SharedItemsImports = 13 src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{438db8af-f3f0-4ed9-80b5-13fddd5b8787}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{5018d049-5870-465a-889b-c742ce1e31cb}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{58969243-7f59-4236-93d0-c93b81f569b3}*SharedItemsImports = 13 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{60db272a-21c9-4e8d-9803-ff4e132392c8}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{699fea05-aea7-403d-827e-53cf4e826955}*SharedItemsImports = 13 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1842}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1843}*SharedItemsImports = 5 src\Analyzers\Core\Analyzers\Analyzers.projitems*{76e96966-4780-4040-8197-bde2879516f4}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{94faf461-2e74-4dbb-9813-6b2cde6f1880}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{99f594b1-3916-471d-a761-a6731fc50e9a}*SharedItemsImports = 13 src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{9f9ccc78-7487-4127-9d46-db23e501f001}*SharedItemsImports = 13 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{abdbac1e-350e-4dc3-bb45-3504404545ee}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{ac2bcefb-9298-4621-ac48-1ff5e639e48d}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{ace53515-482c-4c6a-e2d2-4242a687dfee}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bb3ca047-5d00-48d4-b7d3-233c1265c065}*SharedItemsImports = 13 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bedc5a4a-809e-4017-9cfd-6c8d4e1847f0}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d3}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d4}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{cec0dce7-8d52-45c3-9295-fc7b16bd2451}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{da973826-c985-4128-9948-0b445e638bdb}*SharedItemsImports = 13 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{e512c6c1-f085-4ad7-b0d9-e8f1a0a2a510}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{e8f0baa5-7327-43d1-9a51-644e81ae55f1}*SharedItemsImports = 13 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{e919dd77-34f8-4f57-8058-4d3ff4c2b241}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{e9dbfa41-7a9c-49be-bd36-fd71b31aa9fe}*SharedItemsImports = 13 src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{eaffca55-335b-4860-bb99-efcead123199}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{ec946164-1e17-410b-b7d9-7de7e6268d63}*SharedItemsImports = 13 src\Analyzers\Core\Analyzers\Analyzers.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {600AF682-E097-407B-AD85-EE3CED37E680}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600AF682-E097-407B-AD85-EE3CED37E680}.Debug|Any CPU.Build.0 = Debug|Any CPU {600AF682-E097-407B-AD85-EE3CED37E680}.Release|Any CPU.ActiveCfg = Release|Any CPU {600AF682-E097-407B-AD85-EE3CED37E680}.Release|Any CPU.Build.0 = Release|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4C99B85-765C-4C65-9C2A-BB609AAB09E6}.Release|Any CPU.Build.0 = Release|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}.Release|Any CPU.Build.0 = Release|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Release|Any CPU.ActiveCfg = Release|Any CPU {9508F118-F62E-4C16-A6F4-7C3B56E166AD}.Release|Any CPU.Build.0 = Release|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {F5CE416E-B906-41D2-80B9-0078E887A3F6}.Release|Any CPU.Build.0 = Release|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B45CA0C-03A0-400F-B454-3D4BCB16AF38}.Release|Any CPU.Build.0 = Release|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B501A547-C911-4A05-AC6E-274A50DFF30E}.Release|Any CPU.Build.0 = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Debug|Any CPU.Build.0 = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Release|Any CPU.ActiveCfg = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D203}.Release|Any CPU.Build.0 = Release|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Debug|Any CPU.Build.0 = Debug|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Release|Any CPU.ActiveCfg = Release|Any CPU {4462B57A-7245-4146-B504-D46FDE762948}.Release|Any CPU.Build.0 = Release|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1}.Release|Any CPU.Build.0 = Release|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Debug|Any CPU.Build.0 = Debug|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Release|Any CPU.ActiveCfg = Release|Any CPU {B2C33A93-DB30-4099-903E-77D75C4C3F45}.Release|Any CPU.Build.0 = Release|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC}.Release|Any CPU.Build.0 = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Debug|Any CPU.Build.0 = Debug|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Release|Any CPU.ActiveCfg = Release|Any CPU {50D26304-0961-4A51-ABF6-6CAD1A56D202}.Release|Any CPU.Build.0 = Release|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}.Release|Any CPU.Build.0 = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9}.Release|Any CPU.Build.0 = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8}.Release|Any CPU.Build.0 = Release|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Release|Any CPU.ActiveCfg = Release|Any CPU {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}.Release|Any CPU.Build.0 = Release|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3B32027-3362-41DF-9172-4D3B623F42A5}.Release|Any CPU.Build.0 = Release|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Debug|Any CPU.Build.0 = Debug|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Release|Any CPU.ActiveCfg = Release|Any CPU {190CE348-596E-435A-9E5B-12A689F9FC29}.Release|Any CPU.Build.0 = Release|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C9DABA4-0E72-4469-ADF1-4991F3CA572A}.Release|Any CPU.Build.0 = Release|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A}.Release|Any CPU.Build.0 = Release|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Release|Any CPU.ActiveCfg = Release|Any CPU {BDA5D613-596D-4B61-837C-63554151C8F5}.Release|Any CPU.Build.0 = Release|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Debug|Any CPU.Build.0 = Debug|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Release|Any CPU.ActiveCfg = Release|Any CPU {91F6F646-4F6E-449A-9AB4-2986348F329D}.Release|Any CPU.Build.0 = Release|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED}.Release|Any CPU.Build.0 = Release|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Debug|Any CPU.Build.0 = Debug|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F8D2414-064A-4B3A-9B42-8E2A04246BE5}.Release|Any CPU.Build.0 = Release|Any CPU {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Debug|Any CPU.ActiveCfg = Debug|x64 {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Debug|Any CPU.Build.0 = Debug|x64 {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Release|Any CPU.ActiveCfg = Release|x64 {02459936-CD2C-4F61-B671-5C518F2A3DDC}.Release|Any CPU.Build.0 = Release|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Debug|Any CPU.ActiveCfg = Debug|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Debug|Any CPU.Build.0 = Debug|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Release|Any CPU.ActiveCfg = Release|x64 {288089C5-8721-458E-BE3E-78990DAB5E2E}.Release|Any CPU.Build.0 = Release|x64 {288089C5-8721-458E-BE3E-78990DAB5E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {288089C5-8721-458E-BE3E-78990DAB5E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU {288089C5-8721-458E-BE3E-78990DAB5E2D}.Release|Any CPU.ActiveCfg = Release|Any CPU {288089C5-8721-458E-BE3E-78990DAB5E2D}.Release|Any CPU.Build.0 = Release|Any CPU {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Debug|Any CPU.ActiveCfg = Debug|x64 {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Debug|Any CPU.Build.0 = Debug|x64 {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Release|Any CPU.ActiveCfg = Release|x64 {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34}.Release|Any CPU.Build.0 = Release|x64 {C50166F1-BABC-40A9-95EB-8200080CD701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C50166F1-BABC-40A9-95EB-8200080CD701}.Debug|Any CPU.Build.0 = Debug|Any CPU {C50166F1-BABC-40A9-95EB-8200080CD701}.Release|Any CPU.ActiveCfg = Release|Any CPU {C50166F1-BABC-40A9-95EB-8200080CD701}.Release|Any CPU.Build.0 = Release|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7}.Release|Any CPU.Build.0 = Release|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3FDC65F-568D-4E2D-A093-5132FD3793B7}.Release|Any CPU.Build.0 = Release|Any CPU {909B656F-6095-4AC2-A5AB-C3F032315C45}.Debug|Any CPU.ActiveCfg = Debug|x64 {909B656F-6095-4AC2-A5AB-C3F032315C45}.Debug|Any CPU.Build.0 = Debug|x64 {909B656F-6095-4AC2-A5AB-C3F032315C45}.Release|Any CPU.ActiveCfg = Release|x64 {909B656F-6095-4AC2-A5AB-C3F032315C45}.Release|Any CPU.Build.0 = Release|x64 {2E87FA96-50BB-4607-8676-46521599F998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E87FA96-50BB-4607-8676-46521599F998}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E87FA96-50BB-4607-8676-46521599F998}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E87FA96-50BB-4607-8676-46521599F998}.Release|Any CPU.Build.0 = Release|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Debug|Any CPU.Build.0 = Debug|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Release|Any CPU.ActiveCfg = Release|Any CPU {96EB2D3B-F694-48C6-A284-67382841E086}.Release|Any CPU.Build.0 = Release|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B239D0-D144-430F-A394-C066D58EE267}.Release|Any CPU.Build.0 = Release|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Release|Any CPU.ActiveCfg = Release|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Release|Any CPU.Build.0 = Release|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA}.Release|Any CPU.Build.0 = Release|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D}.Release|Any CPU.Build.0 = Release|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Debug|Any CPU.Build.0 = Debug|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Release|Any CPU.ActiveCfg = Release|Any CPU {3973B09A-4FBF-44A5-8359-3D22CEB71F71}.Release|Any CPU.Build.0 = Release|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDC68A0E-C68D-4A74-91B7-BF38EC909888}.Release|Any CPU.Build.0 = Release|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}.Release|Any CPU.Build.0 = Release|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Debug|Any CPU.Build.0 = Debug|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Release|Any CPU.ActiveCfg = Release|Any CPU {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD}.Release|Any CPU.Build.0 = Release|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2}.Release|Any CPU.Build.0 = Release|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|Any CPU.ActiveCfg = Release|Any CPU {3CDEEAB7-2256-418A-BEB2-620B5CB16302}.Release|Any CPU.Build.0 = Release|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Debug|Any CPU.Build.0 = Debug|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Release|Any CPU.ActiveCfg = Release|Any CPU {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A}.Release|Any CPU.Build.0 = Release|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {3E7DEA65-317B-4F43-A25D-62F18D96CFD7}.Release|Any CPU.Build.0 = Release|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Debug|Any CPU.Build.0 = Debug|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Release|Any CPU.ActiveCfg = Release|Any CPU {12A68549-4E8C-42D6-8703-A09335F97997}.Release|Any CPU.Build.0 = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE}.Release|Any CPU.Build.0 = Release|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Debug|Any CPU.Build.0 = Debug|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|Any CPU.ActiveCfg = Release|Any CPU {066F0DBD-C46C-4C20-AFEC-99829A172625}.Release|Any CPU.Build.0 = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE}.Release|Any CPU.Build.0 = Release|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E2A252E-A140-45A6-A81A-2652996EA589}.Release|Any CPU.Build.0 = Release|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC2BCEFB-9298-4621-AC48-1FF5E639E48D}.Release|Any CPU.Build.0 = Release|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Debug|Any CPU.Build.0 = Debug|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Release|Any CPU.ActiveCfg = Release|Any CPU {16E93074-4252-466C-89A3-3B905ABAF779}.Release|Any CPU.Build.0 = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33}.Release|Any CPU.Build.0 = Release|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Release|Any CPU.ActiveCfg = Release|Any CPU {3CEA0D69-00D3-40E5-A661-DC41EA07269B}.Release|Any CPU.Build.0 = Release|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Debug|Any CPU.Build.0 = Debug|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Release|Any CPU.ActiveCfg = Release|Any CPU {76C6F005-C89D-4348-BB4A-39189DDBEB52}.Release|Any CPU.Build.0 = Release|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Release|Any CPU.ActiveCfg = Release|Any CPU {EBA4DFA1-6DED-418F-A485-A3B608978906}.Release|Any CPU.Build.0 = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34}.Release|Any CPU.Build.0 = Release|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Debug|Any CPU.Build.0 = Debug|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Release|Any CPU.ActiveCfg = Release|Any CPU {14118347-ED06-4608-9C45-18228273C712}.Release|Any CPU.Build.0 = Release|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B}.Release|Any CPU.Build.0 = Release|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Debug|Any CPU.Build.0 = Debug|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Release|Any CPU.ActiveCfg = Release|Any CPU {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C}.Release|Any CPU.Build.0 = Release|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0E80510-4FBE-4B0C-AF2C-4F473787722C}.Release|Any CPU.Build.0 = Release|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D49439D7-56D2-450F-A4F0-74CB95D620E6}.Release|Any CPU.Build.0 = Release|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9}.Release|Any CPU.Build.0 = Release|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Debug|Any CPU.Build.0 = Debug|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Release|Any CPU.ActiveCfg = Release|Any CPU {91C574AD-0352-47E9-A019-EE02CC32A396}.Release|Any CPU.Build.0 = Release|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1455D30-55FC-45EF-8759-3AEBDB13D940}.Release|Any CPU.Build.0 = Release|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC}.Release|Any CPU.Build.0 = Release|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Debug|Any CPU.Build.0 = Debug|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Release|Any CPU.ActiveCfg = Release|Any CPU {A486D7DE-F614-409D-BB41-0FFDF582E35C}.Release|Any CPU.Build.0 = Release|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {B617717C-7881-4F01-AB6D-B1B6CC0483A0}.Release|Any CPU.Build.0 = Release|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Debug|Any CPU.Build.0 = Debug|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Release|Any CPU.ActiveCfg = Release|Any CPU {FD6BA96C-7905-4876-8BCC-E38E2CA64F31}.Release|Any CPU.Build.0 = Release|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE297965-4D56-4BA9-85EB-655AC4FC95A0}.Release|Any CPU.Build.0 = Release|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {60DB272A-21C9-4E8D-9803-FF4E132392C8}.Release|Any CPU.Build.0 = Release|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Debug|Any CPU.Build.0 = Debug|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Release|Any CPU.ActiveCfg = Release|Any CPU {73242A2D-6300-499D-8C15-FADF7ECB185C}.Release|Any CPU.Build.0 = Release|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2}.Release|Any CPU.Build.0 = Release|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8DA3A90-A60C-42E3-9D8E-6C67B800C395}.Release|Any CPU.Build.0 = Release|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACE53515-482C-4C6A-E2D2-4242A687DFEE}.Release|Any CPU.Build.0 = Release|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B80A31-8FF9-4E3A-8403-AABD635AEED9}.Release|Any CPU.Build.0 = Release|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {ABDBAC1E-350E-4DC3-BB45-3504404545EE}.Release|Any CPU.Build.0 = Release|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Debug|Any CPU.Build.0 = Debug|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}.Release|Any CPU.Build.0 = Release|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.Build.0 = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|Any CPU.Build.0 = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Release|Any CPU.ActiveCfg = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1842}.Release|Any CPU.Build.0 = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Debug|Any CPU.Build.0 = Debug|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Release|Any CPU.ActiveCfg = Release|Any CPU {76242A2D-2600-49DD-8C15-FEA07ECB1843}.Release|Any CPU.Build.0 = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3}.Release|Any CPU.Build.0 = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4}.Release|Any CPU.Build.0 = Release|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Release|Any CPU.Build.0 = Release|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Debug|Any CPU.Build.0 = Debug|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Release|Any CPU.ActiveCfg = Release|Any CPU {FA0E905D-EC46-466D-B7B2-3B5557F9428C}.Release|Any CPU.Build.0 = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.Build.0 = Release|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FD1CC3E-6A99-4736-9B8D-757992DDE75D}.Release|Any CPU.Build.0 = Release|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {286B01F3-811A-40A7-8C1F-10C9BB0597F7}.Release|Any CPU.Build.0 = Release|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Debug|Any CPU.Build.0 = Debug|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Release|Any CPU.ActiveCfg = Release|Any CPU {24973B4C-FD09-4EE1-97F4-EA03E6B12040}.Release|Any CPU.Build.0 = Release|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Debug|Any CPU.Build.0 = Debug|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|Any CPU.ActiveCfg = Release|Any CPU {ABC7262E-1053-49F3-B846-E3091BB92E8C}.Release|Any CPU.Build.0 = Release|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU {E2E889A5-2489-4546-9194-47C63E49EAEB}.Release|Any CPU.Build.0 = Release|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {43026D51-3083-4850-928D-07E1883D5B1A}.Release|Any CPU.Build.0 = Release|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Debug|Any CPU.Build.0 = Debug|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Release|Any CPU.ActiveCfg = Release|Any CPU {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}.Release|Any CPU.Build.0 = Release|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5A55C16-A5B9-4874-9043-A5266DC02F58}.Release|Any CPU.Build.0 = Release|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BED15FD-D608-4573-B432-1569C1026F6D}.Release|Any CPU.Build.0 = Release|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1}.Release|Any CPU.Build.0 = Release|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU {971E832B-7471-48B5-833E-5913188EC0E4}.Release|Any CPU.Build.0 = Release|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Debug|Any CPU.Build.0 = Debug|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Release|Any CPU.ActiveCfg = Release|Any CPU {59AD474E-2A35-4E8A-A74D-E33479977FBF}.Release|Any CPU.Build.0 = Release|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F822F72A-CC87-4E31-B57D-853F65CBEBF3}.Release|Any CPU.Build.0 = Release|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Debug|Any CPU.Build.0 = Debug|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Release|Any CPU.ActiveCfg = Release|Any CPU {80FDDD00-9393-47F7-8BAF-7E87CE011068}.Release|Any CPU.Build.0 = Release|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3}.Release|Any CPU.Build.0 = Release|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E1658E2-5045-4F85-A64C-C0ECCD39F719}.Release|Any CPU.Build.0 = Release|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}.Release|Any CPU.Build.0 = Release|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Debug|Any CPU.Build.0 = Debug|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Release|Any CPU.ActiveCfg = Release|Any CPU {21A01C2D-2501-4619-8144-48977DD22D9C}.Release|Any CPU.Build.0 = Release|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Release|Any CPU.ActiveCfg = Release|Any CPU {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E}.Release|Any CPU.Build.0 = Release|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {3DFB4701-E3D6-4435-9F70-A6E35822C4F2}.Release|Any CPU.Build.0 = Release|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Debug|Any CPU.Build.0 = Debug|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Release|Any CPU.ActiveCfg = Release|Any CPU {69F853E5-BD04-4842-984F-FC68CC51F402}.Release|Any CPU.Build.0 = Release|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FC8E6F5-659C-424D-AEB5-331B95883E29}.Release|Any CPU.Build.0 = Release|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD317BE1-42A1-4795-B1D4-F370C40D649A}.Release|Any CPU.Build.0 = Release|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Debug|Any CPU.Build.0 = Debug|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Release|Any CPU.ActiveCfg = Release|Any CPU {1688E1E5-D510-4E06-86F3-F8DB10B1393D}.Release|Any CPU.Build.0 = Release|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Debug|Any CPU.Build.0 = Debug|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Release|Any CPU.ActiveCfg = Release|Any CPU {F040CEC5-5E11-4DBD-9F6A-250478E28177}.Release|Any CPU.Build.0 = Release|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {275812EE-DEDB-4232-9439-91C9757D2AE4}.Release|Any CPU.Build.0 = Release|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Release|Any CPU.Build.0 = Release|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Release|Any CPU.Build.0 = Release|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Debug|Any CPU.Build.0 = Debug|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Release|Any CPU.ActiveCfg = Release|Any CPU {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Release|Any CPU.Build.0 = Release|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Debug|Any CPU.Build.0 = Debug|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Release|Any CPU.ActiveCfg = Release|Any CPU {2531A8C4-97DD-47BC-A79C-B7846051E137}.Release|Any CPU.Build.0 = Release|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Debug|Any CPU.Build.0 = Debug|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Release|Any CPU.ActiveCfg = Release|Any CPU {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Release|Any CPU.Build.0 = Release|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Release|Any CPU.ActiveCfg = Release|Any CPU {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Release|Any CPU.Build.0 = Release|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {5018D049-5870-465A-889B-C742CE1E31CB}.Release|Any CPU.Build.0 = Release|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Debug|Any CPU.Build.0 = Debug|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Release|Any CPU.ActiveCfg = Release|Any CPU {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Release|Any CPU.Build.0 = Release|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1}.Release|Any CPU.Build.0 = Release|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU {60166C60-813C-46C4-911D-2411B4ABBC0F}.Release|Any CPU.Build.0 = Release|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}.Release|Any CPU.Build.0 = Release|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {49E7C367-181B-499C-AC2E-8E17C81418D6}.Release|Any CPU.Build.0 = Release|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {037F06F0-3BE8-42D0-801E-2F74FC380AB8}.Release|Any CPU.Build.0 = Release|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F11618A-9251-4609-B3D5-CE4D2B3D3E49}.Release|Any CPU.Build.0 = Release|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {764D2C19-0187-4837-A2A3-96DDC6EF4CE2}.Release|Any CPU.Build.0 = Release|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Debug|Any CPU.Build.0 = Debug|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Release|Any CPU.ActiveCfg = Release|Any CPU {9102ECF3-5CD1-4107-B8B7-F3795A52D790}.Release|Any CPU.Build.0 = Release|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Debug|Any CPU.Build.0 = Debug|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Release|Any CPU.ActiveCfg = Release|Any CPU {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49}.Release|Any CPU.Build.0 = Release|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {CFA94A39-4805-456D-A369-FC35CCC170E9}.Release|Any CPU.Build.0 = Release|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {4A490CBC-37F4-4859-AFDB-4B0833D144AF}.Release|Any CPU.Build.0 = Release|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Release|Any CPU.ActiveCfg = Release|Any CPU {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F}.Release|Any CPU.Build.0 = Release|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {0EB22BD1-B8B1-417D-8276-F475C2E190FF}.Release|Any CPU.Build.0 = Release|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {3636D3E2-E3EF-4815-B020-819F382204CD}.Release|Any CPU.Build.0 = Release|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Debug|Any CPU.Build.0 = Debug|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9843F65-262E-4F40-A0BC-2CBEF7563A44}.Release|Any CPU.Build.0 = Release|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {03607817-6800-40B6-BEAA-D6F437CD62B7}.Release|Any CPU.Build.0 = Release|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5}.Release|Any CPU.Build.0 = Release|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Debug|Any CPU.Build.0 = Debug|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Release|Any CPU.ActiveCfg = Release|Any CPU {23405307-7EFF-4774-8B11-8F5885439761}.Release|Any CPU.Build.0 = Release|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU {6362616E-6A47-48F0-9EE0-27800B306ACB}.Release|Any CPU.Build.0 = Release|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Release|Any CPU.Build.0 = Release|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Release|Any CPU.Build.0 = Release|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Release|Any CPU.Build.0 = Release|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A74C7D2E-92FA-490A-B80A-28BEF56B56FC}.Release|Any CPU.Build.0 = Release|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Debug|Any CPU.Build.0 = Debug|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Release|Any CPU.ActiveCfg = Release|Any CPU {686BF57E-A6FF-467B-AAB3-44DE916A9772}.Release|Any CPU.Build.0 = Release|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Debug|Any CPU.Build.0 = Debug|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Release|Any CPU.ActiveCfg = Release|Any CPU {1DDE89EE-5819-441F-A060-2FF4A986F372}.Release|Any CPU.Build.0 = Release|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {655A5B07-39B8-48CD-8590-8AC0C2B708D8}.Release|Any CPU.Build.0 = Release|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {DE53934B-7FC1-48A0-85AB-C519FBBD02CF}.Release|Any CPU.Build.0 = Release|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Release|Any CPU.Build.0 = Release|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Release|Any CPU.Build.0 = Release|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC32EF16-31B1-47B3-B625-A80933CB3F29}.Release|Any CPU.Build.0 = Release|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Debug|Any CPU.Build.0 = Debug|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Release|Any CPU.ActiveCfg = Release|Any CPU {453C8E28-81D4-431E-BFB0-F3D413346E51}.Release|Any CPU.Build.0 = Release|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE7F7553-DB2D-4839-92E3-F042E4261B4E}.Release|Any CPU.Build.0 = Release|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6}.Release|Any CPU.Build.0 = Release|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.Build.0 = Release|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Debug|Any CPU.Build.0 = Debug|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Release|Any CPU.Build.0 = Release|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Debug|Any CPU.Build.0 = Debug|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Release|Any CPU.ActiveCfg = Release|Any CPU {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Release|Any CPU.Build.0 = Release|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.Build.0 = Release|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5}.Release|Any CPU.Build.0 = Release|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA}.Release|Any CPU.Build.0 = Release|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D22FC91-BDFE-4342-999B-D695E1C57E85}.Release|Any CPU.Build.0 = Release|Any CPU {2801F82B-78CE-4BAE-B06F-537574751E2E}.Debug|Any CPU.ActiveCfg = Debug|x86 {2801F82B-78CE-4BAE-B06F-537574751E2E}.Debug|Any CPU.Build.0 = Debug|x86 {2801F82B-78CE-4BAE-B06F-537574751E2E}.Release|Any CPU.ActiveCfg = Release|x86 {2801F82B-78CE-4BAE-B06F-537574751E2E}.Release|Any CPU.Build.0 = Release|x86 {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Debug|Any CPU.Build.0 = Debug|Any CPU {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B25E472-DF94-4E24-9F5D-E487CE5A91FB}.Release|Any CPU.Build.0 = Release|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Debug|Any CPU.Build.0 = Debug|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Release|Any CPU.ActiveCfg = Release|Any CPU {67F44564-759B-4643-BD86-407B010B0B74}.Release|Any CPU.Build.0 = Release|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Release|Any CPU.ActiveCfg = Release|Any CPU {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6}.Release|Any CPU.Build.0 = Release|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B50E65-D601-4D82-B98A-FFE6DE3B25DC}.Release|Any CPU.Build.0 = Release|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {967A8F5E-7D18-436C-97ED-1DB303FE5DE0}.Release|Any CPU.Build.0 = Release|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Debug|Any CPU.Build.0 = Debug|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Release|Any CPU.ActiveCfg = Release|Any CPU {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0}.Release|Any CPU.Build.0 = Release|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Debug|Any CPU.Build.0 = Debug|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Release|Any CPU.ActiveCfg = Release|Any CPU {0C2E1633-1462-4712-88F4-A0C945BAD3A8}.Release|Any CPU.Build.0 = Release|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7D29559-4360-434A-B9B9-2C0612287999}.Release|Any CPU.Build.0 = Release|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Debug|Any CPU.Build.0 = Debug|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Release|Any CPU.ActiveCfg = Release|Any CPU {21B49277-E55A-45EF-8818-744BCD6CB732}.Release|Any CPU.Build.0 = Release|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB987FFC-B758-4F73-96A3-923DE8DCFF1A}.Release|Any CPU.Build.0 = Release|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B73FB08-9A17-497E-97C5-FA312867D51B}.Release|Any CPU.Build.0 = Release|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE976DE9-811D-4C86-AEBB-DCDC1226D754}.Release|Any CPU.Build.0 = Release|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Debug|Any CPU.Build.0 = Debug|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Release|Any CPU.ActiveCfg = Release|Any CPU {3829F774-33F2-41E9-B568-AE555004FC62}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {32A48625-F0AD-419D-828B-A50BDABA38EA} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {C65C6143-BED3-46E6-869E-9F0BE6E84C37} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {913A4C08-898E-49C7-9692-0EF9DC56CF6E} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {4C81EBB2-82E1-4C81-80C4-84CC40FA281B} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {19148439-436F-4CDA-B493-70AF4FFC13E9} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} {7E907718-0B33-45C8-851F-396CEFDC1AB6} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} = {8DBA5174-B0AA-4561-82B1-A46607697753} {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} = {CAD2965A-19AB-489F-BE2E-7649957F914A} {DC014586-8D07-4DE6-B28E-C0540C59C085} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {A4C99B85-765C-4C65-9C2A-BB609AAB09E6} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {1EE8CAD3-55F9-4D91-96B2-084641DA9A6C} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {9508F118-F62E-4C16-A6F4-7C3B56E166AD} = {7E907718-0B33-45C8-851F-396CEFDC1AB6} {F5CE416E-B906-41D2-80B9-0078E887A3F6} = {7E907718-0B33-45C8-851F-396CEFDC1AB6} {4B45CA0C-03A0-400F-B454-3D4BCB16AF38} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {B501A547-C911-4A05-AC6E-274A50DFF30E} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {50D26304-0961-4A51-ABF6-6CAD1A56D203} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {4462B57A-7245-4146-B504-D46FDE762948} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {1AF3672A-C5F1-4604-B6AB-D98C4DE9C3B1} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {B2C33A93-DB30-4099-903E-77D75C4C3F45} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {28026D16-EB0C-40B0-BDA7-11CAA2B97CCC} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {50D26304-0961-4A51-ABF6-6CAD1A56D202} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {4371944A-D3BA-4B5B-8285-82E5FFC6D1F9} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {4371944A-D3BA-4B5B-8285-82E5FFC6D1F8} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {E3B32027-3362-41DF-9172-4D3B623F42A5} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {190CE348-596E-435A-9E5B-12A689F9FC29} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {9C9DABA4-0E72-4469-ADF1-4991F3CA572A} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {BF180BD2-4FB7-4252-A7EC-A00E0C7A028A} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {BDA5D613-596D-4B61-837C-63554151C8F5} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {91F6F646-4F6E-449A-9AB4-2986348F329D} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {5F8D2414-064A-4B3A-9B42-8E2A04246BE5} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {02459936-CD2C-4F61-B671-5C518F2A3DDC} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {288089C5-8721-458E-BE3E-78990DAB5E2E} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {288089C5-8721-458E-BE3E-78990DAB5E2D} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {6AA96934-D6B7-4CC8-990D-DB6B9DD56E34} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {C50166F1-BABC-40A9-95EB-8200080CD701} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {E195A63F-B5A4-4C5A-96BD-8E7ED6A181B7} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {E3FDC65F-568D-4E2D-A093-5132FD3793B7} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {909B656F-6095-4AC2-A5AB-C3F032315C45} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {2E87FA96-50BB-4607-8676-46521599F998} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {96EB2D3B-F694-48C6-A284-67382841E086} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {21B239D0-D144-430F-A394-C066D58EE267} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {1A3941F1-1E1F-4EF7-8064-7729C4C2E2AA} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {A1BCD0CE-6C2F-4F8C-9A48-D9D93928E26D} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {3973B09A-4FBF-44A5-8359-3D22CEB71F71} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {EDC68A0E-C68D-4A74-91B7-BF38EC909888} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {49BFAE50-1BCE-48AE-BC89-78B7D90A3ECD} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {B0CE9307-FFDB-4838-A5EC-CE1F7CDC4AC2} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {3CDEEAB7-2256-418A-BEB2-620B5CB16302} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {0BE66736-CDAA-4989-88B1-B3F46EBDCA4A} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {3E7DEA65-317B-4F43-A25D-62F18D96CFD7} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {12A68549-4E8C-42D6-8703-A09335F97997} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {2DAE4406-7A89-4B5F-95C3-BC5472CE47CE} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {066F0DBD-C46C-4C20-AFEC-99829A172625} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {2DAE4406-7A89-4B5F-95C3-BC5422CE47CE} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {8E2A252E-A140-45A6-A81A-2652996EA589} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {AC2BCEFB-9298-4621-AC48-1FF5E639E48D} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {16E93074-4252-466C-89A3-3B905ABAF779} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {8CEE3609-A5A9-4A9B-86D7-33118F5D6B33} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {3CEA0D69-00D3-40E5-A661-DC41EA07269B} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {76C6F005-C89D-4348-BB4A-39189DDBEB52} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {EBA4DFA1-6DED-418F-A485-A3B608978906} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {8CEE3609-A5A9-4A9B-86D7-33118F5D6B34} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {14118347-ED06-4608-9C45-18228273C712} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {6E62A0FF-D0DC-4109-9131-AB8E60CDFF7B} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {86FD5B9A-4FA0-4B10-B59F-CFAF077A859C} = {8DBA5174-B0AA-4561-82B1-A46607697753} {C0E80510-4FBE-4B0C-AF2C-4F473787722C} = {8DBA5174-B0AA-4561-82B1-A46607697753} {D49439D7-56D2-450F-A4F0-74CB95D620E6} = {8DBA5174-B0AA-4561-82B1-A46607697753} {5DEFADBD-44EB-47A2-A53E-F1282CC9E4E9} = {8DBA5174-B0AA-4561-82B1-A46607697753} {91C574AD-0352-47E9-A019-EE02CC32A396} = {8DBA5174-B0AA-4561-82B1-A46607697753} {A1455D30-55FC-45EF-8759-3AEBDB13D940} = {8DBA5174-B0AA-4561-82B1-A46607697753} {201EC5B7-F91E-45E5-B9F2-67A266CCE6FC} = {8DBA5174-B0AA-4561-82B1-A46607697753} {A486D7DE-F614-409D-BB41-0FFDF582E35C} = {8DBA5174-B0AA-4561-82B1-A46607697753} {B617717C-7881-4F01-AB6D-B1B6CC0483A0} = {4C81EBB2-82E1-4C81-80C4-84CC40FA281B} {FD6BA96C-7905-4876-8BCC-E38E2CA64F31} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {AE297965-4D56-4BA9-85EB-655AC4FC95A0} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {60DB272A-21C9-4E8D-9803-FF4E132392C8} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {73242A2D-6300-499D-8C15-FADF7ECB185C} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {AC5E3515-482C-4C6A-92D9-D0CEA687DFC2} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {B8DA3A90-A60C-42E3-9D8E-6C67B800C395} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {ACE53515-482C-4C6A-E2D2-4242A687DFEE} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {21B80A31-8FF9-4E3A-8403-AABD635AEED9} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {ABDBAC1E-350E-4DC3-BB45-3504404545EE} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {3140FE61-0856-4367-9AA3-8081B9A80E35} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {76242A2D-2600-49DD-8C15-FEA07ECB1842} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {76242A2D-2600-49DD-8C15-FEA07ECB1843} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB} {3140FE61-0856-4367-9AA3-8081B9A80E36} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D3} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {BF9DAC1E-3A5E-4DC3-BB44-9A64E0D4E9D4} = {913A4C08-898E-49C7-9692-0EF9DC56CF6E} {BB3CA047-5D00-48D4-B7D3-233C1265C065} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {FA0E905D-EC46-466D-B7B2-3B5557F9428C} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {6FD1CC3E-6A99-4736-9B8D-757992DDE75D} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {286B01F3-811A-40A7-8C1F-10C9BB0597F7} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {24973B4C-FD09-4EE1-97F4-EA03E6B12040} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {ABC7262E-1053-49F3-B846-E3091BB92E8C} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {E2E889A5-2489-4546-9194-47C63E49EAEB} = {8DBA5174-B0AA-4561-82B1-A46607697753} {E8F0BAA5-7327-43D1-9A51-644E81AE55F1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {54E08BF5-F819-404F-A18D-0AB9EA81EA04} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {AD6F474E-E6D4-4217-91F3-B7AF1BE31CCC} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {43026D51-3083-4850-928D-07E1883D5B1A} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {A88AB44F-7F9D-43F6-A127-83BB65E5A7E2} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {E5A55C16-A5B9-4874-9043-A5266DC02F58} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {3BED15FD-D608-4573-B432-1569C1026F6D} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {DA0D2A70-A2F9-4654-A99A-3227EDF54FF1} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} {971E832B-7471-48B5-833E-5913188EC0E4} = {8DBA5174-B0AA-4561-82B1-A46607697753} {59AD474E-2A35-4E8A-A74D-E33479977FBF} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} {D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71} = {C2D1346B-9665-4150-B644-075CF1636BAA} {C1930979-C824-496B-A630-70F5369A636F} = {C2D1346B-9665-4150-B644-075CF1636BAA} {F822F72A-CC87-4E31-B57D-853F65CBEBF3} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {80FDDD00-9393-47F7-8BAF-7E87CE011068} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {7AD4FE65-9A30-41A6-8004-AA8F89BCB7F3} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {2E1658E2-5045-4F85-A64C-C0ECCD39F719} = {8DBA5174-B0AA-4561-82B1-A46607697753} {9C0660D9-48CA-40E1-BABA-8F6A1F11FE10} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {21A01C2D-2501-4619-8144-48977DD22D9C} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {3F2FDC1C-DC6F-44CB-B4A1-A9026F25D66E} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {3DFB4701-E3D6-4435-9F70-A6E35822C4F2} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {69F853E5-BD04-4842-984F-FC68CC51F402} = {8DBA5174-B0AA-4561-82B1-A46607697753} {6FC8E6F5-659C-424D-AEB5-331B95883E29} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {DD317BE1-42A1-4795-B1D4-F370C40D649A} = {998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} {1688E1E5-D510-4E06-86F3-F8DB10B1393D} = {8DBA5174-B0AA-4561-82B1-A46607697753} {F040CEC5-5E11-4DBD-9F6A-250478E28177} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5} {275812EE-DEDB-4232-9439-91C9757D2AE4} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {5FF1E493-69CC-4D0B-83F2-039F469A04E1} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {AA87BFED-089A-4096-B8D5-690BDC7D5B24} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {2531A8C4-97DD-47BC-A79C-B7846051E137} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {5018D049-5870-465A-889B-C742CE1E31CB} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {FFB00FB5-8C8C-4A02-B67D-262B9D28E8B1} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {60166C60-813C-46C4-911D-2411B4ABBC0F} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89} = {C2D1346B-9665-4150-B644-075CF1636BAA} {49E7C367-181B-499C-AC2E-8E17C81418D6} = {C2D1346B-9665-4150-B644-075CF1636BAA} {037F06F0-3BE8-42D0-801E-2F74FC380AB8} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {2F11618A-9251-4609-B3D5-CE4D2B3D3E49} = {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} {764D2C19-0187-4837-A2A3-96DDC6EF4CE2} = {CC126D03-7EAC-493F-B187-DCDEE1EF6A70} {9102ECF3-5CD1-4107-B8B7-F3795A52D790} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {50CF5D8F-F82F-4210-A06E-37CC9BFFDD49} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {CFA94A39-4805-456D-A369-FC35CCC170E9} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {C52D8057-43AF-40E6-A01B-6CDBB7301985} = {3F40F71B-7DCF-44A1-B15C-38CA34824143} {4A490CBC-37F4-4859-AFDB-4B0833D144AF} = {38940C5F-97FD-4B2A-B2CD-C4E4EF601B05} {34E868E9-D30B-4FB5-BC61-AFC4A9612A0F} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {BE25E872-1667-4649-9D19-96B83E75A44E} = {8DBA5174-B0AA-4561-82B1-A46607697753} {0EB22BD1-B8B1-417D-8276-F475C2E190FF} = {BE25E872-1667-4649-9D19-96B83E75A44E} {3636D3E2-E3EF-4815-B020-819F382204CD} = {BE25E872-1667-4649-9D19-96B83E75A44E} {B9843F65-262E-4F40-A0BC-2CBEF7563A44} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {03607817-6800-40B6-BEAA-D6F437CD62B7} = {BE25E872-1667-4649-9D19-96B83E75A44E} {6A68FDF9-24B3-4CB6-A808-96BF50D1BCE5} = {BE25E872-1667-4649-9D19-96B83E75A44E} {23405307-7EFF-4774-8B11-8F5885439761} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {AFA5F921-0650-45E8-B293-51A0BB89DEA0} = {8DBA5174-B0AA-4561-82B1-A46607697753} {6362616E-6A47-48F0-9EE0-27800B306ACB} = {AFA5F921-0650-45E8-B293-51A0BB89DEA0} {8977A560-45C2-4EC2-A849-97335B382C74} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {BD8CE303-5F04-45EC-8DCF-73C9164CD614} = {8977A560-45C2-4EC2-A849-97335B382C74} {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC} = {8977A560-45C2-4EC2-A849-97335B382C74} {5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE} = {8DBA5174-B0AA-4561-82B1-A46607697753} {A74C7D2E-92FA-490A-B80A-28BEF56B56FC} = {C52D8057-43AF-40E6-A01B-6CDBB7301985} {686BF57E-A6FF-467B-AAB3-44DE916A9772} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {1DDE89EE-5819-441F-A060-2FF4A986F372} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {655A5B07-39B8-48CD-8590-8AC0C2B708D8} = {8977A560-45C2-4EC2-A849-97335B382C74} {DE53934B-7FC1-48A0-85AB-C519FBBD02CF} = {8977A560-45C2-4EC2-A849-97335B382C74} {3D33BBFD-EC63-4E8C-A714-0A48A3809A87} = {BE25E872-1667-4649-9D19-96B83E75A44E} {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5} = {8977A560-45C2-4EC2-A849-97335B382C74} {FC32EF16-31B1-47B3-B625-A80933CB3F29} = {8977A560-45C2-4EC2-A849-97335B382C74} {453C8E28-81D4-431E-BFB0-F3D413346E51} = {8DBA5174-B0AA-4561-82B1-A46607697753} {CE7F7553-DB2D-4839-92E3-F042E4261B4E} = {8DBA5174-B0AA-4561-82B1-A46607697753} {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {D55FB2BD-CC9E-454B-9654-94AF5D910BF7} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {B9899CF1-E0EB-4599-9E24-6939A04B4979} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {D15BF03E-04ED-4BEE-A72B-7620F541F4E2} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {4A49D526-1644-4819-AA4F-95B348D447D4} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {EC946164-1E17-410B-B7D9-7DE7E6268D63} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {99F594B1-3916-471D-A761-A6731FC50E9A} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {699FEA05-AEA7-403D-827E-53CF4E826955} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {58969243-7F59-4236-93D0-C93B81F569B3} = {4A49D526-1644-4819-AA4F-95B348D447D4} {CEC0DCE7-8D52-45C3-9295-FC7B16BD2451} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {7B7F4153-AE93-4908-B8F0-430871589F83} = {4A49D526-1644-4819-AA4F-95B348D447D4} {76E96966-4780-4040-8197-BDE2879516F4} = {4A49D526-1644-4819-AA4F-95B348D447D4} {1B6C4A1A-413B-41FB-9F85-5C09118E541B} = {4A49D526-1644-4819-AA4F-95B348D447D4} {EAFFCA55-335B-4860-BB99-EFCEAD123199} = {4A49D526-1644-4819-AA4F-95B348D447D4} {DA973826-C985-4128-9948-0B445E638BDB} = {4A49D526-1644-4819-AA4F-95B348D447D4} {94FAF461-2E74-4DBB-9813-6B2CDE6F1880} = {4A49D526-1644-4819-AA4F-95B348D447D4} {9F9CCC78-7487-4127-9D46-DB23E501F001} = {4A49D526-1644-4819-AA4F-95B348D447D4} {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {7A69EA65-4411-4CD0-B439-035E720C1BD3} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} {9C1BE25C-5926-4E56-84AE-D2242CB0627E} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} {B64766CD-1A1F-4C1B-B11F-C30F82B8E41E} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {2D5E2DE4-5DA8-41C1-A14F-49855DCCE9C5} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {CEA80C83-5848-4FF6-B4E8-CEEE9482E4AA} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {8D22FC91-BDFE-4342-999B-D695E1C57E85} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {2801F82B-78CE-4BAE-B06F-537574751E2E} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {9B25E472-DF94-4E24-9F5D-E487CE5A91FB} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {67F44564-759B-4643-BD86-407B010B0B74} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {5D94ED65-EFA3-44EB-A5DA-62E85BAC9DD6} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {21B50E65-D601-4D82-B98A-FFE6DE3B25DC} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {967A8F5E-7D18-436C-97ED-1DB303FE5DE0} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} {41ED1BFA-FDAD-4FE4-8118-DB23FB49B0B0} = {DC014586-8D07-4DE6-B28E-C0540C59C085} {E919DD77-34F8-4F57-8058-4D3FF4C2B241} = {C2D1346B-9665-4150-B644-075CF1636BAA} {0C2E1633-1462-4712-88F4-A0C945BAD3A8} = {C2D1346B-9665-4150-B644-075CF1636BAA} {B7D29559-4360-434A-B9B9-2C0612287999} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {21B49277-E55A-45EF-8818-744BCD6CB732} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} {BB987FFC-B758-4F73-96A3-923DE8DCFF1A} = {8977A560-45C2-4EC2-A849-97335B382C74} {1B73FB08-9A17-497E-97C5-FA312867D51B} = {8977A560-45C2-4EC2-A849-97335B382C74} {AE976DE9-811D-4C86-AEBB-DCDC1226D754} = {8977A560-45C2-4EC2-A849-97335B382C74} {3829F774-33F2-41E9-B568-AE555004FC62} = {8977A560-45C2-4EC2-A849-97335B382C74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} EndGlobalSection EndGlobal
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/NuGet/VisualStudio/VS.ExternalAPIs.Roslyn.Package.csproj
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net472</TargetFramework> <!-- The package is inserted to Visual Studio CoreXT package store --> <IsShipping>false</IsShipping> <IsVisualStudioBuildPackage>true</IsVisualStudioBuildPackage> <IsPackable>true</IsPackable> <PackageId>VS.ExternalAPIs.Roslyn</PackageId> <IncludeBuildOutput>false</IncludeBuildOutput> <PackageDescription>CoreXT package for the VS build</PackageDescription> <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_GetFilesToPackage</TargetsForTfmSpecificContentInPackage> <!-- Suppress NuGet warning: "The assembly '...' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project." --> <NoWarn>$(NoWarn);NU5100</NoWarn> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\Debugger\Microsoft.CodeAnalysis.ExternalAccess.Debugger.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\LiveShare\Impl\Microsoft.VisualStudio.LanguageServices.LiveShare.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Core\Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Core\MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Remote\Razor\Microsoft.CodeAnalysis.Remote.Razor.ServiceHub.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\Core\Def\Microsoft.VisualStudio.LanguageServices.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\Xaml\Impl\Microsoft.VisualStudio.LanguageServices.Xaml.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\ExpressionCompiler\Microsoft.CodeAnalysis.ExpressionCompiler.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\CSharp\Source\ExpressionCompiler\Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\VisualBasic\Source\ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\FunctionResolver\Microsoft.CodeAnalysis.FunctionResolver.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.ResultProvider.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\ResultProvider\NetFX20\ResultProvider.NetFX20.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\CSharp\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.CSharp.ResultProvider.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\CSharp\Source\ResultProvider\NetFX20\CSharpResultProvider.NetFX20.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\VisualBasic\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.VisualBasic.ResultProvider.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\VisualBasic\Source\ResultProvider\NetFX20\BasicResultProvider.NetFX20.vbproj" PrivateAssets="all" /> </ItemGroup> <Target Name="_GetFilesToPackage"> <ItemGroup> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.EditorFeatures\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Features\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Features.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Scripting\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Scripting.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.EditorFeatures.Text\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.EditorFeatures.Text.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.EditorFeatures.Wpf\$(Configuration)\net472\Microsoft.CodeAnalysis.EditorFeatures.Wpf.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.EditorFeatures\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.EditorFeatures.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.Apex\$(Configuration)\net472\Microsoft.CodeAnalysis.ExternalAccess.Apex.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.Debugger\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.ExternalAccess.Debugger.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.FSharp\$(Configuration)\net472\Microsoft.CodeAnalysis.ExternalAccess.FSharp.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.Razor\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.ExternalAccess.Razor.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Features\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Features.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.InteractiveHost\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.InteractiveHost.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.LanguageServer.Protocol\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.LanguageServer.Protocol.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Remote.Razor.ServiceHub\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Remote.Razor.ServiceHub.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Remote.ServiceHub\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Remote.ServiceHub.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Remote.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Remote.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Scripting\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Scripting.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.EditorFeatures\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.Features\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Features.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.MSBuild\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.Desktop\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.Desktop.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.CSharp\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.CSharp.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.Implementation\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.Implementation.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.LiveShare\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.LiveShare.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.VisualBasic\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.VisualBasic.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.Xaml\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.Xaml.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ResultProvider.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.FunctionResolver\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)BasicResultProvider.NetFX20\$(Configuration)\net20\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.dll" TargetDir="RemoteDebugger\net20" /> <_File Include="$(ArtifactsBinDir)CSharpResultProvider.NetFX20\$(Configuration)\net20\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ResultProvider.dll" TargetDir="RemoteDebugger\net20" /> <_File Include="$(ArtifactsBinDir)ResultProvider.NetFX20\$(Configuration)\net20\Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.dll" TargetDir="RemoteDebugger\net20" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.FunctionResolver\$(Configuration)\net45\Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.dll" TargetDir="RemoteDebugger\net45" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ResultProvider.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.FunctionResolver\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <!-- Include a few dependencies of Roslyn. These right now are consumed out of the ExternalAPIs NuGet package to do assembly consistency checking in the main VS repo. We should remove these and insert the packages directly, but for now we'll include these to limit the work needed to consume this package. --> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\Humanizer.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\Microsoft.CodeAnalysis.AnalyzerUtilities.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\ICSharpCode.Decompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\System.Composition.Hosting.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\System.Composition.TypedParts.dll" TargetDir="" /> </ItemGroup> <!-- Add xml doc comment files --> <ItemGroup> <_File Include="%(_File.RootDir)%(_File.Directory)%(_File.FileName).xml" TargetDir="%(_File.TargetDir)" Condition="Exists('%(_File.RootDir)%(_File.Directory)%(_File.FileName).xml')" /> </ItemGroup> <ItemGroup> <TfmSpecificPackageFile Include="@(_File)" PackagePath="%(_File.TargetDir)/%(_File.RecursiveDir)%(_File.FileName)%(_File.Extension)" /> </ItemGroup> </Target> </Project>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net472</TargetFramework> <!-- The package is inserted to Visual Studio CoreXT package store --> <IsShipping>false</IsShipping> <IsVisualStudioBuildPackage>true</IsVisualStudioBuildPackage> <IsPackable>true</IsPackable> <PackageId>VS.ExternalAPIs.Roslyn</PackageId> <IncludeBuildOutput>false</IncludeBuildOutput> <PackageDescription>CoreXT package for the VS build</PackageDescription> <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_GetFilesToPackage</TargetsForTfmSpecificContentInPackage> <!-- Suppress NuGet warning: "The assembly '...' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project." --> <NoWarn>$(NoWarn);NU5100</NoWarn> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\Debugger\Microsoft.CodeAnalysis.ExternalAccess.Debugger.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\LiveShare\Impl\Microsoft.VisualStudio.LanguageServices.LiveShare.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Core\Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Core\MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\Core\Def\Microsoft.VisualStudio.LanguageServices.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\VisualStudio\Xaml\Impl\Microsoft.VisualStudio.LanguageServices.Xaml.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\ExpressionCompiler\Microsoft.CodeAnalysis.ExpressionCompiler.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\CSharp\Source\ExpressionCompiler\Microsoft.CodeAnalysis.CSharp.ExpressionCompiler.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\VisualBasic\Source\ExpressionCompiler\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\FunctionResolver\Microsoft.CodeAnalysis.FunctionResolver.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.ResultProvider.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\Core\Source\ResultProvider\NetFX20\ResultProvider.NetFX20.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\CSharp\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.CSharp.ResultProvider.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\CSharp\Source\ResultProvider\NetFX20\CSharpResultProvider.NetFX20.csproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\VisualBasic\Source\ResultProvider\Portable\Microsoft.CodeAnalysis.VisualBasic.ResultProvider.vbproj" PrivateAssets="all" /> <ProjectReference Include="..\..\ExpressionEvaluator\VisualBasic\Source\ResultProvider\NetFX20\BasicResultProvider.NetFX20.vbproj" PrivateAssets="all" /> </ItemGroup> <Target Name="_GetFilesToPackage"> <ItemGroup> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.EditorFeatures\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Features\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Features.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Scripting\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Scripting.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.EditorFeatures.Text\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.EditorFeatures.Text.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.EditorFeatures.Wpf\$(Configuration)\net472\Microsoft.CodeAnalysis.EditorFeatures.Wpf.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.EditorFeatures\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.EditorFeatures.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.Apex\$(Configuration)\net472\Microsoft.CodeAnalysis.ExternalAccess.Apex.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.Debugger\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.ExternalAccess.Debugger.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.FSharp\$(Configuration)\net472\Microsoft.CodeAnalysis.ExternalAccess.FSharp.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExternalAccess.Razor\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.ExternalAccess.Razor.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Features\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Features.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.InteractiveHost\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.InteractiveHost.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.LanguageServer.Protocol\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.LanguageServer.Protocol.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Remote.ServiceHub\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Remote.ServiceHub.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Remote.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Remote.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Scripting\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Scripting.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.EditorFeatures\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.Features\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Features.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.MSBuild\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.Desktop\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.Desktop.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.CSharp\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.CSharp.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.Implementation\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.Implementation.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.LiveShare\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.LiveShare.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.VisualBasic\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.VisualBasic.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices.Xaml\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.Xaml.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServices\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServices.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ResultProvider.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.FunctionResolver\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)BasicResultProvider.NetFX20\$(Configuration)\net20\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.dll" TargetDir="RemoteDebugger\net20" /> <_File Include="$(ArtifactsBinDir)CSharpResultProvider.NetFX20\$(Configuration)\net20\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ResultProvider.dll" TargetDir="RemoteDebugger\net20" /> <_File Include="$(ArtifactsBinDir)ResultProvider.NetFX20\$(Configuration)\net20\Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.dll" TargetDir="RemoteDebugger\net20" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.FunctionResolver\$(Configuration)\net45\Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.dll" TargetDir="RemoteDebugger\net45" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ResultProvider.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ResultProvider\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.FunctionResolver\$(Configuration)\netstandard1.3\Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler.vsdconfig" TargetDir="LanguageServiceRegistration\ExpressionEvaluatorPackage" /> <!-- Include a few dependencies of Roslyn. These right now are consumed out of the ExternalAPIs NuGet package to do assembly consistency checking in the main VS repo. We should remove these and insert the packages directly, but for now we'll include these to limit the work needed to consume this package. --> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\Humanizer.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\Microsoft.CodeAnalysis.AnalyzerUtilities.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\ICSharpCode.Decompiler.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\System.Composition.Hosting.dll" TargetDir="" /> <_File Include="$(ArtifactsBinDir)Roslyn.VisualStudio.Setup\$(Configuration)\net472\System.Composition.TypedParts.dll" TargetDir="" /> </ItemGroup> <!-- Add xml doc comment files --> <ItemGroup> <_File Include="%(_File.RootDir)%(_File.Directory)%(_File.FileName).xml" TargetDir="%(_File.TargetDir)" Condition="Exists('%(_File.RootDir)%(_File.Directory)%(_File.FileName).xml')" /> </ItemGroup> <ItemGroup> <TfmSpecificPackageFile Include="@(_File)" PackagePath="%(_File.TargetDir)/%(_File.RecursiveDir)%(_File.FileName)%(_File.Extension)" /> </ItemGroup> </Target> </Project>
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Tools/ExternalAccess/Razor/Remote/RazorRemoteHostClient.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using MessagePack; using MessagePack.Formatters; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Remote; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { internal sealed class RazorRemoteHostClient { private readonly ServiceHubRemoteHostClient _client; private readonly RazorServiceDescriptorsWrapper _serviceDescriptors; private readonly RazorRemoteServiceCallbackDispatcherRegistry _callbackDispatchers; internal RazorRemoteHostClient(ServiceHubRemoteHostClient client, RazorServiceDescriptorsWrapper serviceDescriptors, RazorRemoteServiceCallbackDispatcherRegistry callbackDispatchers) { _client = client; _serviceDescriptors = serviceDescriptors; _callbackDispatchers = callbackDispatchers; } [Obsolete] public static async Task<RazorRemoteHostClient?> CreateAsync(Workspace workspace, CancellationToken cancellationToken = default) { var client = await RemoteHostClient.TryGetClientAsync(workspace.Services, cancellationToken).ConfigureAwait(false); var descriptors = new RazorServiceDescriptorsWrapper("dummy", _ => throw ExceptionUtilities.Unreachable, ImmutableArray<IMessagePackFormatter>.Empty, ImmutableArray<IFormatterResolver>.Empty, Array.Empty<(Type, Type?)>()); return client == null ? null : new RazorRemoteHostClient((ServiceHubRemoteHostClient)client, descriptors, RazorRemoteServiceCallbackDispatcherRegistry.Empty); } [Obsolete] public async Task<Optional<T>> TryRunRemoteAsync<T>(string targetName, Solution? solution, IReadOnlyList<object?> arguments, CancellationToken cancellationToken) => await _client.RunRemoteAsync<T>(WellKnownServiceHubService.Razor, targetName, solution, arguments, callbackTarget: null, cancellationToken).ConfigureAwait(false); public static async Task<RazorRemoteHostClient?> TryGetClientAsync(HostWorkspaceServices services, RazorServiceDescriptorsWrapper serviceDescriptors, RazorRemoteServiceCallbackDispatcherRegistry callbackDispatchers, CancellationToken cancellationToken = default) { var client = await RemoteHostClient.TryGetClientAsync(services, cancellationToken).ConfigureAwait(false); if (client is null) return null; return new RazorRemoteHostClient((ServiceHubRemoteHostClient)client, serviceDescriptors, callbackDispatchers); } public RazorRemoteServiceConnectionWrapper<TService> CreateConnection<TService>(object? callbackTarget) where TService : class => new(_client.CreateConnection<TService>(_serviceDescriptors.UnderlyingObject, _callbackDispatchers, callbackTarget)); // no solution, no callback: public async ValueTask<bool> TryInvokeAsync<TService>(Func<TService, CancellationToken, ValueTask> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } // no solution, callback: public async ValueTask<bool> TryInvokeAsync<TService>(Func<TService, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } // solution, no callback: public async ValueTask<bool> TryInvokeAsync<TService>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } // solution, callback: public async ValueTask<bool> TryInvokeAsync<TService>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Remote; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { internal sealed class RazorRemoteHostClient { private readonly ServiceHubRemoteHostClient _client; private readonly RazorServiceDescriptorsWrapper _serviceDescriptors; private readonly RazorRemoteServiceCallbackDispatcherRegistry _callbackDispatchers; internal RazorRemoteHostClient(ServiceHubRemoteHostClient client, RazorServiceDescriptorsWrapper serviceDescriptors, RazorRemoteServiceCallbackDispatcherRegistry callbackDispatchers) { _client = client; _serviceDescriptors = serviceDescriptors; _callbackDispatchers = callbackDispatchers; } public static async Task<RazorRemoteHostClient?> TryGetClientAsync(HostWorkspaceServices services, RazorServiceDescriptorsWrapper serviceDescriptors, RazorRemoteServiceCallbackDispatcherRegistry callbackDispatchers, CancellationToken cancellationToken = default) { var client = await RemoteHostClient.TryGetClientAsync(services, cancellationToken).ConfigureAwait(false); if (client is null) return null; return new RazorRemoteHostClient((ServiceHubRemoteHostClient)client, serviceDescriptors, callbackDispatchers); } public RazorRemoteServiceConnectionWrapper<TService> CreateConnection<TService>(object? callbackTarget) where TService : class => new(_client.CreateConnection<TService>(_serviceDescriptors.UnderlyingObject, _callbackDispatchers, callbackTarget)); // no solution, no callback: public async ValueTask<bool> TryInvokeAsync<TService>(Func<TService, CancellationToken, ValueTask> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } // no solution, callback: public async ValueTask<bool> TryInvokeAsync<TService>(Func<TService, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(invocation, cancellationToken).ConfigureAwait(false); } // solution, no callback: public async ValueTask<bool> TryInvokeAsync<TService>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget: null); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } // solution, callback: public async ValueTask<bool> TryInvokeAsync<TService>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class { using var connection = CreateConnection<TService>(callbackTarget); return await connection.TryInvokeAsync(solution, invocation, cancellationToken).ConfigureAwait(false); } } }
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <Import Project="$(RepositoryEngineeringDir)targets\Services.props" /> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Roslyn.VisualStudio.Setup</RootNamespace> <TargetFramework>net472</TargetFramework> <!-- VSIX --> <GeneratePkgDefFile>true</GeneratePkgDefFile> <IncludeAssemblyInVSIXContainer>false</IncludeAssemblyInVSIXContainer> <IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer> <IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment> <ExtensionInstallationRoot>$(CommonExtensionInstallationRoot)</ExtensionInstallationRoot> <ExtensionInstallationFolder>$(LanguageServicesExtensionInstallationFolder)</ExtensionInstallationFolder> <!-- VS Insertion --> <VisualStudioInsertionComponent>Microsoft.CodeAnalysis.LanguageServices</VisualStudioInsertionComponent> <!-- ServiceHub AssemblyPath --> <!-- Path to our servicehub entry point dll in the vsix directory relative to our servicehub.servicehub.json files in the same vsix directory --> <ServiceHubAssemblyBasePath>.\</ServiceHubAssemblyBasePath> </PropertyGroup> <ItemGroup Label="PkgDef"> <None Include="PackageRegistration.pkgdef" PkgDefEntry="FileContent" /> </ItemGroup> <ItemGroup Label="Project References"> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj"> <Name>CodeAnalysis</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj"> <Name>CSharpCodeAnalysis</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <NgenPriority>1</NgenPriority> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj"> <Name>BasicCodeAnalysis</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Apex</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Debugger\Microsoft.CodeAnalysis.ExternalAccess.Debugger.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Debugger</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.FSharp</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Razor</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Xamarin.Remote\Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Core\Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.csproj"> <Name>Workspaces.Desktop</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj"> <Name>BasicFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj"> <Name>CSharpFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj"> <Name>CSharpEditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj"> <Name>EditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj"> <Name>EditorFeatures.Wpf</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj"> <Name>Features</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj"> <Name>LanguageServerProtocol</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\VisualStudio\LiveShare\Impl\Microsoft.VisualStudio.LanguageServices.LiveShare.csproj"> <Name>LiveShareLanguageServices</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj"> <Name>TextEditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj"> <Name>BasicEditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj"> <Name>Workspaces</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Core\MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj"> <Name>Workspaces.MSBuild</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <AdditionalProperties>TargetFramework=net472</AdditionalProperties> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj"> <Name>CSharpWorkspace</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj"> <Name>BasicWorkspace</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\Core\Def\Microsoft.VisualStudio.LanguageServices.csproj"> <Name>ServicesVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;PkgDefProjectOutputGroup;VsdConfigOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\CodeLens\Microsoft.VisualStudio.LanguageServices.CodeLens.csproj"> <Name>CodeAnalysisCodeLensVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation.csproj"> <Name>ServicesVisualStudioImpl</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj"> <Name>CSharpVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;PkgDefProjectOutputGroup;ContentFilesProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj"> <Name>BasicVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;PkgDefProjectOutputGroup;ContentFilesProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\Setup.Dependencies\Roslyn.VisualStudio.Setup.Dependencies.csproj"> <Name>VisualStudioSetup.Dependencies</Name> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <IncludeOutputGroupsInVSIX>SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> <Private>false</Private> </ProjectReference> <ProjectReference Include="..\Xaml\Impl\Microsoft.VisualStudio.LanguageServices.Xaml.csproj"> <Name>XamlVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj"> <Name>RemoteWorkspaces</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Remote\Razor\Microsoft.CodeAnalysis.Remote.Razor.ServiceHub.csproj"> <Name>RazorServiceHub</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj"> <Name>ServiceHub</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj"> <Name>Scripting</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup</IncludeOutputGroupsInVSIXLocalOnly> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj"> <Name>CSharpScripting</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup</IncludeOutputGroupsInVSIXLocalOnly> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj"> <Name>InteractiveFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup</IncludeOutputGroupsInVSIXLocalOnly> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Interactive\HostProcess\InteractiveHost64.csproj"> <Name>InteractiveHost.Core64</Name> <SetTargetFramework>TargetFramework=net5.0-windows7.0</SetTargetFramework> <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <Private>false</Private> <VSIXSubPath>InteractiveHost\Core</VSIXSubPath> <IncludeOutputGroupsInVSIX>PublishProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> <!-- Disable NGEN. Core assemblies are crossgened. --> <Ngen>false</Ngen> </ProjectReference> <ProjectReference Include="..\..\Interactive\HostProcess\InteractiveHost64.csproj"> <Name>InteractiveHost.Desktop64</Name> <SetTargetFramework>TargetFramework=net472</SetTargetFramework> <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <Private>false</Private> <VSIXSubPath>InteractiveHost\Desktop</VSIXSubPath> <IncludeOutputGroupsInVSIX>PublishProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> </ProjectReference> <ProjectReference Include="..\..\Interactive\HostProcess\InteractiveHost32.csproj"> <Name>InteractiveHost.Desktop32</Name> <!-- Note: do not set TargetFramework=net472 for InteractiveHost32. The project is not multi-targeted. Setting the property would create a build configuration that's different from the one the solution uses and thus would result in building the project twice. --> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <Private>false</Private> <VSIXSubPath>InteractiveHost\Desktop</VSIXSubPath> <IncludeOutputGroupsInVSIX>PublishProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> </ProjectReference> </ItemGroup> <ItemGroup> <NuGetPackageToIncludeInVsix Include="Humanizer.Core" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="Microsoft.CodeAnalysis.AnalyzerUtilities" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.core" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.bundle_green" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.provider.e_sqlite3.net45" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.provider.dynamic_cdecl" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="Microsoft.CodeAnalysis.Elfie" PkgDefEntry="BindingRedirect" /> <!-- Visual Studio ships with some, but not all, of the assemblies in System.Composition, but we need them all --> <NuGetPackageToIncludeInVsix Include="System.Composition.TypedParts" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="System.Composition.Convention" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="System.Composition.Hosting" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="ICSharpCode.Decompiler" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="Microsoft.VisualStudio.LanguageServer.Protocol" PkgDefEntry="CodeBase" /> <NugetPackageToIncludeInVsix Include="Microsoft.VisualStudio.LanguageServer.Protocol.Extensions" PkgDefEntry="CodeBase" /> </ItemGroup> <ItemGroup> <Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x86\native\e_sqlite3.dll"> <Link>runtimes\win-x86\native\e_sqlite3.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <IncludeInVSIX>true</IncludeInVSIX> <Visible>false</Visible> </Content> <Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x64\native\e_sqlite3.dll"> <Link>runtimes\win-x64\native\e_sqlite3.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <IncludeInVSIX>true</IncludeInVSIX> <Visible>false</Visible> </Content> </ItemGroup> <ItemGroup> <None Include="source.extension.vsixmanifest"> <SubType>Designer</SubType> </None> </ItemGroup> <ItemGroup> <Reference Include="System" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.DiaSymReader.PortablePdb" Version="$(MicrosoftDiaSymReaderPortablePdbVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="$(MicrosoftVisualStudioImagingInterop140DesignTimeVersion)" /> <PackageReference Include="Microsoft.VisualStudio.SDK.Analyzers" Version="$(MicrosoftVisualStudioSDKAnalyzersVersion)" PrivateAssets="all" /> <PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="$(MicrosoftVisualStudioShell150Version)" /> <PackageReference Include="Microsoft.VisualStudio.Shell.Framework" Version="$(MicrosoftVisualStudioShellFrameworkVersion)" /> <PackageReference Include="SQLitePCLRaw.bundle_green" Version="$(SQLitePCLRawbundle_greenVersion)" /> <PackageReference Include="Microsoft.CodeAnalysis.AnalyzerUtilities" Version="$(MicrosoftCodeAnalysisAnalyzerUtilitiesVersion)" PrivateAssets="all" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" /> </ItemGroup> <Import Project="$(RepositoryEngineeringDir)targets\GenerateServiceHubConfigurationFiles.targets" /> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <Import Project="$(RepositoryEngineeringDir)targets\Services.props" /> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Roslyn.VisualStudio.Setup</RootNamespace> <TargetFramework>net472</TargetFramework> <!-- VSIX --> <GeneratePkgDefFile>true</GeneratePkgDefFile> <IncludeAssemblyInVSIXContainer>false</IncludeAssemblyInVSIXContainer> <IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer> <IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment> <ExtensionInstallationRoot>$(CommonExtensionInstallationRoot)</ExtensionInstallationRoot> <ExtensionInstallationFolder>$(LanguageServicesExtensionInstallationFolder)</ExtensionInstallationFolder> <!-- VS Insertion --> <VisualStudioInsertionComponent>Microsoft.CodeAnalysis.LanguageServices</VisualStudioInsertionComponent> <!-- ServiceHub AssemblyPath --> <!-- Path to our servicehub entry point dll in the vsix directory relative to our servicehub.servicehub.json files in the same vsix directory --> <ServiceHubAssemblyBasePath>.\</ServiceHubAssemblyBasePath> </PropertyGroup> <ItemGroup Label="PkgDef"> <None Include="PackageRegistration.pkgdef" PkgDefEntry="FileContent" /> </ItemGroup> <ItemGroup Label="Project References"> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj"> <Name>CodeAnalysis</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj"> <Name>CSharpCodeAnalysis</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <NgenPriority>1</NgenPriority> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj"> <Name>BasicCodeAnalysis</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Apex</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Debugger\Microsoft.CodeAnalysis.ExternalAccess.Debugger.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Debugger</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.FSharp</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Razor</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Tools\ExternalAccess\Xamarin.Remote\Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote.csproj"> <Name>Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Core\Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.csproj"> <Name>Workspaces.Desktop</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj"> <Name>BasicFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj"> <Name>CSharpFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj"> <Name>CSharpEditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj"> <Name>EditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj"> <Name>EditorFeatures.Wpf</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj"> <Name>Features</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj"> <Name>LanguageServerProtocol</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\VisualStudio\LiveShare\Impl\Microsoft.VisualStudio.LanguageServices.LiveShare.csproj"> <Name>LiveShareLanguageServices</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj"> <Name>TextEditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj"> <Name>BasicEditorFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj"> <Name>Workspaces</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Core\MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj"> <Name>Workspaces.MSBuild</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <AdditionalProperties>TargetFramework=net472</AdditionalProperties> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj"> <Name>CSharpWorkspace</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj"> <Name>BasicWorkspace</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\Core\Def\Microsoft.VisualStudio.LanguageServices.csproj"> <Name>ServicesVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;PkgDefProjectOutputGroup;VsdConfigOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\CodeLens\Microsoft.VisualStudio.LanguageServices.CodeLens.csproj"> <Name>CodeAnalysisCodeLensVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation.csproj"> <Name>ServicesVisualStudioImpl</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj"> <Name>CSharpVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;PkgDefProjectOutputGroup;ContentFilesProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj"> <Name>BasicVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;PkgDefProjectOutputGroup;ContentFilesProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\Setup.Dependencies\Roslyn.VisualStudio.Setup.Dependencies.csproj"> <Name>VisualStudioSetup.Dependencies</Name> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <IncludeOutputGroupsInVSIX>SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> <Private>false</Private> </ProjectReference> <ProjectReference Include="..\Xaml\Impl\Microsoft.VisualStudio.LanguageServices.Xaml.csproj"> <Name>XamlVisualStudio</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj"> <Name>RemoteWorkspaces</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj"> <Name>ServiceHub</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> <NgenPriority>1</NgenPriority> </ProjectReference> <ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj"> <Name>Scripting</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup</IncludeOutputGroupsInVSIXLocalOnly> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj"> <Name>CSharpScripting</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup</IncludeOutputGroupsInVSIXLocalOnly> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj"> <Name>InteractiveFeatures</Name> <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup</IncludeOutputGroupsInVSIXLocalOnly> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> <PkgDefEntry>BindingRedirect</PkgDefEntry> </ProjectReference> <ProjectReference Include="..\..\Interactive\HostProcess\InteractiveHost64.csproj"> <Name>InteractiveHost.Core64</Name> <SetTargetFramework>TargetFramework=net5.0-windows7.0</SetTargetFramework> <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <Private>false</Private> <VSIXSubPath>InteractiveHost\Core</VSIXSubPath> <IncludeOutputGroupsInVSIX>PublishProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> <!-- Disable NGEN. Core assemblies are crossgened. --> <Ngen>false</Ngen> </ProjectReference> <ProjectReference Include="..\..\Interactive\HostProcess\InteractiveHost64.csproj"> <Name>InteractiveHost.Desktop64</Name> <SetTargetFramework>TargetFramework=net472</SetTargetFramework> <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <Private>false</Private> <VSIXSubPath>InteractiveHost\Desktop</VSIXSubPath> <IncludeOutputGroupsInVSIX>PublishProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> </ProjectReference> <ProjectReference Include="..\..\Interactive\HostProcess\InteractiveHost32.csproj"> <Name>InteractiveHost.Desktop32</Name> <!-- Note: do not set TargetFramework=net472 for InteractiveHost32. The project is not multi-targeted. Setting the property would create a build configuration that's different from the one the solution uses and thus would result in building the project twice. --> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <Private>false</Private> <VSIXSubPath>InteractiveHost\Desktop</VSIXSubPath> <IncludeOutputGroupsInVSIX>PublishProjectOutputGroup</IncludeOutputGroupsInVSIX> <IncludeOutputGroupsInVSIXLocalOnly></IncludeOutputGroupsInVSIXLocalOnly> </ProjectReference> </ItemGroup> <ItemGroup> <NuGetPackageToIncludeInVsix Include="Humanizer.Core" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="Microsoft.CodeAnalysis.AnalyzerUtilities" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.core" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.bundle_green" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.provider.e_sqlite3.net45" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="SQLitePCLRaw.provider.dynamic_cdecl" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="Microsoft.CodeAnalysis.Elfie" PkgDefEntry="BindingRedirect" /> <!-- Visual Studio ships with some, but not all, of the assemblies in System.Composition, but we need them all --> <NuGetPackageToIncludeInVsix Include="System.Composition.TypedParts" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="System.Composition.Convention" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="System.Composition.Hosting" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="ICSharpCode.Decompiler" PkgDefEntry="CodeBase" /> <NuGetPackageToIncludeInVsix Include="Microsoft.VisualStudio.LanguageServer.Protocol" PkgDefEntry="CodeBase" /> <NugetPackageToIncludeInVsix Include="Microsoft.VisualStudio.LanguageServer.Protocol.Extensions" PkgDefEntry="CodeBase" /> </ItemGroup> <ItemGroup> <Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x86\native\e_sqlite3.dll"> <Link>runtimes\win-x86\native\e_sqlite3.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <IncludeInVSIX>true</IncludeInVSIX> <Visible>false</Visible> </Content> <Content Include="$(NuGetPackageRoot)\sqlitepclraw.lib.e_sqlite3\$(SQLitePCLRawbundle_greenVersion)\runtimes\win-x64\native\e_sqlite3.dll"> <Link>runtimes\win-x64\native\e_sqlite3.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <IncludeInVSIX>true</IncludeInVSIX> <Visible>false</Visible> </Content> </ItemGroup> <ItemGroup> <None Include="source.extension.vsixmanifest"> <SubType>Designer</SubType> </None> </ItemGroup> <ItemGroup> <Reference Include="System" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.DiaSymReader.PortablePdb" Version="$(MicrosoftDiaSymReaderPortablePdbVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="$(MicrosoftVisualStudioImagingInterop140DesignTimeVersion)" /> <PackageReference Include="Microsoft.VisualStudio.SDK.Analyzers" Version="$(MicrosoftVisualStudioSDKAnalyzersVersion)" PrivateAssets="all" /> <PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="$(MicrosoftVisualStudioShell150Version)" /> <PackageReference Include="Microsoft.VisualStudio.Shell.Framework" Version="$(MicrosoftVisualStudioShellFrameworkVersion)" /> <PackageReference Include="SQLitePCLRaw.bundle_green" Version="$(SQLitePCLRawbundle_greenVersion)" /> <PackageReference Include="Microsoft.CodeAnalysis.AnalyzerUtilities" Version="$(MicrosoftCodeAnalysisAnalyzerUtilitiesVersion)" PrivateAssets="all" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" /> </ItemGroup> <Import Project="$(RepositoryEngineeringDir)targets\GenerateServiceHubConfigurationFiles.targets" /> </Project>
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Desktop/Microsoft.CodeAnalysis.Workspaces.Desktop.csproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis</RootNamespace> <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks> <ExcludeFromSourceBuild>true</ExcludeFromSourceBuild> <!-- NuGet --> <IsPackable>true</IsPackable> </PropertyGroup> <ItemGroup> <PackageReference Include="System.ComponentModel.Composition" Version="$(SystemComponentModelCompositionVersion)" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Features" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor.ServiceHub" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" /> <InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Setup" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" /> <!-- BEGIN MONODEVELOP These MonoDevelop dependencies don't ship with Visual Studio, so can't break our binary insertions and are exempted from the ExternalAccess adapter assembly policies. --> <InternalsVisibleTo Include="MonoDevelop.Ide" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <!-- END MONODEVELOP --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Desktop.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" /> <InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis</RootNamespace> <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks> <ExcludeFromSourceBuild>true</ExcludeFromSourceBuild> <!-- NuGet --> <IsPackable>true</IsPackable> </PropertyGroup> <ItemGroup> <PackageReference Include="System.ComponentModel.Composition" Version="$(SystemComponentModelCompositionVersion)" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Features" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" /> <InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Setup" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" /> <!-- BEGIN MONODEVELOP These MonoDevelop dependencies don't ship with Visual Studio, so can't break our binary insertions and are exempted from the ExternalAccess adapter assembly policies. --> <InternalsVisibleTo Include="MonoDevelop.Ide" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <!-- END MONODEVELOP --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Desktop.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" /> <InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> </Project>
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis</RootNamespace> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks> <DefineConstants>$(DefineConstants);WORKSPACE</DefineConstants> <GeneratePerformanceSensitiveAttribute>true</GeneratePerformanceSensitiveAttribute> <ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">partial</ApplyNgenOptimization> <!-- NuGet --> <IsPackable>true</IsPackable> <PackageId>Microsoft.CodeAnalysis.Workspaces.Common</PackageId> <PackageDescription> A shared package used by the .NET Compiler Platform ("Roslyn") including support for analyzing projects and solutions. Do not install this package manually, it will be added as a prerequisite by other packages that require it. </PackageDescription> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="SQLitePCLRaw.bundle_green" Version="$(SQLitePCLRawbundle_greenVersion)" PrivateAssets="all" Condition="'$(DotNetBuildFromSource)' != 'true'" /> <PackageReference Include="System.Composition" Version="$(SystemCompositionVersion)" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesVersion)" /> <PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesVersion)" /> </ItemGroup> <ItemGroup Label="Linked Files"> <Compile Remove="Storage\Sqlite\**\*.cs" Condition="'$(DotNetBuildFromSource)' == 'true'" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerAssemblyLoader.cs" Link="Diagnostics\CompilerShared\AnalyzerAssemblyLoader.cs" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\DefaultAnalyzerAssemblyLoader.Core.cs" Link="Diagnostics\CompilerShared\DefaultAnalyzerAssemblyLoader.Core.cs" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\DefaultAnalyzerAssemblyLoader.Desktop.cs" Link="Diagnostics\CompilerShared\DefaultAnalyzerAssemblyLoader.Desktop.cs" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\ShadowCopyAnalyzerAssemblyLoader.cs" Link="Diagnostics\CompilerShared\ShadowCopyAnalyzerAssemblyLoader.cs" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="AnalyzerRunner" /> <InternalsVisibleTo Include="csi" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Features" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Workspaces" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Text" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Wpf" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Apex" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Debugger" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.UnitTesting" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Features" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.UnitTests" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator.UnitTests" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Test.Utilities" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor.ServiceHub" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.UnitTests" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Features" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Desktop" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Xaml" /> <InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Setup" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" /> <!-- BEGIN MONODEVELOP These MonoDevelop dependencies don't ship with Visual Studio, so can't break our binary insertions and are exempted from the ExternalAccess adapter assembly policies. --> <InternalsVisibleTo Include="MonoDevelop.Ide" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <!-- this is currently built externally, as part of the MonoDevelop build --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Cocoa" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Cocoa.UnitTests" LoadsWithinVisualStudio="false" /> <!-- END MONODEVELOP --> <InternalsVisibleTo Include="Xamarin.Ide" Key="$(MonoDevelopKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35099" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="IdeBenchmarks" /> <InternalsVisibleTo Include="IdeCoreBenchmarks" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Closed.UnitTests" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.IntegrationTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Setup" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Utilities" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.TypeScript.EditorFeatures" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.TypeScript" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" /> <InternalsVisibleTo Include="Roslyn.Services.Editor.TypeScript.UnitTests" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" /> <InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="Microsoft.Test.Apex.VisualStudio" Key="$(VisualStudioKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> </ItemGroup> <ItemGroup> <!-- TODO: Remove the below IVTs to CodeStyle Unit test projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities" /> </ItemGroup> <ItemGroup> <EmbeddedResource Update="WorkspacesResources.resx" GenerateSource="true" /> </ItemGroup> <ItemGroup> <PackageReference Include="Humanizer.Core" Version="$(HumanizerCoreVersion)" PrivateAssets="compile" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> <Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" /> <Import Project="..\..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems" Label="Shared" /> <Import Project="..\..\..\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems" Label="Shared" /> <Import Project="..\..\..\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems" Label="Shared" /> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis</RootNamespace> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks> <DefineConstants>$(DefineConstants);WORKSPACE</DefineConstants> <GeneratePerformanceSensitiveAttribute>true</GeneratePerformanceSensitiveAttribute> <ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">partial</ApplyNgenOptimization> <!-- NuGet --> <IsPackable>true</IsPackable> <PackageId>Microsoft.CodeAnalysis.Workspaces.Common</PackageId> <PackageDescription> A shared package used by the .NET Compiler Platform ("Roslyn") including support for analyzing projects and solutions. Do not install this package manually, it will be added as a prerequisite by other packages that require it. </PackageDescription> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="SQLitePCLRaw.bundle_green" Version="$(SQLitePCLRawbundle_greenVersion)" PrivateAssets="all" Condition="'$(DotNetBuildFromSource)' != 'true'" /> <PackageReference Include="System.Composition" Version="$(SystemCompositionVersion)" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesVersion)" /> <PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesVersion)" /> </ItemGroup> <ItemGroup Label="Linked Files"> <Compile Remove="Storage\Sqlite\**\*.cs" Condition="'$(DotNetBuildFromSource)' == 'true'" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerAssemblyLoader.cs" Link="Diagnostics\CompilerShared\AnalyzerAssemblyLoader.cs" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\DefaultAnalyzerAssemblyLoader.Core.cs" Link="Diagnostics\CompilerShared\DefaultAnalyzerAssemblyLoader.Core.cs" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\DefaultAnalyzerAssemblyLoader.Desktop.cs" Link="Diagnostics\CompilerShared\DefaultAnalyzerAssemblyLoader.Desktop.cs" /> <Compile Include="..\..\..\Compilers\Core\Portable\DiagnosticAnalyzer\ShadowCopyAnalyzerAssemblyLoader.cs" Link="Diagnostics\CompilerShared\ShadowCopyAnalyzerAssemblyLoader.cs" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="AnalyzerRunner" /> <InternalsVisibleTo Include="csi" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Features" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Workspaces" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Text" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Wpf" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Apex" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Debugger" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.UnitTesting" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Features" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.UnitTests" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator.UnitTests" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Test.Utilities" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.UnitTests" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Features" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Desktop" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Xaml" /> <InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Setup" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" /> <!-- BEGIN MONODEVELOP These MonoDevelop dependencies don't ship with Visual Studio, so can't break our binary insertions and are exempted from the ExternalAccess adapter assembly policies. --> <InternalsVisibleTo Include="MonoDevelop.Ide" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.VBNetBinding.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <!-- this is currently built externally, as part of the MonoDevelop build --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Cocoa" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Cocoa.UnitTests" LoadsWithinVisualStudio="false" /> <!-- END MONODEVELOP --> <InternalsVisibleTo Include="Xamarin.Ide" Key="$(MonoDevelopKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35099" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="IdeBenchmarks" /> <InternalsVisibleTo Include="IdeCoreBenchmarks" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Closed.UnitTests" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.IntegrationTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Setup" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Utilities" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.TypeScript.EditorFeatures" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.TypeScript" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" /> <InternalsVisibleTo Include="Roslyn.Services.Editor.TypeScript.UnitTests" Key="$(TypeScriptKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35077" /> <InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="Microsoft.Test.Apex.VisualStudio" Key="$(VisualStudioKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> </ItemGroup> <ItemGroup> <!-- TODO: Remove the below IVTs to CodeStyle Unit test projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities" /> </ItemGroup> <ItemGroup> <EmbeddedResource Update="WorkspacesResources.resx" GenerateSource="true" /> </ItemGroup> <ItemGroup> <PackageReference Include="Humanizer.Core" Version="$(HumanizerCoreVersion)" PrivateAssets="compile" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> <Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" /> <Import Project="..\..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems" Label="Shared" /> <Import Project="..\..\..\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems" Label="Shared" /> <Import Project="..\..\..\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems" Label="Shared" /> </Project>
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Remote/RemoteServiceName.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Remote { /// <summary> /// Abstract the name of a remote service. /// </summary> /// <remarks> /// Allows partner teams to specify bitness-specific service name, while we can use bitness agnostic id for well-known services. /// TODO: Update LUT and SBD to use well-known ids and remove this abstraction (https://github.com/dotnet/roslyn/issues/44327). /// </remarks> internal readonly struct RemoteServiceName : IEquatable<RemoteServiceName> { internal const string Prefix = "roslyn"; internal const string Suffix64 = "64"; internal const string SuffixServerGC = "S"; internal const string IntelliCodeServiceName = "pythia"; internal const string RazorServiceName = "razorLanguageService"; internal const string UnitTestingAnalysisServiceName = "UnitTestingAnalysis"; internal const string LiveUnitTestingBuildServiceName = "LiveUnitTestingBuild"; internal const string UnitTestingSourceLookupServiceName = "UnitTestingSourceLookup"; public readonly WellKnownServiceHubService WellKnownService; public readonly string? CustomServiceName; public RemoteServiceName(WellKnownServiceHubService wellKnownService) { WellKnownService = wellKnownService; CustomServiceName = null; } /// <summary> /// Exact service name - must be reflect the bitness of the ServiceHub process. /// </summary> public RemoteServiceName(string customServiceName) { WellKnownService = WellKnownServiceHubService.None; CustomServiceName = customServiceName; } public string ToString(bool isRemoteHost64Bit, bool isRemoteHostServerGC) { return CustomServiceName ?? (WellKnownService, isRemoteHost64Bit, isRemoteHostServerGC) switch { (WellKnownServiceHubService.RemoteHost, false, _) => Prefix + nameof(WellKnownServiceHubService.RemoteHost), (WellKnownServiceHubService.RemoteHost, true, false) => Prefix + nameof(WellKnownServiceHubService.RemoteHost) + Suffix64, (WellKnownServiceHubService.RemoteHost, true, true) => Prefix + nameof(WellKnownServiceHubService.RemoteHost) + Suffix64 + SuffixServerGC, (WellKnownServiceHubService.IntelliCode, false, _) => IntelliCodeServiceName, (WellKnownServiceHubService.IntelliCode, true, false) => IntelliCodeServiceName + Suffix64, (WellKnownServiceHubService.IntelliCode, true, true) => IntelliCodeServiceName + Suffix64 + SuffixServerGC, (WellKnownServiceHubService.Razor, false, _) => RazorServiceName, (WellKnownServiceHubService.Razor, true, false) => RazorServiceName + Suffix64, (WellKnownServiceHubService.Razor, true, true) => RazorServiceName + Suffix64 + SuffixServerGC, (WellKnownServiceHubService.UnitTestingAnalysisService, false, _) => UnitTestingAnalysisServiceName, (WellKnownServiceHubService.UnitTestingAnalysisService, true, false) => UnitTestingAnalysisServiceName + Suffix64, (WellKnownServiceHubService.UnitTestingAnalysisService, true, true) => UnitTestingAnalysisServiceName + Suffix64 + SuffixServerGC, (WellKnownServiceHubService.LiveUnitTestingBuildService, false, _) => LiveUnitTestingBuildServiceName, (WellKnownServiceHubService.LiveUnitTestingBuildService, true, false) => LiveUnitTestingBuildServiceName + Suffix64, (WellKnownServiceHubService.LiveUnitTestingBuildService, true, true) => LiveUnitTestingBuildServiceName + Suffix64 + SuffixServerGC, (WellKnownServiceHubService.UnitTestingSourceLookupService, false, _) => UnitTestingSourceLookupServiceName, (WellKnownServiceHubService.UnitTestingSourceLookupService, true, false) => UnitTestingSourceLookupServiceName + Suffix64, (WellKnownServiceHubService.UnitTestingSourceLookupService, true, true) => UnitTestingSourceLookupServiceName + Suffix64 + SuffixServerGC, _ => throw ExceptionUtilities.UnexpectedValue(WellKnownService), }; } public override bool Equals(object? obj) => obj is RemoteServiceName name && Equals(name); public override int GetHashCode() => Hash.Combine(CustomServiceName, (int)WellKnownService); public bool Equals(RemoteServiceName other) => CustomServiceName == other.CustomServiceName && WellKnownService == other.WellKnownService; public static bool operator ==(RemoteServiceName left, RemoteServiceName right) => left.Equals(right); public static bool operator !=(RemoteServiceName left, RemoteServiceName right) => !(left == right); public static implicit operator RemoteServiceName(WellKnownServiceHubService wellKnownService) => new(wellKnownService); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Remote { /// <summary> /// Abstract the name of a remote service. /// </summary> /// <remarks> /// Allows partner teams to specify bitness-specific service name, while we can use bitness agnostic id for well-known services. /// TODO: Update LUT and SBD to use well-known ids and remove this abstraction (https://github.com/dotnet/roslyn/issues/44327). /// </remarks> internal readonly struct RemoteServiceName : IEquatable<RemoteServiceName> { internal const string Prefix = "roslyn"; internal const string Suffix64 = "64"; internal const string SuffixServerGC = "S"; internal const string IntelliCodeServiceName = "pythia"; internal const string RazorServiceName = "razorLanguageService"; internal const string UnitTestingAnalysisServiceName = "UnitTestingAnalysis"; internal const string LiveUnitTestingBuildServiceName = "LiveUnitTestingBuild"; internal const string UnitTestingSourceLookupServiceName = "UnitTestingSourceLookup"; public readonly WellKnownServiceHubService WellKnownService; public readonly string? CustomServiceName; public RemoteServiceName(WellKnownServiceHubService wellKnownService) { WellKnownService = wellKnownService; CustomServiceName = null; } /// <summary> /// Exact service name - must be reflect the bitness of the ServiceHub process. /// </summary> public RemoteServiceName(string customServiceName) { WellKnownService = WellKnownServiceHubService.None; CustomServiceName = customServiceName; } public string ToString(bool isRemoteHost64Bit, bool isRemoteHostServerGC) { return CustomServiceName ?? (WellKnownService, isRemoteHost64Bit, isRemoteHostServerGC) switch { (WellKnownServiceHubService.RemoteHost, false, _) => Prefix + nameof(WellKnownServiceHubService.RemoteHost), (WellKnownServiceHubService.RemoteHost, true, false) => Prefix + nameof(WellKnownServiceHubService.RemoteHost) + Suffix64, (WellKnownServiceHubService.RemoteHost, true, true) => Prefix + nameof(WellKnownServiceHubService.RemoteHost) + Suffix64 + SuffixServerGC, (WellKnownServiceHubService.IntelliCode, false, _) => IntelliCodeServiceName, (WellKnownServiceHubService.IntelliCode, true, false) => IntelliCodeServiceName + Suffix64, (WellKnownServiceHubService.IntelliCode, true, true) => IntelliCodeServiceName + Suffix64 + SuffixServerGC, _ => throw ExceptionUtilities.UnexpectedValue(WellKnownService), }; } public override bool Equals(object? obj) => obj is RemoteServiceName name && Equals(name); public override int GetHashCode() => Hash.Combine(CustomServiceName, (int)WellKnownService); public bool Equals(RemoteServiceName other) => CustomServiceName == other.CustomServiceName && WellKnownService == other.WellKnownService; public static bool operator ==(RemoteServiceName left, RemoteServiceName right) => left.Equals(right); public static bool operator !=(RemoteServiceName left, RemoteServiceName right) => !(left == right); public static implicit operator RemoteServiceName(WellKnownServiceHubService wellKnownService) => new(wellKnownService); } }
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Remote/WellKnownServiceHubService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.Remote { internal enum WellKnownServiceHubService { None = 0, RemoteHost = 1, // obsolete: CodeAnalysis = 2, // obsolete: RemoteSymbolSearchUpdateService = 3, // obsolete: RemoteDesignerAttributeService = 4, // obsolete: RemoteProjectTelemetryService = 5, // obsolete: RemoteTodoCommentsService = 6, // obsolete: RemoteLanguageServer = 7, IntelliCode = 8, Razor = 9, // owned by Unit Testing team: UnitTestingAnalysisService = 10, LiveUnitTestingBuildService = 11, UnitTestingSourceLookupService = 12, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.Remote { internal enum WellKnownServiceHubService { None = 0, RemoteHost = 1, // obsolete: CodeAnalysis = 2, // obsolete: RemoteSymbolSearchUpdateService = 3, // obsolete: RemoteDesignerAttributeService = 4, // obsolete: RemoteProjectTelemetryService = 5, // obsolete: RemoteTodoCommentsService = 6, // obsolete: RemoteLanguageServer = 7, IntelliCode = 8, // obsolete: Razor = 9, // owned by Unit Testing team: // obsolete: UnitTestingAnalysisService = 10, // obsolete: LiveUnitTestingBuildService = 11, // obsolete: UnitTestingSourceLookupService = 12, } }
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Remote/Core/Microsoft.CodeAnalysis.Remote.Workspaces.csproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis.Remote</RootNamespace> <TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">partial</ApplyNgenOptimization> <!-- NuGet --> <IsPackable>true</IsPackable> <PackageDescription> A shared package used by the .NET Compiler Platform ("Roslyn") including support for coordinating analysis of projects and solutions using a separate server process. Do not install this package manually, it will be added as a prerequisite by other packages that require it. </PackageDescription> </PropertyGroup> <ItemGroup Label="Project References"> <!-- Features are currently required due to dependencies from JSON serializer and SolutionChecksumUpdater (Solution Crawler). https://github.com/dotnet/roslyn/issues/46519 --> <ProjectReference Include="..\..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="System.Composition" Version="$(SystemCompositionVersion)" /> <PackageReference Include="System.ComponentModel.Composition" Version="$(SystemComponentModelCompositionVersion)" /> <PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Composition" Version="$(MicrosoftVisualStudioCompositionVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" PrivateAssets="all" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" /> <PackageReference Include="Microsoft.ServiceHub.Client" Version="$(MicrosoftServiceHubClientVersion)" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> <ItemGroup> <EmbeddedResource Update="RemoteWorkspacesResources.resx" GenerateSource="true" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor.ServiceHub" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor"/> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <!-- BEGIN MONODEVELOP These MonoDevelop dependencies don't ship with Visual Studio, so can't break our binary insertions and are exempted from the ExternalAccess adapter assembly policies. --> <InternalsVisibleTo Include="MonoDevelop.Ide" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <!-- END MONODEVELOP --> </ItemGroup> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis.Remote</RootNamespace> <TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">partial</ApplyNgenOptimization> <!-- NuGet --> <IsPackable>true</IsPackable> <PackageDescription> A shared package used by the .NET Compiler Platform ("Roslyn") including support for coordinating analysis of projects and solutions using a separate server process. Do not install this package manually, it will be added as a prerequisite by other packages that require it. </PackageDescription> </PropertyGroup> <ItemGroup Label="Project References"> <!-- Features are currently required due to dependencies from JSON serializer and SolutionChecksumUpdater (Solution Crawler). https://github.com/dotnet/roslyn/issues/46519 --> <ProjectReference Include="..\..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="System.Composition" Version="$(SystemCompositionVersion)" /> <PackageReference Include="System.ComponentModel.Composition" Version="$(SystemComponentModelCompositionVersion)" /> <PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Composition" Version="$(MicrosoftVisualStudioCompositionVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" PrivateAssets="all" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" /> <PackageReference Include="Microsoft.ServiceHub.Client" Version="$(MicrosoftServiceHubClientVersion)" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> <ItemGroup> <EmbeddedResource Update="RemoteWorkspacesResources.resx" GenerateSource="true" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.DiagnosticsWindow" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.VisualBasic" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <!-- BEGIN MONODEVELOP These MonoDevelop dependencies don't ship with Visual Studio, so can't break our binary insertions and are exempted from the ExternalAccess adapter assembly policies. --> <InternalsVisibleTo Include="MonoDevelop.Ide" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <InternalsVisibleTo Include="MonoDevelop.Refactoring.Tests" Key="$(MonoDevelopKey)" LoadsWithinVisualStudio="false" /> <!-- END MONODEVELOP --> </ItemGroup> </Project>
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis.Remote</RootNamespace> <TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <!-- NuGet --> <IsPackable>true</IsPackable> <PackageDescription> A shared package used by the .NET Compiler Platform ("Roslyn") including support for coordinating analysis of projects and solutions using a separate server process. Do not install this package manually, it will be added as a prerequisite by other packages that require it. </PackageDescription> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" /> <ProjectReference Include="..\..\..\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj" /> <ProjectReference Include="..\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" /> <PackageReference Include="Microsoft.VisualStudio.CoreUtility" Version="$(MicrosoftVisualStudioCoreUtilityVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.Data" Version="$(MicrosoftVisualStudioTextDataVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.Logic" Version="$(MicrosoftVisualStudioTextLogicVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.UI" Version="$(MicrosoftVisualStudioTextUIVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" PrivateAssets="all" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Microsoft.ServiceHub.Framework" Version="$(MicrosoftServiceHubFrameworkVersion)" /> <PackageReference Include="Microsoft.VisualStudio.RpcContracts" Version="$(MicrosoftVisualStudioRpcContractsVersion)" /> <PackageReference Include="Nerdbank.Streams" Version="$(NerdbankStreamsVersion)" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> <ItemGroup> <Compile Include="..\..\..\VisualStudio\Core\Def\Implementation\UnusedReferences\ProjectAssets\ProjectAssetsFileReader.cs" Link="Services\UnusedReferences\ProjectAssets\ProjectAssetsFileReader.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Implementation\Watson\WatsonExtensions.cs" Link="Services\WorkspaceTelemetry\WatsonExtensions.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Implementation\Watson\WatsonReporter.cs" Link="Services\WorkspaceTelemetry\WatsonReporter.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Storage\AbstractCloudCachePersistentStorageService.cs" Link="Host\Storage\AbstractCloudCachePersistentStorageService.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Storage\CloudCachePersistentStorage.cs" Link="Host\Storage\CloudCachePersistentStorage.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Storage\ProjectContainerKeyCache.cs" Link="Host\Storage\ProjectContainerKeyCache.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\VSTelemetryCache.cs" Link="Services\WorkspaceTelemetry\VSTelemetryCache.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\VSTelemetryLogger.cs" Link="Services\WorkspaceTelemetry\VSTelemetryLogger.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\AbstractWorkspaceTelemetryService.cs" Link="Services\WorkspaceTelemetry\AbstractWorkspaceTelemetryService.cs" /> </ItemGroup> <ItemGroup> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor.ServiceHub" /> <!-- TODO - This IVT should be removed - https://github.com/dotnet/roslyn/issues/46940 --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor" Key="$(RazorKey)" /> </ItemGroup> <ItemGroup> <Folder Include="Services\UnusedReferences\ProjectAssets\" /> </ItemGroup> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis.Remote</RootNamespace> <TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <!-- NuGet --> <IsPackable>true</IsPackable> <PackageDescription> A shared package used by the .NET Compiler Platform ("Roslyn") including support for coordinating analysis of projects and solutions using a separate server process. Do not install this package manually, it will be added as a prerequisite by other packages that require it. </PackageDescription> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" /> <ProjectReference Include="..\..\..\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj" /> <ProjectReference Include="..\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" /> <PackageReference Include="Microsoft.VisualStudio.CoreUtility" Version="$(MicrosoftVisualStudioCoreUtilityVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.Data" Version="$(MicrosoftVisualStudioTextDataVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.Logic" Version="$(MicrosoftVisualStudioTextLogicVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.UI" Version="$(MicrosoftVisualStudioTextUIVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" PrivateAssets="all" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Microsoft.ServiceHub.Framework" Version="$(MicrosoftServiceHubFrameworkVersion)" /> <PackageReference Include="Microsoft.VisualStudio.RpcContracts" Version="$(MicrosoftVisualStudioRpcContractsVersion)" /> <PackageReference Include="Nerdbank.Streams" Version="$(NerdbankStreamsVersion)" /> </ItemGroup> <ItemGroup> <PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" /> </ItemGroup> <ItemGroup> <Compile Include="..\..\..\VisualStudio\Core\Def\Implementation\UnusedReferences\ProjectAssets\ProjectAssetsFileReader.cs" Link="Services\UnusedReferences\ProjectAssets\ProjectAssetsFileReader.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Implementation\Watson\WatsonExtensions.cs" Link="Services\WorkspaceTelemetry\WatsonExtensions.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Implementation\Watson\WatsonReporter.cs" Link="Services\WorkspaceTelemetry\WatsonReporter.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Storage\AbstractCloudCachePersistentStorageService.cs" Link="Host\Storage\AbstractCloudCachePersistentStorageService.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Storage\CloudCachePersistentStorage.cs" Link="Host\Storage\CloudCachePersistentStorage.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Storage\ProjectContainerKeyCache.cs" Link="Host\Storage\ProjectContainerKeyCache.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\VSTelemetryCache.cs" Link="Services\WorkspaceTelemetry\VSTelemetryCache.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\VSTelemetryLogger.cs" Link="Services\WorkspaceTelemetry\VSTelemetryLogger.cs" /> <Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\AbstractWorkspaceTelemetryService.cs" Link="Services\WorkspaceTelemetry\AbstractWorkspaceTelemetryService.cs" /> </ItemGroup> <ItemGroup> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" /> <InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> <InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Xamarin.Remote" /> <!-- TODO - This IVT should be removed - https://github.com/dotnet/roslyn/issues/46940 --> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor" Key="$(RazorKey)" /> </ItemGroup> <ItemGroup> <Folder Include="Services\UnusedReferences\ProjectAssets\" /> </ItemGroup> </Project>
1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Core/Def/Utilities/IServiceProviderExtensions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Diagnostics; namespace Microsoft.VisualStudio.LanguageServices.Utilities { internal static class IServiceProviderExtensions { /// <inheritdoc cref="Shell.ServiceExtensions.GetService{TService, TInterface}(IServiceProvider, bool)"/> public static TInterface GetService<TService, TInterface>(this IServiceProvider sp) { var service = (TInterface)sp.GetService(typeof(TService)); Debug.Assert(service != null); return service; } /// <summary> /// Returns the specified service type from the service. /// </summary> public static TServiceType GetService<TServiceType>(this IServiceProvider sp) where TServiceType : class => sp.GetService<TServiceType, TServiceType>(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Diagnostics; namespace Microsoft.VisualStudio.LanguageServices.Utilities { internal static class IServiceProviderExtensions { /// <inheritdoc cref="Shell.ServiceExtensions.GetService{TService, TInterface}(IServiceProvider, bool)"/> public static TInterface GetService<TService, TInterface>(this IServiceProvider sp) { var service = (TInterface)sp.GetService(typeof(TService)); Debug.Assert(service != null); return service; } /// <summary> /// Returns the specified service type from the service. /// </summary> public static TServiceType GetService<TServiceType>(this IServiceProvider sp) where TServiceType : class => sp.GetService<TServiceType, TServiceType>(); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Test/Symbol/Symbols/LocalFunctionTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols { public class LocalFunctionTests : CSharpTestBase { [Fact, WorkItem(27719, "https://github.com/dotnet/roslyn/issues/27719")] public void LocalFunctionIsNotStatic() { var source = @" class C { void M() { void local() {} local(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); var local = semanticModel.GetDeclaredSymbol(localSyntax); Assert.False(local.IsStatic); } [Fact, WorkItem(27719, "https://github.com/dotnet/roslyn/issues/27719")] public void StaticLocalFunctionIsStatic() { var source = @" class C { void M() { static void local() {} local(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); var local = semanticModel.GetDeclaredSymbol(localSyntax); Assert.True(local.IsStatic); } [Fact, WorkItem(27719, "https://github.com/dotnet/roslyn/issues/27719")] public void LocalFunctionInStaticMethodIsNotStatic() { var source = @" class C { static void M() { void local() {} local(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); var local = semanticModel.GetDeclaredSymbol(localSyntax); Assert.False(local.IsStatic); } [Fact] public void LocalFunctionDoesNotRequireInstanceReceiver() { var source = @" class C { void M() { void local() {} static void staticLocal() {} local(); staticLocal(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localsSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); var local = semanticModel.GetDeclaredSymbol(localsSyntax[0]).GetSymbol<MethodSymbol>(); Assert.False(local.RequiresInstanceReceiver); var staticLocal = semanticModel.GetDeclaredSymbol(localsSyntax[0]).GetSymbol<MethodSymbol>(); Assert.False(staticLocal.RequiresInstanceReceiver); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols { public class LocalFunctionTests : CSharpTestBase { [Fact, WorkItem(27719, "https://github.com/dotnet/roslyn/issues/27719")] public void LocalFunctionIsNotStatic() { var source = @" class C { void M() { void local() {} local(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); var local = semanticModel.GetDeclaredSymbol(localSyntax); Assert.False(local.IsStatic); } [Fact, WorkItem(27719, "https://github.com/dotnet/roslyn/issues/27719")] public void StaticLocalFunctionIsStatic() { var source = @" class C { void M() { static void local() {} local(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); var local = semanticModel.GetDeclaredSymbol(localSyntax); Assert.True(local.IsStatic); } [Fact, WorkItem(27719, "https://github.com/dotnet/roslyn/issues/27719")] public void LocalFunctionInStaticMethodIsNotStatic() { var source = @" class C { static void M() { void local() {} local(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); var local = semanticModel.GetDeclaredSymbol(localSyntax); Assert.False(local.IsStatic); } [Fact] public void LocalFunctionDoesNotRequireInstanceReceiver() { var source = @" class C { void M() { void local() {} static void staticLocal() {} local(); staticLocal(); } }"; var compilation = CreateCompilation(source).VerifyDiagnostics(); var tree = compilation.SyntaxTrees[0]; var semanticModel = compilation.GetSemanticModel(tree); var localsSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); var local = semanticModel.GetDeclaredSymbol(localsSyntax[0]).GetSymbol<MethodSymbol>(); Assert.False(local.RequiresInstanceReceiver); var staticLocal = semanticModel.GetDeclaredSymbol(localsSyntax[0]).GetSymbol<MethodSymbol>(); Assert.False(staticLocal.RequiresInstanceReceiver); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/RQName/Nodes/RQType.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Microsoft.CodeAnalysis.Features.RQName.SimpleTree; namespace Microsoft.CodeAnalysis.Features.RQName.Nodes { internal abstract class RQType { public static readonly RQType ObjectType = new RQConstructedType( new RQUnconstructedType(new[] { "System" }, new[] { new RQUnconstructedTypeInfo("Object", 0) }), Array.Empty<RQType>()); public abstract SimpleTreeNode ToSimpleTree(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Microsoft.CodeAnalysis.Features.RQName.SimpleTree; namespace Microsoft.CodeAnalysis.Features.RQName.Nodes { internal abstract class RQType { public static readonly RQType ObjectType = new RQConstructedType( new RQUnconstructedType(new[] { "System" }, new[] { new RQUnconstructedTypeInfo("Object", 0) }), Array.Empty<RQType>()); public abstract SimpleTreeNode ToSimpleTree(); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Serialization/SerializerService_Asset.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Linq; using System.Text; using System.Threading; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Serialization { /// <summary> /// serialize and deserialize objects to stream. /// some of these could be moved into actual object, but putting everything here is a bit easier to find I believe. /// </summary> internal partial class SerializerService { public void SerializeSourceText(SerializableSourceText text, ObjectWriter writer, SolutionReplicationContext context, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (text.Storage is not null) { context.AddResource(text.Storage); writer.WriteInt32((int)text.Storage.ChecksumAlgorithm); writer.WriteEncoding(text.Storage.Encoding); writer.WriteInt32((int)SerializationKinds.MemoryMapFile); writer.WriteString(text.Storage.Name); writer.WriteInt64(text.Storage.Offset); writer.WriteInt64(text.Storage.Size); } else { RoslynDebug.AssertNotNull(text.Text); writer.WriteInt32((int)text.Text.ChecksumAlgorithm); writer.WriteEncoding(text.Text.Encoding); writer.WriteInt32((int)SerializationKinds.Bits); text.Text.WriteTo(writer, cancellationToken); } } private SerializableSourceText DeserializeSerializableSourceText(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var checksumAlgorithm = (SourceHashAlgorithm)reader.ReadInt32(); var encoding = (Encoding)reader.ReadValue(); var kind = (SerializationKinds)reader.ReadInt32(); if (kind == SerializationKinds.MemoryMapFile) { var storage2 = (ITemporaryStorageService2)_storageService; var name = reader.ReadString(); var offset = reader.ReadInt64(); var size = reader.ReadInt64(); var storage = storage2.AttachTemporaryTextStorage(name, offset, size, checksumAlgorithm, encoding, cancellationToken); if (storage is ITemporaryTextStorageWithName storageWithName) { return new SerializableSourceText(storageWithName); } else { return new SerializableSourceText(storage.ReadText(cancellationToken)); } } Contract.ThrowIfFalse(kind == SerializationKinds.Bits); return new SerializableSourceText(SourceTextExtensions.ReadFrom(_textService, reader, encoding, cancellationToken)); } private SourceText DeserializeSourceText(ObjectReader reader, CancellationToken cancellationToken) { var serializableSourceText = DeserializeSerializableSourceText(reader, cancellationToken); return serializableSourceText.Text ?? serializableSourceText.Storage!.ReadText(cancellationToken); } public void SerializeCompilationOptions(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var language = options.Language; // TODO: once compiler team adds ability to serialize compilation options to ObjectWriter directly, we won't need this. writer.WriteString(language); var service = GetOptionsSerializationService(language); service.WriteTo(options, writer, cancellationToken); } private CompilationOptions DeserializeCompilationOptions(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var language = reader.ReadString(); var service = GetOptionsSerializationService(language); return service.ReadCompilationOptionsFrom(reader, cancellationToken); } public void SerializeParseOptions(ParseOptions options, ObjectWriter writer) { var language = options.Language; // TODO: once compiler team adds ability to serialize parse options to ObjectWriter directly, we won't need this. writer.WriteString(language); var service = GetOptionsSerializationService(language); service.WriteTo(options, writer); } private ParseOptions DeserializeParseOptions(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var language = reader.ReadString(); var service = GetOptionsSerializationService(language); return service.ReadParseOptionsFrom(reader, cancellationToken); } public void SerializeProjectReference(ProjectReference reference, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); reference.ProjectId.WriteTo(writer); writer.WriteValue(reference.Aliases.ToArray()); writer.WriteBoolean(reference.EmbedInteropTypes); } private static ProjectReference DeserializeProjectReference(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var projectId = ProjectId.ReadFrom(reader); var aliases = reader.ReadArray<string>(); var embedInteropTypes = reader.ReadBoolean(); return new ProjectReference(projectId, aliases.ToImmutableArrayOrEmpty(), embedInteropTypes); } public void SerializeMetadataReference(MetadataReference reference, ObjectWriter writer, SolutionReplicationContext context, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); WriteMetadataReferenceTo(reference, writer, context, cancellationToken); } private MetadataReference DeserializeMetadataReference(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return ReadMetadataReferenceFrom(reader, cancellationToken); } public void SerializeAnalyzerReference(AnalyzerReference reference, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); WriteAnalyzerReferenceTo(reference, writer, cancellationToken); } private AnalyzerReference DeserializeAnalyzerReference(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return ReadAnalyzerReferenceFrom(reader, cancellationToken); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Linq; using System.Text; using System.Threading; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Serialization { /// <summary> /// serialize and deserialize objects to stream. /// some of these could be moved into actual object, but putting everything here is a bit easier to find I believe. /// </summary> internal partial class SerializerService { public void SerializeSourceText(SerializableSourceText text, ObjectWriter writer, SolutionReplicationContext context, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (text.Storage is not null) { context.AddResource(text.Storage); writer.WriteInt32((int)text.Storage.ChecksumAlgorithm); writer.WriteEncoding(text.Storage.Encoding); writer.WriteInt32((int)SerializationKinds.MemoryMapFile); writer.WriteString(text.Storage.Name); writer.WriteInt64(text.Storage.Offset); writer.WriteInt64(text.Storage.Size); } else { RoslynDebug.AssertNotNull(text.Text); writer.WriteInt32((int)text.Text.ChecksumAlgorithm); writer.WriteEncoding(text.Text.Encoding); writer.WriteInt32((int)SerializationKinds.Bits); text.Text.WriteTo(writer, cancellationToken); } } private SerializableSourceText DeserializeSerializableSourceText(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var checksumAlgorithm = (SourceHashAlgorithm)reader.ReadInt32(); var encoding = (Encoding)reader.ReadValue(); var kind = (SerializationKinds)reader.ReadInt32(); if (kind == SerializationKinds.MemoryMapFile) { var storage2 = (ITemporaryStorageService2)_storageService; var name = reader.ReadString(); var offset = reader.ReadInt64(); var size = reader.ReadInt64(); var storage = storage2.AttachTemporaryTextStorage(name, offset, size, checksumAlgorithm, encoding, cancellationToken); if (storage is ITemporaryTextStorageWithName storageWithName) { return new SerializableSourceText(storageWithName); } else { return new SerializableSourceText(storage.ReadText(cancellationToken)); } } Contract.ThrowIfFalse(kind == SerializationKinds.Bits); return new SerializableSourceText(SourceTextExtensions.ReadFrom(_textService, reader, encoding, cancellationToken)); } private SourceText DeserializeSourceText(ObjectReader reader, CancellationToken cancellationToken) { var serializableSourceText = DeserializeSerializableSourceText(reader, cancellationToken); return serializableSourceText.Text ?? serializableSourceText.Storage!.ReadText(cancellationToken); } public void SerializeCompilationOptions(CompilationOptions options, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var language = options.Language; // TODO: once compiler team adds ability to serialize compilation options to ObjectWriter directly, we won't need this. writer.WriteString(language); var service = GetOptionsSerializationService(language); service.WriteTo(options, writer, cancellationToken); } private CompilationOptions DeserializeCompilationOptions(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var language = reader.ReadString(); var service = GetOptionsSerializationService(language); return service.ReadCompilationOptionsFrom(reader, cancellationToken); } public void SerializeParseOptions(ParseOptions options, ObjectWriter writer) { var language = options.Language; // TODO: once compiler team adds ability to serialize parse options to ObjectWriter directly, we won't need this. writer.WriteString(language); var service = GetOptionsSerializationService(language); service.WriteTo(options, writer); } private ParseOptions DeserializeParseOptions(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var language = reader.ReadString(); var service = GetOptionsSerializationService(language); return service.ReadParseOptionsFrom(reader, cancellationToken); } public void SerializeProjectReference(ProjectReference reference, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); reference.ProjectId.WriteTo(writer); writer.WriteValue(reference.Aliases.ToArray()); writer.WriteBoolean(reference.EmbedInteropTypes); } private static ProjectReference DeserializeProjectReference(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var projectId = ProjectId.ReadFrom(reader); var aliases = reader.ReadArray<string>(); var embedInteropTypes = reader.ReadBoolean(); return new ProjectReference(projectId, aliases.ToImmutableArrayOrEmpty(), embedInteropTypes); } public void SerializeMetadataReference(MetadataReference reference, ObjectWriter writer, SolutionReplicationContext context, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); WriteMetadataReferenceTo(reference, writer, context, cancellationToken); } private MetadataReference DeserializeMetadataReference(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return ReadMetadataReferenceFrom(reader, cancellationToken); } public void SerializeAnalyzerReference(AnalyzerReference reference, ObjectWriter writer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); WriteAnalyzerReferenceTo(reference, writer, cancellationToken); } private AnalyzerReference DeserializeAnalyzerReference(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return ReadAnalyzerReferenceFrom(reader, cancellationToken); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Dependencies/PooledObjects/ArrayBuilder.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; namespace Microsoft.CodeAnalysis.PooledObjects { [DebuggerDisplay("Count = {Count,nq}")] [DebuggerTypeProxy(typeof(ArrayBuilder<>.DebuggerProxy))] internal sealed partial class ArrayBuilder<T> : IReadOnlyCollection<T>, IReadOnlyList<T> { #region DebuggerProxy private sealed class DebuggerProxy { private readonly ArrayBuilder<T> _builder; public DebuggerProxy(ArrayBuilder<T> builder) { _builder = builder; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] A { get { var result = new T[_builder.Count]; for (var i = 0; i < result.Length; i++) { result[i] = _builder[i]; } return result; } } } #endregion private readonly ImmutableArray<T>.Builder _builder; private readonly ObjectPool<ArrayBuilder<T>>? _pool; public ArrayBuilder(int size) { _builder = ImmutableArray.CreateBuilder<T>(size); } public ArrayBuilder() : this(8) { } private ArrayBuilder(ObjectPool<ArrayBuilder<T>> pool) : this() { _pool = pool; } /// <summary> /// Realizes the array. /// </summary> public ImmutableArray<T> ToImmutable() { return _builder.ToImmutable(); } /// <summary> /// Realizes the array and clears the collection. /// </summary> public ImmutableArray<T> ToImmutableAndClear() { ImmutableArray<T> result; if (Count == 0) { result = ImmutableArray<T>.Empty; } else if (_builder.Capacity == Count) { result = _builder.MoveToImmutable(); } else { result = ToImmutable(); Clear(); } return result; } public int Count { get { return _builder.Count; } set { _builder.Count = value; } } public T this[int index] { get { return _builder[index]; } set { _builder[index] = value; } } /// <summary> /// Write <paramref name="value"/> to slot <paramref name="index"/>. /// Fills in unallocated slots preceding the <paramref name="index"/>, if any. /// </summary> public void SetItem(int index, T value) { while (index > _builder.Count) { _builder.Add(default!); } if (index == _builder.Count) { _builder.Add(value); } else { _builder[index] = value; } } public void Add(T item) { _builder.Add(item); } public void Insert(int index, T item) { _builder.Insert(index, item); } public void EnsureCapacity(int capacity) { if (_builder.Capacity < capacity) { _builder.Capacity = capacity; } } public void Clear() { _builder.Clear(); } public bool Contains(T item) { return _builder.Contains(item); } public int IndexOf(T item) { return _builder.IndexOf(item); } public int IndexOf(T item, IEqualityComparer<T> equalityComparer) { return _builder.IndexOf(item, 0, _builder.Count, equalityComparer); } public int IndexOf(T item, int startIndex, int count) { return _builder.IndexOf(item, startIndex, count); } public int FindIndex(Predicate<T> match) => FindIndex(0, this.Count, match); public int FindIndex(int startIndex, Predicate<T> match) => FindIndex(startIndex, this.Count - startIndex, match); public int FindIndex(int startIndex, int count, Predicate<T> match) { var endIndex = startIndex + count; for (var i = startIndex; i < endIndex; i++) { if (match(_builder[i])) { return i; } } return -1; } public int FindIndex<TArg>(Func<T, TArg, bool> match, TArg arg) => FindIndex(0, Count, match, arg); public int FindIndex<TArg>(int startIndex, Func<T, TArg, bool> match, TArg arg) => FindIndex(startIndex, Count - startIndex, match, arg); public int FindIndex<TArg>(int startIndex, int count, Func<T, TArg, bool> match, TArg arg) { var endIndex = startIndex + count; for (var i = startIndex; i < endIndex; i++) { if (match(_builder[i], arg)) { return i; } } return -1; } public bool Remove(T element) { return _builder.Remove(element); } public void RemoveAt(int index) { _builder.RemoveAt(index); } public void RemoveLast() { _builder.RemoveAt(_builder.Count - 1); } public void ReverseContents() { _builder.Reverse(); } public void Sort() { _builder.Sort(); } public void Sort(IComparer<T> comparer) { _builder.Sort(comparer); } public void Sort(Comparison<T> compare) => Sort(Comparer<T>.Create(compare)); public void Sort(int startIndex, IComparer<T> comparer) { _builder.Sort(startIndex, _builder.Count - startIndex, comparer); } public T[] ToArray() { return _builder.ToArray(); } public void CopyTo(T[] array, int start) { _builder.CopyTo(array, start); } public T Last() { return _builder[_builder.Count - 1]; } public T First() { return _builder[0]; } public bool Any() { return _builder.Count > 0; } /// <summary> /// Realizes the array. /// </summary> public ImmutableArray<T> ToImmutableOrNull() { if (Count == 0) { return default; } return this.ToImmutable(); } /// <summary> /// Realizes the array, downcasting each element to a derived type. /// </summary> public ImmutableArray<U> ToDowncastedImmutable<U>() where U : T { if (Count == 0) { return ImmutableArray<U>.Empty; } var tmp = ArrayBuilder<U>.GetInstance(Count); foreach (var i in this) { tmp.Add((U)i!); } return tmp.ToImmutableAndFree(); } /// <summary> /// Realizes the array and disposes the builder in one operation. /// </summary> public ImmutableArray<T> ToImmutableAndFree() { // This is mostly the same as 'MoveToImmutable', but avoids delegating to that method since 'Free' contains // fast paths to avoid caling 'Clear' in some cases. ImmutableArray<T> result; if (Count == 0) { result = ImmutableArray<T>.Empty; } else if (_builder.Capacity == Count) { result = _builder.MoveToImmutable(); } else { result = ToImmutable(); } this.Free(); return result; } public T[] ToArrayAndFree() { var result = this.ToArray(); this.Free(); return result; } #region Poolable // To implement Poolable, you need two things: // 1) Expose Freeing primitive. public void Free() { var pool = _pool; if (pool != null) { // According to the statistics of a C# compiler self-build, the most commonly used builder size is 0. (808003 uses). // The distant second is the Count == 1 (455619), then 2 (106362) ... // After about 50 (just 67) we have a long tail of infrequently used builder sizes. // However we have builders with size up to 50K (just one such thing) // // We do not want to retain (potentially indefinitely) very large builders // while the chance that we will need their size is diminishingly small. // It makes sense to constrain the size to some "not too small" number. // Overall perf does not seem to be very sensitive to this number, so I picked 128 as a limit. if (_builder.Capacity < 128) { if (this.Count != 0) { this.Clear(); } pool.Free(this); return; } else { pool.ForgetTrackedObject(this); } } } // 2) Expose the pool or the way to create a pool or the way to get an instance. // for now we will expose both and figure which way works better private static readonly ObjectPool<ArrayBuilder<T>> s_poolInstance = CreatePool(); public static ArrayBuilder<T> GetInstance() { var builder = s_poolInstance.Allocate(); Debug.Assert(builder.Count == 0); return builder; } public static ArrayBuilder<T> GetInstance(int capacity) { var builder = GetInstance(); builder.EnsureCapacity(capacity); return builder; } public static ArrayBuilder<T> GetInstance(int capacity, T fillWithValue) { var builder = GetInstance(); builder.EnsureCapacity(capacity); for (var i = 0; i < capacity; i++) { builder.Add(fillWithValue); } return builder; } public static ObjectPool<ArrayBuilder<T>> CreatePool() { return CreatePool(128); // we rarely need more than 10 } public static ObjectPool<ArrayBuilder<T>> CreatePool(int size) { ObjectPool<ArrayBuilder<T>>? pool = null; pool = new ObjectPool<ArrayBuilder<T>>(() => new ArrayBuilder<T>(pool!), size); return pool; } #endregion public Enumerator GetEnumerator() { return new Enumerator(this); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return _builder.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return _builder.GetEnumerator(); } internal Dictionary<K, ImmutableArray<T>> ToDictionary<K>(Func<T, K> keySelector, IEqualityComparer<K>? comparer = null) where K : notnull { if (this.Count == 1) { var dictionary1 = new Dictionary<K, ImmutableArray<T>>(1, comparer); var value = this[0]; dictionary1.Add(keySelector(value), ImmutableArray.Create(value)); return dictionary1; } if (this.Count == 0) { return new Dictionary<K, ImmutableArray<T>>(comparer); } // bucketize // prevent reallocation. it may not have 'count' entries, but it won't have more. var accumulator = new Dictionary<K, ArrayBuilder<T>>(Count, comparer); for (var i = 0; i < Count; i++) { var item = this[i]; var key = keySelector(item); if (!accumulator.TryGetValue(key, out var bucket)) { bucket = ArrayBuilder<T>.GetInstance(); accumulator.Add(key, bucket); } bucket.Add(item); } var dictionary = new Dictionary<K, ImmutableArray<T>>(accumulator.Count, comparer); // freeze foreach (var pair in accumulator) { dictionary.Add(pair.Key, pair.Value.ToImmutableAndFree()); } return dictionary; } public void AddRange(ArrayBuilder<T> items) { _builder.AddRange(items._builder); } public void AddRange<U>(ArrayBuilder<U> items, Func<U, T> selector) { foreach (var item in items) { _builder.Add(selector(item)); } } public void AddRange<U>(ArrayBuilder<U> items) where U : T { _builder.AddRange(items._builder); } public void AddRange<U>(ArrayBuilder<U> items, int start, int length) where U : T { Debug.Assert(start >= 0 && length >= 0); Debug.Assert(start + length <= items.Count); for (int i = start, end = start + length; i < end; i++) { Add(items[i]); } } public void AddRange(ImmutableArray<T> items) { _builder.AddRange(items); } public void AddRange(ImmutableArray<T> items, int length) { _builder.AddRange(items, length); } public void AddRange(ImmutableArray<T> items, int start, int length) { Debug.Assert(start >= 0 && length >= 0); Debug.Assert(start + length <= items.Length); for (int i = start, end = start + length; i < end; i++) { Add(items[i]); } } public void AddRange<S>(ImmutableArray<S> items) where S : class, T { AddRange(ImmutableArray<T>.CastUp(items)); } public void AddRange(T[] items, int start, int length) { Debug.Assert(start >= 0 && length >= 0); Debug.Assert(start + length <= items.Length); for (int i = start, end = start + length; i < end; i++) { Add(items[i]); } } public void AddRange(IEnumerable<T> items) { _builder.AddRange(items); } public void AddRange(params T[] items) { _builder.AddRange(items); } public void AddRange(T[] items, int length) { _builder.AddRange(items, length); } public void Clip(int limit) { Debug.Assert(limit <= Count); _builder.Count = limit; } public void ZeroInit(int count) { _builder.Clear(); _builder.Count = count; } public void AddMany(T item, int count) { for (var i = 0; i < count; i++) { Add(item); } } public void RemoveDuplicates() { var set = PooledHashSet<T>.GetInstance(); var j = 0; for (var i = 0; i < Count; i++) { if (set.Add(this[i])) { this[j] = this[i]; j++; } } Clip(j); set.Free(); } public void SortAndRemoveDuplicates(IComparer<T> comparer) { if (Count <= 1) { return; } Sort(comparer); int j = 0; for (int i = 1; i < Count; i++) { if (comparer.Compare(this[j], this[i]) < 0) { j++; this[j] = this[i]; } } Clip(j + 1); } public ImmutableArray<S> SelectDistinct<S>(Func<T, S> selector) { var result = ArrayBuilder<S>.GetInstance(Count); var set = PooledHashSet<S>.GetInstance(); foreach (var item in this) { var selected = selector(item); if (set.Add(selected)) { result.Add(selected); } } set.Free(); return result.ToImmutableAndFree(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; namespace Microsoft.CodeAnalysis.PooledObjects { [DebuggerDisplay("Count = {Count,nq}")] [DebuggerTypeProxy(typeof(ArrayBuilder<>.DebuggerProxy))] internal sealed partial class ArrayBuilder<T> : IReadOnlyCollection<T>, IReadOnlyList<T> { #region DebuggerProxy private sealed class DebuggerProxy { private readonly ArrayBuilder<T> _builder; public DebuggerProxy(ArrayBuilder<T> builder) { _builder = builder; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] A { get { var result = new T[_builder.Count]; for (var i = 0; i < result.Length; i++) { result[i] = _builder[i]; } return result; } } } #endregion private readonly ImmutableArray<T>.Builder _builder; private readonly ObjectPool<ArrayBuilder<T>>? _pool; public ArrayBuilder(int size) { _builder = ImmutableArray.CreateBuilder<T>(size); } public ArrayBuilder() : this(8) { } private ArrayBuilder(ObjectPool<ArrayBuilder<T>> pool) : this() { _pool = pool; } /// <summary> /// Realizes the array. /// </summary> public ImmutableArray<T> ToImmutable() { return _builder.ToImmutable(); } /// <summary> /// Realizes the array and clears the collection. /// </summary> public ImmutableArray<T> ToImmutableAndClear() { ImmutableArray<T> result; if (Count == 0) { result = ImmutableArray<T>.Empty; } else if (_builder.Capacity == Count) { result = _builder.MoveToImmutable(); } else { result = ToImmutable(); Clear(); } return result; } public int Count { get { return _builder.Count; } set { _builder.Count = value; } } public T this[int index] { get { return _builder[index]; } set { _builder[index] = value; } } /// <summary> /// Write <paramref name="value"/> to slot <paramref name="index"/>. /// Fills in unallocated slots preceding the <paramref name="index"/>, if any. /// </summary> public void SetItem(int index, T value) { while (index > _builder.Count) { _builder.Add(default!); } if (index == _builder.Count) { _builder.Add(value); } else { _builder[index] = value; } } public void Add(T item) { _builder.Add(item); } public void Insert(int index, T item) { _builder.Insert(index, item); } public void EnsureCapacity(int capacity) { if (_builder.Capacity < capacity) { _builder.Capacity = capacity; } } public void Clear() { _builder.Clear(); } public bool Contains(T item) { return _builder.Contains(item); } public int IndexOf(T item) { return _builder.IndexOf(item); } public int IndexOf(T item, IEqualityComparer<T> equalityComparer) { return _builder.IndexOf(item, 0, _builder.Count, equalityComparer); } public int IndexOf(T item, int startIndex, int count) { return _builder.IndexOf(item, startIndex, count); } public int FindIndex(Predicate<T> match) => FindIndex(0, this.Count, match); public int FindIndex(int startIndex, Predicate<T> match) => FindIndex(startIndex, this.Count - startIndex, match); public int FindIndex(int startIndex, int count, Predicate<T> match) { var endIndex = startIndex + count; for (var i = startIndex; i < endIndex; i++) { if (match(_builder[i])) { return i; } } return -1; } public int FindIndex<TArg>(Func<T, TArg, bool> match, TArg arg) => FindIndex(0, Count, match, arg); public int FindIndex<TArg>(int startIndex, Func<T, TArg, bool> match, TArg arg) => FindIndex(startIndex, Count - startIndex, match, arg); public int FindIndex<TArg>(int startIndex, int count, Func<T, TArg, bool> match, TArg arg) { var endIndex = startIndex + count; for (var i = startIndex; i < endIndex; i++) { if (match(_builder[i], arg)) { return i; } } return -1; } public bool Remove(T element) { return _builder.Remove(element); } public void RemoveAt(int index) { _builder.RemoveAt(index); } public void RemoveLast() { _builder.RemoveAt(_builder.Count - 1); } public void ReverseContents() { _builder.Reverse(); } public void Sort() { _builder.Sort(); } public void Sort(IComparer<T> comparer) { _builder.Sort(comparer); } public void Sort(Comparison<T> compare) => Sort(Comparer<T>.Create(compare)); public void Sort(int startIndex, IComparer<T> comparer) { _builder.Sort(startIndex, _builder.Count - startIndex, comparer); } public T[] ToArray() { return _builder.ToArray(); } public void CopyTo(T[] array, int start) { _builder.CopyTo(array, start); } public T Last() { return _builder[_builder.Count - 1]; } public T First() { return _builder[0]; } public bool Any() { return _builder.Count > 0; } /// <summary> /// Realizes the array. /// </summary> public ImmutableArray<T> ToImmutableOrNull() { if (Count == 0) { return default; } return this.ToImmutable(); } /// <summary> /// Realizes the array, downcasting each element to a derived type. /// </summary> public ImmutableArray<U> ToDowncastedImmutable<U>() where U : T { if (Count == 0) { return ImmutableArray<U>.Empty; } var tmp = ArrayBuilder<U>.GetInstance(Count); foreach (var i in this) { tmp.Add((U)i!); } return tmp.ToImmutableAndFree(); } /// <summary> /// Realizes the array and disposes the builder in one operation. /// </summary> public ImmutableArray<T> ToImmutableAndFree() { // This is mostly the same as 'MoveToImmutable', but avoids delegating to that method since 'Free' contains // fast paths to avoid caling 'Clear' in some cases. ImmutableArray<T> result; if (Count == 0) { result = ImmutableArray<T>.Empty; } else if (_builder.Capacity == Count) { result = _builder.MoveToImmutable(); } else { result = ToImmutable(); } this.Free(); return result; } public T[] ToArrayAndFree() { var result = this.ToArray(); this.Free(); return result; } #region Poolable // To implement Poolable, you need two things: // 1) Expose Freeing primitive. public void Free() { var pool = _pool; if (pool != null) { // According to the statistics of a C# compiler self-build, the most commonly used builder size is 0. (808003 uses). // The distant second is the Count == 1 (455619), then 2 (106362) ... // After about 50 (just 67) we have a long tail of infrequently used builder sizes. // However we have builders with size up to 50K (just one such thing) // // We do not want to retain (potentially indefinitely) very large builders // while the chance that we will need their size is diminishingly small. // It makes sense to constrain the size to some "not too small" number. // Overall perf does not seem to be very sensitive to this number, so I picked 128 as a limit. if (_builder.Capacity < 128) { if (this.Count != 0) { this.Clear(); } pool.Free(this); return; } else { pool.ForgetTrackedObject(this); } } } // 2) Expose the pool or the way to create a pool or the way to get an instance. // for now we will expose both and figure which way works better private static readonly ObjectPool<ArrayBuilder<T>> s_poolInstance = CreatePool(); public static ArrayBuilder<T> GetInstance() { var builder = s_poolInstance.Allocate(); Debug.Assert(builder.Count == 0); return builder; } public static ArrayBuilder<T> GetInstance(int capacity) { var builder = GetInstance(); builder.EnsureCapacity(capacity); return builder; } public static ArrayBuilder<T> GetInstance(int capacity, T fillWithValue) { var builder = GetInstance(); builder.EnsureCapacity(capacity); for (var i = 0; i < capacity; i++) { builder.Add(fillWithValue); } return builder; } public static ObjectPool<ArrayBuilder<T>> CreatePool() { return CreatePool(128); // we rarely need more than 10 } public static ObjectPool<ArrayBuilder<T>> CreatePool(int size) { ObjectPool<ArrayBuilder<T>>? pool = null; pool = new ObjectPool<ArrayBuilder<T>>(() => new ArrayBuilder<T>(pool!), size); return pool; } #endregion public Enumerator GetEnumerator() { return new Enumerator(this); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return _builder.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return _builder.GetEnumerator(); } internal Dictionary<K, ImmutableArray<T>> ToDictionary<K>(Func<T, K> keySelector, IEqualityComparer<K>? comparer = null) where K : notnull { if (this.Count == 1) { var dictionary1 = new Dictionary<K, ImmutableArray<T>>(1, comparer); var value = this[0]; dictionary1.Add(keySelector(value), ImmutableArray.Create(value)); return dictionary1; } if (this.Count == 0) { return new Dictionary<K, ImmutableArray<T>>(comparer); } // bucketize // prevent reallocation. it may not have 'count' entries, but it won't have more. var accumulator = new Dictionary<K, ArrayBuilder<T>>(Count, comparer); for (var i = 0; i < Count; i++) { var item = this[i]; var key = keySelector(item); if (!accumulator.TryGetValue(key, out var bucket)) { bucket = ArrayBuilder<T>.GetInstance(); accumulator.Add(key, bucket); } bucket.Add(item); } var dictionary = new Dictionary<K, ImmutableArray<T>>(accumulator.Count, comparer); // freeze foreach (var pair in accumulator) { dictionary.Add(pair.Key, pair.Value.ToImmutableAndFree()); } return dictionary; } public void AddRange(ArrayBuilder<T> items) { _builder.AddRange(items._builder); } public void AddRange<U>(ArrayBuilder<U> items, Func<U, T> selector) { foreach (var item in items) { _builder.Add(selector(item)); } } public void AddRange<U>(ArrayBuilder<U> items) where U : T { _builder.AddRange(items._builder); } public void AddRange<U>(ArrayBuilder<U> items, int start, int length) where U : T { Debug.Assert(start >= 0 && length >= 0); Debug.Assert(start + length <= items.Count); for (int i = start, end = start + length; i < end; i++) { Add(items[i]); } } public void AddRange(ImmutableArray<T> items) { _builder.AddRange(items); } public void AddRange(ImmutableArray<T> items, int length) { _builder.AddRange(items, length); } public void AddRange(ImmutableArray<T> items, int start, int length) { Debug.Assert(start >= 0 && length >= 0); Debug.Assert(start + length <= items.Length); for (int i = start, end = start + length; i < end; i++) { Add(items[i]); } } public void AddRange<S>(ImmutableArray<S> items) where S : class, T { AddRange(ImmutableArray<T>.CastUp(items)); } public void AddRange(T[] items, int start, int length) { Debug.Assert(start >= 0 && length >= 0); Debug.Assert(start + length <= items.Length); for (int i = start, end = start + length; i < end; i++) { Add(items[i]); } } public void AddRange(IEnumerable<T> items) { _builder.AddRange(items); } public void AddRange(params T[] items) { _builder.AddRange(items); } public void AddRange(T[] items, int length) { _builder.AddRange(items, length); } public void Clip(int limit) { Debug.Assert(limit <= Count); _builder.Count = limit; } public void ZeroInit(int count) { _builder.Clear(); _builder.Count = count; } public void AddMany(T item, int count) { for (var i = 0; i < count; i++) { Add(item); } } public void RemoveDuplicates() { var set = PooledHashSet<T>.GetInstance(); var j = 0; for (var i = 0; i < Count; i++) { if (set.Add(this[i])) { this[j] = this[i]; j++; } } Clip(j); set.Free(); } public void SortAndRemoveDuplicates(IComparer<T> comparer) { if (Count <= 1) { return; } Sort(comparer); int j = 0; for (int i = 1; i < Count; i++) { if (comparer.Compare(this[j], this[i]) < 0) { j++; this[j] = this[i]; } } Clip(j + 1); } public ImmutableArray<S> SelectDistinct<S>(Func<T, S> selector) { var result = ArrayBuilder<S>.GetInstance(Count); var set = PooledHashSet<S>.GetInstance(); foreach (var item in this) { var selected = selector(item); if (set.Add(selected)) { result.Add(selected); } } set.Free(); return result.ToImmutableAndFree(); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/EmbeddedLanguages/Common/EmbeddedSyntaxHelpers.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.EmbeddedLanguages.VirtualChars; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.EmbeddedLanguages.Common { internal static class EmbeddedSyntaxHelpers { public static TextSpan GetSpan<TSyntaxKind>(EmbeddedSyntaxToken<TSyntaxKind> token1, EmbeddedSyntaxToken<TSyntaxKind> token2) where TSyntaxKind : struct => GetSpan(token1.VirtualChars[0], token2.VirtualChars.Last()); public static TextSpan GetSpan(VirtualCharSequence virtualChars) => GetSpan(virtualChars[0], virtualChars.Last()); public static TextSpan GetSpan(VirtualChar firstChar, VirtualChar lastChar) => TextSpan.FromBounds(firstChar.Span.Start, lastChar.Span.End); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.EmbeddedLanguages.VirtualChars; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.EmbeddedLanguages.Common { internal static class EmbeddedSyntaxHelpers { public static TextSpan GetSpan<TSyntaxKind>(EmbeddedSyntaxToken<TSyntaxKind> token1, EmbeddedSyntaxToken<TSyntaxKind> token2) where TSyntaxKind : struct => GetSpan(token1.VirtualChars[0], token2.VirtualChars.Last()); public static TextSpan GetSpan(VirtualCharSequence virtualChars) => GetSpan(virtualChars[0], virtualChars.Last()); public static TextSpan GetSpan(VirtualChar firstChar, VirtualChar lastChar) => TextSpan.FromBounds(firstChar.Span.Start, lastChar.Span.End); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Core/Portable/MetadataReference/MetadataImageReference.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Diagnostics; using System.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis { /// <summary> /// Represents an in-memory Portable-Executable image. /// </summary> [DebuggerDisplay("{GetDebuggerDisplay(), nq}")] internal sealed class MetadataImageReference : PortableExecutableReference { private readonly string? _display; private readonly Metadata _metadata; internal MetadataImageReference(Metadata metadata, MetadataReferenceProperties properties, DocumentationProvider? documentation, string? filePath, string? display) : base(properties, filePath, documentation ?? DocumentationProvider.Default) { _display = display; _metadata = metadata; } protected override Metadata GetMetadataImpl() { return _metadata; } protected override DocumentationProvider CreateDocumentationProvider() { // documentation provider is initialized in the constructor throw ExceptionUtilities.Unreachable; } protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties) { return new MetadataImageReference( _metadata, properties, this.DocumentationProvider, this.FilePath, _display); } public override string Display { get { return _display ?? FilePath ?? (Properties.Kind == MetadataImageKind.Assembly ? CodeAnalysisResources.InMemoryAssembly : CodeAnalysisResources.InMemoryModule); } } private string GetDebuggerDisplay() { var sb = new StringBuilder(); sb.Append(Properties.Kind == MetadataImageKind.Module ? "Module" : "Assembly"); if (!Properties.Aliases.IsEmpty) { sb.Append(" Aliases={"); sb.Append(string.Join(", ", Properties.Aliases)); sb.Append("}"); } if (Properties.EmbedInteropTypes) { sb.Append(" Embed"); } if (FilePath != null) { sb.Append(" Path='"); sb.Append(FilePath); sb.Append("'"); } if (_display != null) { sb.Append(" Display='"); sb.Append(_display); sb.Append("'"); } return sb.ToString(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Diagnostics; using System.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis { /// <summary> /// Represents an in-memory Portable-Executable image. /// </summary> [DebuggerDisplay("{GetDebuggerDisplay(), nq}")] internal sealed class MetadataImageReference : PortableExecutableReference { private readonly string? _display; private readonly Metadata _metadata; internal MetadataImageReference(Metadata metadata, MetadataReferenceProperties properties, DocumentationProvider? documentation, string? filePath, string? display) : base(properties, filePath, documentation ?? DocumentationProvider.Default) { _display = display; _metadata = metadata; } protected override Metadata GetMetadataImpl() { return _metadata; } protected override DocumentationProvider CreateDocumentationProvider() { // documentation provider is initialized in the constructor throw ExceptionUtilities.Unreachable; } protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties) { return new MetadataImageReference( _metadata, properties, this.DocumentationProvider, this.FilePath, _display); } public override string Display { get { return _display ?? FilePath ?? (Properties.Kind == MetadataImageKind.Assembly ? CodeAnalysisResources.InMemoryAssembly : CodeAnalysisResources.InMemoryModule); } } private string GetDebuggerDisplay() { var sb = new StringBuilder(); sb.Append(Properties.Kind == MetadataImageKind.Module ? "Module" : "Assembly"); if (!Properties.Aliases.IsEmpty) { sb.Append(" Aliases={"); sb.Append(string.Join(", ", Properties.Aliases)); sb.Append("}"); } if (Properties.EmbedInteropTypes) { sb.Append(" Embed"); } if (FilePath != null) { sb.Append(" Path='"); sb.Append(FilePath); sb.Append("'"); } if (_display != null) { sb.Append(" Display='"); sb.Append(_display); sb.Append("'"); } return sb.ToString(); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/MSBuildTest/Resources/NetCoreMultiTFM/Project.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFrameworks>netcoreapp2.1;netstandard2.0;net461</TargetFrameworks> </PropertyGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFrameworks>netcoreapp2.1;netstandard2.0;net461</TargetFrameworks> </PropertyGroup> </Project>
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/LinkedFileDiffMerging/LinkedFileMergeSessionResult.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Generic; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis { internal sealed class LinkedFileMergeSessionResult { public Solution MergedSolution { get; } private readonly Dictionary<DocumentId, IEnumerable<TextSpan>> _mergeConflictCommentSpans = new(); public Dictionary<DocumentId, IEnumerable<TextSpan>> MergeConflictCommentSpans => _mergeConflictCommentSpans; public LinkedFileMergeSessionResult(Solution mergedSolution, IEnumerable<LinkedFileMergeResult> fileMergeResults) { this.MergedSolution = mergedSolution; foreach (var fileMergeResult in fileMergeResults) { foreach (var documentId in fileMergeResult.DocumentIds) { _mergeConflictCommentSpans.Add(documentId, fileMergeResult.MergeConflictResolutionSpans); } } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Generic; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis { internal sealed class LinkedFileMergeSessionResult { public Solution MergedSolution { get; } private readonly Dictionary<DocumentId, IEnumerable<TextSpan>> _mergeConflictCommentSpans = new(); public Dictionary<DocumentId, IEnumerable<TextSpan>> MergeConflictCommentSpans => _mergeConflictCommentSpans; public LinkedFileMergeSessionResult(Solution mergedSolution, IEnumerable<LinkedFileMergeResult> fileMergeResults) { this.MergedSolution = mergedSolution; foreach (var fileMergeResult in fileMergeResults) { foreach (var documentId in fileMergeResult.DocumentIds) { _mergeConflictCommentSpans.Add(documentId, fileMergeResult.MergeConflictResolutionSpans); } } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Core/Def/Implementation/LanguageClient/VisualStudioInProcLanguageServer.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; using Roslyn.Utilities; using StreamJsonRpc; using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageClient { /// <summary> /// Implementation of <see cref="LanguageServerTarget"/> that also supports /// VS LSP extension methods. /// </summary> internal class VisualStudioInProcLanguageServer : LanguageServerTarget { /// <summary> /// Legacy support for LSP push diagnostics. /// Work queue responsible for receiving notifications about diagnostic updates and publishing those to /// interested parties. /// </summary> private readonly AsyncBatchingWorkQueue<DocumentId> _diagnosticsWorkQueue; private readonly IDiagnosticService? _diagnosticService; internal VisualStudioInProcLanguageServer( AbstractRequestDispatcherFactory requestDispatcherFactory, JsonRpc jsonRpc, ICapabilitiesProvider capabilitiesProvider, ILspWorkspaceRegistrationService workspaceRegistrationService, IAsynchronousOperationListenerProvider listenerProvider, ILspLogger logger, IDiagnosticService? diagnosticService, string? clientName, string userVisibleServerName, string telemetryServerTypeName) : base(requestDispatcherFactory, jsonRpc, capabilitiesProvider, workspaceRegistrationService, listenerProvider, logger, clientName, userVisibleServerName, telemetryServerTypeName) { _diagnosticService = diagnosticService; // Dedupe on DocumentId. If we hear about the same document multiple times, we only need to process that id once. _diagnosticsWorkQueue = new AsyncBatchingWorkQueue<DocumentId>( TimeSpan.FromMilliseconds(250), (ids, ct) => ProcessDiagnosticUpdatedBatchAsync(_diagnosticService, ids, ct), EqualityComparer<DocumentId>.Default, Listener, Queue.CancellationToken); if (_diagnosticService != null) _diagnosticService.DiagnosticsUpdated += DiagnosticService_DiagnosticsUpdated; } public override Task InitializedAsync() { try { Logger?.TraceStart("Initialized"); // Publish diagnostics for all open documents immediately following initialization. PublishOpenFileDiagnostics(); return Task.CompletedTask; } finally { Logger?.TraceStop("Initialized"); } void PublishOpenFileDiagnostics() { foreach (var workspace in WorkspaceRegistrationService.GetAllRegistrations()) { var solution = workspace.CurrentSolution; var openDocuments = workspace.GetOpenDocumentIds(); foreach (var documentId in openDocuments) DiagnosticService_DiagnosticsUpdated(solution, documentId); } } } [JsonRpcMethod(MSLSPMethods.TextDocumentCodeActionResolveName, UseSingleObjectParameterDeserialization = true)] public Task<VSCodeAction> ResolveCodeActionAsync(VSCodeAction vsCodeAction, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<VSCodeAction, VSCodeAction>(Queue, MSLSPMethods.TextDocumentCodeActionResolveName, vsCodeAction, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.DocumentPullDiagnosticName, UseSingleObjectParameterDeserialization = true)] public Task<DiagnosticReport[]?> GetDocumentPullDiagnosticsAsync(DocumentDiagnosticsParams diagnosticsParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<DocumentDiagnosticsParams, DiagnosticReport[]?>( Queue, MSLSPMethods.DocumentPullDiagnosticName, diagnosticsParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.WorkspacePullDiagnosticName, UseSingleObjectParameterDeserialization = true)] public Task<WorkspaceDiagnosticReport[]?> GetWorkspacePullDiagnosticsAsync(WorkspaceDocumentDiagnosticsParams diagnosticsParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<WorkspaceDocumentDiagnosticsParams, WorkspaceDiagnosticReport[]?>( Queue, MSLSPMethods.WorkspacePullDiagnosticName, diagnosticsParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.ProjectContextsName, UseSingleObjectParameterDeserialization = true)] public Task<ActiveProjectContexts?> GetProjectContextsAsync(GetTextDocumentWithContextParams textDocumentWithContextParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<GetTextDocumentWithContextParams, ActiveProjectContexts?>(Queue, MSLSPMethods.ProjectContextsName, textDocumentWithContextParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.OnAutoInsertName, UseSingleObjectParameterDeserialization = true)] public Task<DocumentOnAutoInsertResponseItem?> GetDocumentOnAutoInsertAsync(DocumentOnAutoInsertParams autoInsertParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<DocumentOnAutoInsertParams, DocumentOnAutoInsertResponseItem?>(Queue, MSLSPMethods.OnAutoInsertName, autoInsertParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.OnTypeRenameName, UseSingleObjectParameterDeserialization = true)] public Task<DocumentOnTypeRenameResponseItem?> GetTypeRenameAsync(DocumentOnTypeRenameParams renameParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<DocumentOnTypeRenameParams, DocumentOnTypeRenameResponseItem?>(Queue, MSLSPMethods.OnTypeRenameName, renameParams, _clientCapabilities, ClientName, cancellationToken); } protected override void ShutdownImpl() { base.ShutdownImpl(); if (_diagnosticService != null) _diagnosticService.DiagnosticsUpdated -= DiagnosticService_DiagnosticsUpdated; } private void DiagnosticService_DiagnosticsUpdated(object _, DiagnosticsUpdatedArgs e) => DiagnosticService_DiagnosticsUpdated(e.Solution, e.DocumentId); private void DiagnosticService_DiagnosticsUpdated(Solution? solution, DocumentId? documentId) { // LSP doesn't support diagnostics without a document. So if we get project level diagnostics without a document, ignore them. if (documentId != null && solution != null) { var document = solution.GetDocument(documentId); if (document == null || document.FilePath == null) return; // Only publish document diagnostics for the languages this provider supports. if (document.Project.Language != CodeAnalysis.LanguageNames.CSharp && document.Project.Language != CodeAnalysis.LanguageNames.VisualBasic) return; _diagnosticsWorkQueue.AddWork(document.Id); } } /// <summary> /// Stores the last published LSP diagnostics with the Roslyn document that they came from. /// This is useful in the following scenario. Imagine we have documentA which has contributions to mapped files m1 and m2. /// dA -> m1 /// And m1 has contributions from documentB. /// m1 -> dA, dB /// When we query for diagnostic on dA, we get a subset of the diagnostics on m1 (missing the contributions from dB) /// Since each publish diagnostics notification replaces diagnostics per document, /// we must union the diagnostics contribution from dB and dA to produce all diagnostics for m1 and publish all at once. /// /// This dictionary stores the previously computed diagnostics for the published file so that we can /// union the currently computed diagnostics (e.g. for dA) with previously computed diagnostics (e.g. from dB). /// </summary> private readonly Dictionary<Uri, Dictionary<DocumentId, ImmutableArray<LSP.Diagnostic>>> _publishedFileToDiagnostics = new(); /// <summary> /// Stores the mapping of a document to the uri(s) of diagnostics previously produced for this document. When /// we get empty diagnostics for the document we need to find the uris we previously published for this /// document. Then we can publish the updated diagnostics set for those uris (either empty or the diagnostic /// contributions from other documents). We use a sorted set to ensure consistency in the order in which we /// report URIs. While it's not necessary to publish a document's mapped file diagnostics in a particular /// order, it does make it much easier to write tests and debug issues if we have a consistent ordering. /// </summary> private readonly Dictionary<DocumentId, ImmutableSortedSet<Uri>> _documentsToPublishedUris = new(); /// <summary> /// Basic comparer for Uris used by <see cref="_documentsToPublishedUris"/> when publishing notifications. /// </summary> private static readonly Comparer<Uri> s_uriComparer = Comparer<Uri>.Create((uri1, uri2) => Uri.Compare(uri1, uri2, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase)); // internal for testing purposes internal async ValueTask ProcessDiagnosticUpdatedBatchAsync( IDiagnosticService? diagnosticService, ImmutableArray<DocumentId> documentIds, CancellationToken cancellationToken) { if (diagnosticService == null) return; foreach (var documentId in documentIds) { cancellationToken.ThrowIfCancellationRequested(); var document = WorkspaceRegistrationService.GetAllRegistrations().Select(w => w.CurrentSolution.GetDocument(documentId)).FirstOrDefault(); if (document != null) { // If this is a `pull` client, and `pull` diagnostics is on, then we should not `publish` (push) the // diagnostics here. var diagnosticMode = document.IsRazorDocument() ? InternalDiagnosticsOptions.RazorDiagnosticMode : InternalDiagnosticsOptions.NormalDiagnosticMode; if (document.Project.Solution.Workspace.IsPushDiagnostics(diagnosticMode)) await PublishDiagnosticsAsync(diagnosticService, document, cancellationToken).ConfigureAwait(false); } } } private async Task PublishDiagnosticsAsync(IDiagnosticService diagnosticService, Document document, CancellationToken cancellationToken) { // Retrieve all diagnostics for the current document grouped by their actual file uri. var fileUriToDiagnostics = await GetDiagnosticsAsync(diagnosticService, document, cancellationToken).ConfigureAwait(false); // Get the list of file uris with diagnostics (for the document). // We need to join the uris from current diagnostics with those previously published // so that we clear out any diagnostics in mapped files that are no longer a part // of the current diagnostics set (because the diagnostics were fixed). // Use sorted set to have consistent publish ordering for tests and debugging. var urisForCurrentDocument = _documentsToPublishedUris.GetValueOrDefault(document.Id, ImmutableSortedSet.Create<Uri>(s_uriComparer)).Union(fileUriToDiagnostics.Keys); // Update the mapping for this document to be the uris we're about to publish diagnostics for. _documentsToPublishedUris[document.Id] = urisForCurrentDocument; // Go through each uri and publish the updated set of diagnostics per uri. foreach (var fileUri in urisForCurrentDocument) { // Get the updated diagnostics for a single uri that were contributed by the current document. var diagnostics = fileUriToDiagnostics.GetValueOrDefault(fileUri, ImmutableArray<LSP.Diagnostic>.Empty); if (_publishedFileToDiagnostics.ContainsKey(fileUri)) { // Get all previously published diagnostics for this uri excluding those that were contributed from the current document. // We don't need those since we just computed the updated values above. var diagnosticsFromOtherDocuments = _publishedFileToDiagnostics[fileUri].Where(kvp => kvp.Key != document.Id).SelectMany(kvp => kvp.Value); // Since diagnostics are replaced per uri, we must publish both contributions from this document and any other document // that has diagnostic contributions to this uri, so union the two sets. diagnostics = diagnostics.AddRange(diagnosticsFromOtherDocuments); } await SendDiagnosticsNotificationAsync(fileUri, diagnostics).ConfigureAwait(false); // There are three cases here -> // 1. There are no diagnostics to publish for this fileUri. We no longer need to track the fileUri at all. // 2. There are diagnostics from the current document. Store the diagnostics for the fileUri and document // so they can be published along with contributions to the fileUri from other documents. // 3. There are no diagnostics contributed by this document to the fileUri (could be some from other documents). // We should clear out the diagnostics for this document for the fileUri. if (diagnostics.IsEmpty) { // We published an empty set of diagnostics for this uri. We no longer need to keep track of this mapping // since there will be no previous diagnostics that we need to clear out. _documentsToPublishedUris.MultiRemove(document.Id, fileUri); // There are not any diagnostics to keep track of for this file, so we can stop. _publishedFileToDiagnostics.Remove(fileUri); } else if (fileUriToDiagnostics.ContainsKey(fileUri)) { // We do have diagnostics from the current document - update the published diagnostics map // to contain the new diagnostics contributed by this document for this uri. var documentsToPublishedDiagnostics = _publishedFileToDiagnostics.GetOrAdd(fileUri, (_) => new Dictionary<DocumentId, ImmutableArray<LSP.Diagnostic>>()); documentsToPublishedDiagnostics[document.Id] = fileUriToDiagnostics[fileUri]; } else { // There were diagnostics from other documents, but none from the current document. // If we're tracking the current document, we can stop. IReadOnlyDictionaryExtensions.GetValueOrDefault(_publishedFileToDiagnostics, fileUri)?.Remove(document.Id); _documentsToPublishedUris.MultiRemove(document.Id, fileUri); } } } private async Task SendDiagnosticsNotificationAsync(Uri uri, ImmutableArray<LSP.Diagnostic> diagnostics) { var publishDiagnosticsParams = new PublishDiagnosticParams { Diagnostics = diagnostics.ToArray(), Uri = uri }; await JsonRpc.NotifyWithParameterObjectAsync(Methods.TextDocumentPublishDiagnosticsName, publishDiagnosticsParams).ConfigureAwait(false); } private async Task<Dictionary<Uri, ImmutableArray<LSP.Diagnostic>>> GetDiagnosticsAsync( IDiagnosticService diagnosticService, Document document, CancellationToken cancellationToken) { var option = document.IsRazorDocument() ? InternalDiagnosticsOptions.RazorDiagnosticMode : InternalDiagnosticsOptions.NormalDiagnosticMode; var pushDiagnostics = await diagnosticService.GetPushDiagnosticsAsync(document.Project.Solution.Workspace, document.Project.Id, document.Id, id: null, includeSuppressedDiagnostics: false, option, cancellationToken).ConfigureAwait(false); var diagnostics = pushDiagnostics.WhereAsArray(IncludeDiagnostic); var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); // Retrieve diagnostics for the document. These diagnostics could be for the current document, or they could map // to a different location in a different file. We need to publish the diagnostics for the mapped locations as well. // An example of this is razor imports where the generated C# document maps to many razor documents. // https://docs.microsoft.com/en-us/aspnet/core/mvc/views/layout?view=aspnetcore-3.1#importing-shared-directives // https://docs.microsoft.com/en-us/aspnet/core/blazor/layouts?view=aspnetcore-3.1#centralized-layout-selection // So we get the diagnostics and group them by the actual mapped path so we can publish notifications // for each mapped file's diagnostics. var fileUriToDiagnostics = diagnostics.GroupBy(diagnostic => GetDiagnosticUri(document, diagnostic)).ToDictionary( group => group.Key, group => group.Select(diagnostic => ConvertToLspDiagnostic(diagnostic, text)).ToImmutableArray()); return fileUriToDiagnostics; static Uri GetDiagnosticUri(Document document, DiagnosticData diagnosticData) { Contract.ThrowIfNull(diagnosticData.DataLocation, "Diagnostic data location should not be null here"); // Razor wants to handle all span mapping themselves. So if we are in razor, return the raw doc spans, and // do not map them. var filePath = diagnosticData.DataLocation.MappedFilePath ?? diagnosticData.DataLocation.OriginalFilePath; return ProtocolConversions.GetUriFromFilePath(filePath); } } private LSP.Diagnostic ConvertToLspDiagnostic(DiagnosticData diagnosticData, SourceText text) { Contract.ThrowIfNull(diagnosticData.DataLocation); var diagnostic = new LSP.Diagnostic { Source = TelemetryServerName, Code = diagnosticData.Id, Severity = Convert(diagnosticData.Severity), Range = GetDiagnosticRange(diagnosticData.DataLocation, text), // Only the unnecessary diagnostic tag is currently supported via LSP. Tags = diagnosticData.CustomTags.Contains(WellKnownDiagnosticTags.Unnecessary) ? new DiagnosticTag[] { DiagnosticTag.Unnecessary } : Array.Empty<DiagnosticTag>() }; if (diagnosticData.Message != null) diagnostic.Message = diagnosticData.Message; return diagnostic; } private static LSP.DiagnosticSeverity Convert(CodeAnalysis.DiagnosticSeverity severity) => severity switch { CodeAnalysis.DiagnosticSeverity.Hidden => LSP.DiagnosticSeverity.Hint, CodeAnalysis.DiagnosticSeverity.Info => LSP.DiagnosticSeverity.Hint, CodeAnalysis.DiagnosticSeverity.Warning => LSP.DiagnosticSeverity.Warning, CodeAnalysis.DiagnosticSeverity.Error => LSP.DiagnosticSeverity.Error, _ => throw ExceptionUtilities.UnexpectedValue(severity), }; // Some diagnostics only apply to certain clients and document types, e.g. Razor. // If the DocumentPropertiesService.DiagnosticsLspClientName property exists, we only include the // diagnostic if it directly matches the client name. // If the DocumentPropertiesService.DiagnosticsLspClientName property doesn't exist, // we know that the diagnostic we're working with is contained in a C#/VB file, since // if we were working with a non-C#/VB file, then the property should have been populated. // In this case, unless we have a null client name, we don't want to publish the diagnostic // (since a null client name represents the C#/VB language server). private bool IncludeDiagnostic(DiagnosticData diagnostic) => IReadOnlyDictionaryExtensions.GetValueOrDefault(diagnostic.Properties, nameof(DocumentPropertiesService.DiagnosticsLspClientName)) == ClientName; private static LSP.Range GetDiagnosticRange(DiagnosticDataLocation diagnosticDataLocation, SourceText text) { var linePositionSpan = DiagnosticData.GetLinePositionSpan(diagnosticDataLocation, text, useMapped: true); return ProtocolConversions.LinePositionToRange(linePositionSpan); } internal TestAccessor GetTestAccessor() => new(this); internal readonly struct TestAccessor { private readonly VisualStudioInProcLanguageServer _server; internal TestAccessor(VisualStudioInProcLanguageServer server) { _server = server; } internal ImmutableArray<Uri> GetFileUrisInPublishDiagnostics() => _server._publishedFileToDiagnostics.Keys.ToImmutableArray(); internal ImmutableArray<DocumentId> GetDocumentIdsInPublishedUris() => _server._documentsToPublishedUris.Keys.ToImmutableArray(); internal IImmutableSet<Uri> GetFileUrisForDocument(DocumentId documentId) => _server._documentsToPublishedUris.GetValueOrDefault(documentId, ImmutableSortedSet<Uri>.Empty); internal ImmutableArray<LSP.Diagnostic> GetDiagnosticsForUriAndDocument(DocumentId documentId, Uri uri) { if (_server._publishedFileToDiagnostics.TryGetValue(uri, out var dict) && dict.TryGetValue(documentId, out var diagnostics)) return diagnostics; return ImmutableArray<LSP.Diagnostic>.Empty; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; using Roslyn.Utilities; using StreamJsonRpc; using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageClient { /// <summary> /// Implementation of <see cref="LanguageServerTarget"/> that also supports /// VS LSP extension methods. /// </summary> internal class VisualStudioInProcLanguageServer : LanguageServerTarget { /// <summary> /// Legacy support for LSP push diagnostics. /// Work queue responsible for receiving notifications about diagnostic updates and publishing those to /// interested parties. /// </summary> private readonly AsyncBatchingWorkQueue<DocumentId> _diagnosticsWorkQueue; private readonly IDiagnosticService? _diagnosticService; internal VisualStudioInProcLanguageServer( AbstractRequestDispatcherFactory requestDispatcherFactory, JsonRpc jsonRpc, ICapabilitiesProvider capabilitiesProvider, ILspWorkspaceRegistrationService workspaceRegistrationService, IAsynchronousOperationListenerProvider listenerProvider, ILspLogger logger, IDiagnosticService? diagnosticService, string? clientName, string userVisibleServerName, string telemetryServerTypeName) : base(requestDispatcherFactory, jsonRpc, capabilitiesProvider, workspaceRegistrationService, listenerProvider, logger, clientName, userVisibleServerName, telemetryServerTypeName) { _diagnosticService = diagnosticService; // Dedupe on DocumentId. If we hear about the same document multiple times, we only need to process that id once. _diagnosticsWorkQueue = new AsyncBatchingWorkQueue<DocumentId>( TimeSpan.FromMilliseconds(250), (ids, ct) => ProcessDiagnosticUpdatedBatchAsync(_diagnosticService, ids, ct), EqualityComparer<DocumentId>.Default, Listener, Queue.CancellationToken); if (_diagnosticService != null) _diagnosticService.DiagnosticsUpdated += DiagnosticService_DiagnosticsUpdated; } public override Task InitializedAsync() { try { Logger?.TraceStart("Initialized"); // Publish diagnostics for all open documents immediately following initialization. PublishOpenFileDiagnostics(); return Task.CompletedTask; } finally { Logger?.TraceStop("Initialized"); } void PublishOpenFileDiagnostics() { foreach (var workspace in WorkspaceRegistrationService.GetAllRegistrations()) { var solution = workspace.CurrentSolution; var openDocuments = workspace.GetOpenDocumentIds(); foreach (var documentId in openDocuments) DiagnosticService_DiagnosticsUpdated(solution, documentId); } } } [JsonRpcMethod(MSLSPMethods.TextDocumentCodeActionResolveName, UseSingleObjectParameterDeserialization = true)] public Task<VSCodeAction> ResolveCodeActionAsync(VSCodeAction vsCodeAction, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<VSCodeAction, VSCodeAction>(Queue, MSLSPMethods.TextDocumentCodeActionResolveName, vsCodeAction, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.DocumentPullDiagnosticName, UseSingleObjectParameterDeserialization = true)] public Task<DiagnosticReport[]?> GetDocumentPullDiagnosticsAsync(DocumentDiagnosticsParams diagnosticsParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<DocumentDiagnosticsParams, DiagnosticReport[]?>( Queue, MSLSPMethods.DocumentPullDiagnosticName, diagnosticsParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.WorkspacePullDiagnosticName, UseSingleObjectParameterDeserialization = true)] public Task<WorkspaceDiagnosticReport[]?> GetWorkspacePullDiagnosticsAsync(WorkspaceDocumentDiagnosticsParams diagnosticsParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<WorkspaceDocumentDiagnosticsParams, WorkspaceDiagnosticReport[]?>( Queue, MSLSPMethods.WorkspacePullDiagnosticName, diagnosticsParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.ProjectContextsName, UseSingleObjectParameterDeserialization = true)] public Task<ActiveProjectContexts?> GetProjectContextsAsync(GetTextDocumentWithContextParams textDocumentWithContextParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<GetTextDocumentWithContextParams, ActiveProjectContexts?>(Queue, MSLSPMethods.ProjectContextsName, textDocumentWithContextParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.OnAutoInsertName, UseSingleObjectParameterDeserialization = true)] public Task<DocumentOnAutoInsertResponseItem?> GetDocumentOnAutoInsertAsync(DocumentOnAutoInsertParams autoInsertParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<DocumentOnAutoInsertParams, DocumentOnAutoInsertResponseItem?>(Queue, MSLSPMethods.OnAutoInsertName, autoInsertParams, _clientCapabilities, ClientName, cancellationToken); } [JsonRpcMethod(MSLSPMethods.OnTypeRenameName, UseSingleObjectParameterDeserialization = true)] public Task<DocumentOnTypeRenameResponseItem?> GetTypeRenameAsync(DocumentOnTypeRenameParams renameParams, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); return RequestDispatcher.ExecuteRequestAsync<DocumentOnTypeRenameParams, DocumentOnTypeRenameResponseItem?>(Queue, MSLSPMethods.OnTypeRenameName, renameParams, _clientCapabilities, ClientName, cancellationToken); } protected override void ShutdownImpl() { base.ShutdownImpl(); if (_diagnosticService != null) _diagnosticService.DiagnosticsUpdated -= DiagnosticService_DiagnosticsUpdated; } private void DiagnosticService_DiagnosticsUpdated(object _, DiagnosticsUpdatedArgs e) => DiagnosticService_DiagnosticsUpdated(e.Solution, e.DocumentId); private void DiagnosticService_DiagnosticsUpdated(Solution? solution, DocumentId? documentId) { // LSP doesn't support diagnostics without a document. So if we get project level diagnostics without a document, ignore them. if (documentId != null && solution != null) { var document = solution.GetDocument(documentId); if (document == null || document.FilePath == null) return; // Only publish document diagnostics for the languages this provider supports. if (document.Project.Language != CodeAnalysis.LanguageNames.CSharp && document.Project.Language != CodeAnalysis.LanguageNames.VisualBasic) return; _diagnosticsWorkQueue.AddWork(document.Id); } } /// <summary> /// Stores the last published LSP diagnostics with the Roslyn document that they came from. /// This is useful in the following scenario. Imagine we have documentA which has contributions to mapped files m1 and m2. /// dA -> m1 /// And m1 has contributions from documentB. /// m1 -> dA, dB /// When we query for diagnostic on dA, we get a subset of the diagnostics on m1 (missing the contributions from dB) /// Since each publish diagnostics notification replaces diagnostics per document, /// we must union the diagnostics contribution from dB and dA to produce all diagnostics for m1 and publish all at once. /// /// This dictionary stores the previously computed diagnostics for the published file so that we can /// union the currently computed diagnostics (e.g. for dA) with previously computed diagnostics (e.g. from dB). /// </summary> private readonly Dictionary<Uri, Dictionary<DocumentId, ImmutableArray<LSP.Diagnostic>>> _publishedFileToDiagnostics = new(); /// <summary> /// Stores the mapping of a document to the uri(s) of diagnostics previously produced for this document. When /// we get empty diagnostics for the document we need to find the uris we previously published for this /// document. Then we can publish the updated diagnostics set for those uris (either empty or the diagnostic /// contributions from other documents). We use a sorted set to ensure consistency in the order in which we /// report URIs. While it's not necessary to publish a document's mapped file diagnostics in a particular /// order, it does make it much easier to write tests and debug issues if we have a consistent ordering. /// </summary> private readonly Dictionary<DocumentId, ImmutableSortedSet<Uri>> _documentsToPublishedUris = new(); /// <summary> /// Basic comparer for Uris used by <see cref="_documentsToPublishedUris"/> when publishing notifications. /// </summary> private static readonly Comparer<Uri> s_uriComparer = Comparer<Uri>.Create((uri1, uri2) => Uri.Compare(uri1, uri2, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase)); // internal for testing purposes internal async ValueTask ProcessDiagnosticUpdatedBatchAsync( IDiagnosticService? diagnosticService, ImmutableArray<DocumentId> documentIds, CancellationToken cancellationToken) { if (diagnosticService == null) return; foreach (var documentId in documentIds) { cancellationToken.ThrowIfCancellationRequested(); var document = WorkspaceRegistrationService.GetAllRegistrations().Select(w => w.CurrentSolution.GetDocument(documentId)).FirstOrDefault(); if (document != null) { // If this is a `pull` client, and `pull` diagnostics is on, then we should not `publish` (push) the // diagnostics here. var diagnosticMode = document.IsRazorDocument() ? InternalDiagnosticsOptions.RazorDiagnosticMode : InternalDiagnosticsOptions.NormalDiagnosticMode; if (document.Project.Solution.Workspace.IsPushDiagnostics(diagnosticMode)) await PublishDiagnosticsAsync(diagnosticService, document, cancellationToken).ConfigureAwait(false); } } } private async Task PublishDiagnosticsAsync(IDiagnosticService diagnosticService, Document document, CancellationToken cancellationToken) { // Retrieve all diagnostics for the current document grouped by their actual file uri. var fileUriToDiagnostics = await GetDiagnosticsAsync(diagnosticService, document, cancellationToken).ConfigureAwait(false); // Get the list of file uris with diagnostics (for the document). // We need to join the uris from current diagnostics with those previously published // so that we clear out any diagnostics in mapped files that are no longer a part // of the current diagnostics set (because the diagnostics were fixed). // Use sorted set to have consistent publish ordering for tests and debugging. var urisForCurrentDocument = _documentsToPublishedUris.GetValueOrDefault(document.Id, ImmutableSortedSet.Create<Uri>(s_uriComparer)).Union(fileUriToDiagnostics.Keys); // Update the mapping for this document to be the uris we're about to publish diagnostics for. _documentsToPublishedUris[document.Id] = urisForCurrentDocument; // Go through each uri and publish the updated set of diagnostics per uri. foreach (var fileUri in urisForCurrentDocument) { // Get the updated diagnostics for a single uri that were contributed by the current document. var diagnostics = fileUriToDiagnostics.GetValueOrDefault(fileUri, ImmutableArray<LSP.Diagnostic>.Empty); if (_publishedFileToDiagnostics.ContainsKey(fileUri)) { // Get all previously published diagnostics for this uri excluding those that were contributed from the current document. // We don't need those since we just computed the updated values above. var diagnosticsFromOtherDocuments = _publishedFileToDiagnostics[fileUri].Where(kvp => kvp.Key != document.Id).SelectMany(kvp => kvp.Value); // Since diagnostics are replaced per uri, we must publish both contributions from this document and any other document // that has diagnostic contributions to this uri, so union the two sets. diagnostics = diagnostics.AddRange(diagnosticsFromOtherDocuments); } await SendDiagnosticsNotificationAsync(fileUri, diagnostics).ConfigureAwait(false); // There are three cases here -> // 1. There are no diagnostics to publish for this fileUri. We no longer need to track the fileUri at all. // 2. There are diagnostics from the current document. Store the diagnostics for the fileUri and document // so they can be published along with contributions to the fileUri from other documents. // 3. There are no diagnostics contributed by this document to the fileUri (could be some from other documents). // We should clear out the diagnostics for this document for the fileUri. if (diagnostics.IsEmpty) { // We published an empty set of diagnostics for this uri. We no longer need to keep track of this mapping // since there will be no previous diagnostics that we need to clear out. _documentsToPublishedUris.MultiRemove(document.Id, fileUri); // There are not any diagnostics to keep track of for this file, so we can stop. _publishedFileToDiagnostics.Remove(fileUri); } else if (fileUriToDiagnostics.ContainsKey(fileUri)) { // We do have diagnostics from the current document - update the published diagnostics map // to contain the new diagnostics contributed by this document for this uri. var documentsToPublishedDiagnostics = _publishedFileToDiagnostics.GetOrAdd(fileUri, (_) => new Dictionary<DocumentId, ImmutableArray<LSP.Diagnostic>>()); documentsToPublishedDiagnostics[document.Id] = fileUriToDiagnostics[fileUri]; } else { // There were diagnostics from other documents, but none from the current document. // If we're tracking the current document, we can stop. IReadOnlyDictionaryExtensions.GetValueOrDefault(_publishedFileToDiagnostics, fileUri)?.Remove(document.Id); _documentsToPublishedUris.MultiRemove(document.Id, fileUri); } } } private async Task SendDiagnosticsNotificationAsync(Uri uri, ImmutableArray<LSP.Diagnostic> diagnostics) { var publishDiagnosticsParams = new PublishDiagnosticParams { Diagnostics = diagnostics.ToArray(), Uri = uri }; await JsonRpc.NotifyWithParameterObjectAsync(Methods.TextDocumentPublishDiagnosticsName, publishDiagnosticsParams).ConfigureAwait(false); } private async Task<Dictionary<Uri, ImmutableArray<LSP.Diagnostic>>> GetDiagnosticsAsync( IDiagnosticService diagnosticService, Document document, CancellationToken cancellationToken) { var option = document.IsRazorDocument() ? InternalDiagnosticsOptions.RazorDiagnosticMode : InternalDiagnosticsOptions.NormalDiagnosticMode; var pushDiagnostics = await diagnosticService.GetPushDiagnosticsAsync(document.Project.Solution.Workspace, document.Project.Id, document.Id, id: null, includeSuppressedDiagnostics: false, option, cancellationToken).ConfigureAwait(false); var diagnostics = pushDiagnostics.WhereAsArray(IncludeDiagnostic); var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); // Retrieve diagnostics for the document. These diagnostics could be for the current document, or they could map // to a different location in a different file. We need to publish the diagnostics for the mapped locations as well. // An example of this is razor imports where the generated C# document maps to many razor documents. // https://docs.microsoft.com/en-us/aspnet/core/mvc/views/layout?view=aspnetcore-3.1#importing-shared-directives // https://docs.microsoft.com/en-us/aspnet/core/blazor/layouts?view=aspnetcore-3.1#centralized-layout-selection // So we get the diagnostics and group them by the actual mapped path so we can publish notifications // for each mapped file's diagnostics. var fileUriToDiagnostics = diagnostics.GroupBy(diagnostic => GetDiagnosticUri(document, diagnostic)).ToDictionary( group => group.Key, group => group.Select(diagnostic => ConvertToLspDiagnostic(diagnostic, text)).ToImmutableArray()); return fileUriToDiagnostics; static Uri GetDiagnosticUri(Document document, DiagnosticData diagnosticData) { Contract.ThrowIfNull(diagnosticData.DataLocation, "Diagnostic data location should not be null here"); // Razor wants to handle all span mapping themselves. So if we are in razor, return the raw doc spans, and // do not map them. var filePath = diagnosticData.DataLocation.MappedFilePath ?? diagnosticData.DataLocation.OriginalFilePath; return ProtocolConversions.GetUriFromFilePath(filePath); } } private LSP.Diagnostic ConvertToLspDiagnostic(DiagnosticData diagnosticData, SourceText text) { Contract.ThrowIfNull(diagnosticData.DataLocation); var diagnostic = new LSP.Diagnostic { Source = TelemetryServerName, Code = diagnosticData.Id, Severity = Convert(diagnosticData.Severity), Range = GetDiagnosticRange(diagnosticData.DataLocation, text), // Only the unnecessary diagnostic tag is currently supported via LSP. Tags = diagnosticData.CustomTags.Contains(WellKnownDiagnosticTags.Unnecessary) ? new DiagnosticTag[] { DiagnosticTag.Unnecessary } : Array.Empty<DiagnosticTag>() }; if (diagnosticData.Message != null) diagnostic.Message = diagnosticData.Message; return diagnostic; } private static LSP.DiagnosticSeverity Convert(CodeAnalysis.DiagnosticSeverity severity) => severity switch { CodeAnalysis.DiagnosticSeverity.Hidden => LSP.DiagnosticSeverity.Hint, CodeAnalysis.DiagnosticSeverity.Info => LSP.DiagnosticSeverity.Hint, CodeAnalysis.DiagnosticSeverity.Warning => LSP.DiagnosticSeverity.Warning, CodeAnalysis.DiagnosticSeverity.Error => LSP.DiagnosticSeverity.Error, _ => throw ExceptionUtilities.UnexpectedValue(severity), }; // Some diagnostics only apply to certain clients and document types, e.g. Razor. // If the DocumentPropertiesService.DiagnosticsLspClientName property exists, we only include the // diagnostic if it directly matches the client name. // If the DocumentPropertiesService.DiagnosticsLspClientName property doesn't exist, // we know that the diagnostic we're working with is contained in a C#/VB file, since // if we were working with a non-C#/VB file, then the property should have been populated. // In this case, unless we have a null client name, we don't want to publish the diagnostic // (since a null client name represents the C#/VB language server). private bool IncludeDiagnostic(DiagnosticData diagnostic) => IReadOnlyDictionaryExtensions.GetValueOrDefault(diagnostic.Properties, nameof(DocumentPropertiesService.DiagnosticsLspClientName)) == ClientName; private static LSP.Range GetDiagnosticRange(DiagnosticDataLocation diagnosticDataLocation, SourceText text) { var linePositionSpan = DiagnosticData.GetLinePositionSpan(diagnosticDataLocation, text, useMapped: true); return ProtocolConversions.LinePositionToRange(linePositionSpan); } internal TestAccessor GetTestAccessor() => new(this); internal readonly struct TestAccessor { private readonly VisualStudioInProcLanguageServer _server; internal TestAccessor(VisualStudioInProcLanguageServer server) { _server = server; } internal ImmutableArray<Uri> GetFileUrisInPublishDiagnostics() => _server._publishedFileToDiagnostics.Keys.ToImmutableArray(); internal ImmutableArray<DocumentId> GetDocumentIdsInPublishedUris() => _server._documentsToPublishedUris.Keys.ToImmutableArray(); internal IImmutableSet<Uri> GetFileUrisForDocument(DocumentId documentId) => _server._documentsToPublishedUris.GetValueOrDefault(documentId, ImmutableSortedSet<Uri>.Empty); internal ImmutableArray<LSP.Diagnostic> GetDiagnosticsForUriAndDocument(DocumentId documentId, Uri uri) { if (_server._publishedFileToDiagnostics.TryGetValue(uri, out var dict) && dict.TryGetValue(documentId, out var diagnostics)) return diagnostics; return ImmutableArray<LSP.Diagnostic>.Empty; } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/CSharp/Portable/CodeCleanup/CSharpCodeCleanerService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; using Microsoft.CodeAnalysis.CodeCleanup; using Microsoft.CodeAnalysis.CodeCleanup.Providers; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.CSharp.CodeCleanup { internal class CSharpCodeCleanerService : AbstractCodeCleanerService { private static readonly ImmutableArray<ICodeCleanupProvider> s_defaultProviders = ImmutableArray.Create<ICodeCleanupProvider>( new SimplificationCodeCleanupProvider(), new FormatCodeCleanupProvider()); public override ImmutableArray<ICodeCleanupProvider> GetDefaultProviders() => s_defaultProviders; protected override ImmutableArray<TextSpan> GetSpansToAvoid(SyntaxNode root) => ImmutableArray<TextSpan>.Empty; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; using Microsoft.CodeAnalysis.CodeCleanup; using Microsoft.CodeAnalysis.CodeCleanup.Providers; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.CSharp.CodeCleanup { internal class CSharpCodeCleanerService : AbstractCodeCleanerService { private static readonly ImmutableArray<ICodeCleanupProvider> s_defaultProviders = ImmutableArray.Create<ICodeCleanupProvider>( new SimplificationCodeCleanupProvider(), new FormatCodeCleanupProvider()); public override ImmutableArray<ICodeCleanupProvider> GetDefaultProviders() => s_defaultProviders; protected override ImmutableArray<TextSpan> GetSpansToAvoid(SyntaxNode root) => ImmutableArray<TextSpan>.Empty; } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/IncrementalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Concurrent; using System.Composition; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.FindSymbols.SymbolTree; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.SolutionCrawler; namespace Microsoft.CodeAnalysis.IncrementalCaches { /// <summary> /// Features like add-using want to be able to quickly search symbol indices for projects and /// metadata. However, creating those indices can be expensive. As such, we don't want to /// construct them during the add-using process itself. Instead, we expose this type as an /// Incremental-Analyzer to walk our projects/metadata in the background to keep the indices /// up to date. /// /// We also then export this type as a service that can give back the index for a project or /// metadata dll on request. If the index has been produced then it will be returned and /// can be used by add-using. Otherwise, nothing is returned and no results will be found. /// /// This means that as the project is being indexed, partial results may be returned. However /// once it is fully indexed, then total results will be returned. /// </summary> [Shared] [ExportIncrementalAnalyzerProvider(nameof(SymbolTreeInfoIncrementalAnalyzerProvider), new[] { WorkspaceKind.RemoteWorkspace })] [ExportWorkspaceServiceFactory(typeof(ISymbolTreeInfoCacheService))] internal partial class SymbolTreeInfoIncrementalAnalyzerProvider : IIncrementalAnalyzerProvider, IWorkspaceServiceFactory { // Concurrent dictionaries so they can be read from the SymbolTreeInfoCacheService while they are being // populated/updated by the IncrementalAnalyzer. // // We always keep around the latest computed information produced by the incremental analyzer. That way the // values are hopefully ready when someone calls on them for the current solution. private readonly ConcurrentDictionary<ProjectId, SymbolTreeInfo> _projectIdToInfo = new(); private readonly ConcurrentDictionary<MetadataId, MetadataInfo> _metadataIdToInfo = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public SymbolTreeInfoIncrementalAnalyzerProvider() { } public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace) => new SymbolTreeInfoIncrementalAnalyzer(_projectIdToInfo, _metadataIdToInfo); public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) => new SymbolTreeInfoCacheService(_projectIdToInfo, _metadataIdToInfo); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Concurrent; using System.Composition; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.FindSymbols.SymbolTree; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.SolutionCrawler; namespace Microsoft.CodeAnalysis.IncrementalCaches { /// <summary> /// Features like add-using want to be able to quickly search symbol indices for projects and /// metadata. However, creating those indices can be expensive. As such, we don't want to /// construct them during the add-using process itself. Instead, we expose this type as an /// Incremental-Analyzer to walk our projects/metadata in the background to keep the indices /// up to date. /// /// We also then export this type as a service that can give back the index for a project or /// metadata dll on request. If the index has been produced then it will be returned and /// can be used by add-using. Otherwise, nothing is returned and no results will be found. /// /// This means that as the project is being indexed, partial results may be returned. However /// once it is fully indexed, then total results will be returned. /// </summary> [Shared] [ExportIncrementalAnalyzerProvider(nameof(SymbolTreeInfoIncrementalAnalyzerProvider), new[] { WorkspaceKind.RemoteWorkspace })] [ExportWorkspaceServiceFactory(typeof(ISymbolTreeInfoCacheService))] internal partial class SymbolTreeInfoIncrementalAnalyzerProvider : IIncrementalAnalyzerProvider, IWorkspaceServiceFactory { // Concurrent dictionaries so they can be read from the SymbolTreeInfoCacheService while they are being // populated/updated by the IncrementalAnalyzer. // // We always keep around the latest computed information produced by the incremental analyzer. That way the // values are hopefully ready when someone calls on them for the current solution. private readonly ConcurrentDictionary<ProjectId, SymbolTreeInfo> _projectIdToInfo = new(); private readonly ConcurrentDictionary<MetadataId, MetadataInfo> _metadataIdToInfo = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public SymbolTreeInfoIncrementalAnalyzerProvider() { } public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace) => new SymbolTreeInfoIncrementalAnalyzer(_projectIdToInfo, _metadataIdToInfo); public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) => new SymbolTreeInfoCacheService(_projectIdToInfo, _metadataIdToInfo); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Xaml/Impl/Features/Completion/IXamlCompletionService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Host; namespace Microsoft.VisualStudio.LanguageServices.Xaml.Features.Completion { internal interface IXamlCompletionService : ILanguageService { Task<XamlCompletionResult> GetCompletionsAsync(XamlCompletionContext completionContext, CancellationToken cancellationToken); Task<ISymbol> GetSymbolAsync(XamlCompletionContext completionContext, string label, CancellationToken cancellationToken); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Host; namespace Microsoft.VisualStudio.LanguageServices.Xaml.Features.Completion { internal interface IXamlCompletionService : ILanguageService { Task<XamlCompletionResult> GetCompletionsAsync(XamlCompletionContext completionContext, CancellationToken cancellationToken); Task<ISymbol> GetSymbolAsync(XamlCompletionContext completionContext, string label, CancellationToken cancellationToken); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Test/Core/Mocks/TestMessageProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Globalization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; namespace Roslyn.Test.Utilities { internal abstract class TestMessageProvider : CommonMessageProvider { public override Type ErrorCodeType { get { throw new NotImplementedException(); } } public override Diagnostic CreateDiagnostic(int code, Location location, params object[] args) { throw new NotImplementedException(); } public override Diagnostic CreateDiagnostic(DiagnosticInfo info) { throw new NotImplementedException(); } public override string GetMessagePrefix(string id, DiagnosticSeverity severity, bool isWarningAsError, CultureInfo culture) { throw new NotImplementedException(); } public override ReportDiagnostic GetDiagnosticReport(DiagnosticInfo diagnosticInfo, CompilationOptions options) { throw new NotImplementedException(); } public override int ERR_EncodinglessSyntaxTree { get { throw new NotImplementedException(); } } public override int ERR_InvalidPathMap { get { throw new NotImplementedException(); } } public override int ERR_FailedToCreateTempFile { get { throw new NotImplementedException(); } } public override int ERR_MultipleAnalyzerConfigsInSameDir => throw new NotImplementedException(); public override int ERR_ExpectedSingleScript { get { throw new NotImplementedException(); } } public override int ERR_OpenResponseFile { get { throw new NotImplementedException(); } } public override int FTL_InvalidInputFileName { get { throw new NotImplementedException(); } } public override int ERR_FileNotFound { get { throw new NotImplementedException(); } } public override int ERR_NoSourceFile { get { throw new NotImplementedException(); } } public override int ERR_CantOpenFileWrite { get { throw new NotImplementedException(); } } public override int ERR_OutputWriteFailed { get { throw new NotImplementedException(); } } public override int WRN_NoConfigNotOnCommandLine { get { throw new NotImplementedException(); } } public override int ERR_BinaryFile { get { throw new NotImplementedException(); } } public override int ERR_MetadataFileNotAssembly { get { throw new NotImplementedException(); } } public override int ERR_MetadataFileNotModule { get { throw new NotImplementedException(); } } public override int ERR_InvalidAssemblyMetadata { get { throw new NotImplementedException(); } } public override int ERR_InvalidModuleMetadata { get { throw new NotImplementedException(); } } public override int ERR_ErrorOpeningAssemblyFile { get { throw new NotImplementedException(); } } public override int ERR_ErrorOpeningModuleFile { get { throw new NotImplementedException(); } } public override int ERR_MetadataFileNotFound { get { throw new NotImplementedException(); } } public override int ERR_MetadataReferencesNotSupported { get { throw new NotImplementedException(); } } public override int ERR_PublicKeyFileFailure { get { throw new NotImplementedException(); } } public override int ERR_PublicKeyContainerFailure { get { throw new NotImplementedException(); } } public override int ERR_OptionMustBeAbsolutePath { get { throw new NotImplementedException(); } } public override int ERR_CantReadResource { get { throw new NotImplementedException(); } } public override int ERR_CantOpenWin32Resource { get { throw new NotImplementedException(); } } public override int ERR_CantOpenWin32Manifest { get { throw new NotImplementedException(); } } public override int ERR_CantOpenWin32Icon { get { throw new NotImplementedException(); } } public override int ERR_BadWin32Resource { get { throw new NotImplementedException(); } } public override int ERR_ErrorBuildingWin32Resource { get { throw new NotImplementedException(); } } public override int ERR_ResourceNotUnique { get { throw new NotImplementedException(); } } public override int ERR_ResourceFileNameNotUnique { get { throw new NotImplementedException(); } } public override int ERR_ResourceInModule { get { throw new NotImplementedException(); } } public override int ERR_PermissionSetAttributeFileReadError { get { throw new NotImplementedException(); } } public override int ERR_PdbWritingFailed { get { throw new NotImplementedException(); } } public override int WRN_PdbUsingNameTooLong { get { throw new NotImplementedException(); } } public override int WRN_PdbLocalNameTooLong { get { throw new NotImplementedException(); } } public override int ERR_MetadataNameTooLong { get { throw new NotImplementedException(); } } public override int WRN_AnalyzerCannotBeCreated { get { throw new NotImplementedException(); } } public override int WRN_NoAnalyzerInAssembly { get { throw new NotImplementedException(); } } public override int WRN_UnableToLoadAnalyzer { get { throw new NotImplementedException(); } } public override int INF_UnableToLoadSomeTypesInAnalyzer { get { throw new NotImplementedException(); } } public override int ERR_CantReadRulesetFile { get { throw new NotImplementedException(); } } public override int ERR_CompileCancelled { get { throw new NotImplementedException(); } } public override void ReportDuplicateMetadataReferenceStrong(DiagnosticBag diagnostics, Location location, MetadataReference reference, AssemblyIdentity identity, MetadataReference equivalentReference, AssemblyIdentity equivalentIdentity) { throw new NotImplementedException(); } public override void ReportDuplicateMetadataReferenceWeak(DiagnosticBag diagnostics, Location location, MetadataReference reference, AssemblyIdentity identity, MetadataReference equivalentReference, AssemblyIdentity equivalentIdentity) { throw new NotImplementedException(); } protected override void ReportInvalidAttributeArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, AttributeData attribute) { throw new NotImplementedException(); } protected override void ReportInvalidNamedArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int namedArgumentIndex, ITypeSymbol attributeClass, string parameterName) { throw new NotImplementedException(); } protected override void ReportParameterNotValidForType(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int namedArgumentIndex) { throw new NotImplementedException(); } protected override void ReportMarshalUnmanagedTypeNotValidForFields(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, string unmanagedTypeName, AttributeData attribute) { throw new NotImplementedException(); } protected override void ReportMarshalUnmanagedTypeOnlyValidForFields(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, string unmanagedTypeName, AttributeData attribute) { throw new NotImplementedException(); } protected override void ReportAttributeParameterRequired(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, string parameterName) { throw new NotImplementedException(); } protected override void ReportAttributeParameterRequired(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, string parameterName1, string parameterName2) { throw new NotImplementedException(); } public override DiagnosticSeverity GetSeverity(int code) { throw new NotImplementedException(); } public override string LoadMessage(int code, CultureInfo language) { throw new NotImplementedException(); } public override string CodePrefix { get { throw new NotImplementedException(); } } public override int GetWarningLevel(int code) { throw new NotImplementedException(); } public override int ERR_LinkedNetmoduleMetadataMustProvideFullPEImage { get { throw new NotImplementedException(); } } public override int ERR_InvalidDebugInformationFormat { get { throw new NotImplementedException(); } } public override int ERR_InvalidFileAlignment { get { throw new NotImplementedException(); } } public override int ERR_InvalidSubsystemVersion { get { throw new NotImplementedException(); } } public override int ERR_InvalidInstrumentationKind { get { throw new NotImplementedException(); } } public override int ERR_InvalidOutputName { get { throw new NotImplementedException(); } } public override int ERR_EncReferenceToAddedMember { get { throw new NotImplementedException(); } } public override int ERR_BadCompilationOptionValue { get { throw new NotImplementedException(); } } public override int ERR_MutuallyExclusiveOptions { get { throw new NotImplementedException(); } } public override int ERR_TooManyUserStrings { get { throw new NotImplementedException(); } } public override int ERR_PeWritingFailure { get { throw new NotImplementedException(); } } public override int ERR_ModuleEmitFailure { get { throw new NotImplementedException(); } } public override int ERR_EncUpdateFailedMissingAttribute { get { throw new NotImplementedException(); } } public override int ERR_BadAssemblyName { get { throw new NotImplementedException(); } } public override int ERR_BadSourceCodeKind { get { throw new NotImplementedException(); } } public override int ERR_BadDocumentationMode { get { throw new NotImplementedException(); } } public override int ERR_InvalidDebugInfo { get { throw new NotImplementedException(); } } public override int ERR_InvalidHashAlgorithmName => throw new NotImplementedException(); public override int WRN_GeneratorFailedDuringGeneration => throw new NotImplementedException(); public override int WRN_GeneratorFailedDuringInitialization => throw new NotImplementedException(); public override int WRN_AnalyzerReferencesFramework => throw new NotImplementedException(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Globalization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; namespace Roslyn.Test.Utilities { internal abstract class TestMessageProvider : CommonMessageProvider { public override Type ErrorCodeType { get { throw new NotImplementedException(); } } public override Diagnostic CreateDiagnostic(int code, Location location, params object[] args) { throw new NotImplementedException(); } public override Diagnostic CreateDiagnostic(DiagnosticInfo info) { throw new NotImplementedException(); } public override string GetMessagePrefix(string id, DiagnosticSeverity severity, bool isWarningAsError, CultureInfo culture) { throw new NotImplementedException(); } public override ReportDiagnostic GetDiagnosticReport(DiagnosticInfo diagnosticInfo, CompilationOptions options) { throw new NotImplementedException(); } public override int ERR_EncodinglessSyntaxTree { get { throw new NotImplementedException(); } } public override int ERR_InvalidPathMap { get { throw new NotImplementedException(); } } public override int ERR_FailedToCreateTempFile { get { throw new NotImplementedException(); } } public override int ERR_MultipleAnalyzerConfigsInSameDir => throw new NotImplementedException(); public override int ERR_ExpectedSingleScript { get { throw new NotImplementedException(); } } public override int ERR_OpenResponseFile { get { throw new NotImplementedException(); } } public override int FTL_InvalidInputFileName { get { throw new NotImplementedException(); } } public override int ERR_FileNotFound { get { throw new NotImplementedException(); } } public override int ERR_NoSourceFile { get { throw new NotImplementedException(); } } public override int ERR_CantOpenFileWrite { get { throw new NotImplementedException(); } } public override int ERR_OutputWriteFailed { get { throw new NotImplementedException(); } } public override int WRN_NoConfigNotOnCommandLine { get { throw new NotImplementedException(); } } public override int ERR_BinaryFile { get { throw new NotImplementedException(); } } public override int ERR_MetadataFileNotAssembly { get { throw new NotImplementedException(); } } public override int ERR_MetadataFileNotModule { get { throw new NotImplementedException(); } } public override int ERR_InvalidAssemblyMetadata { get { throw new NotImplementedException(); } } public override int ERR_InvalidModuleMetadata { get { throw new NotImplementedException(); } } public override int ERR_ErrorOpeningAssemblyFile { get { throw new NotImplementedException(); } } public override int ERR_ErrorOpeningModuleFile { get { throw new NotImplementedException(); } } public override int ERR_MetadataFileNotFound { get { throw new NotImplementedException(); } } public override int ERR_MetadataReferencesNotSupported { get { throw new NotImplementedException(); } } public override int ERR_PublicKeyFileFailure { get { throw new NotImplementedException(); } } public override int ERR_PublicKeyContainerFailure { get { throw new NotImplementedException(); } } public override int ERR_OptionMustBeAbsolutePath { get { throw new NotImplementedException(); } } public override int ERR_CantReadResource { get { throw new NotImplementedException(); } } public override int ERR_CantOpenWin32Resource { get { throw new NotImplementedException(); } } public override int ERR_CantOpenWin32Manifest { get { throw new NotImplementedException(); } } public override int ERR_CantOpenWin32Icon { get { throw new NotImplementedException(); } } public override int ERR_BadWin32Resource { get { throw new NotImplementedException(); } } public override int ERR_ErrorBuildingWin32Resource { get { throw new NotImplementedException(); } } public override int ERR_ResourceNotUnique { get { throw new NotImplementedException(); } } public override int ERR_ResourceFileNameNotUnique { get { throw new NotImplementedException(); } } public override int ERR_ResourceInModule { get { throw new NotImplementedException(); } } public override int ERR_PermissionSetAttributeFileReadError { get { throw new NotImplementedException(); } } public override int ERR_PdbWritingFailed { get { throw new NotImplementedException(); } } public override int WRN_PdbUsingNameTooLong { get { throw new NotImplementedException(); } } public override int WRN_PdbLocalNameTooLong { get { throw new NotImplementedException(); } } public override int ERR_MetadataNameTooLong { get { throw new NotImplementedException(); } } public override int WRN_AnalyzerCannotBeCreated { get { throw new NotImplementedException(); } } public override int WRN_NoAnalyzerInAssembly { get { throw new NotImplementedException(); } } public override int WRN_UnableToLoadAnalyzer { get { throw new NotImplementedException(); } } public override int INF_UnableToLoadSomeTypesInAnalyzer { get { throw new NotImplementedException(); } } public override int ERR_CantReadRulesetFile { get { throw new NotImplementedException(); } } public override int ERR_CompileCancelled { get { throw new NotImplementedException(); } } public override void ReportDuplicateMetadataReferenceStrong(DiagnosticBag diagnostics, Location location, MetadataReference reference, AssemblyIdentity identity, MetadataReference equivalentReference, AssemblyIdentity equivalentIdentity) { throw new NotImplementedException(); } public override void ReportDuplicateMetadataReferenceWeak(DiagnosticBag diagnostics, Location location, MetadataReference reference, AssemblyIdentity identity, MetadataReference equivalentReference, AssemblyIdentity equivalentIdentity) { throw new NotImplementedException(); } protected override void ReportInvalidAttributeArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, AttributeData attribute) { throw new NotImplementedException(); } protected override void ReportInvalidNamedArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int namedArgumentIndex, ITypeSymbol attributeClass, string parameterName) { throw new NotImplementedException(); } protected override void ReportParameterNotValidForType(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int namedArgumentIndex) { throw new NotImplementedException(); } protected override void ReportMarshalUnmanagedTypeNotValidForFields(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, string unmanagedTypeName, AttributeData attribute) { throw new NotImplementedException(); } protected override void ReportMarshalUnmanagedTypeOnlyValidForFields(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, string unmanagedTypeName, AttributeData attribute) { throw new NotImplementedException(); } protected override void ReportAttributeParameterRequired(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, string parameterName) { throw new NotImplementedException(); } protected override void ReportAttributeParameterRequired(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, string parameterName1, string parameterName2) { throw new NotImplementedException(); } public override DiagnosticSeverity GetSeverity(int code) { throw new NotImplementedException(); } public override string LoadMessage(int code, CultureInfo language) { throw new NotImplementedException(); } public override string CodePrefix { get { throw new NotImplementedException(); } } public override int GetWarningLevel(int code) { throw new NotImplementedException(); } public override int ERR_LinkedNetmoduleMetadataMustProvideFullPEImage { get { throw new NotImplementedException(); } } public override int ERR_InvalidDebugInformationFormat { get { throw new NotImplementedException(); } } public override int ERR_InvalidFileAlignment { get { throw new NotImplementedException(); } } public override int ERR_InvalidSubsystemVersion { get { throw new NotImplementedException(); } } public override int ERR_InvalidInstrumentationKind { get { throw new NotImplementedException(); } } public override int ERR_InvalidOutputName { get { throw new NotImplementedException(); } } public override int ERR_EncReferenceToAddedMember { get { throw new NotImplementedException(); } } public override int ERR_BadCompilationOptionValue { get { throw new NotImplementedException(); } } public override int ERR_MutuallyExclusiveOptions { get { throw new NotImplementedException(); } } public override int ERR_TooManyUserStrings { get { throw new NotImplementedException(); } } public override int ERR_PeWritingFailure { get { throw new NotImplementedException(); } } public override int ERR_ModuleEmitFailure { get { throw new NotImplementedException(); } } public override int ERR_EncUpdateFailedMissingAttribute { get { throw new NotImplementedException(); } } public override int ERR_BadAssemblyName { get { throw new NotImplementedException(); } } public override int ERR_BadSourceCodeKind { get { throw new NotImplementedException(); } } public override int ERR_BadDocumentationMode { get { throw new NotImplementedException(); } } public override int ERR_InvalidDebugInfo { get { throw new NotImplementedException(); } } public override int ERR_InvalidHashAlgorithmName => throw new NotImplementedException(); public override int WRN_GeneratorFailedDuringGeneration => throw new NotImplementedException(); public override int WRN_GeneratorFailedDuringInitialization => throw new NotImplementedException(); public override int WRN_AnalyzerReferencesFramework => throw new NotImplementedException(); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.UnitTests { public class PatternMatchingTests_Global : PatternMatchingTestBase { [Fact] public void GlobalCode_ExpressionStatement_01() { string source = @" H.Dummy(1 is int x1); H.Dummy(x1); object x2; H.Dummy(2 is int x2); H.Dummy(3 is int x3); object x3; H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,20): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 20), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,20): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 20), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ExpressionStatement_02() { string source = @" H.Dummy(1 is var x1); H.Dummy(x1); object x2; H.Dummy(2 is var x2); H.Dummy(3 is var x3); object x3; H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,20): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 20), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,20): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 20), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ExpressionStatement_03() { string source = @" System.Console.WriteLine(x1); H.Dummy(1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_IfStatement_01() { string source = @" if ((1 is int x1)) {} H.Dummy(x1); object x2; if ((2 is int x2)) {} if ((3 is int x3)) {} object x3; if (H.Dummy((41 is int x4), (42 is int x4))) {} if ((51 is int x5)) { H.Dummy(""52"" is string x5); H.Dummy(x5); } H.Dummy(x5); int x6 = 6; if (H.Dummy()) { string x6 = ""6""; H.Dummy(x6); } void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,15): error CS0102: The type 'Script' already contains a definition for 'x2' // if ((2 is int x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 15), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,24): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 24), // (30,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(30, 17), // (30,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(30, 21), // (30,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(30, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,15): error CS0128: A local variable or function named 'x2' is already defined in this scope // if ((2 is int x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 15), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,24): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 24), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (21,5): warning CS0219: The variable 'x6' is assigned but its value is never used // int x6 = 6; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "x6").WithArguments("x6").WithLocation(21, 5), // (24,12): error CS0136: A local or parameter named 'x6' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // string x6 = "6"; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x6").WithArguments("x6").WithLocation(24, 12), // (33,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(33, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_IfStatement_02() { string source = @" if ((1 is var x1)) {} H.Dummy(x1); object x2; if ((2 is var x2)) {} if ((3 is var x3)) {} object x3; if (H.Dummy((41 is var x4), (42 is var x4))) {} void Test() { H.Dummy(x1, x2, x3, x4, x5); } if ((51 is var x5)) { H.Dummy(""52"" is var x5); H.Dummy(x5); } H.Dummy(x5); Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,15): error CS0102: The type 'Script' already contains a definition for 'x2' // if ((2 is var x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 15), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,24): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 24), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[0], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,15): error CS0128: A local variable or function named 'x2' is already defined in this scope // if ((2 is var x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 15), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (12,24): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 24), // (16,29): error CS0841: Cannot use local variable 'x5' before it is declared // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x5").WithArguments("x5").WithLocation(16, 29), // (21,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(21, 25), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[1]); } } [Fact] public void GlobalCode_IfStatement_03() { string source = @" System.Console.WriteLine(x1); if ((1 is var x1)) { H.Dummy(""11"" is var x1); System.Console.WriteLine(x1); } Test(); void Test() { System.Console.WriteLine(x1); } class H { public static bool Dummy(params object[] x) {return false;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_IfStatement_04() { string source = @" System.Console.WriteLine(x1); if ((1 is var x1)) H.Dummy((""11"" is var x1), x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(object x, object y) { System.Console.WriteLine(y); } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_YieldReturnStatement_01() { string source = @" yield return (1 is int x1); H.Dummy(x1); object x2; yield return (2 is int x2); yield return (3 is int x3); object x3; yield return H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // yield return (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,33): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 33), // (2,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (1 is int x1); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(2, 1), // (6,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (2 is int x2); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(6, 1), // (8,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (3 is int x3); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(8, 1), // (11,1): error CS7020: Cannot use 'yield' in top-level script code // yield return H.Dummy((41 is int x4), Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): error CS1624: The body of '<top-level-statements-entry-point>' cannot be an iterator block because 'void' is not an iterator interface type // yield return (1 is int x1); Diagnostic(ErrorCode.ERR_BadIteratorReturn, "yield return (1 is int x1);").WithArguments("<top-level-statements-entry-point>", "void").WithLocation(2, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // yield return (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_YieldReturnStatement_02() { string source = @" yield return (1 is var x1); H.Dummy(x1); object x2; yield return (2 is var x2); yield return (3 is var x3); object x3; yield return H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // yield return (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,33): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 33), // (2,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (1 is var x1); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(2, 1), // (6,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (2 is var x2); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(6, 1), // (8,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (3 is var x3); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(8, 1), // (11,1): error CS7020: Cannot use 'yield' in top-level script code // yield return H.Dummy((41 is var x4), Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl)).Type.ToTestDisplayString()); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): error CS1624: The body of '<top-level-statements-entry-point>' cannot be an iterator block because 'void' is not an iterator interface type // yield return (1 is var x1); Diagnostic(ErrorCode.ERR_BadIteratorReturn, "yield return (1 is var x1);").WithArguments("<top-level-statements-entry-point>", "void").WithLocation(2, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // yield return (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ReturnStatement_01() { string source = @" return (1 is int x1); H.Dummy(x1); object x2; return (2 is int x2); return (3 is int x3); object x3; return H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // return (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,27): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 27), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (1 is int x1); Diagnostic(ErrorCode.ERR_NoImplicitConv, "1 is int x1").WithArguments("bool", "int").WithLocation(2, 9), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // return (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (8,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (3 is int x3); Diagnostic(ErrorCode.ERR_NoImplicitConv, "3 is int x3").WithArguments("bool", "int").WithLocation(8, 9), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (14,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(14, 6) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ReturnStatement_02() { string source = @" return (1 is var x1); H.Dummy(x1); object x2; return (2 is var x2); return (3 is var x3); object x3; return H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // return (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,27): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 27), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (1 is var x1); Diagnostic(ErrorCode.ERR_NoImplicitConv, "1 is var x1").WithArguments("bool", "int").WithLocation(2, 9), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // return (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (8,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (3 is var x3); Diagnostic(ErrorCode.ERR_NoImplicitConv, "3 is var x3").WithArguments("bool", "int").WithLocation(8, 9), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (14,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(14, 6) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ReturnStatement_03() { string source = @" System.Console.WriteLine(x1); Test(); return H.Dummy((1 is var x1), x1); void Test() { System.Console.WriteLine(x1); } class H { public static bool Dummy(object x, object y) { System.Console.WriteLine(y); return true; } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_ThrowStatement_01() { string source = @" throw H.Dummy(1 is int x1); H.Dummy(x1); object x2; throw H.Dummy(2 is int x2); throw H.Dummy(3 is int x3); object x3; throw H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static System.Exception Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // throw H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // throw H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ThrowStatement_02() { string source = @" throw H.Dummy(1 is var x1); H.Dummy(x1); object x2; throw H.Dummy(2 is var x2); throw H.Dummy(3 is var x3); object x3; throw H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static System.Exception Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // throw H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl)).Type.ToTestDisplayString()); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // throw H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_SwitchStatement_01() { string source = @" switch ((1 is int x1)) {default: break;} H.Dummy(x1); object x2; switch ((2 is int x2)) {default: break;} switch ((3 is int x3)) {default: break;} object x3; switch (H.Dummy((41 is int x4), (42 is int x4))) {default: break;} switch ((51 is int x5)) { default: H.Dummy(""52"" is string x5); H.Dummy(x5); break; } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,19): error CS0102: The type 'Script' already contains a definition for 'x2' // switch ((2 is int x2)) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 19), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,28): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4))) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 28), // (25,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(25, 17), // (25,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(25, 21), // (25,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(25, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,19): error CS0128: A local variable or function named 'x2' is already defined in this scope // switch ((2 is int x2)) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 19), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,28): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 28), // (17,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(17, 28), // (28,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(28, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_SwitchStatement_02() { string source = @" switch ((1 is var x1)) {default: break;} H.Dummy(x1); object x2; switch ((2 is var x2)) {default: break;} switch ((3 is var x3)) {default: break;} object x3; switch (H.Dummy((41 is var x4), (42 is var x4))) {default: break;} switch ((51 is var x5)) { default: H.Dummy(""52"" is var x5); H.Dummy(x5); break; } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,19): error CS0102: The type 'Script' already contains a definition for 'x2' // switch ((2 is var x2)) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 19), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,28): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4))) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 28), // (25,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(25, 17), // (25,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(25, 21), // (25,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(25, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,19): error CS0128: A local variable or function named 'x2' is already defined in this scope // switch ((2 is var x2)) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 19), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,28): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 28), // (17,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(17, 25), // (28,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(28, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_SwitchStatement_03() { string source = @" System.Console.WriteLine(x1); switch ((1 is var x1)) { default: H.Dummy(""11"" is var x1); System.Console.WriteLine(x1); break; } Test(); void Test() { System.Console.WriteLine(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_WhileStatement_01() { string source = @" while ((1 is int x1)) {} H.Dummy(x1); object x2; while ((2 is int x2)) {} while ((3 is int x3)) {} object x3; while (H.Dummy((41 is int x4), (42 is int x4))) {} while ((51 is int x5)) { H.Dummy(""52"" is string x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,18): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((2 is int x2)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 18), // (8,18): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((3 is int x3)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 18), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_WhileStatement_02() { string source = @" while ((1 is var x1)) {} H.Dummy(x1); object x2; while ((2 is var x2)) {} while ((3 is var x3)) {} object x3; while (H.Dummy((41 is var x4), (42 is var x4))) {} while ((51 is var x5)) { H.Dummy(""52"" is var x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,18): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((2 is var x2)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 18), // (8,18): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((3 is var x3)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 18), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_WhileStatement_03() { string source = @" while ((1 is var x1)) { System.Console.WriteLine(x1); break; } class H { public static bool Dummy(params object[] x) {return false;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Decl.Length); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[0], x1Ref); } [Fact] public void GlobalCode_DoStatement_01() { string source = @" do {} while ((1 is int x1)); H.Dummy(x1); object x2; do {} while ((2 is int x2)); do {} while ((3 is int x3)); object x3; do {} while (H.Dummy((41 is int x4), (42 is int x4))); do { H.Dummy(""52"" is string x5); H.Dummy(x5); } while ((51 is int x5)); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,24): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((2 is int x2)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 24), // (8,24): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((3 is int x3)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 24), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_DoStatement_02() { string source = @" do {} while ((1 is var x1)); H.Dummy(x1); object x2; do {} while ((2 is var x2)); do {} while ((3 is var x3)); object x3; do {} while (H.Dummy((41 is var x4), (42 is var x4))); do { H.Dummy(""52"" is var x5); H.Dummy(x5); } while ((51 is var x5)); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,24): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((2 is var x2)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 24), // (8,24): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((3 is var x3)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 24), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_DoStatement_03() { string source = @" int f = 1; do { } while ((f++ is var x1) && Test(x1) < 3); int Test(int x) { System.Console.WriteLine(x); return x; } class H { public static bool Dummy(params object[] x) {return false;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 2 3").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Decl.Length); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[0], x1Ref); } [Fact] public void GlobalCode_LockStatement_01() { string source = @" lock (H.Dummy(1 is int x1)) {} H.Dummy(x1); object x2; lock (H.Dummy(2 is int x2)) {} lock (H.Dummy(3 is int x3)) {} object x3; lock (H.Dummy((41 is int x4), (42 is int x4))) {} lock (H.Dummy(51 is int x5)) { H.Dummy(""52"" is string x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static object Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // lock (H.Dummy(2 is int x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // lock (H.Dummy(2 is int x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_LockStatement_02() { string source = @" lock (H.Dummy(1 is var x1)) {} H.Dummy(x1); object x2; lock (H.Dummy(2 is var x2)) {} lock (H.Dummy(3 is var x3)) {} object x3; lock (H.Dummy((41 is var x4), (42 is var x4))) {} lock (H.Dummy(51 is var x5)) { H.Dummy(""52"" is var x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static object Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // lock (H.Dummy(2 is var x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // lock (H.Dummy(2 is var x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_LockStatement_03() { string source = @" System.Console.WriteLine(x1); lock (H.Dummy(1 is var x1)) { H.Dummy(""11"" is var x1); System.Console.WriteLine(x1); } Test(); void Test() { System.Console.WriteLine(x1); } class H { public static object Dummy(params object[] x) {return new object();} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_LockStatement_04() { string source = @" System.Console.WriteLine(x1); lock (H.Dummy(1 is var x1)) H.Dummy((""11"" is var x1), x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(object x, object y) { System.Console.WriteLine(y); } public static object Dummy(object x) { return x; } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact, WorkItem(13716, "https://github.com/dotnet/roslyn/issues/13716")] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_DeconstructionDeclarationStatement_01() { string source = @" (bool a, int b) = ((1 is int x1), 1); H.Dummy(x1); object x2; (bool c, int d) = ((2 is int x2), 2); (bool e, int f) = ((3 is int x3), 3); object x3; (bool g, bool h) = ((41 is int x4), (42 is int x4)); (bool x5, bool x6) = ((5 is int x5), (6 is int x6)); void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,30): error CS0102: The type 'Script' already contains a definition for 'x2' // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 30), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,32): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 32), // (14,33): error CS0102: The type 'Script' already contains a definition for 'x5' // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(14, 33), // (15,33): error CS0102: The type 'Script' already contains a definition for 'x6' // (6 is int x6)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(15, 33), // (19,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(19, 17), // (19,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(19, 21), // (19,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(19, 25), // (19,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(19, 29), // (19,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(19, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,30): error CS0128: A local variable or function named 'x2' is already defined in this scope // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 30), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,32): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 32), // (14,33): error CS0128: A local variable or function named 'x5' is already defined in this scope // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(14, 33), // (15,33): error CS0128: A local variable or function named 'x6' is already defined in this scope // (6 is int x6)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(15, 33), // (22,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(22, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x6Decl); VerifyNotAPatternLocal(model, x6Ref); } } [Fact] public void GlobalCode_LabeledStatement_01() { string source = @" a: H.Dummy(1 is int x1); H.Dummy(x1); object x2; b: H.Dummy(2 is int x2); c: H.Dummy(3 is int x3); object x3; d: H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,21): error CS0102: The type 'Script' already contains a definition for 'x2' // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 21), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,23): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 23), // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is int x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is int x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is int x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is int x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (6,21): error CS0128: A local variable or function named 'x2' is already defined in this scope // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 21), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is int x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is int x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (12,23): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 23), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_LabeledStatement_02() { string source = @" a: H.Dummy(1 is var x1); H.Dummy(x1); object x2; b: H.Dummy(2 is var x2); c: H.Dummy(3 is var x3); object x3; d: H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,21): error CS0102: The type 'Script' already contains a definition for 'x2' // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 21), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,23): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 23), // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is var x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is var x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (6,21): error CS0128: A local variable or function named 'x2' is already defined in this scope // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 21), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is var x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is var x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (12,23): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 23), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_LabeledStatement_03() { string source = @" System.Console.WriteLine(x1); a:b:c:H.Dummy(1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics( // (3,1): warning CS0164: This label has not been referenced // a:b:c:(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(3, 1), // (3,3): warning CS0164: This label has not been referenced // a:b:c:(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(3, 3), // (3,5): warning CS0164: This label has not been referenced // a:b:c:(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(3, 5) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_LabeledStatement_04() { string source = @" a: bool b = (1 is int x1); H.Dummy(x1); object x2; c: bool d = (2 is int x2); e: bool f = (3 is int x3); object x3; g: bool h = H.Dummy((41 is int x4), (42 is int x4)); i: bool x5 = (5 is int x5); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (15,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // bool x5 = (5 is int x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(15, 21), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); VerifyNotAPatternLocal(model, x5Ref[1]); } } [Fact] public void GlobalCode_LabeledStatement_05() { string source = @" a: bool b = (1 is var x1); H.Dummy(x1); object x2; c: bool d = (2 is var x2); e: bool f = (3 is var x3); object x3; g: bool h = H.Dummy((41 is var x4), (42 is var x4)); i: bool x5 = (5 is var x5); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (15,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // bool x5 = (5 is var x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(15, 21), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); VerifyNotAPatternLocal(model, x5Ref[1]); } } [ConditionalFact(typeof(IsRelease), Reason = "https://github.com/dotnet/roslyn/issues/25702")] public void GlobalCode_LabeledStatement_06() { string source = @" System.Console.WriteLine(x1); a:b:c: var d = (1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics( // (3,1): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(3, 1), // (3,3): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(3, 3), // (3,5): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(3, 5) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_LabeledStatement_07() { string source = @"l1: (bool a, int b) = ((1 is int x1), 1); H.Dummy(x1); object x2; l2: (bool c, int d) = ((2 is int x2), 2); l3: (bool e, int f) = ((3 is int x3), 3); object x3; l4: (bool g, bool h) = ((41 is int x4), (42 is int x4)); l5: (bool x5, bool x6) = ((5 is int x5), (6 is int x6)); void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,30): error CS0102: The type 'Script' already contains a definition for 'x2' // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 30), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,32): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 32), // (14,33): error CS0102: The type 'Script' already contains a definition for 'x5' // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(14, 33), // (15,33): error CS0102: The type 'Script' already contains a definition for 'x6' // (6 is int x6)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(15, 33), // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (19,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(19, 17), // (19,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(19, 21), // (19,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(19, 25), // (19,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(19, 29), // (19,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(19, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (6,30): error CS0128: A local variable or function named 'x2' is already defined in this scope // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 30), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (12,32): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 32), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (14,33): error CS0128: A local variable or function named 'x5' is already defined in this scope // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(14, 33), // (15,33): error CS0128: A local variable or function named 'x6' is already defined in this scope // (6 is int x6)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(15, 33), // (22,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(22, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x6Decl); VerifyNotAPatternLocal(model, x6Ref[0]); } } [Fact] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_LabeledStatement_08() { string source = @"l1: (bool a, int b) = ((1 is var x1), 1); H.Dummy(x1); object x2; l2: (bool c, int d) = ((2 is var x2), 2); l3: (bool e, int f) = ((3 is var x3), 3); object x3; l4: (bool g, bool h) = ((41 is var x4), (42 is var x4)); l5: (bool x5, bool x6) = ((5 is var x5), (6 is var x6)); void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,30): error CS0102: The type 'Script' already contains a definition for 'x2' // (bool c, int d) = ((2 is var x2), 2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 30), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,32): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 32), // (14,33): error CS0102: The type 'Script' already contains a definition for 'x5' // (bool x5, bool x6) = ((5 is var x5), Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(14, 33), // (15,33): error CS0102: The type 'Script' already contains a definition for 'x6' // (6 is var x6)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(15, 33), // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (19,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(19, 17), // (19,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(19, 21), // (19,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(19, 25), // (19,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(19, 29), // (19,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(19, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (6,30): error CS0128: A local variable or function named 'x2' is already defined in this scope // (bool c, int d) = ((2 is var x2), 2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 30), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (12,32): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 32), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (14,33): error CS0128: A local variable or function named 'x5' is already defined in this scope // (bool x5, bool x6) = ((5 is var x5), Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(14, 33), // (15,33): error CS0128: A local variable or function named 'x6' is already defined in this scope // (6 is var x6)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(15, 33), // (22,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(22, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x6Decl); VerifyNotAPatternLocal(model, x6Ref[0]); } } [Fact] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_LabeledStatement_09() { string source = @" System.Console.WriteLine(x1); a:b:c: var (d, e) = ((1 is var x1), 1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.DebugExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics( // (3,1): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(3, 1), // (3,3): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(3, 3), // (3,5): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(3, 5) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_01() { string source = @" bool b = (1 is int x1); H.Dummy(x1); object x2; bool d = (2 is int x2); bool f = (3 is int x3); object x3; bool h = H.Dummy((41 is int x4), (42 is int x4)); bool x5 = (5 is int x5); bool i = (5 is int x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is int x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (16,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // (5 is int x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(16, 21), // (19,10): error CS0128: A local variable or function named 'x6' is already defined in this scope // x6; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(19, 10), // (19,10): warning CS0168: The variable 'x6' is declared but never used // x6; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x6").WithArguments("x6").WithLocation(19, 10), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); } } [Fact] public void GlobalCode_FieldDeclaration_02() { string source = @" bool b = (1 is var x1); H.Dummy(x1); object x2; bool d = (2 is var x2); bool f = (3 is var x3); object x3; bool h = H.Dummy((41 is var x4), (42 is var x4)); bool x5 = (5 is var x5); bool i = (5 is var x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is var x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (16,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // (5 is var x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(16, 21), // (19,10): error CS0128: A local variable or function named 'x6' is already defined in this scope // x6; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(19, 10), // (19,10): warning CS0168: The variable 'x6' is declared but never used // x6; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x6").WithArguments("x6").WithLocation(19, 10), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); } } [Fact] public void GlobalCode_FieldDeclaration_03() { string source = @" System.Console.WriteLine(x1); var d = (1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_04() { string source = @" static var a = InitA(); System.Console.WriteLine(x1); static var b = (1 is var x1); Test(); static var c = InitB(); void Test() { System.Console.WriteLine(x1); } static object InitA() { System.Console.WriteLine(""InitA {0}"", x1); return null; } static object InitB() { System.Console.WriteLine(""InitB {0}"", x1); return null; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"InitA 0 InitB 1 1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(4, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_05() { string source = @" bool b = (1 is var x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_06() { string source = @" bool b = (1 is int x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_07() { string source = @" Test(); bool a = (1 is var x1), b = Test(), c = (2 is var x2); Test(); bool Test() { System.Console.WriteLine(""{0} {1}"", x1, x2); return false; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 0 1 0 1 2").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationField(model, x2Decl, x2Ref); } [Fact] public void GlobalCode_PropertyDeclaration_01() { string source = @" bool b { get; } = (1 is int x1); H.Dummy(x1); object x2; bool d { get; } = (2 is int x2); bool f { get; } = (3 is int x3); object x3; bool h { get; } = H.Dummy((41 is int x4), (42 is int x4)); bool x5 { get; } = (5 is int x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,29): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d { get; } = (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 29), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,38): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 38), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is int x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25), // (20,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(20, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool b { get; } = (1 is int x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 6), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool d { get; } = (2 is int x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 6), // (9,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool f { get; } = (3 is int x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 6), // (12,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool h { get; } = H.Dummy((41 is int x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 6), // (13,38): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 38), // (15,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool x5 { get; } = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 6), // (20,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(20, 13), // (20,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(20, 25), // (20,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 29), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1), // (23,1): error CS0165: Use of unassigned local variable 'x3' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x3").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); } } [Fact] public void GlobalCode_PropertyDeclaration_02() { string source = @" bool b { get; } = (1 is var x1); H.Dummy(x1); object x2; bool d { get; } = (2 is var x2); bool f { get; } = (3 is var x3); object x3; bool h { get; } = H.Dummy((41 is var x4), (42 is var x4)); bool x5 { get; } = (5 is var x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,29): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d { get; } = (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 29), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,38): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 38), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is var x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25), // (20,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(20, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool b { get; } = (1 is var x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 6), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool d { get; } = (2 is var x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 6), // (9,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool f { get; } = (3 is var x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 6), // (12,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool h { get; } = H.Dummy((41 is var x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 6), // (13,38): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 38), // (15,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool x5 { get; } = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 6), // (20,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(20, 13), // (20,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(20, 25), // (20,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 29), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1), // (23,1): error CS0165: Use of unassigned local variable 'x3' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x3").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); } } [Fact] public void GlobalCode_PropertyDeclaration_03() { string source = @" System.Console.WriteLine(x1); bool d { get; set; } = (1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_PropertyDeclaration_04() { string source = @" static var a = InitA(); System.Console.WriteLine(x1); static bool b { get; } = (1 is var x1); Test(); static var c = InitB(); void Test() { System.Console.WriteLine(x1); } static object InitA() { System.Console.WriteLine(""InitA {0}"", x1); return null; } static object InitB() { System.Console.WriteLine(""InitB {0}"", x1); return null; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"InitA 0 InitB 1 1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(4, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_PropertyDeclaration_05() { string source = @" bool b { get; } = (1 is var x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_PropertyDeclaration_06() { string source = @" bool b { get; } = (1 is int x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_01() { string source = @" event System.Action b = H.Dummy(1 is int x1); H.Dummy(x1); object x2; event System.Action d = H.Dummy(2 is int x2); event System.Action f = H.Dummy(3 is int x3); object x3; event System.Action h = H.Dummy((41 is int x4), (42 is int x4)); event System.Action x5 = H.Dummy(5 is int x5); event System.Action i = H.Dummy(5 is int x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,42): error CS0102: The type 'Script' already contains a definition for 'x2' // event System.Action d = H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 42), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,36): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 36), // (16,28): error CS0102: The type 'Script' already contains a definition for 'x5' // H.Dummy(5 is int x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 28), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action b = H.Dummy(1 is int x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 21), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action d = H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 21), // (9,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action f = H.Dummy(3 is int x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 21), // (12,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action h = H.Dummy((41 is int x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 21), // (13,36): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 36), // (15,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action x5 = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 21), // (18,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action i = H.Dummy(5 is int x6), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "i").WithLocation(18, 21), // (21,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(21, 6), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29), // (23,33): error CS0103: The name 'x6' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x6").WithArguments("x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl); VerifyNotInScope(model, x6Ref); } } [Fact] public void GlobalCode_EventDeclaration_02() { string source = @" event System.Action b = H.Dummy(1 is var x1); H.Dummy(x1); object x2; event System.Action d = H.Dummy(2 is var x2); event System.Action f = H.Dummy(3 is var x3); object x3; event System.Action h = H.Dummy((41 is var x4), (42 is var x4)); event System.Action x5 = H.Dummy(5 is var x5); event System.Action i = H.Dummy(5 is var x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,42): error CS0102: The type 'Script' already contains a definition for 'x2' // event System.Action d = H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 42), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,36): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 36), // (16,28): error CS0102: The type 'Script' already contains a definition for 'x5' // H.Dummy(5 is var x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 28), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action b = H.Dummy(1 is var x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 21), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action d = H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 21), // (9,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action f = H.Dummy(3 is var x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 21), // (12,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action h = H.Dummy((41 is var x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 21), // (13,36): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 36), // (15,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action x5 = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 21), // (18,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action i = H.Dummy(5 is var x6), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "i").WithLocation(18, 21), // (21,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(21, 6), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29), // (23,33): error CS0103: The name 'x6' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x6").WithArguments("x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl); VerifyNotInScope(model, x6Ref); } } [Fact] public void GlobalCode_EventDeclaration_03() { string source = @" System.Console.WriteLine(x1); event System.Action d = H.Dummy(1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_04() { string source = @" static var a = InitA(); System.Console.WriteLine(x1); static event System.Action b = H.Dummy(1 is var x1); Test(); static var c = InitB(); void Test() { System.Console.WriteLine(x1); } static object InitA() { System.Console.WriteLine(""InitA {0}"", x1); return null; } static object InitB() { System.Console.WriteLine(""InitB {0}"", x1); return null; } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"InitA 0 InitB 1 1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(4, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_05() { string source = @" event System.Action b = H.Dummy(1 is var x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_06() { string source = @" event System.Action b = H.Dummy(1 is int x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_07() { string source = @" Test(); event System.Action a = H.Dummy(1 is var x1), b = Test(), c = H.Dummy(2 is var x2); Test(); System.Action Test() { System.Console.WriteLine(""{0} {1}"", x1, x2); return null; } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 0 1 0 1 2").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationField(model, x2Decl, x2Ref); } [Fact] public void GlobalCode_DeclaratorArguments_01() { string source = @" bool a, b(""5948"" is var x1); H.Dummy(x1); void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_BadVarDecl, @"(""5948"" is var x1").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,27): error CS1003: Syntax error, ']' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 27) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,6): warning CS0168: The variable 'a' is declared but never used // bool a, b("5948" is var x1); Diagnostic(ErrorCode.WRN_UnreferencedVar, "a").WithArguments("a").WithLocation(3, 6), // (3,9): warning CS0168: The variable 'b' is declared but never used // bool a, b("5948" is var x1); Diagnostic(ErrorCode.WRN_UnreferencedVar, "b").WithArguments("b").WithLocation(3, 9), // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_BadVarDecl, @"(""5948"" is var x1").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,27): error CS1003: Syntax error, ']' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 27), // (4,9): error CS0165: Use of unassigned local variable 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_UseDefViolation, "x1").WithArguments("x1").WithLocation(4, 9), // (6,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(6, 6) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); VerifyModelForDeclarationOrVarSimplePatternWithoutDataFlow(model, x1Decl, x1Ref); } } [Fact] public void GlobalCode_DeclaratorArguments_02() { string source = @" label: bool a, b((1 is var x1)); H.Dummy(x1); void Test() { H.Dummy(x1); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "((1 is var x1)").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,24): error CS1003: Syntax error, ']' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 24), // (2,1): warning CS0164: This label has not been referenced // label: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "label").WithLocation(2, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // label: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "label").WithLocation(2, 1), // (3,6): warning CS0168: The variable 'a' is declared but never used // bool a, b((1 is var x1)); Diagnostic(ErrorCode.WRN_UnreferencedVar, "a").WithArguments("a").WithLocation(3, 6), // (3,9): warning CS0168: The variable 'b' is declared but never used // bool a, b((1 is var x1)); Diagnostic(ErrorCode.WRN_UnreferencedVar, "b").WithArguments("b").WithLocation(3, 9), // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "((1 is var x1)").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,24): error CS1003: Syntax error, ']' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 24), // (4,9): error CS0165: Use of unassigned local variable 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_UseDefViolation, "x1").WithArguments("x1").WithLocation(4, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } } [Fact] public void GlobalCode_DeclaratorArguments_03() { string source = @" event System.Action a, b(H.Dummy(1 is var x1)); H.Dummy(x1); void Test() { H.Dummy(x1); } Test(); class H { public static bool Dummy(params object[] x) {return false;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,25): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "(H.Dummy(1 is var x1)").WithLocation(3, 25), // (3,25): error CS1003: Syntax error, '[' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 25), // (3,46): error CS1003: Syntax error, ']' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 46) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,25): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "(H.Dummy(1 is var x1)").WithLocation(3, 25), // (3,25): error CS1003: Syntax error, '[' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 25), // (3,46): error CS1003: Syntax error, ']' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 46), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (8,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationOrVarSimplePatternWithoutDataFlow(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); } } [Fact] public void GlobalCode_DeclaratorArguments_04() { string source = @" fixed bool a[2], b[H.Dummy(1 is var x1)]; H.Dummy(x1); void Test() { H.Dummy(x1); } Test(); class H { public static int Dummy(params object[] x) {return 0;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,18): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "b").WithLocation(3, 18), // (3,20): error CS0133: The expression being assigned to 'b' must be constant // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_NotConstantExpression, "H.Dummy(1 is var x1)").WithArguments("b").WithLocation(3, 20), // (3,12): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "a").WithLocation(3, 12), // (3,12): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_UnsafeNeeded, "a[2]").WithLocation(3, 12) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,12): error CS0116: A namespace cannot directly contain members such as fields or methods // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "a").WithLocation(3, 12), // (3,18): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "b").WithLocation(3, 18), // (3,12): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "a").WithLocation(3, 12), // (3,12): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_UnsafeNeeded, "a[2]").WithLocation(3, 12), // (3,20): error CS0133: The expression being assigned to '<invalid-global-code>.b' must be constant // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_NotConstantExpression, "H.Dummy(1 is var x1)").WithArguments("<invalid-global-code>.b").WithLocation(3, 20), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (8,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 //VerifyModelForDeclarationOrVarSimplePatternWithoutDataFlow(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); } } [Fact] public void GlobalCode_RestrictedType_01() { string source = @" H.Dummy(null is System.ArgIterator x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.GetDeclarationDiagnostics().Verify( // (3,17): error CS0610: Field or property cannot be of type 'ArgIterator' // H.Dummy(null is System.ArgIterator x1); Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "System.ArgIterator").WithArguments("System.ArgIterator").WithLocation(3, 17) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl); } [Fact] public void GlobalCode_StaticType_01() { string source = @" H.Dummy(null is StaticType x1); class H { public static void Dummy(params object[] x) {} } static class StaticType{} "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.GetDeclarationDiagnostics().Verify( // (2,28): error CS0723: Cannot declare a variable of static type 'StaticType' // H.Dummy(null is StaticType x1); Diagnostic(ErrorCode.ERR_VarDeclIsStaticClass, "x1").WithArguments("StaticType").WithLocation(2, 28) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl); } [Fact] public void GlobalCode_AliasInfo_01() { string source = @" H.Dummy(1 is var x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); Assert.True(x1Decl.Parent is VarPatternSyntax); } [Fact] public void GlobalCode_AliasInfo_02() { string source = @" using var = System.Int32; H.Dummy(1 is var x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,14): error CS8508: The syntax 'var' for a pattern is not permitted to refer to a type, but 'var' is in scope here. // H.Dummy(1 is var x1); Diagnostic(ErrorCode.ERR_VarMayNotBindToType, "var").WithArguments("var").WithLocation(4, 14) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); Assert.True(x1Decl.Parent is VarPatternSyntax); } [Fact] public void GlobalCode_AliasInfo_03() { string source = @" using a = System.Int32; H.Dummy(1 is a x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1 = (DeclarationPatternSyntax)x1Decl.Parent; Assert.Equal("a=System.Int32", model.GetAliasInfo(x1.Type).ToTestDisplayString()); } [Fact] public void GlobalCode_AliasInfo_04() { string source = @" H.Dummy(1 is int x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1 = (DeclarationPatternSyntax)x1Decl.Parent; Assert.Null(model.GetAliasInfo(x1.Type)); } [Fact] public void GlobalCode_Catch_01() { var source = @" bool Dummy(params object[] x) {return true;} try {} catch when (123 is var x1 && x1 > 0) { Dummy(x1); } var x4 = 11; Dummy(x4); try {} catch when (123 is var x4 && x4 > 0) { Dummy(x4); } try {} catch when (x6 && 123 is var x6) { Dummy(x6); } try {} catch when (123 is var x7 && x7 > 0) { var x7 = 12; Dummy(x7); } try {} catch when (123 is var x8 && x8 > 0) { Dummy(x8); } System.Console.WriteLine(x8); try {} catch when (123 is var x9 && x9 > 0) { Dummy(x9); try {} catch when (123 is var x9 && x9 > 0) // 2 { Dummy(x9); } } try {} catch when (y10 is var x10) { var y10 = 12; Dummy(y10); } // try {} // catch when (y11 is var x11) // { // let y11 = 12; // Dummy(y11); // } try {} catch when (Dummy(123 is var x14, 123 is var x14, // 2 x14)) { Dummy(x14); } try {} catch (System.Exception x15) when (Dummy(123 is var x15, x15)) { Dummy(x15); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (20,13): error CS0841: Cannot use local variable 'x6' before it is declared // catch when (x6 && 123 is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(20, 13), // (28,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(28, 9), // (38,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(38, 26), // (45,28): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // catch when (123 is var x9 && x9 > 0) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(45, 28), // (52,13): error CS0103: The name 'y10' does not exist in the current context // catch when (y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(52, 13), // (67,32): error CS0128: A local variable or function named 'x14' is already defined in this scope // 123 is var x14, // 2 Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(67, 32), // (75,32): error CS0128: A local variable or function named 'x15' is already defined in this scope // when (Dummy(123 is var x15, x15)) Diagnostic(ErrorCode.ERR_LocalDuplicate, "x15").WithArguments("x15").WithLocation(75, 32) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclaration(tree, "x1"); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x4Decl = GetPatternDeclaration(tree, "x4"); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclaration(tree, "x6"); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclaration(tree, "x7"); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclaration(tree, "x8"); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclaration(tree, "x15"); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x15Decl); VerifyNotAPatternLocal(model, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (14,24): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // catch when (123 is var x4 && x4 > 0) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(14, 24), // (20,13): error CS0841: Cannot use local variable 'x6' before it is declared // catch when (x6 && 123 is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(20, 13), // (28,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(28, 9), // (38,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(38, 26), // (45,28): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // catch when (123 is var x9 && x9 > 0) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(45, 28), // (52,13): error CS0103: The name 'y10' does not exist in the current context // catch when (y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(52, 13), // (67,32): error CS0128: A local variable or function named 'x14' is already defined in this scope // 123 is var x14, // 2 Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(67, 32), // (75,32): error CS0128: A local variable or function named 'x15' is already defined in this scope // when (Dummy(123 is var x15, x15)) Diagnostic(ErrorCode.ERR_LocalDuplicate, "x15").WithArguments("x15").WithLocation(75, 32) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclaration(tree, "x1"); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x4Decl = GetPatternDeclaration(tree, "x4"); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclaration(tree, "x6"); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclaration(tree, "x7"); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclaration(tree, "x8"); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclaration(tree, "x15"); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x15Decl); VerifyNotAPatternLocal(model, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } } [Fact] public void GlobalCode_Catch_02() { var source = @" try { throw new System.InvalidOperationException(); } catch (System.Exception e) when (Dummy(e is var x1, x1)) { System.Console.WriteLine(x1.GetType()); } static bool Dummy(object y, object z) { System.Console.WriteLine(z.GetType()); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"System.InvalidOperationException System.InvalidOperationException"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Block_01() { string source = @" { H.Dummy(1 is var x1); H.Dummy(x1); } object x2; { H.Dummy(2 is var x2); H.Dummy(x2); } { H.Dummy(3 is var x3); } H.Dummy(x3); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (15,9): error CS0103: The name 'x3' does not exist in the current context // H.Dummy(x3); Diagnostic(ErrorCode.ERR_NameNotInContext, "x3").WithArguments("x3").WithLocation(15, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotInScope(model, x3Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (7,8): warning CS0168: The variable 'x2' is declared but never used // object x2; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x2").WithArguments("x2").WithLocation(7, 8), // (9,22): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(9, 22), // (15,9): error CS0103: The name 'x3' does not exist in the current context // H.Dummy(x3); Diagnostic(ErrorCode.ERR_NameNotInContext, "x3").WithArguments("x3").WithLocation(15, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotInScope(model, x3Ref); } } [Fact] public void GlobalCode_Block_02() { string source = @" { var tmp = 1 is var x1; System.Console.WriteLine(x1); Test(); void Test() { System.Console.WriteLine(x1); } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_For_01() { var source = @" bool Dummy(params object[] x) {return true;} for ( Dummy(true is var x1 && x1) ;;) { Dummy(x1); } for ( // 2 Dummy(true is var x2 && x2) ;;) Dummy(x2); var x4 = 11; Dummy(x4); for ( Dummy(true is var x4 && x4) ;;) Dummy(x4); for ( Dummy(x6 && true is var x6) ;;) Dummy(x6); for ( Dummy(true is var x7 && x7) ;;) { var x7 = 12; Dummy(x7); } for ( Dummy(true is var x8 && x8) ;;) Dummy(x8); System.Console.WriteLine(x8); for ( Dummy(true is var x9 && x9) ;;) { Dummy(x9); for ( Dummy(true is var x9 && x9) // 2 ;;) Dummy(x9); } for ( Dummy(y10 is var x10) ;;) { var y10 = 12; Dummy(y10); } // for ( // Dummy(y11 is var x11) // ;;) // { // let y11 = 12; // Dummy(y11); // } for ( Dummy(y12 is var x12) ;;) var y12 = 12; // for ( // Dummy(y13 is var x13) // ;;) // let y13 = 12; for ( Dummy(1 is var x14, 2 is var x14, x14) ;;) { Dummy(x14); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (74,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(74, 5), // (25,15): error CS0841: Cannot use local variable 'x6' before it is declared // Dummy(x6 && true is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(25, 15), // (33,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(33, 9), // (42,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(42, 26), // (50,31): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // Dummy(true is var x9 && x9) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(50, 31), // (56,15): error CS0103: The name 'y10' does not exist in the current context // Dummy(y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(56, 15), // (72,15): error CS0103: The name 'y12' does not exist in the current context // Dummy(y12 is var x12) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(72, 15), // (83,22): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(83, 22), // (11,1): warning CS0162: Unreachable code detected // for ( // 2 Diagnostic(ErrorCode.WRN_UnreachableCode, "for").WithLocation(11, 1), // (74,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(74, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (20,27): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // Dummy(true is var x4 && x4) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(20, 27), // (74,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(74, 5), // (25,15): error CS0841: Cannot use local variable 'x6' before it is declared // Dummy(x6 && true is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(25, 15), // (33,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(33, 9), // (42,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(42, 26), // (50,31): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // Dummy(true is var x9 && x9) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(50, 31), // (56,15): error CS0103: The name 'y10' does not exist in the current context // Dummy(y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(56, 15), // (72,15): error CS0103: The name 'y12' does not exist in the current context // Dummy(y12 is var x12) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(72, 15), // (83,22): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(83, 22), // (11,1): warning CS0162: Unreachable code detected // for ( // 2 Diagnostic(ErrorCode.WRN_UnreachableCode, "for").WithLocation(11, 1), // (74,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(74, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } } [Fact] public void GlobalCode_For_02() { var source = @" bool f = true; for (Dummy(f, ((f ? 10 : 20)) is var x0, x0); Dummy(f, ((f ? 1 : 2)) is var x1, x1); Dummy(f, ((f ? 100 : 200)) is var x2, x2), Dummy(true, null, x2)) { System.Console.WriteLine(x0); System.Console.WriteLine(x1); f = false; } static bool Dummy(bool x, object y, object z) { System.Console.WriteLine(z); return x; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"10 1 10 1 200 200 2"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x0Decl = GetPatternDeclarations(tree, "x0").Single(); var x0Ref = GetReferences(tree, "x0").ToArray(); Assert.Equal(2, x0Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x0Decl, x0Ref); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); } [Fact] public void GlobalCode_Foreach_01() { var source = @" System.Collections.IEnumerable Dummy(params object[] x) {return null;} foreach (var i in Dummy(true is var x1 && x1)) { Dummy(x1); } foreach (var i in Dummy(true is var x2 && x2)) Dummy(x2); var x4 = 11; Dummy(x4); foreach (var i in Dummy(true is var x4 && x4)) Dummy(x4); foreach (var i in Dummy(x6 && true is var x6)) Dummy(x6); foreach (var i in Dummy(true is var x7 && x7)) { var x7 = 12; Dummy(x7); } foreach (var i in Dummy(true is var x8 && x8)) Dummy(x8); System.Console.WriteLine(x8); foreach (var i1 in Dummy(true is var x9 && x9)) { Dummy(x9); foreach (var i2 in Dummy(true is var x9 && x9)) // 2 Dummy(x9); } foreach (var i in Dummy(y10 is var x10)) { var y10 = 12; Dummy(y10); } // foreach (var i in Dummy(y11 is var x11)) // { // let y11 = 12; // Dummy(y11); // } foreach (var i in Dummy(y12 is var x12)) var y12 = 12; // foreach (var i in Dummy(y13 is var x13)) // let y13 = 12; foreach (var i in Dummy(1 is var x14, 2 is var x14, x14)) { Dummy(x14); } foreach (var x15 in Dummy(1 is var x15, x15)) { Dummy(x15); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (18,25): error CS0841: Cannot use local variable 'x6' before it is declared // foreach (var i in Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 25), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,42): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var i2 in Dummy(true is var x9 && x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 42), // (39,25): error CS0103: The name 'y10' does not exist in the current context // foreach (var i in Dummy(y10 is var x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 25), // (51,25): error CS0103: The name 'y12' does not exist in the current context // foreach (var i in Dummy(y12 is var x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 25), // (58,34): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 34), // (64,14): error CS0136: A local or parameter named 'x15' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var x15 in Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x15").WithArguments("x15").WithLocation(64, 14), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclarations(tree, "x15").Single(); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x15Decl, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (15,37): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var i in Dummy(true is var x4 && x4)) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(15, 37), // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (18,25): error CS0841: Cannot use local variable 'x6' before it is declared // foreach (var i in Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 25), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,42): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var i2 in Dummy(true is var x9 && x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 42), // (39,25): error CS0103: The name 'y10' does not exist in the current context // foreach (var i in Dummy(y10 is var x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 25), // (51,25): error CS0103: The name 'y12' does not exist in the current context // foreach (var i in Dummy(y12 is var x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 25), // (58,34): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 34), // (64,14): error CS0136: A local or parameter named 'x15' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var x15 in Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x15").WithArguments("x15").WithLocation(64, 14), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclarations(tree, "x15").Single(); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x15Decl, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } } [Fact] public void GlobalCode_Foreach_02() { var source = @" bool f = true; foreach (var i in Dummy(3 is var x1, x1)) { System.Console.WriteLine(x1); } static System.Collections.IEnumerable Dummy(object y, object z) { System.Console.WriteLine(z); return ""a""; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"3 3"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Lambda_01() { var source = @" bool Dummy(params object[] x) {return true;} Dummy((System.Func<int, bool>) (o => o is var x3 && x3 > 0)); Dummy((System.Func<bool, bool>) (o => x4 && o is var x4)); Dummy((System.Func<int, int, bool>) ((o1, o2) => o1 is var x5 && o2 is var x5 && x5 > 0)); Dummy((System.Func<int, bool>) (o => o is var x6 && x6 > 0), (System.Func<int, bool>) (o => o is var x6 && x6 > 0)); Dummy(x7, 1); Dummy(x7, (System.Func<int, bool>) (o => o is var x7 && x7 > 0), x7); Dummy(x7, 2); Dummy(true is var x8 && x8, (System.Func<bool, bool>) (o => o is var y8 && x8)); Dummy(true is var x9, (System.Func<int, bool>) (o => o is var x9 && x9 > 0), x9); Dummy((System.Func<int, bool>) (o => o is var x10 && x10 > 0), true is var x10, x10); var x11 = 11; Dummy(x11); Dummy((System.Func<int, bool>) (o => o is var x11 && x11 > 0), x11); Dummy((System.Func<int, bool>) (o => o is var x12 && x12 > 0), x12); var x12 = 11; Dummy(x12); "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,39): error CS0841: Cannot use local variable 'x4' before it is declared // Dummy((System.Func<bool, bool>) (o => x4 && o is var x4)); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x4").WithArguments("x4").WithLocation(6, 39), // (9,67): error CS0128: A local variable or function named 'x5' is already defined in this scope // o2 is var x5 && Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(9, 67), // (14,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(14, 7), // (15,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(15, 7), // (17,9): error CS0103: The name 'x7' does not exist in the current context // x7); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(17, 9), // (18,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 2); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(18, 7) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").Single(); Assert.Equal(2, x5Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl[1]); var x6Decl = GetPatternDeclarations(tree, "x6").ToArray(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Decl.Length); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[0], x6Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[1], x6Ref[1]); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(5, x7Ref.Length); VerifyNotInScope(model, x7Ref[0]); VerifyNotInScope(model, x7Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[2]); VerifyNotInScope(model, x7Ref[3]); VerifyNotInScope(model, x7Ref[4]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(2, x8Ref.Length); VerifyModelForDeclarationField(model, x8Decl, x8Ref); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(2, x9Ref.Length); VerifyModelForDeclarationField(model, x9Decl[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[0]); var x10Decl = GetPatternDeclarations(tree, "x10").ToArray(); var x10Ref = GetReferences(tree, "x10").ToArray(); Assert.Equal(2, x10Decl.Length); Assert.Equal(2, x10Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl[0], x10Ref[0]); VerifyModelForDeclarationField(model, x10Decl[1], x10Ref[1]); var x11Decl = GetPatternDeclarations(tree, "x11").Single(); var x11Ref = GetReferences(tree, "x11").ToArray(); Assert.Equal(3, x11Ref.Length); VerifyNotAPatternLocal(model, x11Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x11Decl, x11Ref[1]); VerifyNotAPatternLocal(model, x11Ref[2]); var x12Decl = GetPatternDeclarations(tree, "x12").Single(); var x12Ref = GetReferences(tree, "x12").ToArray(); Assert.Equal(3, x12Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x12Decl, x12Ref[0]); VerifyNotAPatternLocal(model, x12Ref[1]); VerifyNotAPatternLocal(model, x12Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,39): error CS0841: Cannot use local variable 'x4' before it is declared // Dummy((System.Func<bool, bool>) (o => x4 && o is var x4)); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x4").WithArguments("x4").WithLocation(6, 39), // (9,67): error CS0128: A local variable or function named 'x5' is already defined in this scope // o2 is var x5 && Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(9, 67), // (14,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(14, 7), // (15,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(15, 7), // (17,9): error CS0103: The name 'x7' does not exist in the current context // x7); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(17, 9), // (18,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 2); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(18, 7), // (37,9): error CS0841: Cannot use local variable 'x12' before it is declared // x12); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x12").WithArguments("x12").WithLocation(37, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").Single(); Assert.Equal(2, x5Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl[1]); var x6Decl = GetPatternDeclarations(tree, "x6").ToArray(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Decl.Length); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[0], x6Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[1], x6Ref[1]); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(5, x7Ref.Length); VerifyNotInScope(model, x7Ref[0]); VerifyNotInScope(model, x7Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[2]); VerifyNotInScope(model, x7Ref[3]); VerifyNotInScope(model, x7Ref[4]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(2, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(2, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[0]); var x10Decl = GetPatternDeclarations(tree, "x10").ToArray(); var x10Ref = GetReferences(tree, "x10").ToArray(); Assert.Equal(2, x10Decl.Length); Assert.Equal(2, x10Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl[0], x10Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl[1], x10Ref[1]); var x11Decl = GetPatternDeclarations(tree, "x11").Single(); var x11Ref = GetReferences(tree, "x11").ToArray(); Assert.Equal(3, x11Ref.Length); VerifyNotAPatternLocal(model, x11Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x11Decl, x11Ref[1]); VerifyNotAPatternLocal(model, x11Ref[2]); var x12Decl = GetPatternDeclarations(tree, "x12").Single(); var x12Ref = GetReferences(tree, "x12").ToArray(); Assert.Equal(3, x12Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x12Decl, x12Ref[0]); VerifyNotAPatternLocal(model, x12Ref[1]); VerifyNotAPatternLocal(model, x12Ref[2]); } } [Fact] [WorkItem(16935, "https://github.com/dotnet/roslyn/issues/16935")] public void GlobalCode_Lambda_02() { var source = @" System.Func<bool> l = () => 1 is int x1 && Dummy(x1); System.Console.WriteLine(l()); static bool Dummy(int x) { System.Console.WriteLine(x); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 True"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Lambda_03() { var source = @" System.Console.WriteLine(((System.Func<bool>)(() => 1 is int x1 && Dummy(x1)))()); static bool Dummy(int x) { System.Console.WriteLine(x); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 True"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Query_01() { var source = @" using System.Linq; bool Dummy(params object[] x) {return true;} var r01 = from x in new[] { 1 is var y1 ? y1 : 0, y1} select x + y1; Dummy(y1); var r02 = from x1 in new[] { 1 is var y2 ? y2 : 0} from x2 in new[] { x1 is var z2 ? z2 : 0, z2, y2} select x1 + x2 + y2 + z2; Dummy(z2); var r03 = from x1 in new[] { 1 is var y3 ? y3 : 0} let x2 = x1 is var z3 && z3 > 0 && y3 < 0 select new { x1, x2, y3, z3}; Dummy(z3); var r04 = from x1 in new[] { 1 is var y4 ? y4 : 0} join x2 in new[] { 2 is var z4 ? z4 : 0, z4, y4} on x1 + y4 + z4 + (3 is var u4 ? u4 : 0) + v4 equals x2 + y4 + z4 + (4 is var v4 ? v4 : 0) + u4 select new { x1, x2, y4, z4, u4, v4 }; Dummy(z4); Dummy(u4); Dummy(v4); var r05 = from x1 in new[] { 1 is var y5 ? y5 : 0} join x2 in new[] { 2 is var z5 ? z5 : 0, z5, y5} on x1 + y5 + z5 + (3 is var u5 ? u5 : 0) + v5 equals x2 + y5 + z5 + (4 is var v5 ? v5 : 0) + u5 into g select new { x1, y5, z5, g, u5, v5 }; Dummy(z5); Dummy(u5); Dummy(v5); var r06 = from x in new[] { 1 is var y6 ? y6 : 0} where x > y6 && 1 is var z6 && z6 == 1 select x + y6 + z6; Dummy(z6); var r07 = from x in new[] { 1 is var y7 ? y7 : 0} orderby x > y7 && 1 is var z7 && z7 == u7, x > y7 && 1 is var u7 && u7 == z7 select x + y7 + z7 + u7; Dummy(z7); Dummy(u7); var r08 = from x in new[] { 1 is var y8 ? y8 : 0} select x > y8 && 1 is var z8 && z8 == 1; Dummy(z8); var r09 = from x in new[] { 1 is var y9 ? y9 : 0} group x > y9 && 1 is var z9 && z9 == u9 by x > y9 && 1 is var u9 && u9 == z9; Dummy(z9); Dummy(u9); var r10 = from x1 in new[] { 1 is var y10 ? y10 : 0} from y10 in new[] { 1 } select x1 + y10; var r11 = from x1 in new[] { 1 is var y11 ? y11 : 0} let y11 = x1 + 1 select x1 + y11; "; { var compilation = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (14,21): error CS0103: The name 'z2' does not exist in the current context // z2; Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(14, 21), // (21,25): error CS0103: The name 'z3' does not exist in the current context // z3}; Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(21, 25), // (28,29): error CS0103: The name 'v4' does not exist in the current context // v4 Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(28, 29), // (30,29): error CS1938: The name 'u4' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u4 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u4").WithArguments("u4").WithLocation(30, 29), // (32,25): error CS0103: The name 'u4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(32, 25), // (32,29): error CS0103: The name 'v4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(32, 29), // (41,29): error CS0103: The name 'v5' does not exist in the current context // v5 Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(41, 29), // (43,29): error CS1938: The name 'u5' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u5 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u5").WithArguments("u5").WithLocation(43, 29), // (46,25): error CS0103: The name 'u5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(46, 25), // (46,29): error CS0103: The name 'v5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(46, 29), // (55,21): error CS0103: The name 'z6' does not exist in the current context // z6; Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(55, 21), // (61,21): error CS0103: The name 'u7' does not exist in the current context // u7, Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(61, 21), // (63,21): error CS0103: The name 'z7' does not exist in the current context // z7 Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(63, 21), // (65,21): error CS0103: The name 'z7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(65, 21), // (65,26): error CS0103: The name 'u7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(65, 26), // (80,17): error CS0103: The name 'z9' does not exist in the current context // z9; Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(80, 17), // (77,17): error CS0103: The name 'u9' does not exist in the current context // u9 Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(77, 17), // (16,7): error CS0103: The name 'z2' does not exist in the current context // Dummy(z2); Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(16, 7), // (23,7): error CS0103: The name 'z3' does not exist in the current context // Dummy(z3); Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(23, 7), // (35,7): error CS0103: The name 'u4' does not exist in the current context // Dummy(u4); Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(35, 7), // (36,7): error CS0103: The name 'v4' does not exist in the current context // Dummy(v4); Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(36, 7), // (49,7): error CS0103: The name 'u5' does not exist in the current context // Dummy(u5); Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(49, 7), // (50,7): error CS0103: The name 'v5' does not exist in the current context // Dummy(v5); Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(50, 7), // (57,7): error CS0103: The name 'z6' does not exist in the current context // Dummy(z6); Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(57, 7), // (67,7): error CS0103: The name 'z7' does not exist in the current context // Dummy(z7); Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(67, 7), // (68,7): error CS0103: The name 'u7' does not exist in the current context // Dummy(u7); Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(68, 7), // (73,7): error CS0103: The name 'z8' does not exist in the current context // Dummy(z8); Diagnostic(ErrorCode.ERR_NameNotInContext, "z8").WithArguments("z8").WithLocation(73, 7), // (82,7): error CS0103: The name 'z9' does not exist in the current context // Dummy(z9); Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(82, 7), // (83,7): error CS0103: The name 'u9' does not exist in the current context // Dummy(u9); Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(83, 7) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var y1Decl = GetPatternDeclarations(tree, "y1").Single(); var y1Ref = GetReferences(tree, "y1").ToArray(); Assert.Equal(4, y1Ref.Length); VerifyModelForDeclarationField(model, y1Decl, y1Ref); var y2Decl = GetPatternDeclarations(tree, "y2").Single(); var y2Ref = GetReferences(tree, "y2").ToArray(); Assert.Equal(3, y2Ref.Length); VerifyModelForDeclarationField(model, y2Decl, y2Ref); var z2Decl = GetPatternDeclarations(tree, "z2").Single(); var z2Ref = GetReferences(tree, "z2").ToArray(); Assert.Equal(4, z2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z2Decl, z2Ref[0], z2Ref[1]); VerifyNotInScope(model, z2Ref[2]); VerifyNotInScope(model, z2Ref[3]); var y3Decl = GetPatternDeclarations(tree, "y3").Single(); var y3Ref = GetReferences(tree, "y3").ToArray(); Assert.Equal(3, y3Ref.Length); VerifyModelForDeclarationField(model, y3Decl, y3Ref); var z3Decl = GetPatternDeclarations(tree, "z3").Single(); var z3Ref = GetReferences(tree, "z3").ToArray(); Assert.Equal(3, z3Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z3Decl, z3Ref[0]); VerifyNotInScope(model, z3Ref[1]); VerifyNotInScope(model, z3Ref[2]); var y4Decl = GetPatternDeclarations(tree, "y4").Single(); var y4Ref = GetReferences(tree, "y4").ToArray(); Assert.Equal(5, y4Ref.Length); VerifyModelForDeclarationField(model, y4Decl, y4Ref); var z4Decl = GetPatternDeclarations(tree, "z4").Single(); var z4Ref = GetReferences(tree, "z4").ToArray(); Assert.Equal(6, z4Ref.Length); VerifyModelForDeclarationField(model, z4Decl, z4Ref); var u4Decl = GetPatternDeclarations(tree, "u4").Single(); var u4Ref = GetReferences(tree, "u4").ToArray(); Assert.Equal(4, u4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u4Decl, u4Ref[0]); VerifyNotInScope(model, u4Ref[1]); VerifyNotInScope(model, u4Ref[2]); VerifyNotInScope(model, u4Ref[3]); var v4Decl = GetPatternDeclarations(tree, "v4").Single(); var v4Ref = GetReferences(tree, "v4").ToArray(); Assert.Equal(4, v4Ref.Length); VerifyNotInScope(model, v4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v4Decl, v4Ref[1]); VerifyNotInScope(model, v4Ref[2]); VerifyNotInScope(model, v4Ref[3]); var y5Decl = GetPatternDeclarations(tree, "y5").Single(); var y5Ref = GetReferences(tree, "y5").ToArray(); Assert.Equal(5, y5Ref.Length); VerifyModelForDeclarationField(model, y5Decl, y5Ref); var z5Decl = GetPatternDeclarations(tree, "z5").Single(); var z5Ref = GetReferences(tree, "z5").ToArray(); Assert.Equal(6, z5Ref.Length); VerifyModelForDeclarationField(model, z5Decl, z5Ref); var u5Decl = GetPatternDeclarations(tree, "u5").Single(); var u5Ref = GetReferences(tree, "u5").ToArray(); Assert.Equal(4, u5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u5Decl, u5Ref[0]); VerifyNotInScope(model, u5Ref[1]); VerifyNotInScope(model, u5Ref[2]); VerifyNotInScope(model, u5Ref[3]); var v5Decl = GetPatternDeclarations(tree, "v5").Single(); var v5Ref = GetReferences(tree, "v5").ToArray(); Assert.Equal(4, v5Ref.Length); VerifyNotInScope(model, v5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v5Decl, v5Ref[1]); VerifyNotInScope(model, v5Ref[2]); VerifyNotInScope(model, v5Ref[3]); var y6Decl = GetPatternDeclarations(tree, "y6").Single(); var y6Ref = GetReferences(tree, "y6").ToArray(); Assert.Equal(3, y6Ref.Length); VerifyModelForDeclarationField(model, y6Decl, y6Ref); var z6Decl = GetPatternDeclarations(tree, "z6").Single(); var z6Ref = GetReferences(tree, "z6").ToArray(); Assert.Equal(3, z6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z6Decl, z6Ref[0]); VerifyNotInScope(model, z6Ref[1]); VerifyNotInScope(model, z6Ref[2]); var y7Decl = GetPatternDeclarations(tree, "y7").Single(); var y7Ref = GetReferences(tree, "y7").ToArray(); Assert.Equal(4, y7Ref.Length); VerifyModelForDeclarationField(model, y7Decl, y7Ref); var z7Decl = GetPatternDeclarations(tree, "z7").Single(); var z7Ref = GetReferences(tree, "z7").ToArray(); Assert.Equal(4, z7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z7Decl, z7Ref[0]); VerifyNotInScope(model, z7Ref[1]); VerifyNotInScope(model, z7Ref[2]); VerifyNotInScope(model, z7Ref[3]); var u7Decl = GetPatternDeclarations(tree, "u7").Single(); var u7Ref = GetReferences(tree, "u7").ToArray(); Assert.Equal(4, u7Ref.Length); VerifyNotInScope(model, u7Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u7Decl, u7Ref[1]); VerifyNotInScope(model, u7Ref[2]); VerifyNotInScope(model, u7Ref[3]); var y8Decl = GetPatternDeclarations(tree, "y8").Single(); var y8Ref = GetReferences(tree, "y8").ToArray(); Assert.Equal(2, y8Ref.Length); VerifyModelForDeclarationField(model, y8Decl, y8Ref); var z8Decl = GetPatternDeclarations(tree, "z8").Single(); var z8Ref = GetReferences(tree, "z8").ToArray(); Assert.Equal(2, z8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z8Decl, z8Ref[0]); VerifyNotInScope(model, z8Ref[1]); var y9Decl = GetPatternDeclarations(tree, "y9").Single(); var y9Ref = GetReferences(tree, "y9").ToArray(); Assert.Equal(3, y9Ref.Length); VerifyModelForDeclarationField(model, y9Decl, y9Ref); var z9Decl = GetPatternDeclarations(tree, "z9").Single(); var z9Ref = GetReferences(tree, "z9").ToArray(); Assert.Equal(3, z9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z9Decl, z9Ref[0]); VerifyNotInScope(model, z9Ref[1]); VerifyNotInScope(model, z9Ref[2]); var u9Decl = GetPatternDeclarations(tree, "u9").Single(); var u9Ref = GetReferences(tree, "u9").ToArray(); Assert.Equal(3, u9Ref.Length); VerifyNotInScope(model, u9Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u9Decl, u9Ref[1]); VerifyNotInScope(model, u9Ref[2]); var y10Decl = GetPatternDeclarations(tree, "y10").Single(); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyModelForDeclarationField(model, y10Decl, y10Ref[0]); VerifyNotAPatternField(model, y10Ref[1]); var y11Decl = GetPatternDeclarations(tree, "y11").Single(); var y11Ref = GetReferences(tree, "y11").ToArray(); Assert.Equal(2, y11Ref.Length); VerifyModelForDeclarationField(model, y11Decl, y11Ref[0]); VerifyNotAPatternField(model, y11Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (14,21): error CS0103: The name 'z2' does not exist in the current context // z2; Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(14, 21), // (21,25): error CS0103: The name 'z3' does not exist in the current context // z3}; Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(21, 25), // (28,29): error CS0103: The name 'v4' does not exist in the current context // v4 Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(28, 29), // (30,29): error CS1938: The name 'u4' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u4 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u4").WithArguments("u4").WithLocation(30, 29), // (32,25): error CS0103: The name 'u4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(32, 25), // (32,29): error CS0103: The name 'v4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(32, 29), // (41,29): error CS0103: The name 'v5' does not exist in the current context // v5 Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(41, 29), // (43,29): error CS1938: The name 'u5' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u5 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u5").WithArguments("u5").WithLocation(43, 29), // (46,25): error CS0103: The name 'u5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(46, 25), // (46,29): error CS0103: The name 'v5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(46, 29), // (55,21): error CS0103: The name 'z6' does not exist in the current context // z6; Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(55, 21), // (61,21): error CS0103: The name 'u7' does not exist in the current context // u7, Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(61, 21), // (63,21): error CS0103: The name 'z7' does not exist in the current context // z7 Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(63, 21), // (65,21): error CS0103: The name 'z7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(65, 21), // (65,26): error CS0103: The name 'u7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(65, 26), // (80,17): error CS0103: The name 'z9' does not exist in the current context // z9; Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(80, 17), // (77,17): error CS0103: The name 'u9' does not exist in the current context // u9 Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(77, 17), // (16,7): error CS0103: The name 'z2' does not exist in the current context // Dummy(z2); Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(16, 7), // (23,7): error CS0103: The name 'z3' does not exist in the current context // Dummy(z3); Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(23, 7), // (35,7): error CS0103: The name 'u4' does not exist in the current context // Dummy(u4); Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(35, 7), // (36,7): error CS0103: The name 'v4' does not exist in the current context // Dummy(v4); Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(36, 7), // (49,7): error CS0103: The name 'u5' does not exist in the current context // Dummy(u5); Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(49, 7), // (50,7): error CS0103: The name 'v5' does not exist in the current context // Dummy(v5); Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(50, 7), // (57,7): error CS0103: The name 'z6' does not exist in the current context // Dummy(z6); Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(57, 7), // (67,7): error CS0103: The name 'z7' does not exist in the current context // Dummy(z7); Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(67, 7), // (68,7): error CS0103: The name 'u7' does not exist in the current context // Dummy(u7); Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(68, 7), // (73,7): error CS0103: The name 'z8' does not exist in the current context // Dummy(z8); Diagnostic(ErrorCode.ERR_NameNotInContext, "z8").WithArguments("z8").WithLocation(73, 7), // (82,7): error CS0103: The name 'z9' does not exist in the current context // Dummy(z9); Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(82, 7), // (83,7): error CS0103: The name 'u9' does not exist in the current context // Dummy(u9); Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(83, 7), // (86,18): error CS1931: The range variable 'y10' conflicts with a previous declaration of 'y10' // from y10 in new[] { 1 } Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "y10").WithArguments("y10").WithLocation(86, 18), // (90,17): error CS1931: The range variable 'y11' conflicts with a previous declaration of 'y11' // let y11 = x1 + 1 Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "y11").WithArguments("y11").WithLocation(90, 17) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var y1Decl = GetPatternDeclarations(tree, "y1").Single(); var y1Ref = GetReferences(tree, "y1").ToArray(); Assert.Equal(4, y1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y1Decl, y1Ref); var y2Decl = GetPatternDeclarations(tree, "y2").Single(); var y2Ref = GetReferences(tree, "y2").ToArray(); Assert.Equal(3, y2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y2Decl, y2Ref); var z2Decl = GetPatternDeclarations(tree, "z2").Single(); var z2Ref = GetReferences(tree, "z2").ToArray(); Assert.Equal(4, z2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z2Decl, z2Ref[0], z2Ref[1]); VerifyNotInScope(model, z2Ref[2]); VerifyNotInScope(model, z2Ref[3]); var y3Decl = GetPatternDeclarations(tree, "y3").Single(); var y3Ref = GetReferences(tree, "y3").ToArray(); Assert.Equal(3, y3Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y3Decl, y3Ref); var z3Decl = GetPatternDeclarations(tree, "z3").Single(); var z3Ref = GetReferences(tree, "z3").ToArray(); Assert.Equal(3, z3Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z3Decl, z3Ref[0]); VerifyNotInScope(model, z3Ref[1]); VerifyNotInScope(model, z3Ref[2]); var y4Decl = GetPatternDeclarations(tree, "y4").Single(); var y4Ref = GetReferences(tree, "y4").ToArray(); Assert.Equal(5, y4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y4Decl, y4Ref); var z4Decl = GetPatternDeclarations(tree, "z4").Single(); var z4Ref = GetReferences(tree, "z4").ToArray(); Assert.Equal(6, z4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z4Decl, z4Ref); var u4Decl = GetPatternDeclarations(tree, "u4").Single(); var u4Ref = GetReferences(tree, "u4").ToArray(); Assert.Equal(4, u4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u4Decl, u4Ref[0]); VerifyNotInScope(model, u4Ref[1]); VerifyNotInScope(model, u4Ref[2]); VerifyNotInScope(model, u4Ref[3]); var v4Decl = GetPatternDeclarations(tree, "v4").Single(); var v4Ref = GetReferences(tree, "v4").ToArray(); Assert.Equal(4, v4Ref.Length); VerifyNotInScope(model, v4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v4Decl, v4Ref[1]); VerifyNotInScope(model, v4Ref[2]); VerifyNotInScope(model, v4Ref[3]); var y5Decl = GetPatternDeclarations(tree, "y5").Single(); var y5Ref = GetReferences(tree, "y5").ToArray(); Assert.Equal(5, y5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y5Decl, y5Ref); var z5Decl = GetPatternDeclarations(tree, "z5").Single(); var z5Ref = GetReferences(tree, "z5").ToArray(); Assert.Equal(6, z5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z5Decl, z5Ref); var u5Decl = GetPatternDeclarations(tree, "u5").Single(); var u5Ref = GetReferences(tree, "u5").ToArray(); Assert.Equal(4, u5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u5Decl, u5Ref[0]); VerifyNotInScope(model, u5Ref[1]); VerifyNotInScope(model, u5Ref[2]); VerifyNotInScope(model, u5Ref[3]); var v5Decl = GetPatternDeclarations(tree, "v5").Single(); var v5Ref = GetReferences(tree, "v5").ToArray(); Assert.Equal(4, v5Ref.Length); VerifyNotInScope(model, v5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v5Decl, v5Ref[1]); VerifyNotInScope(model, v5Ref[2]); VerifyNotInScope(model, v5Ref[3]); var y6Decl = GetPatternDeclarations(tree, "y6").Single(); var y6Ref = GetReferences(tree, "y6").ToArray(); Assert.Equal(3, y6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y6Decl, y6Ref); var z6Decl = GetPatternDeclarations(tree, "z6").Single(); var z6Ref = GetReferences(tree, "z6").ToArray(); Assert.Equal(3, z6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z6Decl, z6Ref[0]); VerifyNotInScope(model, z6Ref[1]); VerifyNotInScope(model, z6Ref[2]); var y7Decl = GetPatternDeclarations(tree, "y7").Single(); var y7Ref = GetReferences(tree, "y7").ToArray(); Assert.Equal(4, y7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y7Decl, y7Ref); var z7Decl = GetPatternDeclarations(tree, "z7").Single(); var z7Ref = GetReferences(tree, "z7").ToArray(); Assert.Equal(4, z7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z7Decl, z7Ref[0]); VerifyNotInScope(model, z7Ref[1]); VerifyNotInScope(model, z7Ref[2]); VerifyNotInScope(model, z7Ref[3]); var u7Decl = GetPatternDeclarations(tree, "u7").Single(); var u7Ref = GetReferences(tree, "u7").ToArray(); Assert.Equal(4, u7Ref.Length); VerifyNotInScope(model, u7Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u7Decl, u7Ref[1]); VerifyNotInScope(model, u7Ref[2]); VerifyNotInScope(model, u7Ref[3]); var y8Decl = GetPatternDeclarations(tree, "y8").Single(); var y8Ref = GetReferences(tree, "y8").ToArray(); Assert.Equal(2, y8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y8Decl, y8Ref); var z8Decl = GetPatternDeclarations(tree, "z8").Single(); var z8Ref = GetReferences(tree, "z8").ToArray(); Assert.Equal(2, z8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z8Decl, z8Ref[0]); VerifyNotInScope(model, z8Ref[1]); var y9Decl = GetPatternDeclarations(tree, "y9").Single(); var y9Ref = GetReferences(tree, "y9").ToArray(); Assert.Equal(3, y9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y9Decl, y9Ref); var z9Decl = GetPatternDeclarations(tree, "z9").Single(); var z9Ref = GetReferences(tree, "z9").ToArray(); Assert.Equal(3, z9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z9Decl, z9Ref[0]); VerifyNotInScope(model, z9Ref[1]); VerifyNotInScope(model, z9Ref[2]); var u9Decl = GetPatternDeclarations(tree, "u9").Single(); var u9Ref = GetReferences(tree, "u9").ToArray(); Assert.Equal(3, u9Ref.Length); VerifyNotInScope(model, u9Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u9Decl, u9Ref[1]); VerifyNotInScope(model, u9Ref[2]); var y10Decl = GetPatternDeclarations(tree, "y10").Single(); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y10Decl, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y11Decl = GetPatternDeclarations(tree, "y11").Single(); var y11Ref = GetReferences(tree, "y11").ToArray(); Assert.Equal(2, y11Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y11Decl, y11Ref[0]); VerifyNotAPatternLocal(model, y11Ref[1]); } } [Fact] public void GlobalCode_Query_02() { var source = @" using System.Linq; var res = from x1 in new[] { 1 is var y1 && Print(y1) ? 2 : 0} select Print(x1); res.ToArray(); static bool Print(object x) { System.Console.WriteLine(x); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 2"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var yDecl = GetPatternDeclarations(tree, "y1").Single(); var yRef = GetReferences(tree, "y1").Single(); VerifyModelForDeclarationField(model, yDecl, yRef); } [Fact] public void GlobalCode_Using_01() { var source = @" System.IDisposable Dummy(params object[] x) {return null;} using (Dummy(true is var x1, x1)) { Dummy(x1); } using (Dummy(true is var x2, x2)) Dummy(x2); var x4 = 11; Dummy(x4); using (Dummy(true is var x4, x4)) Dummy(x4); using (Dummy(x6 && true is var x6)) Dummy(x6); using (Dummy(true is var x7 && x7)) { var x7 = 12; Dummy(x7); } using (Dummy(true is var x8, x8)) Dummy(x8); System.Console.WriteLine(x8); using (Dummy(true is var x9, x9)) { Dummy(x9); using (Dummy(true is var x9, x9)) // 2 Dummy(x9); } using (Dummy(y10 is var x10, x10)) { var y10 = 12; Dummy(y10); } // using (Dummy(y11 is var x11, x11)) // { // let y11 = 12; // Dummy(y11); // } using (Dummy(y12 is var x12, x12)) var y12 = 12; // using (Dummy(y13 is var x13, x13)) // let y13 = 12; using (Dummy(1 is var x14, 2 is var x14, x14)) { Dummy(x14); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (18,14): error CS0841: Cannot use local variable 'x6' before it is declared // using (Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 14), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,30): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // using (Dummy(true is var x9, x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 30), // (39,14): error CS0103: The name 'y10' does not exist in the current context // using (Dummy(y10 is var x10, x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 14), // (51,14): error CS0103: The name 'y12' does not exist in the current context // using (Dummy(y12 is var x12, x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 14), // (58,26): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 26), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var x10Decl = GetPatternDeclarations(tree, "x10").Single(); var x10Ref = GetReferences(tree, "x10").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl, x10Ref); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (15,26): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // using (Dummy(true is var x4, x4)) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(15, 26), // (18,14): error CS0841: Cannot use local variable 'x6' before it is declared // using (Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 14), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,30): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // using (Dummy(true is var x9, x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 30), // (39,14): error CS0103: The name 'y10' does not exist in the current context // using (Dummy(y10 is var x10, x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 14), // (51,14): error CS0103: The name 'y12' does not exist in the current context // using (Dummy(y12 is var x12, x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 14), // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9), // (58,26): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 26) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var x10Decl = GetPatternDeclarations(tree, "x10").Single(); var x10Ref = GetReferences(tree, "x10").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl, x10Ref); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } } [Fact] public void GlobalCode_Using_02() { var source = @" using (System.IDisposable d1 = Dummy(new C(""a""), (new C(""b"")) is var x1), d2 = Dummy(new C(""c""), (new C(""d"")) is var x2)) { System.Console.WriteLine(d1); System.Console.WriteLine(x1); System.Console.WriteLine(d2); System.Console.WriteLine(x2); } using (Dummy(new C(""e""), (new C(""f"")) is var x1)) { System.Console.WriteLine(x1); } static System.IDisposable Dummy(System.IDisposable x, params object[] y) {return x;} class C : System.IDisposable { private readonly string _val; public C(string val) { _val = val; } public void Dispose() { System.Console.WriteLine(""Disposing {0}"", _val); } public override string ToString() { return _val; } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"a b c d Disposing c Disposing a f Disposing e"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.UnitTests { public class PatternMatchingTests_Global : PatternMatchingTestBase { [Fact] public void GlobalCode_ExpressionStatement_01() { string source = @" H.Dummy(1 is int x1); H.Dummy(x1); object x2; H.Dummy(2 is int x2); H.Dummy(3 is int x3); object x3; H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,20): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 20), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,20): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 20), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ExpressionStatement_02() { string source = @" H.Dummy(1 is var x1); H.Dummy(x1); object x2; H.Dummy(2 is var x2); H.Dummy(3 is var x3); object x3; H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,20): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 20), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,20): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 20), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDuplicateVariableDeclarationInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ExpressionStatement_03() { string source = @" System.Console.WriteLine(x1); H.Dummy(1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_IfStatement_01() { string source = @" if ((1 is int x1)) {} H.Dummy(x1); object x2; if ((2 is int x2)) {} if ((3 is int x3)) {} object x3; if (H.Dummy((41 is int x4), (42 is int x4))) {} if ((51 is int x5)) { H.Dummy(""52"" is string x5); H.Dummy(x5); } H.Dummy(x5); int x6 = 6; if (H.Dummy()) { string x6 = ""6""; H.Dummy(x6); } void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,15): error CS0102: The type 'Script' already contains a definition for 'x2' // if ((2 is int x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 15), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,24): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 24), // (30,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(30, 17), // (30,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(30, 21), // (30,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(30, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,15): error CS0128: A local variable or function named 'x2' is already defined in this scope // if ((2 is int x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 15), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,24): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 24), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (21,5): warning CS0219: The variable 'x6' is assigned but its value is never used // int x6 = 6; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "x6").WithArguments("x6").WithLocation(21, 5), // (24,12): error CS0136: A local or parameter named 'x6' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // string x6 = "6"; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x6").WithArguments("x6").WithLocation(24, 12), // (33,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(33, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_IfStatement_02() { string source = @" if ((1 is var x1)) {} H.Dummy(x1); object x2; if ((2 is var x2)) {} if ((3 is var x3)) {} object x3; if (H.Dummy((41 is var x4), (42 is var x4))) {} void Test() { H.Dummy(x1, x2, x3, x4, x5); } if ((51 is var x5)) { H.Dummy(""52"" is var x5); H.Dummy(x5); } H.Dummy(x5); Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,15): error CS0102: The type 'Script' already contains a definition for 'x2' // if ((2 is var x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 15), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,24): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 24), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[0], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,15): error CS0128: A local variable or function named 'x2' is already defined in this scope // if ((2 is var x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 15), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (12,24): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 24), // (16,29): error CS0841: Cannot use local variable 'x5' before it is declared // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x5").WithArguments("x5").WithLocation(16, 29), // (21,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(21, 25), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[1]); } } [Fact] public void GlobalCode_IfStatement_03() { string source = @" System.Console.WriteLine(x1); if ((1 is var x1)) { H.Dummy(""11"" is var x1); System.Console.WriteLine(x1); } Test(); void Test() { System.Console.WriteLine(x1); } class H { public static bool Dummy(params object[] x) {return false;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_IfStatement_04() { string source = @" System.Console.WriteLine(x1); if ((1 is var x1)) H.Dummy((""11"" is var x1), x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(object x, object y) { System.Console.WriteLine(y); } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_YieldReturnStatement_01() { string source = @" yield return (1 is int x1); H.Dummy(x1); object x2; yield return (2 is int x2); yield return (3 is int x3); object x3; yield return H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // yield return (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,33): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 33), // (2,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (1 is int x1); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(2, 1), // (6,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (2 is int x2); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(6, 1), // (8,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (3 is int x3); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(8, 1), // (11,1): error CS7020: Cannot use 'yield' in top-level script code // yield return H.Dummy((41 is int x4), Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): error CS1624: The body of '<top-level-statements-entry-point>' cannot be an iterator block because 'void' is not an iterator interface type // yield return (1 is int x1); Diagnostic(ErrorCode.ERR_BadIteratorReturn, "yield return (1 is int x1);").WithArguments("<top-level-statements-entry-point>", "void").WithLocation(2, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // yield return (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_YieldReturnStatement_02() { string source = @" yield return (1 is var x1); H.Dummy(x1); object x2; yield return (2 is var x2); yield return (3 is var x3); object x3; yield return H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // yield return (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,33): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 33), // (2,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (1 is var x1); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(2, 1), // (6,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (2 is var x2); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(6, 1), // (8,1): error CS7020: Cannot use 'yield' in top-level script code // yield return (3 is var x3); Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(8, 1), // (11,1): error CS7020: Cannot use 'yield' in top-level script code // yield return H.Dummy((41 is var x4), Diagnostic(ErrorCode.ERR_YieldNotAllowedInScript, "yield").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl)).Type.ToTestDisplayString()); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): error CS1624: The body of '<top-level-statements-entry-point>' cannot be an iterator block because 'void' is not an iterator interface type // yield return (1 is var x1); Diagnostic(ErrorCode.ERR_BadIteratorReturn, "yield return (1 is var x1);").WithArguments("<top-level-statements-entry-point>", "void").WithLocation(2, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // yield return (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ReturnStatement_01() { string source = @" return (1 is int x1); H.Dummy(x1); object x2; return (2 is int x2); return (3 is int x3); object x3; return H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // return (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,27): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 27), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (1 is int x1); Diagnostic(ErrorCode.ERR_NoImplicitConv, "1 is int x1").WithArguments("bool", "int").WithLocation(2, 9), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // return (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (8,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (3 is int x3); Diagnostic(ErrorCode.ERR_NoImplicitConv, "3 is int x3").WithArguments("bool", "int").WithLocation(8, 9), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (14,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(14, 6) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ReturnStatement_02() { string source = @" return (1 is var x1); H.Dummy(x1); object x2; return (2 is var x2); return (3 is var x3); object x3; return H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,18): error CS0102: The type 'Script' already contains a definition for 'x2' // return (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 18), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,27): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 27), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (1 is var x1); Diagnostic(ErrorCode.ERR_NoImplicitConv, "1 is var x1").WithArguments("bool", "int").WithLocation(2, 9), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,18): error CS0128: A local variable or function named 'x2' is already defined in this scope // return (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 18), // (8,9): error CS0029: Cannot implicitly convert type 'bool' to 'int' // return (3 is var x3); Diagnostic(ErrorCode.ERR_NoImplicitConv, "3 is var x3").WithArguments("bool", "int").WithLocation(8, 9), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (14,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(14, 6) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ReturnStatement_03() { string source = @" System.Console.WriteLine(x1); Test(); return H.Dummy((1 is var x1), x1); void Test() { System.Console.WriteLine(x1); } class H { public static bool Dummy(object x, object y) { System.Console.WriteLine(y); return true; } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_ThrowStatement_01() { string source = @" throw H.Dummy(1 is int x1); H.Dummy(x1); object x2; throw H.Dummy(2 is int x2); throw H.Dummy(3 is int x3); object x3; throw H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static System.Exception Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // throw H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // throw H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_ThrowStatement_02() { string source = @" throw H.Dummy(1 is var x1); H.Dummy(x1); object x2; throw H.Dummy(2 is var x2); throw H.Dummy(3 is var x3); object x3; throw H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static System.Exception Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // throw H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl)).Type.ToTestDisplayString()); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,1): warning CS0162: Unreachable code detected // H.Dummy(x1); Diagnostic(ErrorCode.WRN_UnreachableCode, "H").WithLocation(3, 1), // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // throw H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_SwitchStatement_01() { string source = @" switch ((1 is int x1)) {default: break;} H.Dummy(x1); object x2; switch ((2 is int x2)) {default: break;} switch ((3 is int x3)) {default: break;} object x3; switch (H.Dummy((41 is int x4), (42 is int x4))) {default: break;} switch ((51 is int x5)) { default: H.Dummy(""52"" is string x5); H.Dummy(x5); break; } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,19): error CS0102: The type 'Script' already contains a definition for 'x2' // switch ((2 is int x2)) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 19), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,28): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4))) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 28), // (25,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(25, 17), // (25,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(25, 21), // (25,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(25, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,19): error CS0128: A local variable or function named 'x2' is already defined in this scope // switch ((2 is int x2)) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 19), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,28): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 28), // (17,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(17, 28), // (28,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(28, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_SwitchStatement_02() { string source = @" switch ((1 is var x1)) {default: break;} H.Dummy(x1); object x2; switch ((2 is var x2)) {default: break;} switch ((3 is var x3)) {default: break;} object x3; switch (H.Dummy((41 is var x4), (42 is var x4))) {default: break;} switch ((51 is var x5)) { default: H.Dummy(""52"" is var x5); H.Dummy(x5); break; } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,19): error CS0102: The type 'Script' already contains a definition for 'x2' // switch ((2 is var x2)) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 19), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,28): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4))) {default: break;} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 28), // (25,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(25, 17), // (25,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(25, 21), // (25,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(25, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,19): error CS0128: A local variable or function named 'x2' is already defined in this scope // switch ((2 is var x2)) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 19), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,28): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {default: break;} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 28), // (17,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(17, 25), // (28,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(28, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_SwitchStatement_03() { string source = @" System.Console.WriteLine(x1); switch ((1 is var x1)) { default: H.Dummy(""11"" is var x1); System.Console.WriteLine(x1); break; } Test(); void Test() { System.Console.WriteLine(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_WhileStatement_01() { string source = @" while ((1 is int x1)) {} H.Dummy(x1); object x2; while ((2 is int x2)) {} while ((3 is int x3)) {} object x3; while (H.Dummy((41 is int x4), (42 is int x4))) {} while ((51 is int x5)) { H.Dummy(""52"" is string x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,18): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((2 is int x2)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 18), // (8,18): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((3 is int x3)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 18), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_WhileStatement_02() { string source = @" while ((1 is var x1)) {} H.Dummy(x1); object x2; while ((2 is var x2)) {} while ((3 is var x3)) {} object x3; while (H.Dummy((41 is var x4), (42 is var x4))) {} while ((51 is var x5)) { H.Dummy(""52"" is var x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,18): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((2 is var x2)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 18), // (8,18): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // while ((3 is var x3)) {} Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 18), // (12,27): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 27), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (19,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(19, 9), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_WhileStatement_03() { string source = @" while ((1 is var x1)) { System.Console.WriteLine(x1); break; } class H { public static bool Dummy(params object[] x) {return false;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Decl.Length); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[0], x1Ref); } [Fact] public void GlobalCode_DoStatement_01() { string source = @" do {} while ((1 is int x1)); H.Dummy(x1); object x2; do {} while ((2 is int x2)); do {} while ((3 is int x3)); object x3; do {} while (H.Dummy((41 is int x4), (42 is int x4))); do { H.Dummy(""52"" is string x5); H.Dummy(x5); } while ((51 is int x5)); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,24): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((2 is int x2)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 24), // (8,24): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((3 is int x3)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 24), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_DoStatement_02() { string source = @" do {} while ((1 is var x1)); H.Dummy(x1); object x2; do {} while ((2 is var x2)); do {} while ((3 is var x3)); object x3; do {} while (H.Dummy((41 is var x4), (42 is var x4))); do { H.Dummy(""52"" is var x5); H.Dummy(x5); } while ((51 is var x5)); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(3, 9), // (6,24): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((2 is var x2)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(6, 24), // (8,24): error CS0136: A local or parameter named 'x3' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // do {} while ((3 is var x3)); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x3").WithArguments("x3").WithLocation(8, 24), // (12,33): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 33), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (20,9): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 9), // (24,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(24, 13), // (24,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(24, 25), // (24,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(24, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1]); VerifyNotInScope(model, x5Ref[1]); VerifyNotInScope(model, x5Ref[2]); } } [Fact] public void GlobalCode_DoStatement_03() { string source = @" int f = 1; do { } while ((f++ is var x1) && Test(x1) < 3); int Test(int x) { System.Console.WriteLine(x); return x; } class H { public static bool Dummy(params object[] x) {return false;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 2 3").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Decl.Length); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[0], x1Ref); } [Fact] public void GlobalCode_LockStatement_01() { string source = @" lock (H.Dummy(1 is int x1)) {} H.Dummy(x1); object x2; lock (H.Dummy(2 is int x2)) {} lock (H.Dummy(3 is int x3)) {} object x3; lock (H.Dummy((41 is int x4), (42 is int x4))) {} lock (H.Dummy(51 is int x5)) { H.Dummy(""52"" is string x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static object Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // lock (H.Dummy(2 is int x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // lock (H.Dummy(2 is int x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26), // (16,28): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is string x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 28), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_LockStatement_02() { string source = @" lock (H.Dummy(1 is var x1)) {} H.Dummy(x1); object x2; lock (H.Dummy(2 is var x2)) {} lock (H.Dummy(3 is var x3)) {} object x3; lock (H.Dummy((41 is var x4), (42 is var x4))) {} lock (H.Dummy(51 is var x5)) { H.Dummy(""52"" is var x5); H.Dummy(x5); } H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static object Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,24): error CS0102: The type 'Script' already contains a definition for 'x2' // lock (H.Dummy(2 is var x2)) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 24), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,26): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 26), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,24): error CS0128: A local variable or function named 'x2' is already defined in this scope // lock (H.Dummy(2 is var x2)) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 24), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,26): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4))) {} Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 26), // (16,25): error CS0136: A local or parameter named 'x5' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy("52" is var x5); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x5").WithArguments("x5").WithLocation(16, 25), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Decl.Length); Assert.Equal(3, x5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref[1], x5Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[1], x5Ref[0]); } } [Fact] public void GlobalCode_LockStatement_03() { string source = @" System.Console.WriteLine(x1); lock (H.Dummy(1 is var x1)) { H.Dummy(""11"" is var x1); System.Console.WriteLine(x1); } Test(); void Test() { System.Console.WriteLine(x1); } class H { public static object Dummy(params object[] x) {return new object();} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact] public void GlobalCode_LockStatement_04() { string source = @" System.Console.WriteLine(x1); lock (H.Dummy(1 is var x1)) H.Dummy((""11"" is var x1), x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(object x, object y) { System.Console.WriteLine(y); } public static object Dummy(object x) { return x; } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 11 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").ToArray(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Decl.Length); Assert.Equal(3, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl[0], x1Ref[0], x1Ref[2]); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl[1], x1Ref[1]); } [Fact, WorkItem(13716, "https://github.com/dotnet/roslyn/issues/13716")] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_DeconstructionDeclarationStatement_01() { string source = @" (bool a, int b) = ((1 is int x1), 1); H.Dummy(x1); object x2; (bool c, int d) = ((2 is int x2), 2); (bool e, int f) = ((3 is int x3), 3); object x3; (bool g, bool h) = ((41 is int x4), (42 is int x4)); (bool x5, bool x6) = ((5 is int x5), (6 is int x6)); void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,30): error CS0102: The type 'Script' already contains a definition for 'x2' // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 30), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,32): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 32), // (14,33): error CS0102: The type 'Script' already contains a definition for 'x5' // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(14, 33), // (15,33): error CS0102: The type 'Script' already contains a definition for 'x6' // (6 is int x6)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(15, 33), // (19,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(19, 17), // (19,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(19, 21), // (19,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(19, 25), // (19,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(19, 29), // (19,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(19, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,30): error CS0128: A local variable or function named 'x2' is already defined in this scope // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 30), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (12,32): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 32), // (14,33): error CS0128: A local variable or function named 'x5' is already defined in this scope // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(14, 33), // (15,33): error CS0128: A local variable or function named 'x6' is already defined in this scope // (6 is int x6)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(15, 33), // (22,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(22, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x6Decl); VerifyNotAPatternLocal(model, x6Ref); } } [Fact] public void GlobalCode_LabeledStatement_01() { string source = @" a: H.Dummy(1 is int x1); H.Dummy(x1); object x2; b: H.Dummy(2 is int x2); c: H.Dummy(3 is int x3); object x3; d: H.Dummy((41 is int x4), (42 is int x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,21): error CS0102: The type 'Script' already contains a definition for 'x2' // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 21), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,23): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 23), // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is int x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is int x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is int x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is int x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (6,21): error CS0128: A local variable or function named 'x2' is already defined in this scope // b: H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 21), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is int x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is int x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (12,23): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 23), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_LabeledStatement_02() { string source = @" a: H.Dummy(1 is var x1); H.Dummy(x1); object x2; b: H.Dummy(2 is var x2); c: H.Dummy(3 is var x3); object x3; d: H.Dummy((41 is var x4), (42 is var x4)); void Test() { H.Dummy(x1, x2, x3, x4); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,21): error CS0102: The type 'Script' already contains a definition for 'x2' // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 21), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,23): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 23), // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is var x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is var x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (16,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(16, 17), // (16,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(16, 21), // (16,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(16, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: H.Dummy(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(6, 1), // (6,21): error CS0128: A local variable or function named 'x2' is already defined in this scope // b: H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 21), // (8,1): warning CS0164: This label has not been referenced // c: H.Dummy(3 is var x3); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(8, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (11,1): warning CS0164: This label has not been referenced // d: H.Dummy((41 is var x4), Diagnostic(ErrorCode.WRN_UnreferencedLabel, "d").WithLocation(11, 1), // (12,23): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 23), // (19,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(19, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); } } [Fact] public void GlobalCode_LabeledStatement_03() { string source = @" System.Console.WriteLine(x1); a:b:c:H.Dummy(1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics( // (3,1): warning CS0164: This label has not been referenced // a:b:c:(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(3, 1), // (3,3): warning CS0164: This label has not been referenced // a:b:c:(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(3, 3), // (3,5): warning CS0164: This label has not been referenced // a:b:c:(1 is var x1); Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(3, 5) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_LabeledStatement_04() { string source = @" a: bool b = (1 is int x1); H.Dummy(x1); object x2; c: bool d = (2 is int x2); e: bool f = (3 is int x3); object x3; g: bool h = H.Dummy((41 is int x4), (42 is int x4)); i: bool x5 = (5 is int x5); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (15,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // bool x5 = (5 is int x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(15, 21), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); VerifyNotAPatternLocal(model, x5Ref[1]); } } [Fact] public void GlobalCode_LabeledStatement_05() { string source = @" a: bool b = (1 is var x1); H.Dummy(x1); object x2; c: bool d = (2 is var x2); e: bool f = (3 is var x3); object x3; g: bool h = H.Dummy((41 is var x4), (42 is var x4)); i: bool x5 = (5 is var x5); H.Dummy(x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationField(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // a: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(2, 1), // (6,1): warning CS0164: This label has not been referenced // c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(6, 1), // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (8,1): warning CS0164: This label has not been referenced // e: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "e").WithLocation(8, 1), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (11,1): warning CS0164: This label has not been referenced // g: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "g").WithLocation(11, 1), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (14,1): warning CS0164: This label has not been referenced // i: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "i").WithLocation(14, 1), // (15,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // bool x5 = (5 is var x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(15, 21), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(2, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); VerifyNotAPatternLocal(model, x5Ref[1]); } } [ConditionalFact(typeof(IsRelease), Reason = "https://github.com/dotnet/roslyn/issues/25702")] public void GlobalCode_LabeledStatement_06() { string source = @" System.Console.WriteLine(x1); a:b:c: var d = (1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics( // (3,1): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(3, 1), // (3,3): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(3, 3), // (3,5): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(3, 5) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_LabeledStatement_07() { string source = @"l1: (bool a, int b) = ((1 is int x1), 1); H.Dummy(x1); object x2; l2: (bool c, int d) = ((2 is int x2), 2); l3: (bool e, int f) = ((3 is int x3), 3); object x3; l4: (bool g, bool h) = ((41 is int x4), (42 is int x4)); l5: (bool x5, bool x6) = ((5 is int x5), (6 is int x6)); void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,30): error CS0102: The type 'Script' already contains a definition for 'x2' // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 30), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,32): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 32), // (14,33): error CS0102: The type 'Script' already contains a definition for 'x5' // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(14, 33), // (15,33): error CS0102: The type 'Script' already contains a definition for 'x6' // (6 is int x6)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(15, 33), // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (19,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(19, 17), // (19,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(19, 21), // (19,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(19, 25), // (19,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(19, 29), // (19,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(19, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (6,30): error CS0128: A local variable or function named 'x2' is already defined in this scope // (bool c, int d) = ((2 is int x2), 2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 30), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (12,32): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 32), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (14,33): error CS0128: A local variable or function named 'x5' is already defined in this scope // (bool x5, bool x6) = ((5 is int x5), Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(14, 33), // (15,33): error CS0128: A local variable or function named 'x6' is already defined in this scope // (6 is int x6)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(15, 33), // (22,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(22, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x6Decl); VerifyNotAPatternLocal(model, x6Ref[0]); } } [Fact] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_LabeledStatement_08() { string source = @"l1: (bool a, int b) = ((1 is var x1), 1); H.Dummy(x1); object x2; l2: (bool c, int d) = ((2 is var x2), 2); l3: (bool e, int f) = ((3 is var x3), 3); object x3; l4: (bool g, bool h) = ((41 is var x4), (42 is var x4)); l5: (bool x5, bool x6) = ((5 is var x5), (6 is var x6)); void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,30): error CS0102: The type 'Script' already contains a definition for 'x2' // (bool c, int d) = ((2 is var x2), 2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(6, 30), // (9,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(9, 8), // (12,32): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(12, 32), // (14,33): error CS0102: The type 'Script' already contains a definition for 'x5' // (bool x5, bool x6) = ((5 is var x5), Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(14, 33), // (15,33): error CS0102: The type 'Script' already contains a definition for 'x6' // (6 is var x6)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(15, 33), // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (19,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(19, 17), // (19,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(19, 21), // (19,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(19, 25), // (19,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(19, 29), // (19,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(19, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (1,1): warning CS0164: This label has not been referenced // l1: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l1").WithLocation(1, 1), // (5,1): warning CS0164: This label has not been referenced // l2: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l2").WithLocation(5, 1), // (6,30): error CS0128: A local variable or function named 'x2' is already defined in this scope // (bool c, int d) = ((2 is var x2), 2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(6, 30), // (7,1): warning CS0164: This label has not been referenced // l3: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l3").WithLocation(7, 1), // (9,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(9, 8), // (9,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(9, 8), // (10,1): warning CS0164: This label has not been referenced // l4: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l4").WithLocation(10, 1), // (12,32): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(12, 32), // (13,1): warning CS0164: This label has not been referenced // l5: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "l5").WithLocation(13, 1), // (14,33): error CS0128: A local variable or function named 'x5' is already defined in this scope // (bool x5, bool x6) = ((5 is var x5), Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(14, 33), // (15,33): error CS0128: A local variable or function named 'x6' is already defined in this scope // (6 is var x6)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(15, 33), // (22,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(22, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").ToArray(); Assert.Equal(1, x5Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref[0]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(1, x6Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x6Decl); VerifyNotAPatternLocal(model, x6Ref[0]); } } [Fact] [CompilerTrait(CompilerFeature.Tuples)] public void GlobalCode_LabeledStatement_09() { string source = @" System.Console.WriteLine(x1); a:b:c: var (d, e) = ((1 is var x1), 1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.DebugExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics( // (3,1): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "a").WithLocation(3, 1), // (3,3): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "b").WithLocation(3, 3), // (3,5): warning CS0164: This label has not been referenced // a:b:c: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "c").WithLocation(3, 5) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_01() { string source = @" bool b = (1 is int x1); H.Dummy(x1); object x2; bool d = (2 is int x2); bool f = (3 is int x3); object x3; bool h = H.Dummy((41 is int x4), (42 is int x4)); bool x5 = (5 is int x5); bool i = (5 is int x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is int x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is int x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (16,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // (5 is int x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(16, 21), // (19,10): error CS0128: A local variable or function named 'x6' is already defined in this scope // x6; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(19, 10), // (19,10): warning CS0168: The variable 'x6' is declared but never used // x6; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x6").WithArguments("x6").WithLocation(19, 10), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); } } [Fact] public void GlobalCode_FieldDeclaration_02() { string source = @" bool b = (1 is var x1); H.Dummy(x1); object x2; bool d = (2 is var x2); bool f = (3 is var x3); object x3; bool h = H.Dummy((41 is var x4), (42 is var x4)); bool x5 = (5 is var x5); bool i = (5 is var x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,20): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 20), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,29): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 29), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is var x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (7,20): error CS0128: A local variable or function named 'x2' is already defined in this scope // bool d = (2 is var x2); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x2").WithArguments("x2").WithLocation(7, 20), // (10,8): error CS0128: A local variable or function named 'x3' is already defined in this scope // object x3; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x3").WithArguments("x3").WithLocation(10, 8), // (10,8): warning CS0168: The variable 'x3' is declared but never used // object x3; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x3").WithArguments("x3").WithLocation(10, 8), // (13,29): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 29), // (16,21): error CS0128: A local variable or function named 'x5' is already defined in this scope // (5 is var x5); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(16, 21), // (19,10): error CS0128: A local variable or function named 'x6' is already defined in this scope // x6; Diagnostic(ErrorCode.ERR_LocalDuplicate, "x6").WithArguments("x6").WithLocation(19, 10), // (19,10): warning CS0168: The variable 'x6' is declared but never used // x6; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x6").WithArguments("x6").WithLocation(19, 10), // (26,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(26, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0], x4Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl); VerifyNotAPatternLocal(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); } } [Fact] public void GlobalCode_FieldDeclaration_03() { string source = @" System.Console.WriteLine(x1); var d = (1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_04() { string source = @" static var a = InitA(); System.Console.WriteLine(x1); static var b = (1 is var x1); Test(); static var c = InitB(); void Test() { System.Console.WriteLine(x1); } static object InitA() { System.Console.WriteLine(""InitA {0}"", x1); return null; } static object InitB() { System.Console.WriteLine(""InitB {0}"", x1); return null; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"InitA 0 InitB 1 1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(4, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_05() { string source = @" bool b = (1 is var x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_06() { string source = @" bool b = (1 is int x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_FieldDeclaration_07() { string source = @" Test(); bool a = (1 is var x1), b = Test(), c = (2 is var x2); Test(); bool Test() { System.Console.WriteLine(""{0} {1}"", x1, x2); return false; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 0 1 0 1 2").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationField(model, x2Decl, x2Ref); } [Fact] public void GlobalCode_PropertyDeclaration_01() { string source = @" bool b { get; } = (1 is int x1); H.Dummy(x1); object x2; bool d { get; } = (2 is int x2); bool f { get; } = (3 is int x3); object x3; bool h { get; } = H.Dummy((41 is int x4), (42 is int x4)); bool x5 { get; } = (5 is int x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,29): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d { get; } = (2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 29), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,38): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 38), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is int x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25), // (20,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(20, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool b { get; } = (1 is int x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 6), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool d { get; } = (2 is int x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 6), // (9,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool f { get; } = (3 is int x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 6), // (12,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool h { get; } = H.Dummy((41 is int x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 6), // (13,38): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 38), // (15,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool x5 { get; } = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 6), // (20,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(20, 13), // (20,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(20, 25), // (20,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 29), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1), // (23,1): error CS0165: Use of unassigned local variable 'x3' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x3").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); } } [Fact] public void GlobalCode_PropertyDeclaration_02() { string source = @" bool b { get; } = (1 is var x1); H.Dummy(x1); object x2; bool d { get; } = (2 is var x2); bool f { get; } = (3 is var x3); object x3; bool h { get; } = H.Dummy((41 is var x4), (42 is var x4)); bool x5 { get; } = (5 is var x5); void Test() { H.Dummy(x1, x2, x3, x4, x5); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,29): error CS0102: The type 'Script' already contains a definition for 'x2' // bool d { get; } = (2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 29), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,38): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 38), // (16,21): error CS0102: The type 'Script' already contains a definition for 'x5' // (5 is var x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 21), // (20,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(20, 17), // (20,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(20, 21), // (20,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(20, 25), // (20,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(20, 29) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool b { get; } = (1 is var x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 6), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool d { get; } = (2 is var x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 6), // (9,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool f { get; } = (3 is var x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 6), // (12,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool h { get; } = H.Dummy((41 is var x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 6), // (13,38): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 38), // (15,6): error CS0116: A namespace cannot directly contain members such as fields or methods // bool x5 { get; } = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 6), // (20,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(20, 13), // (20,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(20, 25), // (20,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(20, 29), // (23,1): error CS0165: Use of unassigned local variable 'x2' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x2").WithLocation(23, 1), // (23,1): error CS0165: Use of unassigned local variable 'x3' // Test(); Diagnostic(ErrorCode.ERR_UseDefViolation, "Test()").WithArguments("x3").WithLocation(23, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); } } [Fact] public void GlobalCode_PropertyDeclaration_03() { string source = @" System.Console.WriteLine(x1); bool d { get; set; } = (1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_PropertyDeclaration_04() { string source = @" static var a = InitA(); System.Console.WriteLine(x1); static bool b { get; } = (1 is var x1); Test(); static var c = InitB(); void Test() { System.Console.WriteLine(x1); } static object InitA() { System.Console.WriteLine(""InitA {0}"", x1); return null; } static object InitB() { System.Console.WriteLine(""InitB {0}"", x1); return null; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"InitA 0 InitB 1 1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(4, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_PropertyDeclaration_05() { string source = @" bool b { get; } = (1 is var x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_PropertyDeclaration_06() { string source = @" bool b { get; } = (1 is int x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_01() { string source = @" event System.Action b = H.Dummy(1 is int x1); H.Dummy(x1); object x2; event System.Action d = H.Dummy(2 is int x2); event System.Action f = H.Dummy(3 is int x3); object x3; event System.Action h = H.Dummy((41 is int x4), (42 is int x4)); event System.Action x5 = H.Dummy(5 is int x5); event System.Action i = H.Dummy(5 is int x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,42): error CS0102: The type 'Script' already contains a definition for 'x2' // event System.Action d = H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 42), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,36): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is int x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 36), // (16,28): error CS0102: The type 'Script' already contains a definition for 'x5' // H.Dummy(5 is int x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 28), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action b = H.Dummy(1 is int x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 21), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action d = H.Dummy(2 is int x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 21), // (9,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action f = H.Dummy(3 is int x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 21), // (12,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action h = H.Dummy((41 is int x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 21), // (13,36): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is int x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 36), // (15,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action x5 = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 21), // (18,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action i = H.Dummy(5 is int x6), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "i").WithLocation(18, 21), // (21,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(21, 6), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29), // (23,33): error CS0103: The name 'x6' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x6").WithArguments("x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl); VerifyNotInScope(model, x6Ref); } } [Fact] public void GlobalCode_EventDeclaration_02() { string source = @" event System.Action b = H.Dummy(1 is var x1); H.Dummy(x1); object x2; event System.Action d = H.Dummy(2 is var x2); event System.Action f = H.Dummy(3 is var x3); object x3; event System.Action h = H.Dummy((41 is var x4), (42 is var x4)); event System.Action x5 = H.Dummy(5 is var x5); event System.Action i = H.Dummy(5 is var x6), x6; void Test() { H.Dummy(x1, x2, x3, x4, x5, x6); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (7,42): error CS0102: The type 'Script' already contains a definition for 'x2' // event System.Action d = H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x2").WithArguments("Script", "x2").WithLocation(7, 42), // (10,8): error CS0102: The type 'Script' already contains a definition for 'x3' // object x3; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x3").WithArguments("Script", "x3").WithLocation(10, 8), // (13,36): error CS0102: The type 'Script' already contains a definition for 'x4' // (42 is var x4)); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x4").WithArguments("Script", "x4").WithLocation(13, 36), // (16,28): error CS0102: The type 'Script' already contains a definition for 'x5' // H.Dummy(5 is var x5); Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x5").WithArguments("Script", "x5").WithLocation(16, 28), // (19,10): error CS0102: The type 'Script' already contains a definition for 'x6' // x6; Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "x6").WithArguments("Script", "x6").WithLocation(19, 10), // (23,17): error CS0229: Ambiguity between 'x2' and 'x2' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x2").WithArguments("x2", "x2").WithLocation(23, 17), // (23,21): error CS0229: Ambiguity between 'x3' and 'x3' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x3").WithArguments("x3", "x3").WithLocation(23, 21), // (23,25): error CS0229: Ambiguity between 'x4' and 'x4' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x4").WithArguments("x4", "x4").WithLocation(23, 25), // (23,29): error CS0229: Ambiguity between 'x5' and 'x5' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x5").WithArguments("x5", "x5").WithLocation(23, 29), // (23,33): error CS0229: Ambiguity between 'x6' and 'x6' // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_AmbigMember, "x6").WithArguments("x6", "x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationFieldDuplicate(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationFieldDuplicate(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[0], x4Ref); VerifyModelForDeclarationFieldDuplicate(model, x4Decl[1], x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationFieldDuplicate(model, x5Decl, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationFieldDuplicate(model, x6Decl, x6Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action b = H.Dummy(1 is var x1); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "b").WithLocation(3, 21), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (7,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action d = H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "d").WithLocation(7, 21), // (9,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action f = H.Dummy(3 is var x3); Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "f").WithLocation(9, 21), // (12,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action h = H.Dummy((41 is var x4), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "h").WithLocation(12, 21), // (13,36): error CS0128: A local variable or function named 'x4' is already defined in this scope // (42 is var x4)); Diagnostic(ErrorCode.ERR_LocalDuplicate, "x4").WithArguments("x4").WithLocation(13, 36), // (15,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action x5 = Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "x5").WithLocation(15, 21), // (18,21): error CS0116: A namespace cannot directly contain members such as fields or methods // event System.Action i = H.Dummy(5 is var x6), Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "i").WithLocation(18, 21), // (21,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(21, 6), // (23,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(23, 13), // (23,25): error CS0103: The name 'x4' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x4").WithArguments("x4").WithLocation(23, 25), // (23,29): error CS0103: The name 'x5' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x5").WithArguments("x5").WithLocation(23, 29), // (23,33): error CS0103: The name 'x6' does not exist in the current context // H.Dummy(x1, x2, x3, x4, x5, x6); Diagnostic(ErrorCode.ERR_NameNotInContext, "x6").WithArguments("x6").WithLocation(23, 33) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl); VerifyNotAPatternLocal(model, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotAPatternLocal(model, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").ToArray(); var x4Ref = GetReferences(tree, "x4").Single(); Assert.Equal(2, x4Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl[0]); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x4Decl[1]); VerifyNotInScope(model, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").Single(); var x5Ref = GetReferences(tree, "x5").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl); VerifyNotInScope(model, x5Ref); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl); VerifyNotInScope(model, x6Ref); } } [Fact] public void GlobalCode_EventDeclaration_03() { string source = @" System.Console.WriteLine(x1); event System.Action d = H.Dummy(1 is var x1); Test(); void Test() { System.Console.WriteLine(x1); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_04() { string source = @" static var a = InitA(); System.Console.WriteLine(x1); static event System.Action b = H.Dummy(1 is var x1); Test(); static var c = InitB(); void Test() { System.Console.WriteLine(x1); } static object InitA() { System.Console.WriteLine(""InitA {0}"", x1); return null; } static object InitB() { System.Console.WriteLine(""InitB {0}"", x1); return null; } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"InitA 0 InitB 1 1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(4, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_05() { string source = @" event System.Action b = H.Dummy(1 is var x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_06() { string source = @" event System.Action b = H.Dummy(1 is int x1); static var d = x1; static void Test() { H.Dummy(x1); } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,16): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // static var d = x1; Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(4, 16), // (8,13): error CS0120: An object reference is required for the non-static field, method, or property 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_ObjectRequired, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_EventDeclaration_07() { string source = @" Test(); event System.Action a = H.Dummy(1 is var x1), b = Test(), c = H.Dummy(2 is var x2); Test(); System.Action Test() { System.Console.WriteLine(""{0} {1}"", x1, x2); return null; } class H { public static System.Action Dummy(params object[] x) {return null;} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"0 0 1 0 1 2").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationField(model, x2Decl, x2Ref); } [Fact] public void GlobalCode_DeclaratorArguments_01() { string source = @" bool a, b(""5948"" is var x1); H.Dummy(x1); void Test() { H.Dummy(x1); } class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_BadVarDecl, @"(""5948"" is var x1").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,27): error CS1003: Syntax error, ']' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 27) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,6): warning CS0168: The variable 'a' is declared but never used // bool a, b("5948" is var x1); Diagnostic(ErrorCode.WRN_UnreferencedVar, "a").WithArguments("a").WithLocation(3, 6), // (3,9): warning CS0168: The variable 'b' is declared but never used // bool a, b("5948" is var x1); Diagnostic(ErrorCode.WRN_UnreferencedVar, "b").WithArguments("b").WithLocation(3, 9), // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_BadVarDecl, @"(""5948"" is var x1").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,27): error CS1003: Syntax error, ']' expected // bool a, b("5948" is var x1); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 27), // (4,9): error CS0165: Use of unassigned local variable 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_UseDefViolation, "x1").WithArguments("x1").WithLocation(4, 9), // (6,6): warning CS8321: The local function 'Test' is declared but never used // void Test() Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "Test").WithArguments("Test").WithLocation(6, 6) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); VerifyModelForDeclarationOrVarSimplePatternWithoutDataFlow(model, x1Decl, x1Ref); } } [Fact] public void GlobalCode_DeclaratorArguments_02() { string source = @" label: bool a, b((1 is var x1)); H.Dummy(x1); void Test() { H.Dummy(x1); } Test(); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "((1 is var x1)").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,24): error CS1003: Syntax error, ']' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 24), // (2,1): warning CS0164: This label has not been referenced // label: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "label").WithLocation(2, 1) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (2,1): warning CS0164: This label has not been referenced // label: Diagnostic(ErrorCode.WRN_UnreferencedLabel, "label").WithLocation(2, 1), // (3,6): warning CS0168: The variable 'a' is declared but never used // bool a, b((1 is var x1)); Diagnostic(ErrorCode.WRN_UnreferencedVar, "a").WithArguments("a").WithLocation(3, 6), // (3,9): warning CS0168: The variable 'b' is declared but never used // bool a, b((1 is var x1)); Diagnostic(ErrorCode.WRN_UnreferencedVar, "b").WithArguments("b").WithLocation(3, 9), // (3,10): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "((1 is var x1)").WithLocation(3, 10), // (3,10): error CS1003: Syntax error, '[' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 10), // (3,24): error CS1003: Syntax error, ']' expected // bool a, b((1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 24), // (4,9): error CS0165: Use of unassigned local variable 'x1' // H.Dummy(x1); Diagnostic(ErrorCode.ERR_UseDefViolation, "x1").WithArguments("x1").WithLocation(4, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } } [Fact] public void GlobalCode_DeclaratorArguments_03() { string source = @" event System.Action a, b(H.Dummy(1 is var x1)); H.Dummy(x1); void Test() { H.Dummy(x1); } Test(); class H { public static bool Dummy(params object[] x) {return false;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,25): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "(H.Dummy(1 is var x1)").WithLocation(3, 25), // (3,25): error CS1003: Syntax error, '[' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 25), // (3,46): error CS1003: Syntax error, ']' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 46) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,25): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_BadVarDecl, "(H.Dummy(1 is var x1)").WithLocation(3, 25), // (3,25): error CS1003: Syntax error, '[' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, "(").WithArguments("[", "(").WithLocation(3, 25), // (3,46): error CS1003: Syntax error, ']' expected // event System.Action a, b(H.Dummy(1 is var x1)); Diagnostic(ErrorCode.ERR_SyntaxError, ")").WithArguments("]", ")").WithLocation(3, 46), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (8,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationOrVarSimplePatternWithoutDataFlow(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); } } [Fact] public void GlobalCode_DeclaratorArguments_04() { string source = @" fixed bool a[2], b[H.Dummy(1 is var x1)]; H.Dummy(x1); void Test() { H.Dummy(x1); } Test(); class H { public static int Dummy(params object[] x) {return 0;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (3,18): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "b").WithLocation(3, 18), // (3,20): error CS0133: The expression being assigned to 'b' must be constant // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_NotConstantExpression, "H.Dummy(1 is var x1)").WithArguments("b").WithLocation(3, 20), // (3,12): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "a").WithLocation(3, 12), // (3,12): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_UnsafeNeeded, "a[2]").WithLocation(3, 12) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 // VerifyModelForDeclarationField(model, x1Decl, x1Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (3,12): error CS0116: A namespace cannot directly contain members such as fields or methods // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_NamespaceUnexpected, "a").WithLocation(3, 12), // (3,18): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "b").WithLocation(3, 18), // (3,12): error CS1642: Fixed size buffer fields may only be members of structs // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_FixedNotInStruct, "a").WithLocation(3, 12), // (3,12): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_UnsafeNeeded, "a[2]").WithLocation(3, 12), // (3,20): error CS0133: The expression being assigned to '<invalid-global-code>.b' must be constant // fixed bool a[2], b[H.Dummy(1 is var x1)]; Diagnostic(ErrorCode.ERR_NotConstantExpression, "H.Dummy(1 is var x1)").WithArguments("<invalid-global-code>.b").WithLocation(3, 20), // (4,9): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(4, 9), // (8,13): error CS0103: The name 'x1' does not exist in the current context // H.Dummy(x1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x1").WithArguments("x1").WithLocation(8, 13) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); AssertContainedInDeclaratorArguments(x1Decl); // the following would fail due to https://github.com/dotnet/roslyn/issues/13569 //VerifyModelForDeclarationOrVarSimplePatternWithoutDataFlow(model, x1Decl); VerifyNotInScope(model, x1Ref[0]); VerifyNotInScope(model, x1Ref[1]); } } [Fact] public void GlobalCode_RestrictedType_01() { string source = @" H.Dummy(null is System.ArgIterator x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.GetDeclarationDiagnostics().Verify( // (3,17): error CS0610: Field or property cannot be of type 'ArgIterator' // H.Dummy(null is System.ArgIterator x1); Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "System.ArgIterator").WithArguments("System.ArgIterator").WithLocation(3, 17) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl); } [Fact] public void GlobalCode_StaticType_01() { string source = @" H.Dummy(null is StaticType x1); class H { public static void Dummy(params object[] x) {} } static class StaticType{} "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.GetDeclarationDiagnostics().Verify( // (2,28): error CS0723: Cannot declare a variable of static type 'StaticType' // H.Dummy(null is StaticType x1); Diagnostic(ErrorCode.ERR_VarDeclIsStaticClass, "x1").WithArguments("StaticType").WithLocation(2, 28) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); VerifyModelForDeclarationField(model, x1Decl); } [Fact] public void GlobalCode_AliasInfo_01() { string source = @" H.Dummy(1 is var x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); Assert.True(x1Decl.Parent is VarPatternSyntax); } [Fact] public void GlobalCode_AliasInfo_02() { string source = @" using var = System.Int32; H.Dummy(1 is var x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (4,14): error CS8508: The syntax 'var' for a pattern is not permitted to refer to a type, but 'var' is in scope here. // H.Dummy(1 is var x1); Diagnostic(ErrorCode.ERR_VarMayNotBindToType, "var").WithArguments("var").WithLocation(4, 14) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); Assert.True(x1Decl.Parent is VarPatternSyntax); } [Fact] public void GlobalCode_AliasInfo_03() { string source = @" using a = System.Int32; H.Dummy(1 is a x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1 = (DeclarationPatternSyntax)x1Decl.Parent; Assert.Equal("a=System.Int32", model.GetAliasInfo(x1.Type).ToTestDisplayString()); } [Fact] public void GlobalCode_AliasInfo_04() { string source = @" H.Dummy(1 is int x1); class H { public static void Dummy(params object[] x) {} } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1 = (DeclarationPatternSyntax)x1Decl.Parent; Assert.Null(model.GetAliasInfo(x1.Type)); } [Fact] public void GlobalCode_Catch_01() { var source = @" bool Dummy(params object[] x) {return true;} try {} catch when (123 is var x1 && x1 > 0) { Dummy(x1); } var x4 = 11; Dummy(x4); try {} catch when (123 is var x4 && x4 > 0) { Dummy(x4); } try {} catch when (x6 && 123 is var x6) { Dummy(x6); } try {} catch when (123 is var x7 && x7 > 0) { var x7 = 12; Dummy(x7); } try {} catch when (123 is var x8 && x8 > 0) { Dummy(x8); } System.Console.WriteLine(x8); try {} catch when (123 is var x9 && x9 > 0) { Dummy(x9); try {} catch when (123 is var x9 && x9 > 0) // 2 { Dummy(x9); } } try {} catch when (y10 is var x10) { var y10 = 12; Dummy(y10); } // try {} // catch when (y11 is var x11) // { // let y11 = 12; // Dummy(y11); // } try {} catch when (Dummy(123 is var x14, 123 is var x14, // 2 x14)) { Dummy(x14); } try {} catch (System.Exception x15) when (Dummy(123 is var x15, x15)) { Dummy(x15); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (20,13): error CS0841: Cannot use local variable 'x6' before it is declared // catch when (x6 && 123 is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(20, 13), // (28,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(28, 9), // (38,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(38, 26), // (45,28): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // catch when (123 is var x9 && x9 > 0) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(45, 28), // (52,13): error CS0103: The name 'y10' does not exist in the current context // catch when (y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(52, 13), // (67,32): error CS0128: A local variable or function named 'x14' is already defined in this scope // 123 is var x14, // 2 Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(67, 32), // (75,32): error CS0128: A local variable or function named 'x15' is already defined in this scope // when (Dummy(123 is var x15, x15)) Diagnostic(ErrorCode.ERR_LocalDuplicate, "x15").WithArguments("x15").WithLocation(75, 32) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclaration(tree, "x1"); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x4Decl = GetPatternDeclaration(tree, "x4"); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclaration(tree, "x6"); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclaration(tree, "x7"); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclaration(tree, "x8"); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclaration(tree, "x15"); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x15Decl); VerifyNotAPatternLocal(model, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (14,24): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // catch when (123 is var x4 && x4 > 0) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(14, 24), // (20,13): error CS0841: Cannot use local variable 'x6' before it is declared // catch when (x6 && 123 is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(20, 13), // (28,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(28, 9), // (38,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(38, 26), // (45,28): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // catch when (123 is var x9 && x9 > 0) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(45, 28), // (52,13): error CS0103: The name 'y10' does not exist in the current context // catch when (y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(52, 13), // (67,32): error CS0128: A local variable or function named 'x14' is already defined in this scope // 123 is var x14, // 2 Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(67, 32), // (75,32): error CS0128: A local variable or function named 'x15' is already defined in this scope // when (Dummy(123 is var x15, x15)) Diagnostic(ErrorCode.ERR_LocalDuplicate, "x15").WithArguments("x15").WithLocation(75, 32) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclaration(tree, "x1"); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x4Decl = GetPatternDeclaration(tree, "x4"); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclaration(tree, "x6"); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclaration(tree, "x7"); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclaration(tree, "x8"); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclaration(tree, "x15"); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x15Decl); VerifyNotAPatternLocal(model, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } } [Fact] public void GlobalCode_Catch_02() { var source = @" try { throw new System.InvalidOperationException(); } catch (System.Exception e) when (Dummy(e is var x1, x1)) { System.Console.WriteLine(x1.GetType()); } static bool Dummy(object y, object z) { System.Console.WriteLine(z.GetType()); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"System.InvalidOperationException System.InvalidOperationException"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Block_01() { string source = @" { H.Dummy(1 is var x1); H.Dummy(x1); } object x2; { H.Dummy(2 is var x2); H.Dummy(x2); } { H.Dummy(3 is var x3); } H.Dummy(x3); class H { public static bool Dummy(params object[] x) {return true;} } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (15,9): error CS0103: The name 'x3' does not exist in the current context // H.Dummy(x3); Diagnostic(ErrorCode.ERR_NameNotInContext, "x3").WithArguments("x3").WithLocation(15, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotInScope(model, x3Ref); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (7,8): warning CS0168: The variable 'x2' is declared but never used // object x2; Diagnostic(ErrorCode.WRN_UnreferencedVar, "x2").WithArguments("x2").WithLocation(7, 8), // (9,22): error CS0136: A local or parameter named 'x2' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // H.Dummy(2 is var x2); Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x2").WithArguments("x2").WithLocation(9, 22), // (15,9): error CS0103: The name 'x3' does not exist in the current context // H.Dummy(x3); Diagnostic(ErrorCode.ERR_NameNotInContext, "x3").WithArguments("x3").WithLocation(15, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(1, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl); VerifyNotInScope(model, x3Ref); } } [Fact] public void GlobalCode_Block_02() { string source = @" { var tmp = 1 is var x1; System.Console.WriteLine(x1); Test(); void Test() { System.Console.WriteLine(x1); } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 1").VerifyDiagnostics(); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_For_01() { var source = @" bool Dummy(params object[] x) {return true;} for ( Dummy(true is var x1 && x1) ;;) { Dummy(x1); } for ( // 2 Dummy(true is var x2 && x2) ;;) Dummy(x2); var x4 = 11; Dummy(x4); for ( Dummy(true is var x4 && x4) ;;) Dummy(x4); for ( Dummy(x6 && true is var x6) ;;) Dummy(x6); for ( Dummy(true is var x7 && x7) ;;) { var x7 = 12; Dummy(x7); } for ( Dummy(true is var x8 && x8) ;;) Dummy(x8); System.Console.WriteLine(x8); for ( Dummy(true is var x9 && x9) ;;) { Dummy(x9); for ( Dummy(true is var x9 && x9) // 2 ;;) Dummy(x9); } for ( Dummy(y10 is var x10) ;;) { var y10 = 12; Dummy(y10); } // for ( // Dummy(y11 is var x11) // ;;) // { // let y11 = 12; // Dummy(y11); // } for ( Dummy(y12 is var x12) ;;) var y12 = 12; // for ( // Dummy(y13 is var x13) // ;;) // let y13 = 12; for ( Dummy(1 is var x14, 2 is var x14, x14) ;;) { Dummy(x14); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (74,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(74, 5), // (25,15): error CS0841: Cannot use local variable 'x6' before it is declared // Dummy(x6 && true is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(25, 15), // (33,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(33, 9), // (42,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(42, 26), // (50,31): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // Dummy(true is var x9 && x9) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(50, 31), // (56,15): error CS0103: The name 'y10' does not exist in the current context // Dummy(y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(56, 15), // (72,15): error CS0103: The name 'y12' does not exist in the current context // Dummy(y12 is var x12) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(72, 15), // (83,22): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(83, 22), // (11,1): warning CS0162: Unreachable code detected // for ( // 2 Diagnostic(ErrorCode.WRN_UnreachableCode, "for").WithLocation(11, 1), // (74,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(74, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (20,27): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // Dummy(true is var x4 && x4) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(20, 27), // (74,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(74, 5), // (25,15): error CS0841: Cannot use local variable 'x6' before it is declared // Dummy(x6 && true is var x6) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(25, 15), // (33,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(33, 9), // (42,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(42, 26), // (50,31): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // Dummy(true is var x9 && x9) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(50, 31), // (56,15): error CS0103: The name 'y10' does not exist in the current context // Dummy(y10 is var x10) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(56, 15), // (72,15): error CS0103: The name 'y12' does not exist in the current context // Dummy(y12 is var x12) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(72, 15), // (83,22): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(83, 22), // (11,1): warning CS0162: Unreachable code detected // for ( // 2 Diagnostic(ErrorCode.WRN_UnreachableCode, "for").WithLocation(11, 1), // (74,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(74, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } } [Fact] public void GlobalCode_For_02() { var source = @" bool f = true; for (Dummy(f, ((f ? 10 : 20)) is var x0, x0); Dummy(f, ((f ? 1 : 2)) is var x1, x1); Dummy(f, ((f ? 100 : 200)) is var x2, x2), Dummy(true, null, x2)) { System.Console.WriteLine(x0); System.Console.WriteLine(x1); f = false; } static bool Dummy(bool x, object y, object z) { System.Console.WriteLine(z); return x; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"10 1 10 1 200 200 2"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x0Decl = GetPatternDeclarations(tree, "x0").Single(); var x0Ref = GetReferences(tree, "x0").ToArray(); Assert.Equal(2, x0Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x0Decl, x0Ref); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); } [Fact] public void GlobalCode_Foreach_01() { var source = @" System.Collections.IEnumerable Dummy(params object[] x) {return null;} foreach (var i in Dummy(true is var x1 && x1)) { Dummy(x1); } foreach (var i in Dummy(true is var x2 && x2)) Dummy(x2); var x4 = 11; Dummy(x4); foreach (var i in Dummy(true is var x4 && x4)) Dummy(x4); foreach (var i in Dummy(x6 && true is var x6)) Dummy(x6); foreach (var i in Dummy(true is var x7 && x7)) { var x7 = 12; Dummy(x7); } foreach (var i in Dummy(true is var x8 && x8)) Dummy(x8); System.Console.WriteLine(x8); foreach (var i1 in Dummy(true is var x9 && x9)) { Dummy(x9); foreach (var i2 in Dummy(true is var x9 && x9)) // 2 Dummy(x9); } foreach (var i in Dummy(y10 is var x10)) { var y10 = 12; Dummy(y10); } // foreach (var i in Dummy(y11 is var x11)) // { // let y11 = 12; // Dummy(y11); // } foreach (var i in Dummy(y12 is var x12)) var y12 = 12; // foreach (var i in Dummy(y13 is var x13)) // let y13 = 12; foreach (var i in Dummy(1 is var x14, 2 is var x14, x14)) { Dummy(x14); } foreach (var x15 in Dummy(1 is var x15, x15)) { Dummy(x15); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (18,25): error CS0841: Cannot use local variable 'x6' before it is declared // foreach (var i in Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 25), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,42): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var i2 in Dummy(true is var x9 && x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 42), // (39,25): error CS0103: The name 'y10' does not exist in the current context // foreach (var i in Dummy(y10 is var x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 25), // (51,25): error CS0103: The name 'y12' does not exist in the current context // foreach (var i in Dummy(y12 is var x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 25), // (58,34): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 34), // (64,14): error CS0136: A local or parameter named 'x15' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var x15 in Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x15").WithArguments("x15").WithLocation(64, 14), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclarations(tree, "x15").Single(); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x15Decl, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (15,37): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var i in Dummy(true is var x4 && x4)) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(15, 37), // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (18,25): error CS0841: Cannot use local variable 'x6' before it is declared // foreach (var i in Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 25), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,42): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var i2 in Dummy(true is var x9 && x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 42), // (39,25): error CS0103: The name 'y10' does not exist in the current context // foreach (var i in Dummy(y10 is var x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 25), // (51,25): error CS0103: The name 'y12' does not exist in the current context // foreach (var i in Dummy(y12 is var x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 25), // (58,34): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 34), // (64,14): error CS0136: A local or parameter named 'x15' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // foreach (var x15 in Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x15").WithArguments("x15").WithLocation(64, 14), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); var x15Decl = GetPatternDeclarations(tree, "x15").Single(); var x15Ref = GetReferences(tree, "x15").ToArray(); Assert.Equal(2, x15Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x15Decl, x15Ref[0]); VerifyNotAPatternLocal(model, x15Ref[1]); } } [Fact] public void GlobalCode_Foreach_02() { var source = @" bool f = true; foreach (var i in Dummy(3 is var x1, x1)) { System.Console.WriteLine(x1); } static System.Collections.IEnumerable Dummy(object y, object z) { System.Console.WriteLine(z); return ""a""; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"3 3"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Lambda_01() { var source = @" bool Dummy(params object[] x) {return true;} Dummy((System.Func<int, bool>) (o => o is var x3 && x3 > 0)); Dummy((System.Func<bool, bool>) (o => x4 && o is var x4)); Dummy((System.Func<int, int, bool>) ((o1, o2) => o1 is var x5 && o2 is var x5 && x5 > 0)); Dummy((System.Func<int, bool>) (o => o is var x6 && x6 > 0), (System.Func<int, bool>) (o => o is var x6 && x6 > 0)); Dummy(x7, 1); Dummy(x7, (System.Func<int, bool>) (o => o is var x7 && x7 > 0), x7); Dummy(x7, 2); Dummy(true is var x8 && x8, (System.Func<bool, bool>) (o => o is var y8 && x8)); Dummy(true is var x9, (System.Func<int, bool>) (o => o is var x9 && x9 > 0), x9); Dummy((System.Func<int, bool>) (o => o is var x10 && x10 > 0), true is var x10, x10); var x11 = 11; Dummy(x11); Dummy((System.Func<int, bool>) (o => o is var x11 && x11 > 0), x11); Dummy((System.Func<int, bool>) (o => o is var x12 && x12 > 0), x12); var x12 = 11; Dummy(x12); "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (6,39): error CS0841: Cannot use local variable 'x4' before it is declared // Dummy((System.Func<bool, bool>) (o => x4 && o is var x4)); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x4").WithArguments("x4").WithLocation(6, 39), // (9,67): error CS0128: A local variable or function named 'x5' is already defined in this scope // o2 is var x5 && Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(9, 67), // (14,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(14, 7), // (15,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(15, 7), // (17,9): error CS0103: The name 'x7' does not exist in the current context // x7); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(17, 9), // (18,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 2); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(18, 7) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").Single(); Assert.Equal(2, x5Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl[1]); var x6Decl = GetPatternDeclarations(tree, "x6").ToArray(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Decl.Length); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[0], x6Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[1], x6Ref[1]); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(5, x7Ref.Length); VerifyNotInScope(model, x7Ref[0]); VerifyNotInScope(model, x7Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[2]); VerifyNotInScope(model, x7Ref[3]); VerifyNotInScope(model, x7Ref[4]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(2, x8Ref.Length); VerifyModelForDeclarationField(model, x8Decl, x8Ref); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(2, x9Ref.Length); VerifyModelForDeclarationField(model, x9Decl[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[0]); var x10Decl = GetPatternDeclarations(tree, "x10").ToArray(); var x10Ref = GetReferences(tree, "x10").ToArray(); Assert.Equal(2, x10Decl.Length); Assert.Equal(2, x10Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl[0], x10Ref[0]); VerifyModelForDeclarationField(model, x10Decl[1], x10Ref[1]); var x11Decl = GetPatternDeclarations(tree, "x11").Single(); var x11Ref = GetReferences(tree, "x11").ToArray(); Assert.Equal(3, x11Ref.Length); VerifyNotAPatternLocal(model, x11Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x11Decl, x11Ref[1]); VerifyNotAPatternLocal(model, x11Ref[2]); var x12Decl = GetPatternDeclarations(tree, "x12").Single(); var x12Ref = GetReferences(tree, "x12").ToArray(); Assert.Equal(3, x12Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x12Decl, x12Ref[0]); VerifyNotAPatternLocal(model, x12Ref[1]); VerifyNotAPatternLocal(model, x12Ref[2]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (6,39): error CS0841: Cannot use local variable 'x4' before it is declared // Dummy((System.Func<bool, bool>) (o => x4 && o is var x4)); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x4").WithArguments("x4").WithLocation(6, 39), // (9,67): error CS0128: A local variable or function named 'x5' is already defined in this scope // o2 is var x5 && Diagnostic(ErrorCode.ERR_LocalDuplicate, "x5").WithArguments("x5").WithLocation(9, 67), // (14,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 1); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(14, 7), // (15,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(15, 7), // (17,9): error CS0103: The name 'x7' does not exist in the current context // x7); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(17, 9), // (18,7): error CS0103: The name 'x7' does not exist in the current context // Dummy(x7, 2); Diagnostic(ErrorCode.ERR_NameNotInContext, "x7").WithArguments("x7").WithLocation(18, 7), // (37,9): error CS0841: Cannot use local variable 'x12' before it is declared // x12); Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x12").WithArguments("x12").WithLocation(37, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x3Decl = GetPatternDeclarations(tree, "x3").Single(); var x3Ref = GetReferences(tree, "x3").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x3Decl, x3Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref); var x5Decl = GetPatternDeclarations(tree, "x5").ToArray(); var x5Ref = GetReferences(tree, "x5").Single(); Assert.Equal(2, x5Decl.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x5Decl[0], x5Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x5Decl[1]); var x6Decl = GetPatternDeclarations(tree, "x6").ToArray(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Decl.Length); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[0], x6Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl[1], x6Ref[1]); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(5, x7Ref.Length); VerifyNotInScope(model, x7Ref[0]); VerifyNotInScope(model, x7Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[2]); VerifyNotInScope(model, x7Ref[3]); VerifyNotInScope(model, x7Ref[4]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(2, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(2, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[0]); var x10Decl = GetPatternDeclarations(tree, "x10").ToArray(); var x10Ref = GetReferences(tree, "x10").ToArray(); Assert.Equal(2, x10Decl.Length); Assert.Equal(2, x10Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl[0], x10Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl[1], x10Ref[1]); var x11Decl = GetPatternDeclarations(tree, "x11").Single(); var x11Ref = GetReferences(tree, "x11").ToArray(); Assert.Equal(3, x11Ref.Length); VerifyNotAPatternLocal(model, x11Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x11Decl, x11Ref[1]); VerifyNotAPatternLocal(model, x11Ref[2]); var x12Decl = GetPatternDeclarations(tree, "x12").Single(); var x12Ref = GetReferences(tree, "x12").ToArray(); Assert.Equal(3, x12Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x12Decl, x12Ref[0]); VerifyNotAPatternLocal(model, x12Ref[1]); VerifyNotAPatternLocal(model, x12Ref[2]); } } [Fact] [WorkItem(16935, "https://github.com/dotnet/roslyn/issues/16935")] public void GlobalCode_Lambda_02() { var source = @" System.Func<bool> l = () => 1 is int x1 && Dummy(x1); System.Console.WriteLine(l()); static bool Dummy(int x) { System.Console.WriteLine(x); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 True"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Lambda_03() { var source = @" System.Console.WriteLine(((System.Func<bool>)(() => 1 is int x1 && Dummy(x1)))()); static bool Dummy(int x) { System.Console.WriteLine(x); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 True"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); } [Fact] public void GlobalCode_Query_01() { var source = @" using System.Linq; bool Dummy(params object[] x) {return true;} var r01 = from x in new[] { 1 is var y1 ? y1 : 0, y1} select x + y1; Dummy(y1); var r02 = from x1 in new[] { 1 is var y2 ? y2 : 0} from x2 in new[] { x1 is var z2 ? z2 : 0, z2, y2} select x1 + x2 + y2 + z2; Dummy(z2); var r03 = from x1 in new[] { 1 is var y3 ? y3 : 0} let x2 = x1 is var z3 && z3 > 0 && y3 < 0 select new { x1, x2, y3, z3}; Dummy(z3); var r04 = from x1 in new[] { 1 is var y4 ? y4 : 0} join x2 in new[] { 2 is var z4 ? z4 : 0, z4, y4} on x1 + y4 + z4 + (3 is var u4 ? u4 : 0) + v4 equals x2 + y4 + z4 + (4 is var v4 ? v4 : 0) + u4 select new { x1, x2, y4, z4, u4, v4 }; Dummy(z4); Dummy(u4); Dummy(v4); var r05 = from x1 in new[] { 1 is var y5 ? y5 : 0} join x2 in new[] { 2 is var z5 ? z5 : 0, z5, y5} on x1 + y5 + z5 + (3 is var u5 ? u5 : 0) + v5 equals x2 + y5 + z5 + (4 is var v5 ? v5 : 0) + u5 into g select new { x1, y5, z5, g, u5, v5 }; Dummy(z5); Dummy(u5); Dummy(v5); var r06 = from x in new[] { 1 is var y6 ? y6 : 0} where x > y6 && 1 is var z6 && z6 == 1 select x + y6 + z6; Dummy(z6); var r07 = from x in new[] { 1 is var y7 ? y7 : 0} orderby x > y7 && 1 is var z7 && z7 == u7, x > y7 && 1 is var u7 && u7 == z7 select x + y7 + z7 + u7; Dummy(z7); Dummy(u7); var r08 = from x in new[] { 1 is var y8 ? y8 : 0} select x > y8 && 1 is var z8 && z8 == 1; Dummy(z8); var r09 = from x in new[] { 1 is var y9 ? y9 : 0} group x > y9 && 1 is var z9 && z9 == u9 by x > y9 && 1 is var u9 && u9 == z9; Dummy(z9); Dummy(u9); var r10 = from x1 in new[] { 1 is var y10 ? y10 : 0} from y10 in new[] { 1 } select x1 + y10; var r11 = from x1 in new[] { 1 is var y11 ? y11 : 0} let y11 = x1 + 1 select x1 + y11; "; { var compilation = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (14,21): error CS0103: The name 'z2' does not exist in the current context // z2; Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(14, 21), // (21,25): error CS0103: The name 'z3' does not exist in the current context // z3}; Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(21, 25), // (28,29): error CS0103: The name 'v4' does not exist in the current context // v4 Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(28, 29), // (30,29): error CS1938: The name 'u4' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u4 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u4").WithArguments("u4").WithLocation(30, 29), // (32,25): error CS0103: The name 'u4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(32, 25), // (32,29): error CS0103: The name 'v4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(32, 29), // (41,29): error CS0103: The name 'v5' does not exist in the current context // v5 Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(41, 29), // (43,29): error CS1938: The name 'u5' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u5 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u5").WithArguments("u5").WithLocation(43, 29), // (46,25): error CS0103: The name 'u5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(46, 25), // (46,29): error CS0103: The name 'v5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(46, 29), // (55,21): error CS0103: The name 'z6' does not exist in the current context // z6; Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(55, 21), // (61,21): error CS0103: The name 'u7' does not exist in the current context // u7, Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(61, 21), // (63,21): error CS0103: The name 'z7' does not exist in the current context // z7 Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(63, 21), // (65,21): error CS0103: The name 'z7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(65, 21), // (65,26): error CS0103: The name 'u7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(65, 26), // (80,17): error CS0103: The name 'z9' does not exist in the current context // z9; Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(80, 17), // (77,17): error CS0103: The name 'u9' does not exist in the current context // u9 Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(77, 17), // (16,7): error CS0103: The name 'z2' does not exist in the current context // Dummy(z2); Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(16, 7), // (23,7): error CS0103: The name 'z3' does not exist in the current context // Dummy(z3); Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(23, 7), // (35,7): error CS0103: The name 'u4' does not exist in the current context // Dummy(u4); Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(35, 7), // (36,7): error CS0103: The name 'v4' does not exist in the current context // Dummy(v4); Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(36, 7), // (49,7): error CS0103: The name 'u5' does not exist in the current context // Dummy(u5); Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(49, 7), // (50,7): error CS0103: The name 'v5' does not exist in the current context // Dummy(v5); Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(50, 7), // (57,7): error CS0103: The name 'z6' does not exist in the current context // Dummy(z6); Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(57, 7), // (67,7): error CS0103: The name 'z7' does not exist in the current context // Dummy(z7); Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(67, 7), // (68,7): error CS0103: The name 'u7' does not exist in the current context // Dummy(u7); Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(68, 7), // (73,7): error CS0103: The name 'z8' does not exist in the current context // Dummy(z8); Diagnostic(ErrorCode.ERR_NameNotInContext, "z8").WithArguments("z8").WithLocation(73, 7), // (82,7): error CS0103: The name 'z9' does not exist in the current context // Dummy(z9); Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(82, 7), // (83,7): error CS0103: The name 'u9' does not exist in the current context // Dummy(u9); Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(83, 7) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var y1Decl = GetPatternDeclarations(tree, "y1").Single(); var y1Ref = GetReferences(tree, "y1").ToArray(); Assert.Equal(4, y1Ref.Length); VerifyModelForDeclarationField(model, y1Decl, y1Ref); var y2Decl = GetPatternDeclarations(tree, "y2").Single(); var y2Ref = GetReferences(tree, "y2").ToArray(); Assert.Equal(3, y2Ref.Length); VerifyModelForDeclarationField(model, y2Decl, y2Ref); var z2Decl = GetPatternDeclarations(tree, "z2").Single(); var z2Ref = GetReferences(tree, "z2").ToArray(); Assert.Equal(4, z2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z2Decl, z2Ref[0], z2Ref[1]); VerifyNotInScope(model, z2Ref[2]); VerifyNotInScope(model, z2Ref[3]); var y3Decl = GetPatternDeclarations(tree, "y3").Single(); var y3Ref = GetReferences(tree, "y3").ToArray(); Assert.Equal(3, y3Ref.Length); VerifyModelForDeclarationField(model, y3Decl, y3Ref); var z3Decl = GetPatternDeclarations(tree, "z3").Single(); var z3Ref = GetReferences(tree, "z3").ToArray(); Assert.Equal(3, z3Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z3Decl, z3Ref[0]); VerifyNotInScope(model, z3Ref[1]); VerifyNotInScope(model, z3Ref[2]); var y4Decl = GetPatternDeclarations(tree, "y4").Single(); var y4Ref = GetReferences(tree, "y4").ToArray(); Assert.Equal(5, y4Ref.Length); VerifyModelForDeclarationField(model, y4Decl, y4Ref); var z4Decl = GetPatternDeclarations(tree, "z4").Single(); var z4Ref = GetReferences(tree, "z4").ToArray(); Assert.Equal(6, z4Ref.Length); VerifyModelForDeclarationField(model, z4Decl, z4Ref); var u4Decl = GetPatternDeclarations(tree, "u4").Single(); var u4Ref = GetReferences(tree, "u4").ToArray(); Assert.Equal(4, u4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u4Decl, u4Ref[0]); VerifyNotInScope(model, u4Ref[1]); VerifyNotInScope(model, u4Ref[2]); VerifyNotInScope(model, u4Ref[3]); var v4Decl = GetPatternDeclarations(tree, "v4").Single(); var v4Ref = GetReferences(tree, "v4").ToArray(); Assert.Equal(4, v4Ref.Length); VerifyNotInScope(model, v4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v4Decl, v4Ref[1]); VerifyNotInScope(model, v4Ref[2]); VerifyNotInScope(model, v4Ref[3]); var y5Decl = GetPatternDeclarations(tree, "y5").Single(); var y5Ref = GetReferences(tree, "y5").ToArray(); Assert.Equal(5, y5Ref.Length); VerifyModelForDeclarationField(model, y5Decl, y5Ref); var z5Decl = GetPatternDeclarations(tree, "z5").Single(); var z5Ref = GetReferences(tree, "z5").ToArray(); Assert.Equal(6, z5Ref.Length); VerifyModelForDeclarationField(model, z5Decl, z5Ref); var u5Decl = GetPatternDeclarations(tree, "u5").Single(); var u5Ref = GetReferences(tree, "u5").ToArray(); Assert.Equal(4, u5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u5Decl, u5Ref[0]); VerifyNotInScope(model, u5Ref[1]); VerifyNotInScope(model, u5Ref[2]); VerifyNotInScope(model, u5Ref[3]); var v5Decl = GetPatternDeclarations(tree, "v5").Single(); var v5Ref = GetReferences(tree, "v5").ToArray(); Assert.Equal(4, v5Ref.Length); VerifyNotInScope(model, v5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v5Decl, v5Ref[1]); VerifyNotInScope(model, v5Ref[2]); VerifyNotInScope(model, v5Ref[3]); var y6Decl = GetPatternDeclarations(tree, "y6").Single(); var y6Ref = GetReferences(tree, "y6").ToArray(); Assert.Equal(3, y6Ref.Length); VerifyModelForDeclarationField(model, y6Decl, y6Ref); var z6Decl = GetPatternDeclarations(tree, "z6").Single(); var z6Ref = GetReferences(tree, "z6").ToArray(); Assert.Equal(3, z6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z6Decl, z6Ref[0]); VerifyNotInScope(model, z6Ref[1]); VerifyNotInScope(model, z6Ref[2]); var y7Decl = GetPatternDeclarations(tree, "y7").Single(); var y7Ref = GetReferences(tree, "y7").ToArray(); Assert.Equal(4, y7Ref.Length); VerifyModelForDeclarationField(model, y7Decl, y7Ref); var z7Decl = GetPatternDeclarations(tree, "z7").Single(); var z7Ref = GetReferences(tree, "z7").ToArray(); Assert.Equal(4, z7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z7Decl, z7Ref[0]); VerifyNotInScope(model, z7Ref[1]); VerifyNotInScope(model, z7Ref[2]); VerifyNotInScope(model, z7Ref[3]); var u7Decl = GetPatternDeclarations(tree, "u7").Single(); var u7Ref = GetReferences(tree, "u7").ToArray(); Assert.Equal(4, u7Ref.Length); VerifyNotInScope(model, u7Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u7Decl, u7Ref[1]); VerifyNotInScope(model, u7Ref[2]); VerifyNotInScope(model, u7Ref[3]); var y8Decl = GetPatternDeclarations(tree, "y8").Single(); var y8Ref = GetReferences(tree, "y8").ToArray(); Assert.Equal(2, y8Ref.Length); VerifyModelForDeclarationField(model, y8Decl, y8Ref); var z8Decl = GetPatternDeclarations(tree, "z8").Single(); var z8Ref = GetReferences(tree, "z8").ToArray(); Assert.Equal(2, z8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z8Decl, z8Ref[0]); VerifyNotInScope(model, z8Ref[1]); var y9Decl = GetPatternDeclarations(tree, "y9").Single(); var y9Ref = GetReferences(tree, "y9").ToArray(); Assert.Equal(3, y9Ref.Length); VerifyModelForDeclarationField(model, y9Decl, y9Ref); var z9Decl = GetPatternDeclarations(tree, "z9").Single(); var z9Ref = GetReferences(tree, "z9").ToArray(); Assert.Equal(3, z9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z9Decl, z9Ref[0]); VerifyNotInScope(model, z9Ref[1]); VerifyNotInScope(model, z9Ref[2]); var u9Decl = GetPatternDeclarations(tree, "u9").Single(); var u9Ref = GetReferences(tree, "u9").ToArray(); Assert.Equal(3, u9Ref.Length); VerifyNotInScope(model, u9Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u9Decl, u9Ref[1]); VerifyNotInScope(model, u9Ref[2]); var y10Decl = GetPatternDeclarations(tree, "y10").Single(); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyModelForDeclarationField(model, y10Decl, y10Ref[0]); VerifyNotAPatternField(model, y10Ref[1]); var y11Decl = GetPatternDeclarations(tree, "y11").Single(); var y11Ref = GetReferences(tree, "y11").ToArray(); Assert.Equal(2, y11Ref.Length); VerifyModelForDeclarationField(model, y11Decl, y11Ref[0]); VerifyNotAPatternField(model, y11Ref[1]); } { var compilation = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef }, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (14,21): error CS0103: The name 'z2' does not exist in the current context // z2; Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(14, 21), // (21,25): error CS0103: The name 'z3' does not exist in the current context // z3}; Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(21, 25), // (28,29): error CS0103: The name 'v4' does not exist in the current context // v4 Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(28, 29), // (30,29): error CS1938: The name 'u4' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u4 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u4").WithArguments("u4").WithLocation(30, 29), // (32,25): error CS0103: The name 'u4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(32, 25), // (32,29): error CS0103: The name 'v4' does not exist in the current context // u4, v4 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(32, 29), // (41,29): error CS0103: The name 'v5' does not exist in the current context // v5 Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(41, 29), // (43,29): error CS1938: The name 'u5' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'. // u5 Diagnostic(ErrorCode.ERR_QueryInnerKey, "u5").WithArguments("u5").WithLocation(43, 29), // (46,25): error CS0103: The name 'u5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(46, 25), // (46,29): error CS0103: The name 'v5' does not exist in the current context // u5, v5 }; Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(46, 29), // (55,21): error CS0103: The name 'z6' does not exist in the current context // z6; Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(55, 21), // (61,21): error CS0103: The name 'u7' does not exist in the current context // u7, Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(61, 21), // (63,21): error CS0103: The name 'z7' does not exist in the current context // z7 Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(63, 21), // (65,21): error CS0103: The name 'z7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(65, 21), // (65,26): error CS0103: The name 'u7' does not exist in the current context // z7 + u7; Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(65, 26), // (80,17): error CS0103: The name 'z9' does not exist in the current context // z9; Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(80, 17), // (77,17): error CS0103: The name 'u9' does not exist in the current context // u9 Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(77, 17), // (16,7): error CS0103: The name 'z2' does not exist in the current context // Dummy(z2); Diagnostic(ErrorCode.ERR_NameNotInContext, "z2").WithArguments("z2").WithLocation(16, 7), // (23,7): error CS0103: The name 'z3' does not exist in the current context // Dummy(z3); Diagnostic(ErrorCode.ERR_NameNotInContext, "z3").WithArguments("z3").WithLocation(23, 7), // (35,7): error CS0103: The name 'u4' does not exist in the current context // Dummy(u4); Diagnostic(ErrorCode.ERR_NameNotInContext, "u4").WithArguments("u4").WithLocation(35, 7), // (36,7): error CS0103: The name 'v4' does not exist in the current context // Dummy(v4); Diagnostic(ErrorCode.ERR_NameNotInContext, "v4").WithArguments("v4").WithLocation(36, 7), // (49,7): error CS0103: The name 'u5' does not exist in the current context // Dummy(u5); Diagnostic(ErrorCode.ERR_NameNotInContext, "u5").WithArguments("u5").WithLocation(49, 7), // (50,7): error CS0103: The name 'v5' does not exist in the current context // Dummy(v5); Diagnostic(ErrorCode.ERR_NameNotInContext, "v5").WithArguments("v5").WithLocation(50, 7), // (57,7): error CS0103: The name 'z6' does not exist in the current context // Dummy(z6); Diagnostic(ErrorCode.ERR_NameNotInContext, "z6").WithArguments("z6").WithLocation(57, 7), // (67,7): error CS0103: The name 'z7' does not exist in the current context // Dummy(z7); Diagnostic(ErrorCode.ERR_NameNotInContext, "z7").WithArguments("z7").WithLocation(67, 7), // (68,7): error CS0103: The name 'u7' does not exist in the current context // Dummy(u7); Diagnostic(ErrorCode.ERR_NameNotInContext, "u7").WithArguments("u7").WithLocation(68, 7), // (73,7): error CS0103: The name 'z8' does not exist in the current context // Dummy(z8); Diagnostic(ErrorCode.ERR_NameNotInContext, "z8").WithArguments("z8").WithLocation(73, 7), // (82,7): error CS0103: The name 'z9' does not exist in the current context // Dummy(z9); Diagnostic(ErrorCode.ERR_NameNotInContext, "z9").WithArguments("z9").WithLocation(82, 7), // (83,7): error CS0103: The name 'u9' does not exist in the current context // Dummy(u9); Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(83, 7), // (86,18): error CS1931: The range variable 'y10' conflicts with a previous declaration of 'y10' // from y10 in new[] { 1 } Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "y10").WithArguments("y10").WithLocation(86, 18), // (90,17): error CS1931: The range variable 'y11' conflicts with a previous declaration of 'y11' // let y11 = x1 + 1 Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "y11").WithArguments("y11").WithLocation(90, 17) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var y1Decl = GetPatternDeclarations(tree, "y1").Single(); var y1Ref = GetReferences(tree, "y1").ToArray(); Assert.Equal(4, y1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y1Decl, y1Ref); var y2Decl = GetPatternDeclarations(tree, "y2").Single(); var y2Ref = GetReferences(tree, "y2").ToArray(); Assert.Equal(3, y2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y2Decl, y2Ref); var z2Decl = GetPatternDeclarations(tree, "z2").Single(); var z2Ref = GetReferences(tree, "z2").ToArray(); Assert.Equal(4, z2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z2Decl, z2Ref[0], z2Ref[1]); VerifyNotInScope(model, z2Ref[2]); VerifyNotInScope(model, z2Ref[3]); var y3Decl = GetPatternDeclarations(tree, "y3").Single(); var y3Ref = GetReferences(tree, "y3").ToArray(); Assert.Equal(3, y3Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y3Decl, y3Ref); var z3Decl = GetPatternDeclarations(tree, "z3").Single(); var z3Ref = GetReferences(tree, "z3").ToArray(); Assert.Equal(3, z3Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z3Decl, z3Ref[0]); VerifyNotInScope(model, z3Ref[1]); VerifyNotInScope(model, z3Ref[2]); var y4Decl = GetPatternDeclarations(tree, "y4").Single(); var y4Ref = GetReferences(tree, "y4").ToArray(); Assert.Equal(5, y4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y4Decl, y4Ref); var z4Decl = GetPatternDeclarations(tree, "z4").Single(); var z4Ref = GetReferences(tree, "z4").ToArray(); Assert.Equal(6, z4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z4Decl, z4Ref); var u4Decl = GetPatternDeclarations(tree, "u4").Single(); var u4Ref = GetReferences(tree, "u4").ToArray(); Assert.Equal(4, u4Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u4Decl, u4Ref[0]); VerifyNotInScope(model, u4Ref[1]); VerifyNotInScope(model, u4Ref[2]); VerifyNotInScope(model, u4Ref[3]); var v4Decl = GetPatternDeclarations(tree, "v4").Single(); var v4Ref = GetReferences(tree, "v4").ToArray(); Assert.Equal(4, v4Ref.Length); VerifyNotInScope(model, v4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v4Decl, v4Ref[1]); VerifyNotInScope(model, v4Ref[2]); VerifyNotInScope(model, v4Ref[3]); var y5Decl = GetPatternDeclarations(tree, "y5").Single(); var y5Ref = GetReferences(tree, "y5").ToArray(); Assert.Equal(5, y5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y5Decl, y5Ref); var z5Decl = GetPatternDeclarations(tree, "z5").Single(); var z5Ref = GetReferences(tree, "z5").ToArray(); Assert.Equal(6, z5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z5Decl, z5Ref); var u5Decl = GetPatternDeclarations(tree, "u5").Single(); var u5Ref = GetReferences(tree, "u5").ToArray(); Assert.Equal(4, u5Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, u5Decl, u5Ref[0]); VerifyNotInScope(model, u5Ref[1]); VerifyNotInScope(model, u5Ref[2]); VerifyNotInScope(model, u5Ref[3]); var v5Decl = GetPatternDeclarations(tree, "v5").Single(); var v5Ref = GetReferences(tree, "v5").ToArray(); Assert.Equal(4, v5Ref.Length); VerifyNotInScope(model, v5Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, v5Decl, v5Ref[1]); VerifyNotInScope(model, v5Ref[2]); VerifyNotInScope(model, v5Ref[3]); var y6Decl = GetPatternDeclarations(tree, "y6").Single(); var y6Ref = GetReferences(tree, "y6").ToArray(); Assert.Equal(3, y6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y6Decl, y6Ref); var z6Decl = GetPatternDeclarations(tree, "z6").Single(); var z6Ref = GetReferences(tree, "z6").ToArray(); Assert.Equal(3, z6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z6Decl, z6Ref[0]); VerifyNotInScope(model, z6Ref[1]); VerifyNotInScope(model, z6Ref[2]); var y7Decl = GetPatternDeclarations(tree, "y7").Single(); var y7Ref = GetReferences(tree, "y7").ToArray(); Assert.Equal(4, y7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y7Decl, y7Ref); var z7Decl = GetPatternDeclarations(tree, "z7").Single(); var z7Ref = GetReferences(tree, "z7").ToArray(); Assert.Equal(4, z7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z7Decl, z7Ref[0]); VerifyNotInScope(model, z7Ref[1]); VerifyNotInScope(model, z7Ref[2]); VerifyNotInScope(model, z7Ref[3]); var u7Decl = GetPatternDeclarations(tree, "u7").Single(); var u7Ref = GetReferences(tree, "u7").ToArray(); Assert.Equal(4, u7Ref.Length); VerifyNotInScope(model, u7Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u7Decl, u7Ref[1]); VerifyNotInScope(model, u7Ref[2]); VerifyNotInScope(model, u7Ref[3]); var y8Decl = GetPatternDeclarations(tree, "y8").Single(); var y8Ref = GetReferences(tree, "y8").ToArray(); Assert.Equal(2, y8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y8Decl, y8Ref); var z8Decl = GetPatternDeclarations(tree, "z8").Single(); var z8Ref = GetReferences(tree, "z8").ToArray(); Assert.Equal(2, z8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z8Decl, z8Ref[0]); VerifyNotInScope(model, z8Ref[1]); var y9Decl = GetPatternDeclarations(tree, "y9").Single(); var y9Ref = GetReferences(tree, "y9").ToArray(); Assert.Equal(3, y9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y9Decl, y9Ref); var z9Decl = GetPatternDeclarations(tree, "z9").Single(); var z9Ref = GetReferences(tree, "z9").ToArray(); Assert.Equal(3, z9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, z9Decl, z9Ref[0]); VerifyNotInScope(model, z9Ref[1]); VerifyNotInScope(model, z9Ref[2]); var u9Decl = GetPatternDeclarations(tree, "u9").Single(); var u9Ref = GetReferences(tree, "u9").ToArray(); Assert.Equal(3, u9Ref.Length); VerifyNotInScope(model, u9Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, u9Decl, u9Ref[1]); VerifyNotInScope(model, u9Ref[2]); var y10Decl = GetPatternDeclarations(tree, "y10").Single(); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y10Decl, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y11Decl = GetPatternDeclarations(tree, "y11").Single(); var y11Ref = GetReferences(tree, "y11").ToArray(); Assert.Equal(2, y11Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, y11Decl, y11Ref[0]); VerifyNotAPatternLocal(model, y11Ref[1]); } } [Fact] public void GlobalCode_Query_02() { var source = @" using System.Linq; var res = from x1 in new[] { 1 is var y1 && Print(y1) ? 2 : 0} select Print(x1); res.ToArray(); static bool Print(object x) { System.Console.WriteLine(x); return true; } "; var compilation = CreateCompilationWithMscorlib45(source, new[] { SystemCoreRef }, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"1 2"); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var yDecl = GetPatternDeclarations(tree, "y1").Single(); var yRef = GetReferences(tree, "y1").Single(); VerifyModelForDeclarationField(model, yDecl, yRef); } [Fact] public void GlobalCode_Using_01() { var source = @" System.IDisposable Dummy(params object[] x) {return null;} using (Dummy(true is var x1, x1)) { Dummy(x1); } using (Dummy(true is var x2, x2)) Dummy(x2); var x4 = 11; Dummy(x4); using (Dummy(true is var x4, x4)) Dummy(x4); using (Dummy(x6 && true is var x6)) Dummy(x6); using (Dummy(true is var x7 && x7)) { var x7 = 12; Dummy(x7); } using (Dummy(true is var x8, x8)) Dummy(x8); System.Console.WriteLine(x8); using (Dummy(true is var x9, x9)) { Dummy(x9); using (Dummy(true is var x9, x9)) // 2 Dummy(x9); } using (Dummy(y10 is var x10, x10)) { var y10 = 12; Dummy(y10); } // using (Dummy(y11 is var x11, x11)) // { // let y11 = 12; // Dummy(y11); // } using (Dummy(y12 is var x12, x12)) var y12 = 12; // using (Dummy(y13 is var x13, x13)) // let y13 = 12; using (Dummy(1 is var x14, 2 is var x14, x14)) { Dummy(x14); } "; { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); compilation.VerifyDiagnostics( // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (18,14): error CS0841: Cannot use local variable 'x6' before it is declared // using (Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 14), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,30): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // using (Dummy(true is var x9, x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 30), // (39,14): error CS0103: The name 'y10' does not exist in the current context // using (Dummy(y10 is var x10, x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 14), // (51,14): error CS0103: The name 'y12' does not exist in the current context // using (Dummy(y12 is var x12, x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 14), // (58,26): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 26), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var x10Decl = GetPatternDeclarations(tree, "x10").Single(); var x10Ref = GetReferences(tree, "x10").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl, x10Ref); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } { var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (15,26): error CS0136: A local or parameter named 'x4' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // using (Dummy(true is var x4, x4)) Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x4").WithArguments("x4").WithLocation(15, 26), // (18,14): error CS0841: Cannot use local variable 'x6' before it is declared // using (Dummy(x6 && true is var x6)) Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x6").WithArguments("x6").WithLocation(18, 14), // (23,9): error CS0136: A local or parameter named 'x7' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // var x7 = 12; Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x7").WithArguments("x7").WithLocation(23, 9), // (30,26): error CS0103: The name 'x8' does not exist in the current context // System.Console.WriteLine(x8); Diagnostic(ErrorCode.ERR_NameNotInContext, "x8").WithArguments("x8").WithLocation(30, 26), // (35,30): error CS0136: A local or parameter named 'x9' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // using (Dummy(true is var x9, x9)) // 2 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x9").WithArguments("x9").WithLocation(35, 30), // (39,14): error CS0103: The name 'y10' does not exist in the current context // using (Dummy(y10 is var x10, x10)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y10").WithArguments("y10").WithLocation(39, 14), // (51,14): error CS0103: The name 'y12' does not exist in the current context // using (Dummy(y12 is var x12, x12)) Diagnostic(ErrorCode.ERR_NameNotInContext, "y12").WithArguments("y12").WithLocation(51, 14), // (52,5): error CS1023: Embedded statement cannot be a declaration or labeled statement // var y12 = 12; Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "var y12 = 12;").WithLocation(52, 5), // (52,9): warning CS0219: The variable 'y12' is assigned but its value is never used // var y12 = 12; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y12").WithArguments("y12").WithLocation(52, 9), // (58,26): error CS0128: A local variable or function named 'x14' is already defined in this scope // 2 is var x14, Diagnostic(ErrorCode.ERR_LocalDuplicate, "x14").WithArguments("x14").WithLocation(58, 26) ); var tree = compilation.SyntaxTrees.Single(); var model = compilation.GetSemanticModel(tree); var x1Decl = GetPatternDeclarations(tree, "x1").Single(); var x1Ref = GetReferences(tree, "x1").ToArray(); Assert.Equal(2, x1Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x1Decl, x1Ref); var x2Decl = GetPatternDeclarations(tree, "x2").Single(); var x2Ref = GetReferences(tree, "x2").ToArray(); Assert.Equal(2, x2Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x2Decl, x2Ref); var x4Decl = GetPatternDeclarations(tree, "x4").Single(); var x4Ref = GetReferences(tree, "x4").ToArray(); Assert.Equal(3, x4Ref.Length); VerifyNotAPatternLocal(model, x4Ref[0]); VerifyModelForDeclarationOrVarSimplePattern(model, x4Decl, x4Ref[1], x4Ref[2]); var x6Decl = GetPatternDeclarations(tree, "x6").Single(); var x6Ref = GetReferences(tree, "x6").ToArray(); Assert.Equal(2, x6Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x6Decl, x6Ref); var x7Decl = GetPatternDeclarations(tree, "x7").Single(); var x7Ref = GetReferences(tree, "x7").ToArray(); Assert.Equal(2, x7Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x7Decl, x7Ref[0]); VerifyNotAPatternLocal(model, x7Ref[1]); var x8Decl = GetPatternDeclarations(tree, "x8").Single(); var x8Ref = GetReferences(tree, "x8").ToArray(); Assert.Equal(3, x8Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x8Decl, x8Ref[0], x8Ref[1]); VerifyNotInScope(model, x8Ref[2]); var x9Decl = GetPatternDeclarations(tree, "x9").ToArray(); var x9Ref = GetReferences(tree, "x9").ToArray(); Assert.Equal(2, x9Decl.Length); Assert.Equal(4, x9Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[0], x9Ref[0], x9Ref[1]); VerifyModelForDeclarationOrVarSimplePattern(model, x9Decl[1], x9Ref[2], x9Ref[3]); var x10Decl = GetPatternDeclarations(tree, "x10").Single(); var x10Ref = GetReferences(tree, "x10").Single(); VerifyModelForDeclarationOrVarSimplePattern(model, x10Decl, x10Ref); var y10Ref = GetReferences(tree, "y10").ToArray(); Assert.Equal(2, y10Ref.Length); VerifyNotInScope(model, y10Ref[0]); VerifyNotAPatternLocal(model, y10Ref[1]); var y12Ref = GetReferences(tree, "y12").Single(); VerifyNotInScope(model, y12Ref); var x14Decl = GetPatternDeclarations(tree, "x14").ToArray(); var x14Ref = GetReferences(tree, "x14").ToArray(); Assert.Equal(2, x14Decl.Length); Assert.Equal(2, x14Ref.Length); VerifyModelForDeclarationOrVarSimplePattern(model, x14Decl[0], x14Ref); VerifyModelForDeclarationOrVarPatternDuplicateInSameScope(model, x14Decl[1]); } } [Fact] public void GlobalCode_Using_02() { var source = @" using (System.IDisposable d1 = Dummy(new C(""a""), (new C(""b"")) is var x1), d2 = Dummy(new C(""c""), (new C(""d"")) is var x2)) { System.Console.WriteLine(d1); System.Console.WriteLine(x1); System.Console.WriteLine(d2); System.Console.WriteLine(x2); } using (Dummy(new C(""e""), (new C(""f"")) is var x1)) { System.Console.WriteLine(x1); } static System.IDisposable Dummy(System.IDisposable x, params object[] y) {return x;} class C : System.IDisposable { private readonly string _val; public C(string val) { _val = val; } public void Dispose() { System.Console.WriteLine(""Disposing {0}"", _val); } public override string ToString() { return _val; } } "; var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe.WithScriptClassName("Script"), parseOptions: TestOptions.Script); CompileAndVerify(compilation, expectedOutput: @"a b c d Disposing c Disposing a f Disposing e"); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Core/Def/Implementation/VisualStudioWorkspaceContextService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Experiments; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.Shell; namespace Microsoft.VisualStudio.LanguageServices.Implementation { [ExportWorkspaceService(typeof(IWorkspaceContextService), ServiceLayer.Host), Shared] internal class VisualStudioWorkspaceContextService : IWorkspaceContextService { /// <summary> /// Roslyn LSP feature flag name, as defined in the PackageRegistraion.pkgdef /// by everything following '$RootKey$\FeatureFlags\' and '\' replaced by '.' /// </summary> public const string LspEditorFeatureFlagName = "Roslyn.LSP.Editor"; // UI context defined by Live Share when connected as a guest in a Live Share session // https://devdiv.visualstudio.com/DevDiv/_git/Cascade?path=%2Fsrc%2FVS%2FContracts%2FGuidList.cs&version=GBmain&line=32&lineEnd=33&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents private static readonly Guid LiveShareGuestUIContextGuid = Guid.Parse("fd93f3eb-60da-49cd-af15-acda729e357e"); private readonly Workspace _workspace; [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public VisualStudioWorkspaceContextService(VisualStudioWorkspace vsWorkspace) { _workspace = vsWorkspace; } public bool IsCloudEnvironmentClient() { var context = UIContext.FromUIContextGuid(VSConstants.UICONTEXT.CloudEnvironmentConnected_guid); return context.IsActive; } public bool IsInLspEditorContext() { var featureFlagService = _workspace.Services.GetRequiredService<IExperimentationService>(); var isInLspContext = IsLiveShareGuest() || IsCloudEnvironmentClient() || featureFlagService.IsExperimentEnabled(LspEditorFeatureFlagName); return isInLspContext; } /// <summary> /// Checks if the VS instance is running as a Live Share guest session. /// </summary> private static bool IsLiveShareGuest() { var context = UIContext.FromUIContextGuid(LiveShareGuestUIContextGuid); return context.IsActive; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Experiments; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.Shell; namespace Microsoft.VisualStudio.LanguageServices.Implementation { [ExportWorkspaceService(typeof(IWorkspaceContextService), ServiceLayer.Host), Shared] internal class VisualStudioWorkspaceContextService : IWorkspaceContextService { /// <summary> /// Roslyn LSP feature flag name, as defined in the PackageRegistraion.pkgdef /// by everything following '$RootKey$\FeatureFlags\' and '\' replaced by '.' /// </summary> public const string LspEditorFeatureFlagName = "Roslyn.LSP.Editor"; // UI context defined by Live Share when connected as a guest in a Live Share session // https://devdiv.visualstudio.com/DevDiv/_git/Cascade?path=%2Fsrc%2FVS%2FContracts%2FGuidList.cs&version=GBmain&line=32&lineEnd=33&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents private static readonly Guid LiveShareGuestUIContextGuid = Guid.Parse("fd93f3eb-60da-49cd-af15-acda729e357e"); private readonly Workspace _workspace; [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public VisualStudioWorkspaceContextService(VisualStudioWorkspace vsWorkspace) { _workspace = vsWorkspace; } public bool IsCloudEnvironmentClient() { var context = UIContext.FromUIContextGuid(VSConstants.UICONTEXT.CloudEnvironmentConnected_guid); return context.IsActive; } public bool IsInLspEditorContext() { var featureFlagService = _workspace.Services.GetRequiredService<IExperimentationService>(); var isInLspContext = IsLiveShareGuest() || IsCloudEnvironmentClient() || featureFlagService.IsExperimentEnabled(LspEditorFeatureFlagName); return isInLspContext; } /// <summary> /// Checks if the VS instance is running as a Live Share guest session. /// </summary> private static bool IsLiveShareGuest() { var context = UIContext.FromUIContextGuid(LiveShareGuestUIContextGuid); return context.IsActive; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest/ConvertAutoPropertyToFullProperty/ConvertAutoPropertyToFullPropertyTests_OptionSets.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.NamingStyles; using Microsoft.CodeAnalysis.Simplification; using static Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles.SymbolSpecification; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ConvertAutoPropertyToFullProperty { public partial class ConvertAutoPropertyToFullPropertyTests : AbstractCSharpCodeActionTest { private OptionsCollection PreferExpressionBodiedAccessorsWhenPossible => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithSuggestionEnforcement } }; private OptionsCollection PreferExpressionBodiedAccessorsWhenOnSingleLine => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenOnSingleLineWithSilentEnforcement } }; private OptionsCollection DoNotPreferExpressionBodiedAccessors => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement } }; private OptionsCollection DoNotPreferExpressionBodiedAccessorsAndPropertyOpenBraceOnSameLine => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, { CSharpFormattingOptions2.NewLinesForBracesInProperties, false }, }; private OptionsCollection DoNotPreferExpressionBodiedAccessorsAndAccessorOpenBraceOnSameLine => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, { CSharpFormattingOptions2.NewLinesForBracesInAccessors, false }, }; private OptionsCollection PreferExpressionBodiesOnAccessorsAndMethods => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithSilentEnforcement }, { CSharpCodeStyleOptions.PreferExpressionBodiedMethods, CSharpCodeStyleOptions.WhenPossibleWithSilentEnforcement }, }; private OptionsCollection UseCustomFieldName => new OptionsCollection(GetLanguage()) { { NamingStyleOptions.NamingPreferences, CreateCustomFieldNamingStylePreference() }, { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, }; private OptionsCollection UseUnderscorePrefixedFieldName => new OptionsCollection(GetLanguage()) { { NamingStyleOptions.NamingPreferences, CreateUnderscorePrefixedFieldNamingStylePreference() }, { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, }; private OptionsCollection UseCustomStaticFieldName => new OptionsCollection(GetLanguage()) { { NamingStyleOptions.NamingPreferences, CreateCustomStaticFieldNamingStylePreference() }, { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, }; private static NamingStylePreferences CreateCustomFieldNamingStylePreference() { var symbolSpecification = new SymbolSpecification( null, "Name", ImmutableArray.Create(new SymbolSpecification.SymbolKindOrTypeKind(SymbolKind.Field)), accessibilityList: default, modifiers: default); var namingStyle = new NamingStyle( Guid.NewGuid(), capitalizationScheme: Capitalization.PascalCase, name: "CustomFieldTest", prefix: "testing", suffix: "", wordSeparator: ""); var namingRule = new SerializableNamingRule() { SymbolSpecificationID = symbolSpecification.ID, NamingStyleID = namingStyle.ID, EnforcementLevel = ReportDiagnostic.Error }; var info = new NamingStylePreferences( ImmutableArray.Create(symbolSpecification), ImmutableArray.Create(namingStyle), ImmutableArray.Create(namingRule)); return info; } private static NamingStylePreferences CreateUnderscorePrefixedFieldNamingStylePreference() { var symbolSpecification = new SymbolSpecification( null, "Name", ImmutableArray.Create(new SymbolKindOrTypeKind(SymbolKind.Field)), accessibilityList: default, modifiers: default); var namingStyle = new NamingStyle( Guid.NewGuid(), capitalizationScheme: Capitalization.CamelCase, name: "CustomFieldTest", prefix: "_", suffix: "", wordSeparator: ""); var namingRule = new SerializableNamingRule() { SymbolSpecificationID = symbolSpecification.ID, NamingStyleID = namingStyle.ID, EnforcementLevel = ReportDiagnostic.Error }; var info = new NamingStylePreferences( ImmutableArray.Create(symbolSpecification), ImmutableArray.Create(namingStyle), ImmutableArray.Create(namingRule)); return info; } private static NamingStylePreferences CreateCustomStaticFieldNamingStylePreference() { var symbolSpecification = new SymbolSpecification( null, "Name", ImmutableArray.Create(new SymbolKindOrTypeKind(SymbolKind.Field)), accessibilityList: default, ImmutableArray.Create(new ModifierKind(DeclarationModifiers.Static))); var namingStyle = new NamingStyle( Guid.NewGuid(), capitalizationScheme: Capitalization.PascalCase, name: "CustomStaticFieldTest", prefix: "staticfieldtest", suffix: "", wordSeparator: ""); var namingRule = new SerializableNamingRule() { SymbolSpecificationID = symbolSpecification.ID, NamingStyleID = namingStyle.ID, EnforcementLevel = ReportDiagnostic.Error }; var info = new NamingStylePreferences( ImmutableArray.Create(symbolSpecification), ImmutableArray.Create(namingStyle), ImmutableArray.Create(namingRule)); return info; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.NamingStyles; using Microsoft.CodeAnalysis.Simplification; using static Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles.SymbolSpecification; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ConvertAutoPropertyToFullProperty { public partial class ConvertAutoPropertyToFullPropertyTests : AbstractCSharpCodeActionTest { private OptionsCollection PreferExpressionBodiedAccessorsWhenPossible => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithSuggestionEnforcement } }; private OptionsCollection PreferExpressionBodiedAccessorsWhenOnSingleLine => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenOnSingleLineWithSilentEnforcement } }; private OptionsCollection DoNotPreferExpressionBodiedAccessors => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement } }; private OptionsCollection DoNotPreferExpressionBodiedAccessorsAndPropertyOpenBraceOnSameLine => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, { CSharpFormattingOptions2.NewLinesForBracesInProperties, false }, }; private OptionsCollection DoNotPreferExpressionBodiedAccessorsAndAccessorOpenBraceOnSameLine => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, { CSharpFormattingOptions2.NewLinesForBracesInAccessors, false }, }; private OptionsCollection PreferExpressionBodiesOnAccessorsAndMethods => new OptionsCollection(GetLanguage()) { { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithSilentEnforcement }, { CSharpCodeStyleOptions.PreferExpressionBodiedMethods, CSharpCodeStyleOptions.WhenPossibleWithSilentEnforcement }, }; private OptionsCollection UseCustomFieldName => new OptionsCollection(GetLanguage()) { { NamingStyleOptions.NamingPreferences, CreateCustomFieldNamingStylePreference() }, { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, }; private OptionsCollection UseUnderscorePrefixedFieldName => new OptionsCollection(GetLanguage()) { { NamingStyleOptions.NamingPreferences, CreateUnderscorePrefixedFieldNamingStylePreference() }, { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, }; private OptionsCollection UseCustomStaticFieldName => new OptionsCollection(GetLanguage()) { { NamingStyleOptions.NamingPreferences, CreateCustomStaticFieldNamingStylePreference() }, { CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.NeverWithSilentEnforcement }, }; private static NamingStylePreferences CreateCustomFieldNamingStylePreference() { var symbolSpecification = new SymbolSpecification( null, "Name", ImmutableArray.Create(new SymbolSpecification.SymbolKindOrTypeKind(SymbolKind.Field)), accessibilityList: default, modifiers: default); var namingStyle = new NamingStyle( Guid.NewGuid(), capitalizationScheme: Capitalization.PascalCase, name: "CustomFieldTest", prefix: "testing", suffix: "", wordSeparator: ""); var namingRule = new SerializableNamingRule() { SymbolSpecificationID = symbolSpecification.ID, NamingStyleID = namingStyle.ID, EnforcementLevel = ReportDiagnostic.Error }; var info = new NamingStylePreferences( ImmutableArray.Create(symbolSpecification), ImmutableArray.Create(namingStyle), ImmutableArray.Create(namingRule)); return info; } private static NamingStylePreferences CreateUnderscorePrefixedFieldNamingStylePreference() { var symbolSpecification = new SymbolSpecification( null, "Name", ImmutableArray.Create(new SymbolKindOrTypeKind(SymbolKind.Field)), accessibilityList: default, modifiers: default); var namingStyle = new NamingStyle( Guid.NewGuid(), capitalizationScheme: Capitalization.CamelCase, name: "CustomFieldTest", prefix: "_", suffix: "", wordSeparator: ""); var namingRule = new SerializableNamingRule() { SymbolSpecificationID = symbolSpecification.ID, NamingStyleID = namingStyle.ID, EnforcementLevel = ReportDiagnostic.Error }; var info = new NamingStylePreferences( ImmutableArray.Create(symbolSpecification), ImmutableArray.Create(namingStyle), ImmutableArray.Create(namingRule)); return info; } private static NamingStylePreferences CreateCustomStaticFieldNamingStylePreference() { var symbolSpecification = new SymbolSpecification( null, "Name", ImmutableArray.Create(new SymbolKindOrTypeKind(SymbolKind.Field)), accessibilityList: default, ImmutableArray.Create(new ModifierKind(DeclarationModifiers.Static))); var namingStyle = new NamingStyle( Guid.NewGuid(), capitalizationScheme: Capitalization.PascalCase, name: "CustomStaticFieldTest", prefix: "staticfieldtest", suffix: "", wordSeparator: ""); var namingRule = new SerializableNamingRule() { SymbolSpecificationID = symbolSpecification.ID, NamingStyleID = namingStyle.ID, EnforcementLevel = ReportDiagnostic.Error }; var info = new NamingStylePreferences( ImmutableArray.Create(symbolSpecification), ImmutableArray.Create(namingStyle), ImmutableArray.Create(namingRule)); return info; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/Completion/Providers/AbstractMemberInsertingCompletionProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeGeneration; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Simplification; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Completion.Providers { internal abstract partial class AbstractMemberInsertingCompletionProvider : LSPCompletionProvider { private readonly SyntaxAnnotation _annotation = new(); private readonly SyntaxAnnotation _otherAnnotation = new(); protected abstract SyntaxToken GetToken(CompletionItem completionItem, SyntaxTree tree, CancellationToken cancellationToken); protected abstract Task<ISymbol> GenerateMemberAsync(ISymbol member, INamedTypeSymbol containingType, Document document, CompletionItem item, CancellationToken cancellationToken); protected abstract int GetTargetCaretPosition(SyntaxNode caretTarget); protected abstract SyntaxNode GetSyntax(SyntaxToken commonSyntaxToken); public AbstractMemberInsertingCompletionProvider() { } public override async Task<CompletionChange> GetChangeAsync(Document document, CompletionItem item, char? commitKey = null, CancellationToken cancellationToken = default) { var newDocument = await DetermineNewDocumentAsync(document, item, cancellationToken).ConfigureAwait(false); var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); int? newPosition = null; // Attempt to find the inserted node and move the caret appropriately if (newRoot != null) { var caretTarget = newRoot.GetAnnotatedNodesAndTokens(_annotation).FirstOrNull(); if (caretTarget != null) { var targetPosition = GetTargetCaretPosition(caretTarget.Value.AsNode()); // Something weird happened and we failed to get a valid position. // Bail on moving the caret. if (targetPosition > 0 && targetPosition <= newText.Length) { newPosition = targetPosition; } } } var changes = await newDocument.GetTextChangesAsync(document, cancellationToken).ConfigureAwait(false); var changesArray = changes.ToImmutableArray(); var change = Utilities.Collapse(newText, changesArray); return CompletionChange.Create(change, changesArray, newPosition, includesCommitCharacter: true); } private async Task<Document> DetermineNewDocumentAsync(Document document, CompletionItem completionItem, CancellationToken cancellationToken) { var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); // The span we're going to replace var line = text.Lines[MemberInsertionCompletionItem.GetLine(completionItem)]; // Annotate the line we care about so we can find it after adding usings var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var token = GetToken(completionItem, tree, cancellationToken); var annotatedRoot = tree.GetRoot(cancellationToken).ReplaceToken(token, token.WithAdditionalAnnotations(_otherAnnotation)); document = document.WithSyntaxRoot(annotatedRoot); var memberContainingDocument = await GenerateMemberAndUsingsAsync(document, completionItem, line, cancellationToken).ConfigureAwait(false); if (memberContainingDocument == null) { // Generating the new document failed because we somehow couldn't resolve // the underlying symbol's SymbolKey. At this point, we won't be able to // make any changes, so just return the document we started with. return document; } var insertionRoot = await GetTreeWithAddedSyntaxNodeRemovedAsync(memberContainingDocument, cancellationToken).ConfigureAwait(false); var insertionText = await GenerateInsertionTextAsync(memberContainingDocument, cancellationToken).ConfigureAwait(false); var destinationSpan = ComputeDestinationSpan(insertionRoot); var finalText = insertionRoot.GetText(text.Encoding) .Replace(destinationSpan, insertionText.Trim()); document = document.WithText(finalText); var newRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var declaration = GetSyntax(newRoot.FindToken(destinationSpan.End)); document = document.WithSyntaxRoot(newRoot.ReplaceNode(declaration, declaration.WithAdditionalAnnotations(_annotation))); return await Formatter.FormatAsync(document, _annotation, cancellationToken: cancellationToken).ConfigureAwait(false); } private async Task<Document> GenerateMemberAndUsingsAsync( Document document, CompletionItem completionItem, TextLine line, CancellationToken cancellationToken) { var codeGenService = document.GetLanguageService<ICodeGenerationService>(); // Resolve member and type in our new, forked, solution var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var containingType = semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(line.Start, cancellationToken); var symbols = await SymbolCompletionItem.GetSymbolsAsync(completionItem, document, cancellationToken).ConfigureAwait(false); var overriddenMember = symbols.FirstOrDefault(); if (overriddenMember == null) { // Unfortunately, SymbolKey resolution failed. Bail. return null; } // CodeGenerationOptions containing before and after var options = new CodeGenerationOptions( contextLocation: semanticModel.SyntaxTree.GetLocation(TextSpan.FromBounds(line.Start, line.Start)), options: await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false)); var generatedMember = await GenerateMemberAsync(overriddenMember, containingType, document, completionItem, cancellationToken).ConfigureAwait(false); generatedMember = _annotation.AddAnnotationToSymbol(generatedMember); Document memberContainingDocument = null; if (generatedMember.Kind == SymbolKind.Method) { memberContainingDocument = await codeGenService.AddMethodAsync(document.Project.Solution, containingType, (IMethodSymbol)generatedMember, options, cancellationToken).ConfigureAwait(false); } else if (generatedMember.Kind == SymbolKind.Property) { memberContainingDocument = await codeGenService.AddPropertyAsync(document.Project.Solution, containingType, (IPropertySymbol)generatedMember, options, cancellationToken).ConfigureAwait(false); } else if (generatedMember.Kind == SymbolKind.Event) { memberContainingDocument = await codeGenService.AddEventAsync(document.Project.Solution, containingType, (IEventSymbol)generatedMember, options, cancellationToken).ConfigureAwait(false); } return memberContainingDocument; } private TextSpan ComputeDestinationSpan(SyntaxNode insertionRoot) { var targetToken = insertionRoot.GetAnnotatedTokens(_otherAnnotation).FirstOrNull(); var text = insertionRoot.GetText(); var line = text.Lines.GetLineFromPosition(targetToken.Value.Span.End); // DevDiv 958235: // // void goo() // { // } // override $$ // // If our text edit includes the trailing trivia of the close brace of goo(), // that token will be reconstructed. The ensuing tree diff will then count // the { } as replaced even though we didn't want it to. If the user // has collapsed the outline for goo, that means we'll edit the outlined // region and weird stuff will happen. Therefore, we'll start with the first // token on the line in order to leave the token and its trivia alone. var firstToken = insertionRoot.FindToken(line.GetFirstNonWhitespacePosition().Value); return TextSpan.FromBounds(firstToken.SpanStart, line.End); } private async Task<string> GenerateInsertionTextAsync( Document memberContainingDocument, CancellationToken cancellationToken) { memberContainingDocument = await Simplifier.ReduceAsync(memberContainingDocument, Simplifier.Annotation, optionSet: null, cancellationToken).ConfigureAwait(false); memberContainingDocument = await Formatter.FormatAsync(memberContainingDocument, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false); var root = await memberContainingDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); return root.GetAnnotatedNodesAndTokens(_annotation).Single().AsNode().ToString().Trim(); } private async Task<SyntaxNode> GetTreeWithAddedSyntaxNodeRemovedAsync( Document document, CancellationToken cancellationToken) { // Added imports are annotated for simplification too. Therefore, we simplify the document // before removing added member node to preserve those imports in the document. document = await Simplifier.ReduceAsync(document, Simplifier.Annotation, optionSet: null, cancellationToken).ConfigureAwait(false); var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var members = root.GetAnnotatedNodesAndTokens(_annotation) .AsImmutable() .Select(m => m.AsNode()); root = root.RemoveNodes(members, SyntaxRemoveOptions.KeepUnbalancedDirectives); var dismemberedDocument = document.WithSyntaxRoot(root); dismemberedDocument = await Formatter.FormatAsync(dismemberedDocument, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false); return await dismemberedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); } private static readonly ImmutableArray<CharacterSetModificationRule> s_commitRules = ImmutableArray.Create( CharacterSetModificationRule.Create(CharacterSetModificationKind.Replace, '(')); private static readonly ImmutableArray<CharacterSetModificationRule> s_filterRules = ImmutableArray.Create( CharacterSetModificationRule.Create(CharacterSetModificationKind.Remove, '(')); private static readonly CompletionItemRules s_defaultRules = CompletionItemRules.Create( commitCharacterRules: s_commitRules, filterCharacterRules: s_filterRules, enterKeyRule: EnterKeyRule.Never); protected static CompletionItemRules GetRules() => s_defaultRules; protected override Task<CompletionDescription> GetDescriptionWorkerAsync(Document document, CompletionItem item, CancellationToken cancellationToken) => MemberInsertionCompletionItem.GetDescriptionAsync(item, document, cancellationToken); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeGeneration; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Simplification; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Completion.Providers { internal abstract partial class AbstractMemberInsertingCompletionProvider : LSPCompletionProvider { private readonly SyntaxAnnotation _annotation = new(); private readonly SyntaxAnnotation _otherAnnotation = new(); protected abstract SyntaxToken GetToken(CompletionItem completionItem, SyntaxTree tree, CancellationToken cancellationToken); protected abstract Task<ISymbol> GenerateMemberAsync(ISymbol member, INamedTypeSymbol containingType, Document document, CompletionItem item, CancellationToken cancellationToken); protected abstract int GetTargetCaretPosition(SyntaxNode caretTarget); protected abstract SyntaxNode GetSyntax(SyntaxToken commonSyntaxToken); public AbstractMemberInsertingCompletionProvider() { } public override async Task<CompletionChange> GetChangeAsync(Document document, CompletionItem item, char? commitKey = null, CancellationToken cancellationToken = default) { var newDocument = await DetermineNewDocumentAsync(document, item, cancellationToken).ConfigureAwait(false); var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); int? newPosition = null; // Attempt to find the inserted node and move the caret appropriately if (newRoot != null) { var caretTarget = newRoot.GetAnnotatedNodesAndTokens(_annotation).FirstOrNull(); if (caretTarget != null) { var targetPosition = GetTargetCaretPosition(caretTarget.Value.AsNode()); // Something weird happened and we failed to get a valid position. // Bail on moving the caret. if (targetPosition > 0 && targetPosition <= newText.Length) { newPosition = targetPosition; } } } var changes = await newDocument.GetTextChangesAsync(document, cancellationToken).ConfigureAwait(false); var changesArray = changes.ToImmutableArray(); var change = Utilities.Collapse(newText, changesArray); return CompletionChange.Create(change, changesArray, newPosition, includesCommitCharacter: true); } private async Task<Document> DetermineNewDocumentAsync(Document document, CompletionItem completionItem, CancellationToken cancellationToken) { var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); // The span we're going to replace var line = text.Lines[MemberInsertionCompletionItem.GetLine(completionItem)]; // Annotate the line we care about so we can find it after adding usings var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var token = GetToken(completionItem, tree, cancellationToken); var annotatedRoot = tree.GetRoot(cancellationToken).ReplaceToken(token, token.WithAdditionalAnnotations(_otherAnnotation)); document = document.WithSyntaxRoot(annotatedRoot); var memberContainingDocument = await GenerateMemberAndUsingsAsync(document, completionItem, line, cancellationToken).ConfigureAwait(false); if (memberContainingDocument == null) { // Generating the new document failed because we somehow couldn't resolve // the underlying symbol's SymbolKey. At this point, we won't be able to // make any changes, so just return the document we started with. return document; } var insertionRoot = await GetTreeWithAddedSyntaxNodeRemovedAsync(memberContainingDocument, cancellationToken).ConfigureAwait(false); var insertionText = await GenerateInsertionTextAsync(memberContainingDocument, cancellationToken).ConfigureAwait(false); var destinationSpan = ComputeDestinationSpan(insertionRoot); var finalText = insertionRoot.GetText(text.Encoding) .Replace(destinationSpan, insertionText.Trim()); document = document.WithText(finalText); var newRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var declaration = GetSyntax(newRoot.FindToken(destinationSpan.End)); document = document.WithSyntaxRoot(newRoot.ReplaceNode(declaration, declaration.WithAdditionalAnnotations(_annotation))); return await Formatter.FormatAsync(document, _annotation, cancellationToken: cancellationToken).ConfigureAwait(false); } private async Task<Document> GenerateMemberAndUsingsAsync( Document document, CompletionItem completionItem, TextLine line, CancellationToken cancellationToken) { var codeGenService = document.GetLanguageService<ICodeGenerationService>(); // Resolve member and type in our new, forked, solution var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var containingType = semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(line.Start, cancellationToken); var symbols = await SymbolCompletionItem.GetSymbolsAsync(completionItem, document, cancellationToken).ConfigureAwait(false); var overriddenMember = symbols.FirstOrDefault(); if (overriddenMember == null) { // Unfortunately, SymbolKey resolution failed. Bail. return null; } // CodeGenerationOptions containing before and after var options = new CodeGenerationOptions( contextLocation: semanticModel.SyntaxTree.GetLocation(TextSpan.FromBounds(line.Start, line.Start)), options: await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false)); var generatedMember = await GenerateMemberAsync(overriddenMember, containingType, document, completionItem, cancellationToken).ConfigureAwait(false); generatedMember = _annotation.AddAnnotationToSymbol(generatedMember); Document memberContainingDocument = null; if (generatedMember.Kind == SymbolKind.Method) { memberContainingDocument = await codeGenService.AddMethodAsync(document.Project.Solution, containingType, (IMethodSymbol)generatedMember, options, cancellationToken).ConfigureAwait(false); } else if (generatedMember.Kind == SymbolKind.Property) { memberContainingDocument = await codeGenService.AddPropertyAsync(document.Project.Solution, containingType, (IPropertySymbol)generatedMember, options, cancellationToken).ConfigureAwait(false); } else if (generatedMember.Kind == SymbolKind.Event) { memberContainingDocument = await codeGenService.AddEventAsync(document.Project.Solution, containingType, (IEventSymbol)generatedMember, options, cancellationToken).ConfigureAwait(false); } return memberContainingDocument; } private TextSpan ComputeDestinationSpan(SyntaxNode insertionRoot) { var targetToken = insertionRoot.GetAnnotatedTokens(_otherAnnotation).FirstOrNull(); var text = insertionRoot.GetText(); var line = text.Lines.GetLineFromPosition(targetToken.Value.Span.End); // DevDiv 958235: // // void goo() // { // } // override $$ // // If our text edit includes the trailing trivia of the close brace of goo(), // that token will be reconstructed. The ensuing tree diff will then count // the { } as replaced even though we didn't want it to. If the user // has collapsed the outline for goo, that means we'll edit the outlined // region and weird stuff will happen. Therefore, we'll start with the first // token on the line in order to leave the token and its trivia alone. var firstToken = insertionRoot.FindToken(line.GetFirstNonWhitespacePosition().Value); return TextSpan.FromBounds(firstToken.SpanStart, line.End); } private async Task<string> GenerateInsertionTextAsync( Document memberContainingDocument, CancellationToken cancellationToken) { memberContainingDocument = await Simplifier.ReduceAsync(memberContainingDocument, Simplifier.Annotation, optionSet: null, cancellationToken).ConfigureAwait(false); memberContainingDocument = await Formatter.FormatAsync(memberContainingDocument, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false); var root = await memberContainingDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); return root.GetAnnotatedNodesAndTokens(_annotation).Single().AsNode().ToString().Trim(); } private async Task<SyntaxNode> GetTreeWithAddedSyntaxNodeRemovedAsync( Document document, CancellationToken cancellationToken) { // Added imports are annotated for simplification too. Therefore, we simplify the document // before removing added member node to preserve those imports in the document. document = await Simplifier.ReduceAsync(document, Simplifier.Annotation, optionSet: null, cancellationToken).ConfigureAwait(false); var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var members = root.GetAnnotatedNodesAndTokens(_annotation) .AsImmutable() .Select(m => m.AsNode()); root = root.RemoveNodes(members, SyntaxRemoveOptions.KeepUnbalancedDirectives); var dismemberedDocument = document.WithSyntaxRoot(root); dismemberedDocument = await Formatter.FormatAsync(dismemberedDocument, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false); return await dismemberedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); } private static readonly ImmutableArray<CharacterSetModificationRule> s_commitRules = ImmutableArray.Create( CharacterSetModificationRule.Create(CharacterSetModificationKind.Replace, '(')); private static readonly ImmutableArray<CharacterSetModificationRule> s_filterRules = ImmutableArray.Create( CharacterSetModificationRule.Create(CharacterSetModificationKind.Remove, '(')); private static readonly CompletionItemRules s_defaultRules = CompletionItemRules.Create( commitCharacterRules: s_commitRules, filterCharacterRules: s_filterRules, enterKeyRule: EnterKeyRule.Never); protected static CompletionItemRules GetRules() => s_defaultRules; protected override Task<CompletionDescription> GetDescriptionWorkerAsync(Document document, CompletionItem item, CancellationToken cancellationToken) => MemberInsertionCompletionItem.GetDescriptionAsync(item, document, cancellationToken); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/Diagnostics/IAnalyzerDriverService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Diagnostics { internal interface IAnalyzerDriverService : ILanguageService { /// <summary> /// Computes the <see cref="DeclarationInfo"/> for all the declarations whose span overlaps with the given <paramref name="span"/>. /// </summary> /// <param name="model">The semantic model for the document.</param> /// <param name="span">Span to get declarations.</param> /// <param name="getSymbol">Flag indicating whether <see cref="DeclarationInfo.DeclaredSymbol"/> should be computed for the returned declaration infos. /// If false, then <see cref="DeclarationInfo.DeclaredSymbol"/> is always null.</param> /// <param name="builder">Builder to add computed declarations.</param> /// <param name="cancellationToken">Cancellation token.</param> void ComputeDeclarationsInSpan(SemanticModel model, TextSpan span, bool getSymbol, ArrayBuilder<DeclarationInfo> builder, CancellationToken cancellationToken); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Diagnostics { internal interface IAnalyzerDriverService : ILanguageService { /// <summary> /// Computes the <see cref="DeclarationInfo"/> for all the declarations whose span overlaps with the given <paramref name="span"/>. /// </summary> /// <param name="model">The semantic model for the document.</param> /// <param name="span">Span to get declarations.</param> /// <param name="getSymbol">Flag indicating whether <see cref="DeclarationInfo.DeclaredSymbol"/> should be computed for the returned declaration infos. /// If false, then <see cref="DeclarationInfo.DeclaredSymbol"/> is always null.</param> /// <param name="builder">Builder to add computed declarations.</param> /// <param name="cancellationToken">Cancellation token.</param> void ComputeDeclarationsInSpan(SemanticModel model, TextSpan span, bool getSymbol, ArrayBuilder<DeclarationInfo> builder, CancellationToken cancellationToken); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Core/Portable/Symbols/INamespaceSymbol.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis { /// <summary> /// Represents a namespace. /// </summary> /// <remarks> /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// </remarks> public interface INamespaceSymbol : INamespaceOrTypeSymbol { /// <summary> /// Get all the members of this symbol. /// </summary> new IEnumerable<INamespaceOrTypeSymbol> GetMembers(); /// <summary> /// Get all the members of this symbol that have a particular name. /// </summary> new IEnumerable<INamespaceOrTypeSymbol> GetMembers(string name); /// <summary> /// Get all the members of this symbol that are namespaces. /// </summary> IEnumerable<INamespaceSymbol> GetNamespaceMembers(); /// <summary> /// Returns whether this namespace is the unnamed, global namespace that is /// at the root of all namespaces. /// </summary> bool IsGlobalNamespace { get; } /// <summary> /// The kind of namespace: Module, Assembly or Compilation. /// Module namespaces contain only members from the containing module that share the same namespace name. /// Assembly namespaces contain members for all modules in the containing assembly that share the same namespace name. /// Compilation namespaces contain all members, from source or referenced metadata (assemblies and modules) that share the same namespace name. /// </summary> NamespaceKind NamespaceKind { get; } /// <summary> /// The containing compilation for compilation namespaces. /// </summary> Compilation? ContainingCompilation { get; } /// <summary> /// If a namespace is an assembly or compilation namespace, it may be composed of multiple /// namespaces that are merged together. If so, ConstituentNamespaces returns /// all the namespaces that were merged. If this namespace was not merged, returns /// an array containing only this namespace. /// </summary> ImmutableArray<INamespaceSymbol> ConstituentNamespaces { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis { /// <summary> /// Represents a namespace. /// </summary> /// <remarks> /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// </remarks> public interface INamespaceSymbol : INamespaceOrTypeSymbol { /// <summary> /// Get all the members of this symbol. /// </summary> new IEnumerable<INamespaceOrTypeSymbol> GetMembers(); /// <summary> /// Get all the members of this symbol that have a particular name. /// </summary> new IEnumerable<INamespaceOrTypeSymbol> GetMembers(string name); /// <summary> /// Get all the members of this symbol that are namespaces. /// </summary> IEnumerable<INamespaceSymbol> GetNamespaceMembers(); /// <summary> /// Returns whether this namespace is the unnamed, global namespace that is /// at the root of all namespaces. /// </summary> bool IsGlobalNamespace { get; } /// <summary> /// The kind of namespace: Module, Assembly or Compilation. /// Module namespaces contain only members from the containing module that share the same namespace name. /// Assembly namespaces contain members for all modules in the containing assembly that share the same namespace name. /// Compilation namespaces contain all members, from source or referenced metadata (assemblies and modules) that share the same namespace name. /// </summary> NamespaceKind NamespaceKind { get; } /// <summary> /// The containing compilation for compilation namespaces. /// </summary> Compilation? ContainingCompilation { get; } /// <summary> /// If a namespace is an assembly or compilation namespace, it may be composed of multiple /// namespaces that are merged together. If so, ConstituentNamespaces returns /// all the namespaces that were merged. If this namespace was not merged, returns /// an array containing only this namespace. /// </summary> ImmutableArray<INamespaceSymbol> ConstituentNamespaces { get; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputFilePaths.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis { /// <summary> /// Paths of files produced by the compilation. /// </summary> public readonly struct CompilationOutputInfo : IEquatable<CompilationOutputInfo>, IObjectWritable { /// <summary> /// Full path to the assembly or module produced by the compilation, or <see langword="null"/> if unknown. /// </summary> public readonly string? AssemblyPath { get; } bool IObjectWritable.ShouldReuseInSerialization => throw new NotImplementedException(); // TODO: https://github.com/dotnet/roslyn/issues/35065 // The project system doesn't currently provide paths to the PDB or XML files that the compiler produces. // public readonly string? PdbPath { get; } // public readonly string? DocumentationCommentsPath { get; } internal CompilationOutputInfo(string? assemblyPath) { AssemblyPath = assemblyPath; } #pragma warning disable CA1822 // Mark members as static - unshipped public API which will use instance members in future https://github.com/dotnet/roslyn/issues/35065 public CompilationOutputInfo WithAssemblyPath(string? path) #pragma warning restore CA1822 // Mark members as static => new(assemblyPath: path); public override bool Equals(object? obj) => obj is CompilationOutputInfo info && Equals(info); public bool Equals(CompilationOutputInfo other) => AssemblyPath == other.AssemblyPath; public override int GetHashCode() => AssemblyPath?.GetHashCode() ?? 0; public static bool operator ==(in CompilationOutputInfo left, in CompilationOutputInfo right) => left.Equals(right); public static bool operator !=(in CompilationOutputInfo left, in CompilationOutputInfo right) => !left.Equals(right); void IObjectWritable.WriteTo(ObjectWriter writer) { writer.WriteString(AssemblyPath); } internal static CompilationOutputInfo ReadFrom(ObjectReader reader) { var assemblyPath = reader.ReadString(); return new CompilationOutputInfo(assemblyPath); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis { /// <summary> /// Paths of files produced by the compilation. /// </summary> public readonly struct CompilationOutputInfo : IEquatable<CompilationOutputInfo>, IObjectWritable { /// <summary> /// Full path to the assembly or module produced by the compilation, or <see langword="null"/> if unknown. /// </summary> public readonly string? AssemblyPath { get; } bool IObjectWritable.ShouldReuseInSerialization => throw new NotImplementedException(); // TODO: https://github.com/dotnet/roslyn/issues/35065 // The project system doesn't currently provide paths to the PDB or XML files that the compiler produces. // public readonly string? PdbPath { get; } // public readonly string? DocumentationCommentsPath { get; } internal CompilationOutputInfo(string? assemblyPath) { AssemblyPath = assemblyPath; } #pragma warning disable CA1822 // Mark members as static - unshipped public API which will use instance members in future https://github.com/dotnet/roslyn/issues/35065 public CompilationOutputInfo WithAssemblyPath(string? path) #pragma warning restore CA1822 // Mark members as static => new(assemblyPath: path); public override bool Equals(object? obj) => obj is CompilationOutputInfo info && Equals(info); public bool Equals(CompilationOutputInfo other) => AssemblyPath == other.AssemblyPath; public override int GetHashCode() => AssemblyPath?.GetHashCode() ?? 0; public static bool operator ==(in CompilationOutputInfo left, in CompilationOutputInfo right) => left.Equals(right); public static bool operator !=(in CompilationOutputInfo left, in CompilationOutputInfo right) => !left.Equals(right); void IObjectWritable.WriteTo(ObjectWriter writer) { writer.WriteString(AssemblyPath); } internal static CompilationOutputInfo ReadFrom(ObjectReader reader) { var assemblyPath = reader.ReadString(); return new CompilationOutputInfo(assemblyPath); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxToken.SyntaxIdentifierExtended.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax { internal partial class SyntaxToken { internal class SyntaxIdentifierExtended : SyntaxIdentifier { protected readonly SyntaxKind contextualKind; protected readonly string valueText; internal SyntaxIdentifierExtended(SyntaxKind contextualKind, string text, string valueText) : base(text) { this.contextualKind = contextualKind; this.valueText = valueText; } internal SyntaxIdentifierExtended(SyntaxKind contextualKind, string text, string valueText, DiagnosticInfo[] diagnostics, SyntaxAnnotation[] annotations) : base(text, diagnostics, annotations) { this.contextualKind = contextualKind; this.valueText = valueText; } internal SyntaxIdentifierExtended(ObjectReader reader) : base(reader) { this.contextualKind = (SyntaxKind)reader.ReadInt16(); this.valueText = reader.ReadString(); } static SyntaxIdentifierExtended() { ObjectBinder.RegisterTypeReader(typeof(SyntaxIdentifierExtended), r => new SyntaxIdentifierExtended(r)); } internal override void WriteTo(ObjectWriter writer) { base.WriteTo(writer); writer.WriteInt16((short)this.contextualKind); writer.WriteString(this.valueText); } public override SyntaxKind ContextualKind { get { return this.contextualKind; } } public override string ValueText { get { return this.valueText; } } public override object Value { get { return this.valueText; } } public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) { return new SyntaxIdentifierWithTrivia(this.contextualKind, this.TextField, this.valueText, trivia, null, this.GetDiagnostics(), this.GetAnnotations()); } public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia) { return new SyntaxIdentifierWithTrivia(this.contextualKind, this.TextField, this.valueText, null, trivia, this.GetDiagnostics(), this.GetAnnotations()); } internal override GreenNode SetDiagnostics(DiagnosticInfo[] diagnostics) { return new SyntaxIdentifierExtended(this.contextualKind, this.TextField, this.valueText, diagnostics, this.GetAnnotations()); } internal override GreenNode SetAnnotations(SyntaxAnnotation[] annotations) { return new SyntaxIdentifierExtended(this.contextualKind, this.TextField, this.valueText, this.GetDiagnostics(), annotations); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax { internal partial class SyntaxToken { internal class SyntaxIdentifierExtended : SyntaxIdentifier { protected readonly SyntaxKind contextualKind; protected readonly string valueText; internal SyntaxIdentifierExtended(SyntaxKind contextualKind, string text, string valueText) : base(text) { this.contextualKind = contextualKind; this.valueText = valueText; } internal SyntaxIdentifierExtended(SyntaxKind contextualKind, string text, string valueText, DiagnosticInfo[] diagnostics, SyntaxAnnotation[] annotations) : base(text, diagnostics, annotations) { this.contextualKind = contextualKind; this.valueText = valueText; } internal SyntaxIdentifierExtended(ObjectReader reader) : base(reader) { this.contextualKind = (SyntaxKind)reader.ReadInt16(); this.valueText = reader.ReadString(); } static SyntaxIdentifierExtended() { ObjectBinder.RegisterTypeReader(typeof(SyntaxIdentifierExtended), r => new SyntaxIdentifierExtended(r)); } internal override void WriteTo(ObjectWriter writer) { base.WriteTo(writer); writer.WriteInt16((short)this.contextualKind); writer.WriteString(this.valueText); } public override SyntaxKind ContextualKind { get { return this.contextualKind; } } public override string ValueText { get { return this.valueText; } } public override object Value { get { return this.valueText; } } public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) { return new SyntaxIdentifierWithTrivia(this.contextualKind, this.TextField, this.valueText, trivia, null, this.GetDiagnostics(), this.GetAnnotations()); } public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia) { return new SyntaxIdentifierWithTrivia(this.contextualKind, this.TextField, this.valueText, null, trivia, this.GetDiagnostics(), this.GetAnnotations()); } internal override GreenNode SetDiagnostics(DiagnosticInfo[] diagnostics) { return new SyntaxIdentifierExtended(this.contextualKind, this.TextField, this.valueText, diagnostics, this.GetAnnotations()); } internal override GreenNode SetAnnotations(SyntaxAnnotation[] annotations) { return new SyntaxIdentifierExtended(this.contextualKind, this.TextField, this.valueText, this.GetDiagnostics(), annotations); } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Workspace/Solution/ChecksumWithChildren.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Linq; namespace Microsoft.CodeAnalysis.Serialization { /// <summary> /// this is a collection that has its own checksum and contains only checksum or checksum collection as its children. /// </summary> internal abstract class ChecksumWithChildren : IChecksummedObject { public ChecksumWithChildren(object[] children) { Checksum = CreateChecksum(children); Children = children; } public Checksum Checksum { get; } public IReadOnlyList<object> Children { get; } private static Checksum CreateChecksum(object[] children) { // given children must be either Checksum or Checksums (collection of a checksum) return Checksum.Create(children.Select(c => c as Checksum ?? ((ChecksumCollection)c).Checksum)); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Linq; namespace Microsoft.CodeAnalysis.Serialization { /// <summary> /// this is a collection that has its own checksum and contains only checksum or checksum collection as its children. /// </summary> internal abstract class ChecksumWithChildren : IChecksummedObject { public ChecksumWithChildren(object[] children) { Checksum = CreateChecksum(children); Children = children; } public Checksum Checksum { get; } public IReadOnlyList<object> Children { get; } private static Checksum CreateChecksum(object[] children) { // given children must be either Checksum or Checksums (collection of a checksum) return Checksum.Create(children.Select(c => c as Checksum ?? ((ChecksumCollection)c).Checksum)); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/UnusedReferences/ReferenceUpdate.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.UnusedReferences { internal sealed class ReferenceUpdate { /// <summary> /// Indicates action to perform on the reference. /// </summary> public UpdateAction Action { get; set; } /// <summary> /// Gets the reference to be updated. /// </summary> public ReferenceInfo ReferenceInfo { get; } public ReferenceUpdate(UpdateAction action, ReferenceInfo referenceInfo) { Action = action; ReferenceInfo = referenceInfo; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.UnusedReferences { internal sealed class ReferenceUpdate { /// <summary> /// Indicates action to perform on the reference. /// </summary> public UpdateAction Action { get; set; } /// <summary> /// Gets the reference to be updated. /// </summary> public ReferenceInfo ReferenceInfo { get; } public ReferenceUpdate(UpdateAction action, ReferenceInfo referenceInfo) { Action = action; ReferenceInfo = referenceInfo; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/CSharp/Impl/CodeModel/ParameterFlags.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; namespace Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel { [Flags] internal enum ParameterFlags { Ref = 1 << 0, Out = 1 << 1, Params = 1 << 2 } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; namespace Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel { [Flags] internal enum ParameterFlags { Ref = 1 << 0, Out = 1 << 1, Params = 1 << 2 } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest/Structure/TypeDeclarationStructureTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Structure; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure { public class TypeDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<TypeDeclarationSyntax> { internal override AbstractSyntaxStructureProvider CreateProvider() => new TypeDeclarationStructureProvider(); [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestClass1() { const string code = @" {|hint:$$class C{|textspan: { }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestClass2(string typeKind) { var code = $@" {{|hint:$$class C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestClass3(string typeKind) { var code = $@" {{|hint:$$class C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestClassWithLeadingComments() { const string code = @" {|span1:// Goo // Bar|} {|hint2:$$class C{|textspan2: { }|}|}"; await VerifyBlockSpansAsync(code, Region("span1", "// Goo ...", autoCollapse: true), Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestClassWithNestedComments() { const string code = @" {|hint1:$$class C{|textspan1: { {|span2:// Goo // Bar|} }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestInterface1() { const string code = @" {|hint:$$interface I{|textspan: { }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestInterface2(string typeKind) { var code = $@" {{|hint:$$interface I{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestInterface3(string typeKind) { var code = $@" {{|hint:$$interface I{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestInterfaceWithLeadingComments() { const string code = @" {|span1:// Goo // Bar|} {|hint2:$$interface I{|textspan2: { }|}|}"; await VerifyBlockSpansAsync(code, Region("span1", "// Goo ...", autoCollapse: true), Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestInterfaceWithNestedComments() { const string code = @" {|hint1:$$interface I{|textspan1: { {|span2:// Goo // Bar|} }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestStruct1() { const string code = @" {|hint:$$struct S{|textspan: { }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestStruct2(string typeKind) { var code = $@" {{|hint:$$struct C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestStruct3(string typeKind) { var code = $@" {{|hint:$$struct C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestStructWithLeadingComments() { const string code = @" {|span1:// Goo // Bar|} {|hint2:$$struct S{|textspan2: { }|}|}"; await VerifyBlockSpansAsync(code, Region("span1", "// Goo ...", autoCollapse: true), Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestStructWithNestedComments() { const string code = @" {|hint1:$$struct S{|textspan1: { {|span2:// Goo // Bar|} }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Structure; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure { public class TypeDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<TypeDeclarationSyntax> { internal override AbstractSyntaxStructureProvider CreateProvider() => new TypeDeclarationStructureProvider(); [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestClass1() { const string code = @" {|hint:$$class C{|textspan: { }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestClass2(string typeKind) { var code = $@" {{|hint:$$class C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestClass3(string typeKind) { var code = $@" {{|hint:$$class C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestClassWithLeadingComments() { const string code = @" {|span1:// Goo // Bar|} {|hint2:$$class C{|textspan2: { }|}|}"; await VerifyBlockSpansAsync(code, Region("span1", "// Goo ...", autoCollapse: true), Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestClassWithNestedComments() { const string code = @" {|hint1:$$class C{|textspan1: { {|span2:// Goo // Bar|} }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestInterface1() { const string code = @" {|hint:$$interface I{|textspan: { }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestInterface2(string typeKind) { var code = $@" {{|hint:$$interface I{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestInterface3(string typeKind) { var code = $@" {{|hint:$$interface I{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestInterfaceWithLeadingComments() { const string code = @" {|span1:// Goo // Bar|} {|hint2:$$interface I{|textspan2: { }|}|}"; await VerifyBlockSpansAsync(code, Region("span1", "// Goo ...", autoCollapse: true), Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestInterfaceWithNestedComments() { const string code = @" {|hint1:$$interface I{|textspan1: { {|span2:// Goo // Bar|} }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestStruct1() { const string code = @" {|hint:$$struct S{|textspan: { }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestStruct2(string typeKind) { var code = $@" {{|hint:$$struct C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Theory, Trait(Traits.Feature, Traits.Features.Outlining)] [InlineData("enum")] [InlineData("class")] [InlineData("struct")] [InlineData("interface")] public async Task TestStruct3(string typeKind) { var code = $@" {{|hint:$$struct C{{|textspan: {{ }}|}}|}} {typeKind}D {{ }}"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestStructWithLeadingComments() { const string code = @" {|span1:// Goo // Bar|} {|hint2:$$struct S{|textspan2: { }|}|}"; await VerifyBlockSpansAsync(code, Region("span1", "// Goo ...", autoCollapse: true), Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } [Fact, Trait(Traits.Feature, Traits.Features.Outlining)] public async Task TestStructWithNestedComments() { const string code = @" {|hint1:$$struct S{|textspan1: { {|span2:// Goo // Bar|} }|}|}"; await VerifyBlockSpansAsync(code, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Editing/ImportAdder.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editing { public static class ImportAdder { /// <summary> /// Adds namespace imports / using directives for namespace references found in the document. /// </summary> public static Task<Document> AddImportsAsync(Document document, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the span specified. /// </summary> public static Task<Document> AddImportsAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, new[] { span }, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the sub-trees annotated with the <see cref="SyntaxAnnotation"/>. /// </summary> public static Task<Document> AddImportsAsync(Document document, SyntaxAnnotation annotation, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, annotation, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the spans specified. /// </summary> public static Task<Document> AddImportsAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, spans, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document. /// </summary> internal static async Task<Document> AddImportsFromSyntaxesAsync(Document document, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSyntaxesAsync(document, root.FullSpan, options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the span specified. /// </summary> internal static Task<Document> AddImportsFromSyntaxesAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, new[] { span }, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the sub-trees annotated with the <see cref="SyntaxAnnotation"/>. /// </summary> internal static async Task<Document> AddImportsFromSyntaxesAsync(Document document, SyntaxAnnotation annotation, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSyntaxesAsync(document, root.GetAnnotatedNodesAndTokens(annotation).Select(t => t.FullSpan), options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the spans specified. /// </summary> internal static Task<Document> AddImportsFromSyntaxesAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default) { var service = document.GetLanguageService<ImportAdderService>(); if (service != null) { return service.AddImportsAsync(document, spans, ImportAdderService.Strategy.AddImportsFromSyntaxes, options, cancellationToken); } else { return Task.FromResult(document); } } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document. /// </summary> internal static async Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSymbolAnnotationAsync(document, root.FullSpan, options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the span specified. /// </summary> internal static Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSymbolAnnotationAsync(document, new[] { span }, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the sub-trees annotated with the <see cref="SyntaxAnnotation"/>. /// </summary> internal static async Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, SyntaxAnnotation annotation, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSymbolAnnotationAsync(document, root.GetAnnotatedNodesAndTokens(annotation).Select(t => t.FullSpan), options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the spans specified. /// </summary> internal static Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default) { var service = document.GetLanguageService<ImportAdderService>(); if (service != null) { return service.AddImportsAsync(document, spans, ImportAdderService.Strategy.AddImportsFromSymbolAnnotations, options, cancellationToken); } else { return Task.FromResult(document); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editing { public static class ImportAdder { /// <summary> /// Adds namespace imports / using directives for namespace references found in the document. /// </summary> public static Task<Document> AddImportsAsync(Document document, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the span specified. /// </summary> public static Task<Document> AddImportsAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, new[] { span }, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the sub-trees annotated with the <see cref="SyntaxAnnotation"/>. /// </summary> public static Task<Document> AddImportsAsync(Document document, SyntaxAnnotation annotation, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, annotation, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the spans specified. /// </summary> public static Task<Document> AddImportsAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, spans, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document. /// </summary> internal static async Task<Document> AddImportsFromSyntaxesAsync(Document document, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSyntaxesAsync(document, root.FullSpan, options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the span specified. /// </summary> internal static Task<Document> AddImportsFromSyntaxesAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSyntaxesAsync(document, new[] { span }, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the sub-trees annotated with the <see cref="SyntaxAnnotation"/>. /// </summary> internal static async Task<Document> AddImportsFromSyntaxesAsync(Document document, SyntaxAnnotation annotation, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSyntaxesAsync(document, root.GetAnnotatedNodesAndTokens(annotation).Select(t => t.FullSpan), options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the spans specified. /// </summary> internal static Task<Document> AddImportsFromSyntaxesAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default) { var service = document.GetLanguageService<ImportAdderService>(); if (service != null) { return service.AddImportsAsync(document, spans, ImportAdderService.Strategy.AddImportsFromSyntaxes, options, cancellationToken); } else { return Task.FromResult(document); } } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document. /// </summary> internal static async Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSymbolAnnotationAsync(document, root.FullSpan, options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the span specified. /// </summary> internal static Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default) => AddImportsFromSymbolAnnotationAsync(document, new[] { span }, options, cancellationToken); /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the sub-trees annotated with the <see cref="SyntaxAnnotation"/>. /// </summary> internal static async Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, SyntaxAnnotation annotation, OptionSet? options = null, CancellationToken cancellationToken = default) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(root); return await AddImportsFromSymbolAnnotationAsync(document, root.GetAnnotatedNodesAndTokens(annotation).Select(t => t.FullSpan), options, cancellationToken).ConfigureAwait(false); } /// <summary> /// Adds namespace imports / using directives for namespace references found in the document within the spans specified. /// </summary> internal static Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default) { var service = document.GetLanguageService<ImportAdderService>(); if (service != null) { return service.AddImportsAsync(document, spans, ImportAdderService.Strategy.AddImportsFromSymbolAnnotations, options, cancellationToken); } else { return Task.FromResult(document); } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Core/Portable/Operations/ControlFlowGraph.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.Operations; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.FlowAnalysis { /// <summary> /// Control flow graph representation for a given executable code block <see cref="OriginalOperation"/>. /// This graph contains a set of <see cref="BasicBlock"/>s, with an entry block, zero /// or more intermediate basic blocks and an exit block. /// Each basic block contains zero or more <see cref="BasicBlock.Operations"/> and /// explicit <see cref="ControlFlowBranch"/>(s) to other basic block(s). /// </summary> public sealed partial class ControlFlowGraph { private readonly ControlFlowGraphBuilder.CaptureIdDispenser _captureIdDispenser; private readonly ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)> _localFunctionsMap; private ControlFlowGraph?[]? _lazyLocalFunctionsGraphs; private readonly ImmutableDictionary<IFlowAnonymousFunctionOperation, (ControlFlowRegion region, int ordinal)> _anonymousFunctionsMap; private ControlFlowGraph?[]? _lazyAnonymousFunctionsGraphs; internal ControlFlowGraph(IOperation originalOperation, ControlFlowGraph? parent, ControlFlowGraphBuilder.CaptureIdDispenser captureIdDispenser, ImmutableArray<BasicBlock> blocks, ControlFlowRegion root, ImmutableArray<IMethodSymbol> localFunctions, ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)> localFunctionsMap, ImmutableDictionary<IFlowAnonymousFunctionOperation, (ControlFlowRegion region, int ordinal)> anonymousFunctionsMap) { Debug.Assert(parent != null == (originalOperation.Kind == OperationKind.LocalFunction || originalOperation.Kind == OperationKind.AnonymousFunction)); Debug.Assert(captureIdDispenser != null); Debug.Assert(!blocks.IsDefault); Debug.Assert(blocks.First().Kind == BasicBlockKind.Entry); Debug.Assert(blocks.Last().Kind == BasicBlockKind.Exit); Debug.Assert(root != null); Debug.Assert(root.Kind == ControlFlowRegionKind.Root); Debug.Assert(root.FirstBlockOrdinal == 0); Debug.Assert(root.LastBlockOrdinal == blocks.Length - 1); Debug.Assert(!localFunctions.IsDefault); Debug.Assert(localFunctionsMap != null); Debug.Assert(localFunctionsMap.Count == localFunctions.Length); Debug.Assert(localFunctions.Distinct().Length == localFunctions.Length); Debug.Assert(anonymousFunctionsMap != null); #if DEBUG foreach (IMethodSymbol method in localFunctions) { Debug.Assert(method.MethodKind == MethodKind.LocalFunction); Debug.Assert(localFunctionsMap.ContainsKey(method)); } #endif OriginalOperation = originalOperation; Parent = parent; Blocks = blocks; Root = root; LocalFunctions = localFunctions; _localFunctionsMap = localFunctionsMap; _anonymousFunctionsMap = anonymousFunctionsMap; _captureIdDispenser = captureIdDispenser; } #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block root <paramref name="node"/>. /// </summary> /// <param name="node">Root syntax node for an executable code block.</param> /// <param name="semanticModel">Semantic model for the syntax tree containing the <paramref name="node"/>.</param> /// <param name="cancellationToken">Optional cancellation token.</param> /// <returns> /// Returns null if <see cref="SemanticModel.GetOperation(SyntaxNode, CancellationToken)"/> returns null for the given <paramref name="node"/> and <paramref name="semanticModel"/>. /// Otherwise, returns a <see cref="ControlFlowGraph"/> for the executable code block. /// </returns> public static ControlFlowGraph? Create(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken = default) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (semanticModel == null) { throw new ArgumentNullException(nameof(semanticModel)); } IOperation? operation = semanticModel.GetOperation(node, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); return operation == null ? null : CreateCore(operation, nameof(operation), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="body"/>. /// </summary> /// <param name="body">Root operation block, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IBlockOperation body, CancellationToken cancellationToken = default) { return CreateCore(body, nameof(body), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>. /// </summary> /// <param name="initializer">Root field initializer operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IFieldInitializerOperation initializer, CancellationToken cancellationToken = default) { return CreateCore(initializer, nameof(initializer), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>. /// </summary> /// <param name="initializer">Root property initializer operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IPropertyInitializerOperation initializer, CancellationToken cancellationToken = default) { return CreateCore(initializer, nameof(initializer), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>. /// </summary> /// <param name="initializer">Root parameter initializer operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IParameterInitializerOperation initializer, CancellationToken cancellationToken = default) { return CreateCore(initializer, nameof(initializer), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="constructorBody"/>. /// </summary> /// <param name="constructorBody">Root constructor body operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IConstructorBodyOperation constructorBody, CancellationToken cancellationToken = default) { return CreateCore(constructorBody, nameof(constructorBody), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="methodBody"/>. /// </summary> /// <param name="methodBody">Root method body operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IMethodBodyOperation methodBody, CancellationToken cancellationToken = default) { return CreateCore(methodBody, nameof(methodBody), cancellationToken); } #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters internal static ControlFlowGraph CreateCore(IOperation operation, string argumentNameForException, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (operation == null) { throw new ArgumentNullException(argumentNameForException); } if (operation.Parent != null) { throw new ArgumentException(CodeAnalysisResources.NotARootOperation, argumentNameForException); } if (((Operation)operation).OwningSemanticModel == null) { throw new ArgumentException(CodeAnalysisResources.OperationHasNullSemanticModel, argumentNameForException); } try { ControlFlowGraph controlFlowGraph = ControlFlowGraphBuilder.Create(operation); Debug.Assert(controlFlowGraph.OriginalOperation == operation); return controlFlowGraph; } catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e, cancellationToken)) { // Log a Non-fatal-watson and then ignore the crash in the attempt of getting flow graph. Debug.Assert(false, "\n" + e.ToString()); } return null; } /// <summary> /// Original operation, representing an executable code block, from which this control flow graph was generated. /// Note that <see cref="BasicBlock.Operations"/> in the control flow graph are not in the same operation tree as /// the original operation. /// </summary> public IOperation OriginalOperation { get; } /// <summary> /// Optional parent control flow graph for this graph. /// Non-null for a control flow graph generated for a local function or a lambda. /// Null otherwise. /// </summary> public ControlFlowGraph? Parent { get; } /// <summary> /// Basic blocks for the control flow graph. /// </summary> public ImmutableArray<BasicBlock> Blocks { get; } /// <summary> /// Root (<see cref="ControlFlowRegionKind.Root"/>) region for the graph. /// </summary> public ControlFlowRegion Root { get; } /// <summary> /// Local functions declared within <see cref="OriginalOperation"/>. /// </summary> public ImmutableArray<IMethodSymbol> LocalFunctions { get; } /// <summary> /// Creates a control flow graph for the given <paramref name="localFunction"/>. /// </summary> public ControlFlowGraph GetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); if (localFunction is null) { throw new ArgumentNullException(nameof(localFunction)); } if (!TryGetLocalFunctionControlFlowGraph(localFunction, cancellationToken, out var controlFlowGraph)) { throw new ArgumentOutOfRangeException(nameof(localFunction)); } return controlFlowGraph; } internal bool TryGetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, CancellationToken cancellationToken, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph) { if (!_localFunctionsMap.TryGetValue(localFunction, out (ControlFlowRegion enclosing, ILocalFunctionOperation operation, int ordinal) info)) { controlFlowGraph = null; return false; } Debug.Assert(localFunction == LocalFunctions[info.ordinal]); if (_lazyLocalFunctionsGraphs == null) { Interlocked.CompareExchange(ref _lazyLocalFunctionsGraphs, new ControlFlowGraph[LocalFunctions.Length], null); } ref ControlFlowGraph? localFunctionGraph = ref _lazyLocalFunctionsGraphs[info.ordinal]; if (localFunctionGraph == null) { Debug.Assert(localFunction == info.operation.Symbol); ControlFlowGraph graph = ControlFlowGraphBuilder.Create(info.operation, this, info.enclosing, _captureIdDispenser); Debug.Assert(graph.OriginalOperation == info.operation); Interlocked.CompareExchange(ref localFunctionGraph, graph, null); } controlFlowGraph = localFunctionGraph; Debug.Assert(controlFlowGraph.Parent == this); return true; } /// <summary> /// Creates a control flow graph for the given <paramref name="anonymousFunction"/>. /// </summary> public ControlFlowGraph GetAnonymousFunctionControlFlowGraph(IFlowAnonymousFunctionOperation anonymousFunction, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); if (anonymousFunction is null) { throw new ArgumentNullException(nameof(anonymousFunction)); } if (!TryGetAnonymousFunctionControlFlowGraph(anonymousFunction, cancellationToken, out ControlFlowGraph? controlFlowGraph)) { throw new ArgumentOutOfRangeException(nameof(anonymousFunction)); } return controlFlowGraph; } internal bool TryGetAnonymousFunctionControlFlowGraph(IFlowAnonymousFunctionOperation anonymousFunction, CancellationToken cancellationToken, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph) { if (!_anonymousFunctionsMap.TryGetValue(anonymousFunction, out (ControlFlowRegion enclosing, int ordinal) info)) { controlFlowGraph = null; return false; } if (_lazyAnonymousFunctionsGraphs == null) { Interlocked.CompareExchange(ref _lazyAnonymousFunctionsGraphs, new ControlFlowGraph[_anonymousFunctionsMap.Count], null); } ref ControlFlowGraph? anonymousFlowGraph = ref _lazyAnonymousFunctionsGraphs[info.ordinal]; if (anonymousFlowGraph == null) { var anonymous = (FlowAnonymousFunctionOperation)anonymousFunction; ControlFlowGraph graph = ControlFlowGraphBuilder.Create(anonymous.Original, this, info.enclosing, _captureIdDispenser, in anonymous.Context); Debug.Assert(graph.OriginalOperation == anonymous.Original); Interlocked.CompareExchange(ref anonymousFlowGraph, graph, null); } controlFlowGraph = anonymousFlowGraph; Debug.Assert(controlFlowGraph!.Parent == this); return true; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.Operations; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.FlowAnalysis { /// <summary> /// Control flow graph representation for a given executable code block <see cref="OriginalOperation"/>. /// This graph contains a set of <see cref="BasicBlock"/>s, with an entry block, zero /// or more intermediate basic blocks and an exit block. /// Each basic block contains zero or more <see cref="BasicBlock.Operations"/> and /// explicit <see cref="ControlFlowBranch"/>(s) to other basic block(s). /// </summary> public sealed partial class ControlFlowGraph { private readonly ControlFlowGraphBuilder.CaptureIdDispenser _captureIdDispenser; private readonly ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)> _localFunctionsMap; private ControlFlowGraph?[]? _lazyLocalFunctionsGraphs; private readonly ImmutableDictionary<IFlowAnonymousFunctionOperation, (ControlFlowRegion region, int ordinal)> _anonymousFunctionsMap; private ControlFlowGraph?[]? _lazyAnonymousFunctionsGraphs; internal ControlFlowGraph(IOperation originalOperation, ControlFlowGraph? parent, ControlFlowGraphBuilder.CaptureIdDispenser captureIdDispenser, ImmutableArray<BasicBlock> blocks, ControlFlowRegion root, ImmutableArray<IMethodSymbol> localFunctions, ImmutableDictionary<IMethodSymbol, (ControlFlowRegion region, ILocalFunctionOperation operation, int ordinal)> localFunctionsMap, ImmutableDictionary<IFlowAnonymousFunctionOperation, (ControlFlowRegion region, int ordinal)> anonymousFunctionsMap) { Debug.Assert(parent != null == (originalOperation.Kind == OperationKind.LocalFunction || originalOperation.Kind == OperationKind.AnonymousFunction)); Debug.Assert(captureIdDispenser != null); Debug.Assert(!blocks.IsDefault); Debug.Assert(blocks.First().Kind == BasicBlockKind.Entry); Debug.Assert(blocks.Last().Kind == BasicBlockKind.Exit); Debug.Assert(root != null); Debug.Assert(root.Kind == ControlFlowRegionKind.Root); Debug.Assert(root.FirstBlockOrdinal == 0); Debug.Assert(root.LastBlockOrdinal == blocks.Length - 1); Debug.Assert(!localFunctions.IsDefault); Debug.Assert(localFunctionsMap != null); Debug.Assert(localFunctionsMap.Count == localFunctions.Length); Debug.Assert(localFunctions.Distinct().Length == localFunctions.Length); Debug.Assert(anonymousFunctionsMap != null); #if DEBUG foreach (IMethodSymbol method in localFunctions) { Debug.Assert(method.MethodKind == MethodKind.LocalFunction); Debug.Assert(localFunctionsMap.ContainsKey(method)); } #endif OriginalOperation = originalOperation; Parent = parent; Blocks = blocks; Root = root; LocalFunctions = localFunctions; _localFunctionsMap = localFunctionsMap; _anonymousFunctionsMap = anonymousFunctionsMap; _captureIdDispenser = captureIdDispenser; } #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block root <paramref name="node"/>. /// </summary> /// <param name="node">Root syntax node for an executable code block.</param> /// <param name="semanticModel">Semantic model for the syntax tree containing the <paramref name="node"/>.</param> /// <param name="cancellationToken">Optional cancellation token.</param> /// <returns> /// Returns null if <see cref="SemanticModel.GetOperation(SyntaxNode, CancellationToken)"/> returns null for the given <paramref name="node"/> and <paramref name="semanticModel"/>. /// Otherwise, returns a <see cref="ControlFlowGraph"/> for the executable code block. /// </returns> public static ControlFlowGraph? Create(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken = default) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (semanticModel == null) { throw new ArgumentNullException(nameof(semanticModel)); } IOperation? operation = semanticModel.GetOperation(node, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); return operation == null ? null : CreateCore(operation, nameof(operation), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="body"/>. /// </summary> /// <param name="body">Root operation block, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IBlockOperation body, CancellationToken cancellationToken = default) { return CreateCore(body, nameof(body), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>. /// </summary> /// <param name="initializer">Root field initializer operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IFieldInitializerOperation initializer, CancellationToken cancellationToken = default) { return CreateCore(initializer, nameof(initializer), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>. /// </summary> /// <param name="initializer">Root property initializer operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IPropertyInitializerOperation initializer, CancellationToken cancellationToken = default) { return CreateCore(initializer, nameof(initializer), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>. /// </summary> /// <param name="initializer">Root parameter initializer operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IParameterInitializerOperation initializer, CancellationToken cancellationToken = default) { return CreateCore(initializer, nameof(initializer), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="constructorBody"/>. /// </summary> /// <param name="constructorBody">Root constructor body operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IConstructorBodyOperation constructorBody, CancellationToken cancellationToken = default) { return CreateCore(constructorBody, nameof(constructorBody), cancellationToken); } /// <summary> /// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="methodBody"/>. /// </summary> /// <param name="methodBody">Root method body operation, which must have a null parent.</param> /// <param name="cancellationToken">Optional cancellation token.</param> public static ControlFlowGraph Create(Operations.IMethodBodyOperation methodBody, CancellationToken cancellationToken = default) { return CreateCore(methodBody, nameof(methodBody), cancellationToken); } #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters internal static ControlFlowGraph CreateCore(IOperation operation, string argumentNameForException, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (operation == null) { throw new ArgumentNullException(argumentNameForException); } if (operation.Parent != null) { throw new ArgumentException(CodeAnalysisResources.NotARootOperation, argumentNameForException); } if (((Operation)operation).OwningSemanticModel == null) { throw new ArgumentException(CodeAnalysisResources.OperationHasNullSemanticModel, argumentNameForException); } try { ControlFlowGraph controlFlowGraph = ControlFlowGraphBuilder.Create(operation); Debug.Assert(controlFlowGraph.OriginalOperation == operation); return controlFlowGraph; } catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e, cancellationToken)) { // Log a Non-fatal-watson and then ignore the crash in the attempt of getting flow graph. Debug.Assert(false, "\n" + e.ToString()); } return null; } /// <summary> /// Original operation, representing an executable code block, from which this control flow graph was generated. /// Note that <see cref="BasicBlock.Operations"/> in the control flow graph are not in the same operation tree as /// the original operation. /// </summary> public IOperation OriginalOperation { get; } /// <summary> /// Optional parent control flow graph for this graph. /// Non-null for a control flow graph generated for a local function or a lambda. /// Null otherwise. /// </summary> public ControlFlowGraph? Parent { get; } /// <summary> /// Basic blocks for the control flow graph. /// </summary> public ImmutableArray<BasicBlock> Blocks { get; } /// <summary> /// Root (<see cref="ControlFlowRegionKind.Root"/>) region for the graph. /// </summary> public ControlFlowRegion Root { get; } /// <summary> /// Local functions declared within <see cref="OriginalOperation"/>. /// </summary> public ImmutableArray<IMethodSymbol> LocalFunctions { get; } /// <summary> /// Creates a control flow graph for the given <paramref name="localFunction"/>. /// </summary> public ControlFlowGraph GetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); if (localFunction is null) { throw new ArgumentNullException(nameof(localFunction)); } if (!TryGetLocalFunctionControlFlowGraph(localFunction, cancellationToken, out var controlFlowGraph)) { throw new ArgumentOutOfRangeException(nameof(localFunction)); } return controlFlowGraph; } internal bool TryGetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, CancellationToken cancellationToken, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph) { if (!_localFunctionsMap.TryGetValue(localFunction, out (ControlFlowRegion enclosing, ILocalFunctionOperation operation, int ordinal) info)) { controlFlowGraph = null; return false; } Debug.Assert(localFunction == LocalFunctions[info.ordinal]); if (_lazyLocalFunctionsGraphs == null) { Interlocked.CompareExchange(ref _lazyLocalFunctionsGraphs, new ControlFlowGraph[LocalFunctions.Length], null); } ref ControlFlowGraph? localFunctionGraph = ref _lazyLocalFunctionsGraphs[info.ordinal]; if (localFunctionGraph == null) { Debug.Assert(localFunction == info.operation.Symbol); ControlFlowGraph graph = ControlFlowGraphBuilder.Create(info.operation, this, info.enclosing, _captureIdDispenser); Debug.Assert(graph.OriginalOperation == info.operation); Interlocked.CompareExchange(ref localFunctionGraph, graph, null); } controlFlowGraph = localFunctionGraph; Debug.Assert(controlFlowGraph.Parent == this); return true; } /// <summary> /// Creates a control flow graph for the given <paramref name="anonymousFunction"/>. /// </summary> public ControlFlowGraph GetAnonymousFunctionControlFlowGraph(IFlowAnonymousFunctionOperation anonymousFunction, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); if (anonymousFunction is null) { throw new ArgumentNullException(nameof(anonymousFunction)); } if (!TryGetAnonymousFunctionControlFlowGraph(anonymousFunction, cancellationToken, out ControlFlowGraph? controlFlowGraph)) { throw new ArgumentOutOfRangeException(nameof(anonymousFunction)); } return controlFlowGraph; } internal bool TryGetAnonymousFunctionControlFlowGraph(IFlowAnonymousFunctionOperation anonymousFunction, CancellationToken cancellationToken, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph) { if (!_anonymousFunctionsMap.TryGetValue(anonymousFunction, out (ControlFlowRegion enclosing, int ordinal) info)) { controlFlowGraph = null; return false; } if (_lazyAnonymousFunctionsGraphs == null) { Interlocked.CompareExchange(ref _lazyAnonymousFunctionsGraphs, new ControlFlowGraph[_anonymousFunctionsMap.Count], null); } ref ControlFlowGraph? anonymousFlowGraph = ref _lazyAnonymousFunctionsGraphs[info.ordinal]; if (anonymousFlowGraph == null) { var anonymous = (FlowAnonymousFunctionOperation)anonymousFunction; ControlFlowGraph graph = ControlFlowGraphBuilder.Create(anonymous.Original, this, info.enclosing, _captureIdDispenser, in anonymous.Context); Debug.Assert(graph.OriginalOperation == anonymous.Original); Interlocked.CompareExchange(ref anonymousFlowGraph, graph, null); } controlFlowGraph = anonymousFlowGraph; Debug.Assert(controlFlowGraph!.Parent == this); return true; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/MSBuild/MSBuild/Logging/MSBuildDiagnosticLogItem.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; namespace Microsoft.CodeAnalysis.MSBuild.Logging { internal class MSBuildDiagnosticLogItem : DiagnosticLogItem { public string FileName { get; } public int LineNumber { get; } public int ColumnNumber { get; } public MSBuildDiagnosticLogItem(WorkspaceDiagnosticKind kind, string projectFilePath, string message, string fileName, int lineNumber, int columnNumber) : base(kind, message, projectFilePath) { FileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); LineNumber = lineNumber; ColumnNumber = columnNumber; } public override string ToString() => $"{FileName}: ({LineNumber}, {ColumnNumber}): {Message}"; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; namespace Microsoft.CodeAnalysis.MSBuild.Logging { internal class MSBuildDiagnosticLogItem : DiagnosticLogItem { public string FileName { get; } public int LineNumber { get; } public int ColumnNumber { get; } public MSBuildDiagnosticLogItem(WorkspaceDiagnosticKind kind, string projectFilePath, string message, string fileName, int lineNumber, int columnNumber) : base(kind, message, projectFilePath) { FileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); LineNumber = lineNumber; ColumnNumber = columnNumber; } public override string ToString() => $"{FileName}: ({LineNumber}, {ColumnNumber}): {Message}"; } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/CSharp/Portable/Structure/CSharpBlockStructureProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; namespace Microsoft.CodeAnalysis.CSharp.Structure { internal class CSharpBlockStructureProvider : AbstractBlockStructureProvider { private static ImmutableDictionary<Type, ImmutableArray<AbstractSyntaxStructureProvider>> CreateDefaultNodeProviderMap() { var builder = ImmutableDictionary.CreateBuilder<Type, ImmutableArray<AbstractSyntaxStructureProvider>>(); builder.Add<AccessorDeclarationSyntax, AccessorDeclarationStructureProvider>(); builder.Add<AnonymousMethodExpressionSyntax, AnonymousMethodExpressionStructureProvider>(); builder.Add<ArrowExpressionClauseSyntax, ArrowExpressionClauseStructureProvider>(); builder.Add<BlockSyntax, BlockSyntaxStructureProvider>(); builder.Add<ClassDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<CompilationUnitSyntax, CompilationUnitStructureProvider>(); builder.Add<ConstructorDeclarationSyntax, ConstructorDeclarationStructureProvider>(); builder.Add<ConversionOperatorDeclarationSyntax, ConversionOperatorDeclarationStructureProvider>(); builder.Add<DelegateDeclarationSyntax, DelegateDeclarationStructureProvider>(); builder.Add<DestructorDeclarationSyntax, DestructorDeclarationStructureProvider>(); builder.Add<DocumentationCommentTriviaSyntax, DocumentationCommentStructureProvider>(); builder.Add<EnumDeclarationSyntax, EnumDeclarationStructureProvider>(); builder.Add<EnumMemberDeclarationSyntax, EnumMemberDeclarationStructureProvider>(); builder.Add<EventDeclarationSyntax, EventDeclarationStructureProvider>(); builder.Add<EventFieldDeclarationSyntax, EventFieldDeclarationStructureProvider>(); builder.Add<FieldDeclarationSyntax, FieldDeclarationStructureProvider>(); builder.Add<IndexerDeclarationSyntax, IndexerDeclarationStructureProvider>(); builder.Add<InitializerExpressionSyntax, InitializerExpressionStructureProvider>(); builder.Add<InterfaceDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<MethodDeclarationSyntax, MethodDeclarationStructureProvider>(); builder.Add<NamespaceDeclarationSyntax, NamespaceDeclarationStructureProvider>(); builder.Add<OperatorDeclarationSyntax, OperatorDeclarationStructureProvider>(); builder.Add<ParenthesizedLambdaExpressionSyntax, ParenthesizedLambdaExpressionStructureProvider>(); builder.Add<PropertyDeclarationSyntax, PropertyDeclarationStructureProvider>(); builder.Add<RecordDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<RegionDirectiveTriviaSyntax, RegionDirectiveStructureProvider>(); builder.Add<SimpleLambdaExpressionSyntax, SimpleLambdaExpressionStructureProvider>(); builder.Add<StructDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<SwitchStatementSyntax, SwitchStatementStructureProvider>(); builder.Add<LiteralExpressionSyntax, StringLiteralExpressionStructureProvider>(); builder.Add<InterpolatedStringExpressionSyntax, InterpolatedStringExpressionStructureProvider>(); return builder.ToImmutable(); } private static ImmutableDictionary<int, ImmutableArray<AbstractSyntaxStructureProvider>> CreateDefaultTriviaProviderMap() { var builder = ImmutableDictionary.CreateBuilder<int, ImmutableArray<AbstractSyntaxStructureProvider>>(); builder.Add((int)SyntaxKind.DisabledTextTrivia, ImmutableArray.Create<AbstractSyntaxStructureProvider>(new DisabledTextTriviaStructureProvider())); return builder.ToImmutable(); } internal CSharpBlockStructureProvider() : base(CreateDefaultNodeProviderMap(), CreateDefaultTriviaProviderMap()) { } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; namespace Microsoft.CodeAnalysis.CSharp.Structure { internal class CSharpBlockStructureProvider : AbstractBlockStructureProvider { private static ImmutableDictionary<Type, ImmutableArray<AbstractSyntaxStructureProvider>> CreateDefaultNodeProviderMap() { var builder = ImmutableDictionary.CreateBuilder<Type, ImmutableArray<AbstractSyntaxStructureProvider>>(); builder.Add<AccessorDeclarationSyntax, AccessorDeclarationStructureProvider>(); builder.Add<AnonymousMethodExpressionSyntax, AnonymousMethodExpressionStructureProvider>(); builder.Add<ArrowExpressionClauseSyntax, ArrowExpressionClauseStructureProvider>(); builder.Add<BlockSyntax, BlockSyntaxStructureProvider>(); builder.Add<ClassDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<CompilationUnitSyntax, CompilationUnitStructureProvider>(); builder.Add<ConstructorDeclarationSyntax, ConstructorDeclarationStructureProvider>(); builder.Add<ConversionOperatorDeclarationSyntax, ConversionOperatorDeclarationStructureProvider>(); builder.Add<DelegateDeclarationSyntax, DelegateDeclarationStructureProvider>(); builder.Add<DestructorDeclarationSyntax, DestructorDeclarationStructureProvider>(); builder.Add<DocumentationCommentTriviaSyntax, DocumentationCommentStructureProvider>(); builder.Add<EnumDeclarationSyntax, EnumDeclarationStructureProvider>(); builder.Add<EnumMemberDeclarationSyntax, EnumMemberDeclarationStructureProvider>(); builder.Add<EventDeclarationSyntax, EventDeclarationStructureProvider>(); builder.Add<EventFieldDeclarationSyntax, EventFieldDeclarationStructureProvider>(); builder.Add<FieldDeclarationSyntax, FieldDeclarationStructureProvider>(); builder.Add<IndexerDeclarationSyntax, IndexerDeclarationStructureProvider>(); builder.Add<InitializerExpressionSyntax, InitializerExpressionStructureProvider>(); builder.Add<InterfaceDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<MethodDeclarationSyntax, MethodDeclarationStructureProvider>(); builder.Add<NamespaceDeclarationSyntax, NamespaceDeclarationStructureProvider>(); builder.Add<OperatorDeclarationSyntax, OperatorDeclarationStructureProvider>(); builder.Add<ParenthesizedLambdaExpressionSyntax, ParenthesizedLambdaExpressionStructureProvider>(); builder.Add<PropertyDeclarationSyntax, PropertyDeclarationStructureProvider>(); builder.Add<RecordDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<RegionDirectiveTriviaSyntax, RegionDirectiveStructureProvider>(); builder.Add<SimpleLambdaExpressionSyntax, SimpleLambdaExpressionStructureProvider>(); builder.Add<StructDeclarationSyntax, TypeDeclarationStructureProvider>(); builder.Add<SwitchStatementSyntax, SwitchStatementStructureProvider>(); builder.Add<LiteralExpressionSyntax, StringLiteralExpressionStructureProvider>(); builder.Add<InterpolatedStringExpressionSyntax, InterpolatedStringExpressionStructureProvider>(); return builder.ToImmutable(); } private static ImmutableDictionary<int, ImmutableArray<AbstractSyntaxStructureProvider>> CreateDefaultTriviaProviderMap() { var builder = ImmutableDictionary.CreateBuilder<int, ImmutableArray<AbstractSyntaxStructureProvider>>(); builder.Add((int)SyntaxKind.DisabledTextTrivia, ImmutableArray.Create<AbstractSyntaxStructureProvider>(new DisabledTextTriviaStructureProvider())); return builder.ToImmutable(); } internal CSharpBlockStructureProvider() : base(CreateDefaultNodeProviderMap(), CreateDefaultTriviaProviderMap()) { } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Core/Portable/IVTConclusion.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; namespace Microsoft.CodeAnalysis { /// <summary> /// The result of <see cref="ISymbolExtensions.PerformIVTCheck(AssemblyIdentity, ImmutableArray{byte}, ImmutableArray{byte})"/> /// </summary> internal enum IVTConclusion { /// <summary> /// This indicates that friend access should be granted. /// </summary> Match, /// <summary> /// This indicates that friend access should be granted for the purposes of error recovery, /// but the program is wrong. /// /// That's because this indicates that a strong-named assembly has referred to a weak-named assembly /// which has extended friend access to the strong-named assembly. This will ultimately /// result in an error because strong-named assemblies may not refer to weak-named assemblies. /// In Roslyn we give a new error, CS7029, before emit time. In the dev10 compiler we error at /// emit time. /// </summary> OneSignedOneNot, /// <summary> /// This indicates that friend access should not be granted because the other assembly grants /// friend access to a strong-named assembly, and either this assembly is weak-named, or /// it is strong-named and the names don't match. /// </summary> PublicKeyDoesntMatch, /// <summary> /// This indicates that friend access should not be granted because the other assembly /// does not name this assembly as a friend in any way whatsoever. /// </summary> NoRelationshipClaimed } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; namespace Microsoft.CodeAnalysis { /// <summary> /// The result of <see cref="ISymbolExtensions.PerformIVTCheck(AssemblyIdentity, ImmutableArray{byte}, ImmutableArray{byte})"/> /// </summary> internal enum IVTConclusion { /// <summary> /// This indicates that friend access should be granted. /// </summary> Match, /// <summary> /// This indicates that friend access should be granted for the purposes of error recovery, /// but the program is wrong. /// /// That's because this indicates that a strong-named assembly has referred to a weak-named assembly /// which has extended friend access to the strong-named assembly. This will ultimately /// result in an error because strong-named assemblies may not refer to weak-named assemblies. /// In Roslyn we give a new error, CS7029, before emit time. In the dev10 compiler we error at /// emit time. /// </summary> OneSignedOneNot, /// <summary> /// This indicates that friend access should not be granted because the other assembly grants /// friend access to a strong-named assembly, and either this assembly is weak-named, or /// it is strong-named and the names don't match. /// </summary> PublicKeyDoesntMatch, /// <summary> /// This indicates that friend access should not be granted because the other assembly /// does not name this assembly as a friend in any way whatsoever. /// </summary> NoRelationshipClaimed } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CodeCleanup; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.UseExpressionBody; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics.CSharp; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Editor.UnitTests; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Formatting { [UseExportProvider] public class CodeCleanupTests { [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task RemoveUsings() { var code = @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { Console.WriteLine(); } } "; var expected = @"using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(); } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task SortUsings() { var code = @"using System.Collections.Generic; using System; class Program { static void Main(string[] args) { var list = new List<int>(); Console.WriteLine(list.Count); } } "; var expected = @"using System; using System.Collections.Generic; internal class Program { private static void Main(string[] args) { List<int> list = new List<int>(); Console.WriteLine(list.Count); } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task SortGlobalUsings() { var code = @"using System.Threading.Tasks; using System.Threading; global using System.Collections.Generic; global using System; class Program { static async Task Main(string[] args) { Barrier b = new Barrier(0); var list = new List<int>(); Console.WriteLine(list.Count); } } "; var expected = @"global using System; global using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; internal class Program { private static async Task Main(string[] args) { Barrier b = new Barrier(0); List<int> list = new List<int>(); Console.WriteLine(list.Count); } } "; return AssertCodeCleanupResult(expected, code); } [Fact, WorkItem(36984, "https://github.com/dotnet/roslyn/issues/36984")] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task GroupUsings() { var code = @"using M; using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; var expected = @"using M; using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; return AssertCodeCleanupResult(expected, code, systemUsingsFirst: false, separateUsingGroups: true); } [Fact, WorkItem(36984, "https://github.com/dotnet/roslyn/issues/36984")] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task SortAndGroupUsings() { var code = @"using M; using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; var expected = @"using System; using M; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; return AssertCodeCleanupResult(expected, code, systemUsingsFirst: true, separateUsingGroups: true); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixAddRemoveBraces() { var code = @"class Program { void Method() { int a = 0; if (a > 0) a ++; } } "; var expected = @"internal class Program { private void Method() { int a = 0; if (a > 0) { a++; } } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task RemoveUnusedVariable() { var code = @"class Program { void Method() { int a; } } "; var expected = @"internal class Program { private void Method() { } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixAccessibilityModifiers() { var code = @"class Program { void Method() { int a; } } "; var expected = @"internal class Program { private void Method() { } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferOutside() { var code = @"namespace A { using System; internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = @"using System; namespace A { internal class Program { private void Method() { Console.WriteLine(); } } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferInside() { var code = @"using System; namespace A { internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = @"namespace A { using System; internal class Program { private void Method() { Console.WriteLine(); } } } "; return AssertCodeCleanupResult(expected, code, InsideNamespaceOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferInsidePreserve() { var code = @"using System; namespace A { internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, InsidePreferPreservationOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferOutsidePreserve() { var code = @"namespace A { using System; internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, OutsidePreferPreservationOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferOutside() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = @"using System; using System.Collections.Generic; namespace A { internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; return AssertCodeCleanupResult(expected, code, OutsideNamespaceOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferInside() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = @"namespace A { using System; using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; return AssertCodeCleanupResult(expected, code, InsideNamespaceOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferInsidePreserve() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, InsidePreferPreservationOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferOutsidePreserve() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, OutsidePreferPreservationOption); } /// <summary> /// Assert the expected code value equals the actual processed input <paramref name="code"/>. /// </summary> /// <param name="expected">The actual processed code to verify against.</param> /// <param name="code">The input code to be processed and tested.</param> /// <param name="systemUsingsFirst">Indicates whether <c><see cref="System"/>.*</c> '<c>using</c>' directives should preceed others. Default is <c>true</c>.</param> /// <param name="separateUsingGroups">Indicates whether '<c>using</c>' directives should be organized into separated groups. Default is <c>true</c>.</param> /// <returns>The <see cref="Task"/> to test code cleanup.</returns> private protected static Task AssertCodeCleanupResult(string expected, string code, bool systemUsingsFirst = true, bool separateUsingGroups = false) => AssertCodeCleanupResult(expected, code, CSharpCodeStyleOptions.PreferOutsidePlacementWithSilentEnforcement, systemUsingsFirst, separateUsingGroups); /// <summary> /// Assert the expected code value equals the actual processed input <paramref name="code"/>. /// </summary> /// <param name="expected">The actual processed code to verify against.</param> /// <param name="code">The input code to be processed and tested.</param> /// <param name="preferredImportPlacement">Indicates the code style option for the preferred 'using' directives placement.</param> /// <param name="systemUsingsFirst">Indicates whether <c><see cref="System"/>.*</c> '<c>using</c>' directives should preceed others. Default is <c>true</c>.</param> /// <param name="separateUsingGroups">Indicates whether '<c>using</c>' directives should be organized into separated groups. Default is <c>true</c>.</param> /// <returns>The <see cref="Task"/> to test code cleanup.</returns> private protected static async Task AssertCodeCleanupResult(string expected, string code, CodeStyleOption2<AddImportPlacement> preferredImportPlacement, bool systemUsingsFirst = true, bool separateUsingGroups = false) { using var workspace = TestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeaturesWpf); var solution = workspace.CurrentSolution .WithOptions(workspace.Options .WithChangedOption(GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp, systemUsingsFirst) .WithChangedOption(GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp, separateUsingGroups) .WithChangedOption(CSharpCodeStyleOptions.PreferredUsingDirectivePlacement, preferredImportPlacement)) .WithAnalyzerReferences(new[] { new AnalyzerFileReference(typeof(CSharpCompilerDiagnosticAnalyzer).Assembly.Location, TestAnalyzerAssemblyLoader.LoadFromFile), new AnalyzerFileReference(typeof(UseExpressionBodyDiagnosticAnalyzer).Assembly.Location, TestAnalyzerAssemblyLoader.LoadFromFile) }); workspace.TryApplyChanges(solution); // register this workspace to solution crawler so that analyzer service associate itself with given workspace var incrementalAnalyzerProvider = workspace.ExportProvider.GetExportedValue<IDiagnosticAnalyzerService>() as IIncrementalAnalyzerProvider; incrementalAnalyzerProvider.CreateIncrementalAnalyzer(workspace); var hostdoc = workspace.Documents.Single(); var document = workspace.CurrentSolution.GetDocument(hostdoc.Id); var codeCleanupService = document.GetLanguageService<ICodeCleanupService>(); var enabledDiagnostics = codeCleanupService.GetAllDiagnostics(); var newDoc = await codeCleanupService.CleanupAsync( document, enabledDiagnostics, new ProgressTracker(), CancellationToken.None); var actual = await newDoc.GetTextAsync(); Assert.Equal(expected, actual.ToString()); } private static readonly CodeStyleOption2<AddImportPlacement> InsideNamespaceOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.InsideNamespace, NotificationOption2.Error); private static readonly CodeStyleOption2<AddImportPlacement> OutsideNamespaceOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.OutsideNamespace, NotificationOption2.Error); private static readonly CodeStyleOption2<AddImportPlacement> InsidePreferPreservationOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.InsideNamespace, NotificationOption2.None); private static readonly CodeStyleOption2<AddImportPlacement> OutsidePreferPreservationOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.OutsideNamespace, NotificationOption2.None); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CodeCleanup; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.UseExpressionBody; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics.CSharp; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Editor.UnitTests; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Formatting { [UseExportProvider] public class CodeCleanupTests { [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task RemoveUsings() { var code = @"using System; using System.Collections.Generic; class Program { static void Main(string[] args) { Console.WriteLine(); } } "; var expected = @"using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(); } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task SortUsings() { var code = @"using System.Collections.Generic; using System; class Program { static void Main(string[] args) { var list = new List<int>(); Console.WriteLine(list.Count); } } "; var expected = @"using System; using System.Collections.Generic; internal class Program { private static void Main(string[] args) { List<int> list = new List<int>(); Console.WriteLine(list.Count); } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task SortGlobalUsings() { var code = @"using System.Threading.Tasks; using System.Threading; global using System.Collections.Generic; global using System; class Program { static async Task Main(string[] args) { Barrier b = new Barrier(0); var list = new List<int>(); Console.WriteLine(list.Count); } } "; var expected = @"global using System; global using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; internal class Program { private static async Task Main(string[] args) { Barrier b = new Barrier(0); List<int> list = new List<int>(); Console.WriteLine(list.Count); } } "; return AssertCodeCleanupResult(expected, code); } [Fact, WorkItem(36984, "https://github.com/dotnet/roslyn/issues/36984")] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task GroupUsings() { var code = @"using M; using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; var expected = @"using M; using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; return AssertCodeCleanupResult(expected, code, systemUsingsFirst: false, separateUsingGroups: true); } [Fact, WorkItem(36984, "https://github.com/dotnet/roslyn/issues/36984")] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task SortAndGroupUsings() { var code = @"using M; using System; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; var expected = @"using System; using M; internal class Program { private static void Main(string[] args) { Console.WriteLine(""Hello World!""); new Goo(); } } namespace M { public class Goo { } } "; return AssertCodeCleanupResult(expected, code, systemUsingsFirst: true, separateUsingGroups: true); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixAddRemoveBraces() { var code = @"class Program { void Method() { int a = 0; if (a > 0) a ++; } } "; var expected = @"internal class Program { private void Method() { int a = 0; if (a > 0) { a++; } } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task RemoveUnusedVariable() { var code = @"class Program { void Method() { int a; } } "; var expected = @"internal class Program { private void Method() { } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixAccessibilityModifiers() { var code = @"class Program { void Method() { int a; } } "; var expected = @"internal class Program { private void Method() { } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferOutside() { var code = @"namespace A { using System; internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = @"using System; namespace A { internal class Program { private void Method() { Console.WriteLine(); } } } "; return AssertCodeCleanupResult(expected, code); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferInside() { var code = @"using System; namespace A { internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = @"namespace A { using System; internal class Program { private void Method() { Console.WriteLine(); } } } "; return AssertCodeCleanupResult(expected, code, InsideNamespaceOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferInsidePreserve() { var code = @"using System; namespace A { internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, InsidePreferPreservationOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementPreferOutsidePreserve() { var code = @"namespace A { using System; internal class Program { private void Method() { Console.WriteLine(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, OutsidePreferPreservationOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferOutside() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = @"using System; using System.Collections.Generic; namespace A { internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; return AssertCodeCleanupResult(expected, code, OutsideNamespaceOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferInside() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = @"namespace A { using System; using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; return AssertCodeCleanupResult(expected, code, InsideNamespaceOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferInsidePreserve() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, InsidePreferPreservationOption); } [Fact] [Trait(Traits.Feature, Traits.Features.CodeCleanup)] public Task FixUsingPlacementMixedPreferOutsidePreserve() { var code = @"using System; namespace A { using System.Collections.Generic; internal class Program { private void Method() { Console.WriteLine(); List<int> list = new List<int>(); } } } "; var expected = code; return AssertCodeCleanupResult(expected, code, OutsidePreferPreservationOption); } /// <summary> /// Assert the expected code value equals the actual processed input <paramref name="code"/>. /// </summary> /// <param name="expected">The actual processed code to verify against.</param> /// <param name="code">The input code to be processed and tested.</param> /// <param name="systemUsingsFirst">Indicates whether <c><see cref="System"/>.*</c> '<c>using</c>' directives should preceed others. Default is <c>true</c>.</param> /// <param name="separateUsingGroups">Indicates whether '<c>using</c>' directives should be organized into separated groups. Default is <c>true</c>.</param> /// <returns>The <see cref="Task"/> to test code cleanup.</returns> private protected static Task AssertCodeCleanupResult(string expected, string code, bool systemUsingsFirst = true, bool separateUsingGroups = false) => AssertCodeCleanupResult(expected, code, CSharpCodeStyleOptions.PreferOutsidePlacementWithSilentEnforcement, systemUsingsFirst, separateUsingGroups); /// <summary> /// Assert the expected code value equals the actual processed input <paramref name="code"/>. /// </summary> /// <param name="expected">The actual processed code to verify against.</param> /// <param name="code">The input code to be processed and tested.</param> /// <param name="preferredImportPlacement">Indicates the code style option for the preferred 'using' directives placement.</param> /// <param name="systemUsingsFirst">Indicates whether <c><see cref="System"/>.*</c> '<c>using</c>' directives should preceed others. Default is <c>true</c>.</param> /// <param name="separateUsingGroups">Indicates whether '<c>using</c>' directives should be organized into separated groups. Default is <c>true</c>.</param> /// <returns>The <see cref="Task"/> to test code cleanup.</returns> private protected static async Task AssertCodeCleanupResult(string expected, string code, CodeStyleOption2<AddImportPlacement> preferredImportPlacement, bool systemUsingsFirst = true, bool separateUsingGroups = false) { using var workspace = TestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeaturesWpf); var solution = workspace.CurrentSolution .WithOptions(workspace.Options .WithChangedOption(GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp, systemUsingsFirst) .WithChangedOption(GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp, separateUsingGroups) .WithChangedOption(CSharpCodeStyleOptions.PreferredUsingDirectivePlacement, preferredImportPlacement)) .WithAnalyzerReferences(new[] { new AnalyzerFileReference(typeof(CSharpCompilerDiagnosticAnalyzer).Assembly.Location, TestAnalyzerAssemblyLoader.LoadFromFile), new AnalyzerFileReference(typeof(UseExpressionBodyDiagnosticAnalyzer).Assembly.Location, TestAnalyzerAssemblyLoader.LoadFromFile) }); workspace.TryApplyChanges(solution); // register this workspace to solution crawler so that analyzer service associate itself with given workspace var incrementalAnalyzerProvider = workspace.ExportProvider.GetExportedValue<IDiagnosticAnalyzerService>() as IIncrementalAnalyzerProvider; incrementalAnalyzerProvider.CreateIncrementalAnalyzer(workspace); var hostdoc = workspace.Documents.Single(); var document = workspace.CurrentSolution.GetDocument(hostdoc.Id); var codeCleanupService = document.GetLanguageService<ICodeCleanupService>(); var enabledDiagnostics = codeCleanupService.GetAllDiagnostics(); var newDoc = await codeCleanupService.CleanupAsync( document, enabledDiagnostics, new ProgressTracker(), CancellationToken.None); var actual = await newDoc.GetTextAsync(); Assert.Equal(expected, actual.ToString()); } private static readonly CodeStyleOption2<AddImportPlacement> InsideNamespaceOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.InsideNamespace, NotificationOption2.Error); private static readonly CodeStyleOption2<AddImportPlacement> OutsideNamespaceOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.OutsideNamespace, NotificationOption2.Error); private static readonly CodeStyleOption2<AddImportPlacement> InsidePreferPreservationOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.InsideNamespace, NotificationOption2.None); private static readonly CodeStyleOption2<AddImportPlacement> OutsidePreferPreservationOption = new CodeStyleOption2<AddImportPlacement>(AddImportPlacement.OutsideNamespace, NotificationOption2.None); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Portable/Syntax/LockStatementSyntax.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.CodeAnalysis.CSharp.Syntax { public partial class LockStatementSyntax { public LockStatementSyntax Update(SyntaxToken lockKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) => Update(AttributeLists, lockKeyword, openParenToken, expression, closeParenToken, statement); } } namespace Microsoft.CodeAnalysis.CSharp { public partial class SyntaxFactory { public static LockStatementSyntax LockStatement(SyntaxToken lockKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) => LockStatement(attributeLists: default, lockKeyword, openParenToken, expression, closeParenToken, statement); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.CodeAnalysis.CSharp.Syntax { public partial class LockStatementSyntax { public LockStatementSyntax Update(SyntaxToken lockKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) => Update(AttributeLists, lockKeyword, openParenToken, expression, closeParenToken, statement); } } namespace Microsoft.CodeAnalysis.CSharp { public partial class SyntaxFactory { public static LockStatementSyntax LockStatement(SyntaxToken lockKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) => LockStatement(attributeLists: default, lockKeyword, openParenToken, expression, closeParenToken, statement); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/InlineHints/InlineHintsOptions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Composition; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Options.Providers; namespace Microsoft.CodeAnalysis.InlineHints { internal static class InlineHintsOptions { public static readonly Option2<bool> DisplayAllHintsWhilePressingAltF1 = new(nameof(InlineHintsOptions), nameof(DisplayAllHintsWhilePressingAltF1), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.Specific.DisplayAllHintsWhilePressingAltF1")); public static readonly PerLanguageOption2<bool> ColorHints = new(nameof(InlineHintsOptions), nameof(ColorHints), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.ColorHints")); /// <summary> /// Non-persisted option used to switch to displaying everything while the user is holding ctrl-alt. /// </summary> public static readonly Option2<bool> DisplayAllOverride = new(nameof(DisplayAllOverride), nameof(EnabledForParameters), defaultValue: false); public static readonly PerLanguageOption2<bool> EnabledForParameters = new(nameof(InlineHintsOptions), nameof(EnabledForParameters), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints")); public static readonly PerLanguageOption2<bool> ForLiteralParameters = new(nameof(InlineHintsOptions), nameof(ForLiteralParameters), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForLiteralParameters")); public static readonly PerLanguageOption2<bool> ForObjectCreationParameters = new(nameof(InlineHintsOptions), nameof(ForObjectCreationParameters), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForObjectCreationParameters")); public static readonly PerLanguageOption2<bool> ForOtherParameters = new(nameof(InlineHintsOptions), nameof(ForOtherParameters), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForOtherParameters")); public static readonly PerLanguageOption2<bool> SuppressForParametersThatDifferOnlyBySuffix = new(nameof(InlineHintsOptions), nameof(SuppressForParametersThatDifferOnlyBySuffix), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.SuppressForParametersThatDifferOnlyBySuffix")); public static readonly PerLanguageOption2<bool> SuppressForParametersThatMatchMethodIntent = new(nameof(InlineHintsOptions), nameof(SuppressForParametersThatMatchMethodIntent), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.SuppressForParametersThatMatchMethodIntent")); public static readonly PerLanguageOption2<bool> EnabledForTypes = new(nameof(InlineHintsOptions), nameof(EnabledForTypes), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints")); public static readonly PerLanguageOption2<bool> ForImplicitVariableTypes = new(nameof(InlineHintsOptions), nameof(ForImplicitVariableTypes), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForImplicitVariableTypes")); public static readonly PerLanguageOption2<bool> ForLambdaParameterTypes = new(nameof(InlineHintsOptions), nameof(ForLambdaParameterTypes), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForLambdaParameterTypes")); public static readonly PerLanguageOption2<bool> ForImplicitObjectCreation = new(nameof(InlineHintsOptions), nameof(ForImplicitObjectCreation), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForImplicitObjectCreation")); } [ExportOptionProvider, Shared] internal sealed class InlineHintsOptionsProvider : IOptionProvider { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public InlineHintsOptionsProvider() { } public ImmutableArray<IOption> Options { get; } = ImmutableArray.Create<IOption>( InlineHintsOptions.DisplayAllHintsWhilePressingAltF1, InlineHintsOptions.ColorHints, InlineHintsOptions.EnabledForParameters, InlineHintsOptions.ForLiteralParameters, InlineHintsOptions.ForObjectCreationParameters, InlineHintsOptions.ForOtherParameters, InlineHintsOptions.EnabledForTypes, InlineHintsOptions.ForImplicitVariableTypes, InlineHintsOptions.ForLambdaParameterTypes, InlineHintsOptions.ForImplicitObjectCreation); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Composition; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Options.Providers; namespace Microsoft.CodeAnalysis.InlineHints { internal static class InlineHintsOptions { public static readonly Option2<bool> DisplayAllHintsWhilePressingAltF1 = new(nameof(InlineHintsOptions), nameof(DisplayAllHintsWhilePressingAltF1), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.Specific.DisplayAllHintsWhilePressingAltF1")); public static readonly PerLanguageOption2<bool> ColorHints = new(nameof(InlineHintsOptions), nameof(ColorHints), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.ColorHints")); /// <summary> /// Non-persisted option used to switch to displaying everything while the user is holding ctrl-alt. /// </summary> public static readonly Option2<bool> DisplayAllOverride = new(nameof(DisplayAllOverride), nameof(EnabledForParameters), defaultValue: false); public static readonly PerLanguageOption2<bool> EnabledForParameters = new(nameof(InlineHintsOptions), nameof(EnabledForParameters), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints")); public static readonly PerLanguageOption2<bool> ForLiteralParameters = new(nameof(InlineHintsOptions), nameof(ForLiteralParameters), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForLiteralParameters")); public static readonly PerLanguageOption2<bool> ForObjectCreationParameters = new(nameof(InlineHintsOptions), nameof(ForObjectCreationParameters), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForObjectCreationParameters")); public static readonly PerLanguageOption2<bool> ForOtherParameters = new(nameof(InlineHintsOptions), nameof(ForOtherParameters), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForOtherParameters")); public static readonly PerLanguageOption2<bool> SuppressForParametersThatDifferOnlyBySuffix = new(nameof(InlineHintsOptions), nameof(SuppressForParametersThatDifferOnlyBySuffix), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.SuppressForParametersThatDifferOnlyBySuffix")); public static readonly PerLanguageOption2<bool> SuppressForParametersThatMatchMethodIntent = new(nameof(InlineHintsOptions), nameof(SuppressForParametersThatMatchMethodIntent), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.SuppressForParametersThatMatchMethodIntent")); public static readonly PerLanguageOption2<bool> EnabledForTypes = new(nameof(InlineHintsOptions), nameof(EnabledForTypes), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints")); public static readonly PerLanguageOption2<bool> ForImplicitVariableTypes = new(nameof(InlineHintsOptions), nameof(ForImplicitVariableTypes), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForImplicitVariableTypes")); public static readonly PerLanguageOption2<bool> ForLambdaParameterTypes = new(nameof(InlineHintsOptions), nameof(ForLambdaParameterTypes), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForLambdaParameterTypes")); public static readonly PerLanguageOption2<bool> ForImplicitObjectCreation = new(nameof(InlineHintsOptions), nameof(ForImplicitObjectCreation), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForImplicitObjectCreation")); } [ExportOptionProvider, Shared] internal sealed class InlineHintsOptionsProvider : IOptionProvider { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public InlineHintsOptionsProvider() { } public ImmutableArray<IOption> Options { get; } = ImmutableArray.Create<IOption>( InlineHintsOptions.DisplayAllHintsWhilePressingAltF1, InlineHintsOptions.ColorHints, InlineHintsOptions.EnabledForParameters, InlineHintsOptions.ForLiteralParameters, InlineHintsOptions.ForObjectCreationParameters, InlineHintsOptions.ForOtherParameters, InlineHintsOptions.EnabledForTypes, InlineHintsOptions.ForImplicitVariableTypes, InlineHintsOptions.ForLambdaParameterTypes, InlineHintsOptions.ForImplicitObjectCreation); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTag.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.VisualStudio.Text.Tagging; namespace Microsoft.CodeAnalysis.Editor.Implementation.EditAndContinue { internal sealed class ActiveStatementTag : TextMarkerTag { internal const string TagId = "RoslynActiveStatementTag"; public static readonly ActiveStatementTag Instance = new(); private ActiveStatementTag() : base(TagId) { } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.VisualStudio.Text.Tagging; namespace Microsoft.CodeAnalysis.Editor.Implementation.EditAndContinue { internal sealed class ActiveStatementTag : TextMarkerTag { internal const string TagId = "RoslynActiveStatementTag"; public static readonly ActiveStatementTag Instance = new(); private ActiveStatementTag() : base(TagId) { } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Analyzers/CSharp/Analyzers/PopulateSwitch/CSharpPopulateSwitchStatementDiagnosticAnalyzer.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.PopulateSwitch; namespace Microsoft.CodeAnalysis.CSharp.PopulateSwitch { [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpPopulateSwitchStatementDiagnosticAnalyzer : AbstractPopulateSwitchStatementDiagnosticAnalyzer<SwitchStatementSyntax> { } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.PopulateSwitch; namespace Microsoft.CodeAnalysis.CSharp.PopulateSwitch { [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpPopulateSwitchStatementDiagnosticAnalyzer : AbstractPopulateSwitchStatementDiagnosticAnalyzer<SwitchStatementSyntax> { } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest2/Recommendations/CharKeywordRecommenderTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.Completion.Providers; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Recommendations { public class CharKeywordRecommenderTests : KeywordRecommenderTests { [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAtRoot_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterClass_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"class C { } $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterGlobalStatement_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"System.Console.WriteLine(); $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterGlobalVariableDeclaration_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"int i = 0; $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInUsingAlias() { await VerifyAbsenceAsync( @"using Goo = $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInGlobalUsingAlias() { await VerifyAbsenceAsync( @"global using Goo = $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterStackAlloc() { await VerifyKeywordAsync( @"class C { int* goo = stackalloc $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFixedStatement() { await VerifyKeywordAsync( @"fixed ($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInDelegateReturnType() { await VerifyKeywordAsync( @"public delegate $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCastType() { await VerifyKeywordAsync(AddInsideMethod( @"var str = (($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCastType2() { await VerifyKeywordAsync(AddInsideMethod( @"var str = (($$)items) as string;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstInMemberContext() { await VerifyKeywordAsync( @"class C { const $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefInMemberContext() { await VerifyKeywordAsync( @"class C { ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyInMemberContext() { await VerifyKeywordAsync( @"class C { ref readonly $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstInStatementContext() { await VerifyKeywordAsync(AddInsideMethod( @"const $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefInStatementContext() { await VerifyKeywordAsync(AddInsideMethod( @"ref $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyInStatementContext() { await VerifyKeywordAsync(AddInsideMethod( @"ref readonly $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstLocalDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"const $$ int local;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefLocalDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"ref $$ int local;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyLocalDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"ref readonly $$ int local;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefLocalFunction() { await VerifyKeywordAsync(AddInsideMethod( @"ref $$ int Function();")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyLocalFunction() { await VerifyKeywordAsync(AddInsideMethod( @"ref readonly $$ int Function();")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefExpression() { await VerifyKeywordAsync(AddInsideMethod( @"ref int x = ref $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInEmptyStatement() { await VerifyKeywordAsync(AddInsideMethod( @"$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInEnumBaseTypes() { await VerifyAbsenceAsync( @"enum E : $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType1() { await VerifyKeywordAsync(AddInsideMethod( @"IList<$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType2() { await VerifyKeywordAsync(AddInsideMethod( @"IList<int,$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType3() { await VerifyKeywordAsync(AddInsideMethod( @"IList<int[],$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType4() { await VerifyKeywordAsync(AddInsideMethod( @"IList<IGoo<int?,byte*>,$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInBaseList() { await VerifyAbsenceAsync( @"class C : $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType_InBaseList() { await VerifyKeywordAsync( @"class C : IList<$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterIs() { await VerifyKeywordAsync(AddInsideMethod( @"var v = goo is $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterAs() { await VerifyKeywordAsync(AddInsideMethod( @"var v = goo as $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethod() { await VerifyKeywordAsync( @"class C { void Goo() {} $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterField() { await VerifyKeywordAsync( @"class C { int i; $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterProperty() { await VerifyKeywordAsync( @"class C { int i { get; } $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedAttribute() { await VerifyKeywordAsync( @"class C { [goo] $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideStruct() { await VerifyKeywordAsync( @"struct S { $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideInterface() { await VerifyKeywordAsync( @"interface I { $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideClass() { await VerifyKeywordAsync( @"class C { $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterPartial() => await VerifyAbsenceAsync(@"partial $$"); [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterNestedPartial() { await VerifyAbsenceAsync( @"class C { partial $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedAbstract() { await VerifyKeywordAsync( @"class C { abstract $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedInternal() { await VerifyKeywordAsync( @"class C { internal $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedStaticPublic() { await VerifyKeywordAsync( @"class C { static public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedPublicStatic() { await VerifyKeywordAsync( @"class C { public static $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterVirtualPublic() { await VerifyKeywordAsync( @"class C { virtual public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedPublic() { await VerifyKeywordAsync( @"class C { public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedPrivate() { await VerifyKeywordAsync( @"class C { private $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedProtected() { await VerifyKeywordAsync( @"class C { protected $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedSealed() { await VerifyKeywordAsync( @"class C { sealed $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedStatic() { await VerifyKeywordAsync( @"class C { static $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInLocalVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInForVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"for ($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInForeachVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"foreach ($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInUsingVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"using ($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFromVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"var q = from $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInJoinVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"var q = from a in b join $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethodOpenParen() { await VerifyKeywordAsync( @"class C { void Goo($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethodComma() { await VerifyKeywordAsync( @"class C { void Goo(int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethodAttribute() { await VerifyKeywordAsync( @"class C { void Goo(int i, [Goo]$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstructorOpenParen() { await VerifyKeywordAsync( @"class C { public C($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstructorComma() { await VerifyKeywordAsync( @"class C { public C(int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstructorAttribute() { await VerifyKeywordAsync( @"class C { public C(int i, [Goo]$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterDelegateOpenParen() { await VerifyKeywordAsync( @"delegate void D($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterDelegateComma() { await VerifyKeywordAsync( @"delegate void D(int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterDelegateAttribute() { await VerifyKeywordAsync( @"delegate void D(int i, [Goo]$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterThis() { await VerifyKeywordAsync( @"static class C { public static void Goo(this $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRef() { await VerifyKeywordAsync( @"class C { void Goo(ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterOut() { await VerifyKeywordAsync( @"class C { void Goo(out $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterLambdaRef() { await VerifyKeywordAsync( @"class C { void Goo() { System.Func<int, int> f = (ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterLambdaOut() { await VerifyKeywordAsync( @"class C { void Goo() { System.Func<int, int> f = (out $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterParams() { await VerifyKeywordAsync( @"class C { void Goo(params $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInImplicitOperator() { await VerifyKeywordAsync( @"class C { public static implicit operator $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInExplicitOperator() { await VerifyKeywordAsync( @"class C { public static explicit operator $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterIndexerBracket() { await VerifyKeywordAsync( @"class C { int this[$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterIndexerBracketComma() { await VerifyKeywordAsync( @"class C { int this[int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNewInExpression() { await VerifyKeywordAsync(AddInsideMethod( @"new $$")); } [WorkItem(538804, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538804")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInTypeOf() { await VerifyKeywordAsync(AddInsideMethod( @"typeof($$")); } [WorkItem(538804, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538804")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInDefault() { await VerifyKeywordAsync(AddInsideMethod( @"default($$")); } [WorkItem(538804, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538804")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInSizeOf() { await VerifyKeywordAsync(AddInsideMethod( @"sizeof($$")); } [WorkItem(544219, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544219")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInObjectInitializerMemberContext() { await VerifyAbsenceAsync(@" class C { public int x, y; void M() { var c = new C { x = 2, y = 3, $$"); } [WorkItem(546938, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546938")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCrefContext() { await VerifyKeywordAsync(@" class Program { /// <see cref=""$$""> static void Main(string[] args) { } }"); } [WorkItem(546955, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546955")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCrefContextNotAfterDot() { await VerifyAbsenceAsync(@" /// <see cref=""System.$$"" /> class C { } "); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterAsync() => await VerifyKeywordAsync(@"class c { async $$ }"); [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterAsyncAsType() => await VerifyAbsenceAsync(@"class c { async async $$ }"); [WorkItem(988025, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/988025")] [Fact, Trait(Traits.Feature, Traits.Features.Completion)] public async Task TestInGenericMethodTypeParameterList1() { var markup = @" class Class1<T, D> { public static Class1<T, D> Create() { return null; } } static class Class2 { public static void Test<T,D>(this Class1<T, D> arg) { } } class Program { static void Main(string[] args) { Class1<string, int>.Create().Test<$$ } } "; await VerifyKeywordAsync(markup); } [WorkItem(988025, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/988025")] [Fact, Trait(Traits.Feature, Traits.Features.Completion)] public async Task TestInGenericMethodTypeParameterList2() { var markup = @" class Class1<T, D> { public static Class1<T, D> Create() { return null; } } static class Class2 { public static void Test<T,D>(this Class1<T, D> arg) { } } class Program { static void Main(string[] args) { Class1<string, int>.Create().Test<string,$$ } } "; await VerifyKeywordAsync(markup); } [WorkItem(1468, "https://github.com/dotnet/roslyn/issues/1468")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInCrefTypeParameter() { await VerifyAbsenceAsync(@" using System; /// <see cref=""List{$$}"" /> class C { } "); } [WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task Preselection() { await VerifyKeywordAsync(@" class Program { static void Main(string[] args) { Helper($$) } static void Helper(char x) { } } "); } [WorkItem(14127, "https://github.com/dotnet/roslyn/issues/14127")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInTupleWithinType() { await VerifyKeywordAsync(@" class Program { ($$ }"); } [WorkItem(14127, "https://github.com/dotnet/roslyn/issues/14127")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInTupleWithinMember() { await VerifyKeywordAsync(@" class Program { void Method() { ($$ } }"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFunctionPointerType() { await VerifyKeywordAsync(@" class C { delegate*<$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFunctionPointerTypeAfterComma() { await VerifyKeywordAsync(@" class C { delegate*<int, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFunctionPointerTypeAfterModifier() { await VerifyKeywordAsync(@" class C { delegate*<ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterDelegateAsterisk() { await VerifyAbsenceAsync(@" class C { delegate*$$"); } [WorkItem(53585, "https://github.com/dotnet/roslyn/issues/53585")] [Theory, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] [ClassData(typeof(TheoryDataKeywordsIndicatingLocalFunction))] public async Task TestAfterKeywordIndicatingLocalFunction(string keyword) { await VerifyKeywordAsync(AddInsideMethod($@" {keyword} $$")); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.Completion.Providers; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Recommendations { public class CharKeywordRecommenderTests : KeywordRecommenderTests { [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAtRoot_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterClass_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"class C { } $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterGlobalStatement_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"System.Console.WriteLine(); $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterGlobalVariableDeclaration_Interactive() { await VerifyKeywordAsync(SourceCodeKind.Script, @"int i = 0; $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInUsingAlias() { await VerifyAbsenceAsync( @"using Goo = $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInGlobalUsingAlias() { await VerifyAbsenceAsync( @"global using Goo = $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterStackAlloc() { await VerifyKeywordAsync( @"class C { int* goo = stackalloc $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFixedStatement() { await VerifyKeywordAsync( @"fixed ($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInDelegateReturnType() { await VerifyKeywordAsync( @"public delegate $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCastType() { await VerifyKeywordAsync(AddInsideMethod( @"var str = (($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCastType2() { await VerifyKeywordAsync(AddInsideMethod( @"var str = (($$)items) as string;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstInMemberContext() { await VerifyKeywordAsync( @"class C { const $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefInMemberContext() { await VerifyKeywordAsync( @"class C { ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyInMemberContext() { await VerifyKeywordAsync( @"class C { ref readonly $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstInStatementContext() { await VerifyKeywordAsync(AddInsideMethod( @"const $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefInStatementContext() { await VerifyKeywordAsync(AddInsideMethod( @"ref $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyInStatementContext() { await VerifyKeywordAsync(AddInsideMethod( @"ref readonly $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstLocalDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"const $$ int local;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefLocalDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"ref $$ int local;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyLocalDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"ref readonly $$ int local;")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefLocalFunction() { await VerifyKeywordAsync(AddInsideMethod( @"ref $$ int Function();")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefReadonlyLocalFunction() { await VerifyKeywordAsync(AddInsideMethod( @"ref readonly $$ int Function();")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRefExpression() { await VerifyKeywordAsync(AddInsideMethod( @"ref int x = ref $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInEmptyStatement() { await VerifyKeywordAsync(AddInsideMethod( @"$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInEnumBaseTypes() { await VerifyAbsenceAsync( @"enum E : $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType1() { await VerifyKeywordAsync(AddInsideMethod( @"IList<$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType2() { await VerifyKeywordAsync(AddInsideMethod( @"IList<int,$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType3() { await VerifyKeywordAsync(AddInsideMethod( @"IList<int[],$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType4() { await VerifyKeywordAsync(AddInsideMethod( @"IList<IGoo<int?,byte*>,$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInBaseList() { await VerifyAbsenceAsync( @"class C : $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInGenericType_InBaseList() { await VerifyKeywordAsync( @"class C : IList<$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterIs() { await VerifyKeywordAsync(AddInsideMethod( @"var v = goo is $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterAs() { await VerifyKeywordAsync(AddInsideMethod( @"var v = goo as $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethod() { await VerifyKeywordAsync( @"class C { void Goo() {} $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterField() { await VerifyKeywordAsync( @"class C { int i; $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterProperty() { await VerifyKeywordAsync( @"class C { int i { get; } $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedAttribute() { await VerifyKeywordAsync( @"class C { [goo] $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideStruct() { await VerifyKeywordAsync( @"struct S { $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideInterface() { await VerifyKeywordAsync( @"interface I { $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideClass() { await VerifyKeywordAsync( @"class C { $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterPartial() => await VerifyAbsenceAsync(@"partial $$"); [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterNestedPartial() { await VerifyAbsenceAsync( @"class C { partial $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedAbstract() { await VerifyKeywordAsync( @"class C { abstract $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedInternal() { await VerifyKeywordAsync( @"class C { internal $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedStaticPublic() { await VerifyKeywordAsync( @"class C { static public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedPublicStatic() { await VerifyKeywordAsync( @"class C { public static $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterVirtualPublic() { await VerifyKeywordAsync( @"class C { virtual public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedPublic() { await VerifyKeywordAsync( @"class C { public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedPrivate() { await VerifyKeywordAsync( @"class C { private $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedProtected() { await VerifyKeywordAsync( @"class C { protected $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedSealed() { await VerifyKeywordAsync( @"class C { sealed $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedStatic() { await VerifyKeywordAsync( @"class C { static $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInLocalVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"$$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInForVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"for ($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInForeachVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"foreach ($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInUsingVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"using ($$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFromVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"var q = from $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInJoinVariableDeclaration() { await VerifyKeywordAsync(AddInsideMethod( @"var q = from a in b join $$")); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethodOpenParen() { await VerifyKeywordAsync( @"class C { void Goo($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethodComma() { await VerifyKeywordAsync( @"class C { void Goo(int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterMethodAttribute() { await VerifyKeywordAsync( @"class C { void Goo(int i, [Goo]$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstructorOpenParen() { await VerifyKeywordAsync( @"class C { public C($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstructorComma() { await VerifyKeywordAsync( @"class C { public C(int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterConstructorAttribute() { await VerifyKeywordAsync( @"class C { public C(int i, [Goo]$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterDelegateOpenParen() { await VerifyKeywordAsync( @"delegate void D($$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterDelegateComma() { await VerifyKeywordAsync( @"delegate void D(int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterDelegateAttribute() { await VerifyKeywordAsync( @"delegate void D(int i, [Goo]$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterThis() { await VerifyKeywordAsync( @"static class C { public static void Goo(this $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterRef() { await VerifyKeywordAsync( @"class C { void Goo(ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterOut() { await VerifyKeywordAsync( @"class C { void Goo(out $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterLambdaRef() { await VerifyKeywordAsync( @"class C { void Goo() { System.Func<int, int> f = (ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterLambdaOut() { await VerifyKeywordAsync( @"class C { void Goo() { System.Func<int, int> f = (out $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterParams() { await VerifyKeywordAsync( @"class C { void Goo(params $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInImplicitOperator() { await VerifyKeywordAsync( @"class C { public static implicit operator $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInExplicitOperator() { await VerifyKeywordAsync( @"class C { public static explicit operator $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterIndexerBracket() { await VerifyKeywordAsync( @"class C { int this[$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterIndexerBracketComma() { await VerifyKeywordAsync( @"class C { int this[int i, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNewInExpression() { await VerifyKeywordAsync(AddInsideMethod( @"new $$")); } [WorkItem(538804, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538804")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInTypeOf() { await VerifyKeywordAsync(AddInsideMethod( @"typeof($$")); } [WorkItem(538804, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538804")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInDefault() { await VerifyKeywordAsync(AddInsideMethod( @"default($$")); } [WorkItem(538804, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538804")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInSizeOf() { await VerifyKeywordAsync(AddInsideMethod( @"sizeof($$")); } [WorkItem(544219, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544219")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInObjectInitializerMemberContext() { await VerifyAbsenceAsync(@" class C { public int x, y; void M() { var c = new C { x = 2, y = 3, $$"); } [WorkItem(546938, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546938")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCrefContext() { await VerifyKeywordAsync(@" class Program { /// <see cref=""$$""> static void Main(string[] args) { } }"); } [WorkItem(546955, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546955")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInCrefContextNotAfterDot() { await VerifyAbsenceAsync(@" /// <see cref=""System.$$"" /> class C { } "); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterAsync() => await VerifyKeywordAsync(@"class c { async $$ }"); [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterAsyncAsType() => await VerifyAbsenceAsync(@"class c { async async $$ }"); [WorkItem(988025, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/988025")] [Fact, Trait(Traits.Feature, Traits.Features.Completion)] public async Task TestInGenericMethodTypeParameterList1() { var markup = @" class Class1<T, D> { public static Class1<T, D> Create() { return null; } } static class Class2 { public static void Test<T,D>(this Class1<T, D> arg) { } } class Program { static void Main(string[] args) { Class1<string, int>.Create().Test<$$ } } "; await VerifyKeywordAsync(markup); } [WorkItem(988025, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/988025")] [Fact, Trait(Traits.Feature, Traits.Features.Completion)] public async Task TestInGenericMethodTypeParameterList2() { var markup = @" class Class1<T, D> { public static Class1<T, D> Create() { return null; } } static class Class2 { public static void Test<T,D>(this Class1<T, D> arg) { } } class Program { static void Main(string[] args) { Class1<string, int>.Create().Test<string,$$ } } "; await VerifyKeywordAsync(markup); } [WorkItem(1468, "https://github.com/dotnet/roslyn/issues/1468")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotInCrefTypeParameter() { await VerifyAbsenceAsync(@" using System; /// <see cref=""List{$$}"" /> class C { } "); } [WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task Preselection() { await VerifyKeywordAsync(@" class Program { static void Main(string[] args) { Helper($$) } static void Helper(char x) { } } "); } [WorkItem(14127, "https://github.com/dotnet/roslyn/issues/14127")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInTupleWithinType() { await VerifyKeywordAsync(@" class Program { ($$ }"); } [WorkItem(14127, "https://github.com/dotnet/roslyn/issues/14127")] [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInTupleWithinMember() { await VerifyKeywordAsync(@" class Program { void Method() { ($$ } }"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFunctionPointerType() { await VerifyKeywordAsync(@" class C { delegate*<$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFunctionPointerTypeAfterComma() { await VerifyKeywordAsync(@" class C { delegate*<int, $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInFunctionPointerTypeAfterModifier() { await VerifyKeywordAsync(@" class C { delegate*<ref $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotAfterDelegateAsterisk() { await VerifyAbsenceAsync(@" class C { delegate*$$"); } [WorkItem(53585, "https://github.com/dotnet/roslyn/issues/53585")] [Theory, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] [ClassData(typeof(TheoryDataKeywordsIndicatingLocalFunction))] public async Task TestAfterKeywordIndicatingLocalFunction(string keyword) { await VerifyKeywordAsync(AddInsideMethod($@" {keyword} $$")); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/SymbolKey/SymbolKey.ArrayTypeSymbolKey.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis { internal partial struct SymbolKey { private static class ArrayTypeSymbolKey { public static void Create(IArrayTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteSymbolKey(symbol.ElementType); visitor.WriteInteger(symbol.Rank); } public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string? failureReason) { var elementTypeResolution = reader.ReadSymbolKey(out var elementTypeFailureReason); var rank = reader.ReadInteger(); if (elementTypeFailureReason != null) { failureReason = $"({nameof(ArrayTypeSymbolKey)} {nameof(elementTypeResolution)} failed -> {elementTypeFailureReason})"; return default; } using var result = PooledArrayBuilder<IArrayTypeSymbol>.GetInstance(elementTypeResolution.SymbolCount); foreach (var typeSymbol in elementTypeResolution.OfType<ITypeSymbol>()) result.AddIfNotNull(reader.Compilation.CreateArrayTypeSymbol(typeSymbol, rank)); return CreateResolution(result, $"({nameof(ArrayTypeSymbolKey)})", out failureReason); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis { internal partial struct SymbolKey { private static class ArrayTypeSymbolKey { public static void Create(IArrayTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteSymbolKey(symbol.ElementType); visitor.WriteInteger(symbol.Rank); } public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string? failureReason) { var elementTypeResolution = reader.ReadSymbolKey(out var elementTypeFailureReason); var rank = reader.ReadInteger(); if (elementTypeFailureReason != null) { failureReason = $"({nameof(ArrayTypeSymbolKey)} {nameof(elementTypeResolution)} failed -> {elementTypeFailureReason})"; return default; } using var result = PooledArrayBuilder<IArrayTypeSymbol>.GetInstance(elementTypeResolution.SymbolCount); foreach (var typeSymbol in elementTypeResolution.OfType<ITypeSymbol>()) result.AddIfNotNull(reader.Compilation.CreateArrayTypeSymbol(typeSymbol, rank)); return CreateResolution(result, $"({nameof(ArrayTypeSymbolKey)})", out failureReason); } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Legacy.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; namespace Microsoft.CodeAnalysis.FindSymbols { // This file contains the legacy FindReferences APIs. The APIs are legacy because they // do not contain enough information for us to effectively remote them over to the OOP // process to do the work. Specifically, they lack the "current project context" necessary // to be able to effectively serialize symbols to/from the remote process. public static partial class SymbolFinder { /// <summary> /// Finds all references to a symbol throughout a solution /// </summary> /// <param name="symbol">The symbol to find references to.</param> /// <param name="solution">The solution to find references within.</param> /// <param name="cancellationToken">A cancellation token.</param> public static Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, CancellationToken cancellationToken = default) { if (symbol is null) throw new System.ArgumentNullException(nameof(symbol)); if (solution is null) throw new System.ArgumentNullException(nameof(solution)); return FindReferencesAsync(symbol, solution, FindReferencesSearchOptions.Default, cancellationToken); } internal static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, FindReferencesSearchOptions options, CancellationToken cancellationToken) { var progressCollector = new StreamingProgressCollector(); await FindReferencesAsync( symbol, solution, progressCollector, documents: null, options, cancellationToken).ConfigureAwait(false); return progressCollector.GetReferencedSymbols(); } /// <summary> /// Finds all references to a symbol throughout a solution /// </summary> /// <param name="symbol">The symbol to find references to.</param> /// <param name="solution">The solution to find references within.</param> /// <param name="documents">A set of documents to be searched. If documents is null, then that means "all documents".</param> /// <param name="cancellationToken">A cancellation token.</param> public static Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IImmutableSet<Document>? documents, CancellationToken cancellationToken = default) { if (symbol is null) throw new System.ArgumentNullException(nameof(symbol)); if (solution is null) throw new System.ArgumentNullException(nameof(solution)); return FindReferencesAsync(symbol, solution, progress: null, documents: documents, cancellationToken: cancellationToken); } /// <summary> /// Finds all references to a symbol throughout a solution /// </summary> /// <param name="symbol">The symbol to find references to.</param> /// <param name="solution">The solution to find references within.</param> /// <param name="progress">An optional progress object that will receive progress /// information as the search is undertaken.</param> /// <param name="documents">An optional set of documents to be searched. If documents is null, then that means "all documents".</param> /// <param name="cancellationToken">An optional cancellation token.</param> public static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IFindReferencesProgress? progress, IImmutableSet<Document>? documents, CancellationToken cancellationToken = default) { if (symbol is null) throw new System.ArgumentNullException(nameof(symbol)); if (solution is null) throw new System.ArgumentNullException(nameof(solution)); return await FindReferencesAsync( symbol, solution, progress, documents, FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false); } internal static async Task<ImmutableArray<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IFindReferencesProgress? progress, IImmutableSet<Document>? documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { progress ??= NoOpFindReferencesProgress.Instance; var streamingProgress = new StreamingProgressCollector( new StreamingFindReferencesProgressAdapter(progress)); await FindReferencesAsync( symbol, solution, streamingProgress, documents, options, cancellationToken).ConfigureAwait(false); return streamingProgress.GetReferencedSymbols(); } internal static class TestAccessor { internal static Task<ImmutableArray<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IFindReferencesProgress progress, IImmutableSet<Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { return SymbolFinder.FindReferencesAsync(symbol, solution, progress, documents, options, cancellationToken); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; namespace Microsoft.CodeAnalysis.FindSymbols { // This file contains the legacy FindReferences APIs. The APIs are legacy because they // do not contain enough information for us to effectively remote them over to the OOP // process to do the work. Specifically, they lack the "current project context" necessary // to be able to effectively serialize symbols to/from the remote process. public static partial class SymbolFinder { /// <summary> /// Finds all references to a symbol throughout a solution /// </summary> /// <param name="symbol">The symbol to find references to.</param> /// <param name="solution">The solution to find references within.</param> /// <param name="cancellationToken">A cancellation token.</param> public static Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, CancellationToken cancellationToken = default) { if (symbol is null) throw new System.ArgumentNullException(nameof(symbol)); if (solution is null) throw new System.ArgumentNullException(nameof(solution)); return FindReferencesAsync(symbol, solution, FindReferencesSearchOptions.Default, cancellationToken); } internal static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, FindReferencesSearchOptions options, CancellationToken cancellationToken) { var progressCollector = new StreamingProgressCollector(); await FindReferencesAsync( symbol, solution, progressCollector, documents: null, options, cancellationToken).ConfigureAwait(false); return progressCollector.GetReferencedSymbols(); } /// <summary> /// Finds all references to a symbol throughout a solution /// </summary> /// <param name="symbol">The symbol to find references to.</param> /// <param name="solution">The solution to find references within.</param> /// <param name="documents">A set of documents to be searched. If documents is null, then that means "all documents".</param> /// <param name="cancellationToken">A cancellation token.</param> public static Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IImmutableSet<Document>? documents, CancellationToken cancellationToken = default) { if (symbol is null) throw new System.ArgumentNullException(nameof(symbol)); if (solution is null) throw new System.ArgumentNullException(nameof(solution)); return FindReferencesAsync(symbol, solution, progress: null, documents: documents, cancellationToken: cancellationToken); } /// <summary> /// Finds all references to a symbol throughout a solution /// </summary> /// <param name="symbol">The symbol to find references to.</param> /// <param name="solution">The solution to find references within.</param> /// <param name="progress">An optional progress object that will receive progress /// information as the search is undertaken.</param> /// <param name="documents">An optional set of documents to be searched. If documents is null, then that means "all documents".</param> /// <param name="cancellationToken">An optional cancellation token.</param> public static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IFindReferencesProgress? progress, IImmutableSet<Document>? documents, CancellationToken cancellationToken = default) { if (symbol is null) throw new System.ArgumentNullException(nameof(symbol)); if (solution is null) throw new System.ArgumentNullException(nameof(solution)); return await FindReferencesAsync( symbol, solution, progress, documents, FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false); } internal static async Task<ImmutableArray<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IFindReferencesProgress? progress, IImmutableSet<Document>? documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { progress ??= NoOpFindReferencesProgress.Instance; var streamingProgress = new StreamingProgressCollector( new StreamingFindReferencesProgressAdapter(progress)); await FindReferencesAsync( symbol, solution, streamingProgress, documents, options, cancellationToken).ConfigureAwait(false); return streamingProgress.GetReferencedSymbols(); } internal static class TestAccessor { internal static Task<ImmutableArray<ReferencedSymbol>> FindReferencesAsync( ISymbol symbol, Solution solution, IFindReferencesProgress progress, IImmutableSet<Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { return SymbolFinder.FindReferencesAsync(symbol, solution, progress, documents, options, cancellationToken); } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService; using Microsoft.VisualStudio.LanguageServices.Implementation.F1Help; using Microsoft.VisualStudio.LanguageServices.UnitTests; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; namespace Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.F1Help { [UseExportProvider] public class F1HelpTests { private static async Task TestAsync(string markup, string expectedText) { using var workspace = TestWorkspace.CreateCSharp(markup, composition: VisualStudioTestCompositions.LanguageServices); var caret = workspace.Documents.First().CursorPosition; var service = Assert.IsType<CSharpHelpContextService>(workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetService<IHelpContextService>()); var actualText = await service.GetHelpTermAsync(workspace.CurrentSolution.Projects.First().Documents.First(), workspace.Documents.First().SelectedSpans.First(), CancellationToken.None); Assert.Equal(expectedText, actualText); } private static async Task Test_KeywordAsync(string markup, string expectedText) { await TestAsync(markup, expectedText + "_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestInternal() { await Test_KeywordAsync( @"intern[||]al class C { }", "internal"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProtected() { await Test_KeywordAsync( @"public class C { protec[||]ted void goo(); }", "protected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProtectedInternal1() { await Test_KeywordAsync( @"public class C { internal protec[||]ted void goo(); }", "protectedinternal"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProtectedInternal2() { await Test_KeywordAsync( @"public class C { protec[||]ted internal void goo(); }", "protectedinternal"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected1() { await Test_KeywordAsync( @"public class C { private protec[||]ted void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected2() { await Test_KeywordAsync( @"public class C { priv[||]ate protected void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected3() { await Test_KeywordAsync( @"public class C { protected priv[||]ate void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected4() { await Test_KeywordAsync( @"public class C { prot[||]ected private void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestModifierSoup() { await Test_KeywordAsync( @"public class C { private new prot[||]ected static unsafe void foo() { } }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestModifierSoupField() { await Test_KeywordAsync( @"public class C { new prot[||]ected static unsafe private goo; }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVoid() { await Test_KeywordAsync( @"class C { vo[||]id goo() { } }", "void"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestReturn() { await Test_KeywordAsync( @"class C { void goo() { ret[||]urn; } }", "return"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassPartialType() { await Test_KeywordAsync( @"part[||]ial class C { partial void goo(); }", "partialtype"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRecordPartialType() { await Test_KeywordAsync( @"part[||]ial record C { partial void goo(); }", "partialtype"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRecordWithPrimaryConstructorPartialType() { await Test_KeywordAsync( @"part[||]ial record C(string S) { partial void goo(); }", "partialtype"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPartialMethodInClass() { await Test_KeywordAsync( @"partial class C { par[||]tial void goo(); }", "partialmethod"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPartialMethodInRecord() { await Test_KeywordAsync( @"partial record C { par[||]tial void goo(); }", "partialmethod"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestExtendedPartialMethod() { await Test_KeywordAsync( @"partial class C { public par[||]tial void goo(); }", "partialmethod"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestWhereClause() { await Test_KeywordAsync( @"using System.Linq; class Program<T> where T : class { void goo(string[] args) { var x = from a in args whe[||]re a.Length > 0 select a; } }", "whereclause"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestWhereConstraint() { await Test_KeywordAsync( @"using System.Linq; class Program<T> wh[||]ere T : class { void goo(string[] args) { var x = from a in args where a.Length > 0 select a; } }", "whereconstraint"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPreprocessor() { await TestAsync( @"#regi[||]on #endregion", "#region"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestConstructor() { await TestAsync( @"namespace N { class C { void goo() { var x = new [|C|](); } } }", "N.C.#ctor"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestGenericClass() { await TestAsync( @"namespace N { class C<T> { void goo() { [|C|]<int> c; } } }", "N.C`1"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestGenericMethod() { await TestAsync( @"namespace N { class C<T> { void goo<T, U, V>(T t, U u, V v) { C<int> c; c.g[|oo|](1, 1, 1); } } }", "N.C`1.goo``3"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestOperator() { await TestAsync( @"namespace N { class C { void goo() { var two = 1 [|+|] 1; } }", "+_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVar() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var[||] x = 3; } }", "var_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestEquals() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var x =[||] 3; } }", "=_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestFromIn() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var x = from n i[||]n { 1} select n } }", "from_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProperty() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { new UriBuilder().Fragm[||]ent; } }", "System.UriBuilder.Fragment"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestForeachIn() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { foreach (var x in[||] { 1} ) { } } }", "in_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRegionDescription() { await TestAsync( @"class Program { static void Main(string[] args) { #region Begin MyR[||]egion for testing #endregion End } }", "#region"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestGenericAngle() { await TestAsync( @"class Program { static void generic<T>(T t) { generic[||]<int>(0); } }", "Program.generic``1"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLocalReferenceIsType() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { int x; x[||]; } }", "System.Int32"); } [WorkItem(864266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/864266")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestConstantField() { await TestAsync( @"class Program { static void Main(string[] args) { var i = int.Ma[||]xValue; } }", "System.Int32.MaxValue"); } [WorkItem(862420, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862420")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestParameter() { await TestAsync( @"class Class2 { void M1(int par[||]ameter) // 1 { } void M2() { int argument = 1; M1(parameter: argument); // 2 } }", "System.Int32"); } [WorkItem(862420, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862420")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestArgumentType() { await TestAsync( @"class Class2 { void M1(int pa[||]rameter) // 1 { } void M2() { int argument = 1; M1(parameter: argument); // 2 } }", "System.Int32"); } [WorkItem(862396, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862396")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNoToken() { await TestAsync( @"class Program { static void Main(string[] args) { } }[||]", ""); } [WorkItem(862328, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862328")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLiteral() { await TestAsync( @"class Program { static void Main(string[] args) { Main(new string[] { ""fo[||]o"" }); } }", "System.String"); } [WorkItem(862478, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862478")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestColonColon() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { global:[||]:System.Console.Write(""); } }", "::_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStringInterpolation() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine($[||]""Hello, {args[0]}""); } }", "$_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVerbatimString() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine(@[||]""Hello\""); } }", "@_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVerbatimInterpolatedString1() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine(@[||]$""Hello\ {args[0]}""); } }", "@$_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVerbatimInterpolatedString2() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine($[||]@""Hello\ {args[0]}""); } }", "@$_CSharpKeyword"); } [WorkItem(864658, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/864658")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNullable() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { int?[||] a = int.MaxValue; a.Value.GetHashCode(); } }", "System.Nullable`1"); } [WorkItem(863517, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/863517")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestAfterLastToken() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { foreach (char var in ""!!!"")$$[||] { } } }", ""); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestConditional() { await TestAsync( @"class Program { static void Main(string[] args) { var x = true [|?|] true : false; } }", "?_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLocalVar() { await TestAsync( @"class C { void M() { var a = 0; int v[||]ar = 1; } }", "System.Int32"); } [WorkItem(867574, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867574")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestFatArrow() { await TestAsync( @"class C { void M() { var a = new System.Action(() =[||]> { }); } }", "=>_CSharpKeyword"); } [WorkItem(867572, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867572")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestSubscription() { await TestAsync( @"class CCC { event System.Action e; void M() { e +[||]= () => { }; } }", "+=_CSharpKeyword"); } [WorkItem(867554, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867554")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestComment() { await TestAsync(@"// some comm[||]ents here", "comments"); } [WorkItem(867529, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867529")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDynamic() { await TestAsync( @"class C { void M() { dyna[||]mic d = 0; } }", "dynamic_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRangeVariable() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var zzz = from y in args select [||]y; } }", "System.String"); } [WorkItem(36001, "https://github.com/dotnet/roslyn/issues/36001")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNameof() { await Test_KeywordAsync( @"class C { void goo() { var v = [||]nameof(goo); } }", "nameof"); } [WorkItem(46988, "https://github.com/dotnet/roslyn/issues/46988")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNullForgiving() { await Test_KeywordAsync( @"#nullable enable class C { int goo(string? x) { return x[||]!.GetHashCode(); } }", "nullForgiving"); } [WorkItem(46988, "https://github.com/dotnet/roslyn/issues/46988")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLogicalNot() { await Test_KeywordAsync( @"class C { bool goo(bool x) { return [||]!x; } }", "!"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultSwitchCase() { await Test_KeywordAsync( @"class C { void M1(int parameter) { switch(parameter) { defa[||]ult: parameter = default; break; } } }", "defaultcase"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpressionInsideSwitch() { await Test_KeywordAsync( @"class C { void M1(int parameter) { switch(parameter) { default: parameter = defa[||]ult; break; } } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpressionInsideSwitch() { await Test_KeywordAsync( @"class C { void M1(int parameter) { switch(parameter) { default: parameter = defa[||]ult(int); break; } } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpression() { await Test_KeywordAsync( @"class C { int field = defa[||]ult; }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpression() { await Test_KeywordAsync( @"class C { int field = defa[||]ult(int); }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpressionInOptionalParameter() { await Test_KeywordAsync( @"class C { void M1(int parameter = defa[||]ult) { } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpressionInOptionalParameter() { await Test_KeywordAsync( @"class C { void M1(int parameter = defa[||]ult(int)) { } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpressionInMethodCall() { await Test_KeywordAsync( @"class C { void M1() { M2(defa[||]ult); } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpressionInMethodCall() { await Test_KeywordAsync( @"class C { void M1() { M2(defa[||]ult(int)); } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestOuterClassDeclaration() { await Test_KeywordAsync( @"cla[||]ss OuterClass<T> where T : class { class InnerClass<T> where T : class { } }", "class"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestInnerClassDeclaration() { await Test_KeywordAsync( @"class OuterClass<T> where T : class { cla[||]ss InnerClass<T> where T : class { } }", "class"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInOuterClass() { await Test_KeywordAsync( @"class OuterClass<T> where T : cla[||]ss { class InnerClass<T> where T : class { } }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInInnerClass() { await Test_KeywordAsync( @"class OuterClass<T> where T : class { class InnerClass<T> where T : cla[||]ss { } }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInGenericMethod() { await Test_KeywordAsync( @"class C { void M1<T>() where T : cla[||]ss { } }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInGenericDelegate() { await Test_KeywordAsync( @"class C { delegate T MyDelegate<T>() where T : cla[||]ss; }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestOuterStructDeclaration() { await Test_KeywordAsync( @"str[||]uct OuterStruct<T> where T : struct { struct InnerStruct<T> where T : struct { } }", "struct"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestInnerStructDeclaration() { await Test_KeywordAsync( @"struct OuterStruct<T> where T : struct { str[||]uct InnerStruct<T> where T : struct { } }", "struct"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInOuterStruct() { await Test_KeywordAsync( @"struct OuterStruct<T> where T : str[||]uct { struct InnerStruct<T> where T : struct { } }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInInnerStruct() { await Test_KeywordAsync( @"struct OuterStruct<T> where T : struct { struct InnerStruct<T> where T : str[||]uct { } }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInGenericMethod() { await Test_KeywordAsync( @"struct C { void M1<T>() where T : str[||]uct { } }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInGenericDelegate() { await Test_KeywordAsync( @"struct C { delegate T MyDelegate<T>() where T : str[||]uct; }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingStaticOnUsingKeyword() { await Test_KeywordAsync( @"us[||]ing static namespace.Class; static class C { static int Field; static void Method() {} }", "using-static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNormalUsingDirective() { await Test_KeywordAsync( @"us[||]ing namespace.Class; static class C { static int Field; static void Method() {} }", "using"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingStatement() { await Test_KeywordAsync( @"using namespace.Class; class C { void Method(String someString) { us[||]ing (var reader = new StringReader(someString)) { } } }", "using-statement"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingDeclaration() { await Test_KeywordAsync( @"using namespace.Class; class C { void Method(String someString) { us[||]ing var reader = new StringReader(someString); } }", "using-statement"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingStaticOnStaticKeyword() { await Test_KeywordAsync( @"using sta[||]tic namespace.Class; static class C { static int Field; static void Method() {} }", "using-static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStaticClass() { await Test_KeywordAsync( @"using static namespace.Class; sta[||]tic class C { static int Field; static void Method() {} }", "static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStaticField() { await Test_KeywordAsync( @"using static namespace.Class; static class C { sta[||]tic int Field; static void Method() {} }", "static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStaticMethod() { await Test_KeywordAsync( @"using static namespace.Class; static class C { static int Field; sta[||]tic void Method() {} }", "static"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestWithKeyword() { await Test_KeywordAsync( @" public record Point(int X, int Y); public static class Program { public static void Main() { var p1 = new Point(0, 0); var p2 = p1 w[||]ith { X = 5 }; } }", "with"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService; using Microsoft.VisualStudio.LanguageServices.Implementation.F1Help; using Microsoft.VisualStudio.LanguageServices.UnitTests; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; namespace Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.F1Help { [UseExportProvider] public class F1HelpTests { private static async Task TestAsync(string markup, string expectedText) { using var workspace = TestWorkspace.CreateCSharp(markup, composition: VisualStudioTestCompositions.LanguageServices); var caret = workspace.Documents.First().CursorPosition; var service = Assert.IsType<CSharpHelpContextService>(workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetService<IHelpContextService>()); var actualText = await service.GetHelpTermAsync(workspace.CurrentSolution.Projects.First().Documents.First(), workspace.Documents.First().SelectedSpans.First(), CancellationToken.None); Assert.Equal(expectedText, actualText); } private static async Task Test_KeywordAsync(string markup, string expectedText) { await TestAsync(markup, expectedText + "_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestInternal() { await Test_KeywordAsync( @"intern[||]al class C { }", "internal"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProtected() { await Test_KeywordAsync( @"public class C { protec[||]ted void goo(); }", "protected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProtectedInternal1() { await Test_KeywordAsync( @"public class C { internal protec[||]ted void goo(); }", "protectedinternal"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProtectedInternal2() { await Test_KeywordAsync( @"public class C { protec[||]ted internal void goo(); }", "protectedinternal"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected1() { await Test_KeywordAsync( @"public class C { private protec[||]ted void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected2() { await Test_KeywordAsync( @"public class C { priv[||]ate protected void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected3() { await Test_KeywordAsync( @"public class C { protected priv[||]ate void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPrivateProtected4() { await Test_KeywordAsync( @"public class C { prot[||]ected private void goo(); }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestModifierSoup() { await Test_KeywordAsync( @"public class C { private new prot[||]ected static unsafe void foo() { } }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestModifierSoupField() { await Test_KeywordAsync( @"public class C { new prot[||]ected static unsafe private goo; }", "privateprotected"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVoid() { await Test_KeywordAsync( @"class C { vo[||]id goo() { } }", "void"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestReturn() { await Test_KeywordAsync( @"class C { void goo() { ret[||]urn; } }", "return"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassPartialType() { await Test_KeywordAsync( @"part[||]ial class C { partial void goo(); }", "partialtype"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRecordPartialType() { await Test_KeywordAsync( @"part[||]ial record C { partial void goo(); }", "partialtype"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRecordWithPrimaryConstructorPartialType() { await Test_KeywordAsync( @"part[||]ial record C(string S) { partial void goo(); }", "partialtype"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPartialMethodInClass() { await Test_KeywordAsync( @"partial class C { par[||]tial void goo(); }", "partialmethod"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPartialMethodInRecord() { await Test_KeywordAsync( @"partial record C { par[||]tial void goo(); }", "partialmethod"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestExtendedPartialMethod() { await Test_KeywordAsync( @"partial class C { public par[||]tial void goo(); }", "partialmethod"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestWhereClause() { await Test_KeywordAsync( @"using System.Linq; class Program<T> where T : class { void goo(string[] args) { var x = from a in args whe[||]re a.Length > 0 select a; } }", "whereclause"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestWhereConstraint() { await Test_KeywordAsync( @"using System.Linq; class Program<T> wh[||]ere T : class { void goo(string[] args) { var x = from a in args where a.Length > 0 select a; } }", "whereconstraint"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestPreprocessor() { await TestAsync( @"#regi[||]on #endregion", "#region"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestConstructor() { await TestAsync( @"namespace N { class C { void goo() { var x = new [|C|](); } } }", "N.C.#ctor"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestGenericClass() { await TestAsync( @"namespace N { class C<T> { void goo() { [|C|]<int> c; } } }", "N.C`1"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestGenericMethod() { await TestAsync( @"namespace N { class C<T> { void goo<T, U, V>(T t, U u, V v) { C<int> c; c.g[|oo|](1, 1, 1); } } }", "N.C`1.goo``3"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestOperator() { await TestAsync( @"namespace N { class C { void goo() { var two = 1 [|+|] 1; } }", "+_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVar() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var[||] x = 3; } }", "var_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestEquals() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var x =[||] 3; } }", "=_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestFromIn() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var x = from n i[||]n { 1} select n } }", "from_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestProperty() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { new UriBuilder().Fragm[||]ent; } }", "System.UriBuilder.Fragment"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestForeachIn() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { foreach (var x in[||] { 1} ) { } } }", "in_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRegionDescription() { await TestAsync( @"class Program { static void Main(string[] args) { #region Begin MyR[||]egion for testing #endregion End } }", "#region"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestGenericAngle() { await TestAsync( @"class Program { static void generic<T>(T t) { generic[||]<int>(0); } }", "Program.generic``1"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLocalReferenceIsType() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { int x; x[||]; } }", "System.Int32"); } [WorkItem(864266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/864266")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestConstantField() { await TestAsync( @"class Program { static void Main(string[] args) { var i = int.Ma[||]xValue; } }", "System.Int32.MaxValue"); } [WorkItem(862420, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862420")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestParameter() { await TestAsync( @"class Class2 { void M1(int par[||]ameter) // 1 { } void M2() { int argument = 1; M1(parameter: argument); // 2 } }", "System.Int32"); } [WorkItem(862420, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862420")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestArgumentType() { await TestAsync( @"class Class2 { void M1(int pa[||]rameter) // 1 { } void M2() { int argument = 1; M1(parameter: argument); // 2 } }", "System.Int32"); } [WorkItem(862396, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862396")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNoToken() { await TestAsync( @"class Program { static void Main(string[] args) { } }[||]", ""); } [WorkItem(862328, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862328")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLiteral() { await TestAsync( @"class Program { static void Main(string[] args) { Main(new string[] { ""fo[||]o"" }); } }", "System.String"); } [WorkItem(862478, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/862478")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestColonColon() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { global:[||]:System.Console.Write(""); } }", "::_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStringInterpolation() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine($[||]""Hello, {args[0]}""); } }", "$_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVerbatimString() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine(@[||]""Hello\""); } }", "@_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVerbatimInterpolatedString1() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine(@[||]$""Hello\ {args[0]}""); } }", "@$_CSharpKeyword"); } [WorkItem(46986, "https://github.com/dotnet/roslyn/issues/46986")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestVerbatimInterpolatedString2() { await TestAsync( @"using System; class Program { static void Main(string[] args) { Console.WriteLine($[||]@""Hello\ {args[0]}""); } }", "@$_CSharpKeyword"); } [WorkItem(864658, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/864658")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNullable() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { int?[||] a = int.MaxValue; a.Value.GetHashCode(); } }", "System.Nullable`1"); } [WorkItem(863517, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/863517")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestAfterLastToken() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { foreach (char var in ""!!!"")$$[||] { } } }", ""); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestConditional() { await TestAsync( @"class Program { static void Main(string[] args) { var x = true [|?|] true : false; } }", "?_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLocalVar() { await TestAsync( @"class C { void M() { var a = 0; int v[||]ar = 1; } }", "System.Int32"); } [WorkItem(867574, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867574")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestFatArrow() { await TestAsync( @"class C { void M() { var a = new System.Action(() =[||]> { }); } }", "=>_CSharpKeyword"); } [WorkItem(867572, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867572")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestSubscription() { await TestAsync( @"class CCC { event System.Action e; void M() { e +[||]= () => { }; } }", "+=_CSharpKeyword"); } [WorkItem(867554, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867554")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestComment() { await TestAsync(@"// some comm[||]ents here", "comments"); } [WorkItem(867529, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867529")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDynamic() { await TestAsync( @"class C { void M() { dyna[||]mic d = 0; } }", "dynamic_CSharpKeyword"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestRangeVariable() { await TestAsync( @"using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; class Program { static void Main(string[] args) { var zzz = from y in args select [||]y; } }", "System.String"); } [WorkItem(36001, "https://github.com/dotnet/roslyn/issues/36001")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNameof() { await Test_KeywordAsync( @"class C { void goo() { var v = [||]nameof(goo); } }", "nameof"); } [WorkItem(46988, "https://github.com/dotnet/roslyn/issues/46988")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNullForgiving() { await Test_KeywordAsync( @"#nullable enable class C { int goo(string? x) { return x[||]!.GetHashCode(); } }", "nullForgiving"); } [WorkItem(46988, "https://github.com/dotnet/roslyn/issues/46988")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestLogicalNot() { await Test_KeywordAsync( @"class C { bool goo(bool x) { return [||]!x; } }", "!"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultSwitchCase() { await Test_KeywordAsync( @"class C { void M1(int parameter) { switch(parameter) { defa[||]ult: parameter = default; break; } } }", "defaultcase"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpressionInsideSwitch() { await Test_KeywordAsync( @"class C { void M1(int parameter) { switch(parameter) { default: parameter = defa[||]ult; break; } } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpressionInsideSwitch() { await Test_KeywordAsync( @"class C { void M1(int parameter) { switch(parameter) { default: parameter = defa[||]ult(int); break; } } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpression() { await Test_KeywordAsync( @"class C { int field = defa[||]ult; }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpression() { await Test_KeywordAsync( @"class C { int field = defa[||]ult(int); }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpressionInOptionalParameter() { await Test_KeywordAsync( @"class C { void M1(int parameter = defa[||]ult) { } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpressionInOptionalParameter() { await Test_KeywordAsync( @"class C { void M1(int parameter = defa[||]ult(int)) { } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultLiteralExpressionInMethodCall() { await Test_KeywordAsync( @"class C { void M1() { M2(defa[||]ult); } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestDefaultExpressionInMethodCall() { await Test_KeywordAsync( @"class C { void M1() { M2(defa[||]ult(int)); } }", "default"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestOuterClassDeclaration() { await Test_KeywordAsync( @"cla[||]ss OuterClass<T> where T : class { class InnerClass<T> where T : class { } }", "class"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestInnerClassDeclaration() { await Test_KeywordAsync( @"class OuterClass<T> where T : class { cla[||]ss InnerClass<T> where T : class { } }", "class"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInOuterClass() { await Test_KeywordAsync( @"class OuterClass<T> where T : cla[||]ss { class InnerClass<T> where T : class { } }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInInnerClass() { await Test_KeywordAsync( @"class OuterClass<T> where T : class { class InnerClass<T> where T : cla[||]ss { } }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInGenericMethod() { await Test_KeywordAsync( @"class C { void M1<T>() where T : cla[||]ss { } }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestClassConstraintInGenericDelegate() { await Test_KeywordAsync( @"class C { delegate T MyDelegate<T>() where T : cla[||]ss; }", "classconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestOuterStructDeclaration() { await Test_KeywordAsync( @"str[||]uct OuterStruct<T> where T : struct { struct InnerStruct<T> where T : struct { } }", "struct"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestInnerStructDeclaration() { await Test_KeywordAsync( @"struct OuterStruct<T> where T : struct { str[||]uct InnerStruct<T> where T : struct { } }", "struct"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInOuterStruct() { await Test_KeywordAsync( @"struct OuterStruct<T> where T : str[||]uct { struct InnerStruct<T> where T : struct { } }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInInnerStruct() { await Test_KeywordAsync( @"struct OuterStruct<T> where T : struct { struct InnerStruct<T> where T : str[||]uct { } }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInGenericMethod() { await Test_KeywordAsync( @"struct C { void M1<T>() where T : str[||]uct { } }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStructConstraintInGenericDelegate() { await Test_KeywordAsync( @"struct C { delegate T MyDelegate<T>() where T : str[||]uct; }", "structconstraint"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingStaticOnUsingKeyword() { await Test_KeywordAsync( @"us[||]ing static namespace.Class; static class C { static int Field; static void Method() {} }", "using-static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestNormalUsingDirective() { await Test_KeywordAsync( @"us[||]ing namespace.Class; static class C { static int Field; static void Method() {} }", "using"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingStatement() { await Test_KeywordAsync( @"using namespace.Class; class C { void Method(String someString) { us[||]ing (var reader = new StringReader(someString)) { } } }", "using-statement"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingDeclaration() { await Test_KeywordAsync( @"using namespace.Class; class C { void Method(String someString) { us[||]ing var reader = new StringReader(someString); } }", "using-statement"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestUsingStaticOnStaticKeyword() { await Test_KeywordAsync( @"using sta[||]tic namespace.Class; static class C { static int Field; static void Method() {} }", "using-static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStaticClass() { await Test_KeywordAsync( @"using static namespace.Class; sta[||]tic class C { static int Field; static void Method() {} }", "static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStaticField() { await Test_KeywordAsync( @"using static namespace.Class; static class C { sta[||]tic int Field; static void Method() {} }", "static"); } [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestStaticMethod() { await Test_KeywordAsync( @"using static namespace.Class; static class C { static int Field; sta[||]tic void Method() {} }", "static"); } [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] public async Task TestWithKeyword() { await Test_KeywordAsync( @" public record Point(int X, int Y); public static class Program { public static void Main() { var p1 = new Point(0, 0); var p2 = p1 w[||]ith { X = 5 }; } }", "with"); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/ExtractInterface/ExtractInterfaceOptionsResult.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.ExtractInterface { internal class ExtractInterfaceOptionsResult { public enum ExtractLocation { SameFile, NewFile } public static readonly ExtractInterfaceOptionsResult Cancelled = new(isCancelled: true); public bool IsCancelled { get; } public ImmutableArray<ISymbol> IncludedMembers { get; } public string InterfaceName { get; } public string FileName { get; } public ExtractLocation Location { get; } public ExtractInterfaceOptionsResult(bool isCancelled, ImmutableArray<ISymbol> includedMembers, string interfaceName, string fileName, ExtractLocation location) { IsCancelled = isCancelled; IncludedMembers = includedMembers; InterfaceName = interfaceName; Location = location; FileName = fileName; } private ExtractInterfaceOptionsResult(bool isCancelled) => IsCancelled = isCancelled; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.ExtractInterface { internal class ExtractInterfaceOptionsResult { public enum ExtractLocation { SameFile, NewFile } public static readonly ExtractInterfaceOptionsResult Cancelled = new(isCancelled: true); public bool IsCancelled { get; } public ImmutableArray<ISymbol> IncludedMembers { get; } public string InterfaceName { get; } public string FileName { get; } public ExtractLocation Location { get; } public ExtractInterfaceOptionsResult(bool isCancelled, ImmutableArray<ISymbol> includedMembers, string interfaceName, string fileName, ExtractLocation location) { IsCancelled = isCancelled; IncludedMembers = includedMembers; InterfaceName = interfaceName; Location = location; FileName = fileName; } private ExtractInterfaceOptionsResult(bool isCancelled) => IsCancelled = isCancelled; } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/Core/Implementation/Classification/ClassificationTypeDefinitions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.ComponentModel.Composition; using Microsoft.CodeAnalysis.Classification; using Microsoft.VisualStudio.Language.StandardClassification; using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Utilities; namespace Microsoft.CodeAnalysis.Editor.Implementation.Classification { internal sealed class ClassificationTypeDefinitions { #region Preprocessor Text [Export] [Name(ClassificationTypeNames.PreprocessorText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal ClassificationTypeDefinition PreprocessorTextTypeDefinition { get; set; } #endregion #region Punctuation [Export] [Name(ClassificationTypeNames.Punctuation)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal ClassificationTypeDefinition PunctuationTypeDefinition; #endregion #region String - Verbatim [Export] [Name(ClassificationTypeNames.VerbatimStringLiteral)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StringVerbatimTypeDefinition; [Export] [Name(ClassificationTypeNames.StringEscapeCharacter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StringEscapeCharacterTypeDefinition; #endregion #region Keyword - Control // Keyword - Control sets its BaseDefinitions to be Keyword so that // in the absence of specific styling they will appear as keywords. [Export] [Name(ClassificationTypeNames.ControlKeyword)] [BaseDefinition(PredefinedClassificationTypeNames.Keyword)] internal ClassificationTypeDefinition ControlKeywordTypeDefinition; #endregion #region User Types - Classes [Export] [Name(ClassificationTypeNames.ClassName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeClassesTypeDefinition; #endregion #region User Types - Records [Export] [Name(ClassificationTypeNames.RecordClassName)] [BaseDefinition(ClassificationTypeNames.ClassName)] internal readonly ClassificationTypeDefinition UserTypeRecordsTypeDefinition; #endregion #region User Types - Record Structs [Export] [Name(ClassificationTypeNames.RecordStructName)] [BaseDefinition(ClassificationTypeNames.StructName)] internal readonly ClassificationTypeDefinition UserTypeRecordStructsTypeDefinition; #endregion #region User Types - Delegates [Export] [Name(ClassificationTypeNames.DelegateName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeDelegatesTypeDefinition; #endregion #region User Types - Enums [Export] [Name(ClassificationTypeNames.EnumName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeEnumsTypeDefinition; #endregion #region User Types - Interfaces [Export] [Name(ClassificationTypeNames.InterfaceName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeInterfacesTypeDefinition; #endregion #region User Types - Modules [Export] [Name(ClassificationTypeNames.ModuleName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeModulesTypeDefinition; #endregion #region User Types - Structures [Export] [Name(ClassificationTypeNames.StructName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeStructuresTypeDefinition; #endregion #region User Types - Type Parameters [Export] [Name(ClassificationTypeNames.TypeParameterName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeTypeParametersTypeDefinition; #endregion // User Members - * set their BaseDefinitions to be Identifier so that // in the absence of specific styling they will appear as identifiers. // Extension Methods are an exception and their base definition is Method // since it is a more specific type of method. #region User Members - Fields [Export] [Name(ClassificationTypeNames.FieldName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersFieldsTypeDefinition; #endregion #region User Members - Enum Memberd [Export] [Name(ClassificationTypeNames.EnumMemberName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersEnumMembersTypeDefinition; #endregion #region User Members - Constants [Export] [Name(ClassificationTypeNames.ConstantName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersConstantsTypeDefinition; #endregion #region User Members - Locals [Export] [Name(ClassificationTypeNames.LocalName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersLocalsTypeDefinition; #endregion #region User Members - Parameters [Export] [Name(ClassificationTypeNames.ParameterName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersParametersTypeDefinition; #endregion #region User Members - Methods [Export] [Name(ClassificationTypeNames.MethodName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersMethodsTypeDefinition; #endregion #region User Members - Extension Methods [Export] [Name(ClassificationTypeNames.ExtensionMethodName)] [BaseDefinition(ClassificationTypeNames.MethodName)] internal readonly ClassificationTypeDefinition UserMembersExtensionMethodsTypeDefinition; #endregion #region User Members - Properties [Export] [Name(ClassificationTypeNames.PropertyName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersPropertiesTypeDefinition; #endregion #region User Members - Events [Export] [Name(ClassificationTypeNames.EventName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersEventsTypeDefinition; #endregion #region User Members - Namespaces [Export] [Name(ClassificationTypeNames.NamespaceName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersNamespacesTypeDefinition; #endregion #region User Members - Labels [Export] [Name(ClassificationTypeNames.LabelName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersLabelsTypeDefinition; #endregion #region XML Doc Comments - Attribute Name [Export] [Name(ClassificationTypeNames.XmlDocCommentAttributeName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentAttributeNameTypeDefinition; #endregion #region XML Doc Comments - Attribute Quotes [Export] [Name(ClassificationTypeNames.XmlDocCommentAttributeQuotes)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentAttributeQuotesTypeDefinition; #endregion #region XML Doc Comments - Attribute Value [Export] [Name(ClassificationTypeNames.XmlDocCommentAttributeValue)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentAttributeValueTypeDefinition; #endregion #region XML Doc Comments - CData Section [Export] [Name(ClassificationTypeNames.XmlDocCommentCDataSection)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentCDataSectionTypeDefinition; #endregion #region XML Doc Comments - Comment [Export] [Name(ClassificationTypeNames.XmlDocCommentComment)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentCommentTypeDefinition; #endregion #region XML Doc Comments - Delimiter [Export] [Name(ClassificationTypeNames.XmlDocCommentDelimiter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentDelimiterTypeDefinition; #endregion #region XML Doc Comments - Entity Reference [Export] [Name(ClassificationTypeNames.XmlDocCommentEntityReference)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentEntityReferenceTypeDefinition; #endregion #region XML Doc Comments - Name [Export] [Name(ClassificationTypeNames.XmlDocCommentName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentNameTypeDefinition; #endregion #region XML Doc Comments - Processing Instruction [Export] [Name(ClassificationTypeNames.XmlDocCommentProcessingInstruction)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentProcessingInstructionTypeDefinition; #endregion #region XML Doc Comments - Text [Export] [Name(ClassificationTypeNames.XmlDocCommentText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentTextTypeDefinition; #endregion #region Regex [Export] [Name(ClassificationTypeNames.RegexComment)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexCommentTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexTextTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexCharacterClass)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexCharacterClassTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexQuantifier)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexQuantifierTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexAnchor)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexAnchorTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexAlternation)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexAlternationTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexOtherEscape)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexOtherEscapeTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexSelfEscapedCharacter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexSelfEscapedCharacterTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexGrouping)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexGroupingTypeDefinition; #endregion #region VB XML Literals - Attribute Name [Export] [Name(ClassificationTypeNames.XmlLiteralAttributeName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralAttributeNameTypeDefinition; #endregion #region VB XML Literals - Attribute Quotes [Export] [Name(ClassificationTypeNames.XmlLiteralAttributeQuotes)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralAttributeQuotesTypeDefinition; #endregion #region VB XML Literals - Attribute Value [Export] [Name(ClassificationTypeNames.XmlLiteralAttributeValue)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralAttributeValueTypeDefinition; #endregion #region VB XML Literals - CData Section [Export] [Name(ClassificationTypeNames.XmlLiteralCDataSection)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralCDataSectionTypeDefinition; #endregion #region VB XML Literals - Comment [Export] [Name(ClassificationTypeNames.XmlLiteralComment)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralCommentTypeDefinition; #endregion #region VB XML Literals - Delimiter [Export] [Name(ClassificationTypeNames.XmlLiteralDelimiter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralDelimiterTypeDefinition; #endregion #region VB XML Literals - Embedded Expression [Export] [Name(ClassificationTypeNames.XmlLiteralEmbeddedExpression)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralEmbeddedExpressionTypeDefinition; #endregion #region VB XML Literals - Entity Reference [Export] [Name(ClassificationTypeNames.XmlLiteralEntityReference)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralEntityReferenceTypeDefinition; #endregion #region VB XML Literals - Name [Export] [Name(ClassificationTypeNames.XmlLiteralName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralNameTypeDefinition; #endregion #region VB XML Literals - Processing Instruction [Export] [Name(ClassificationTypeNames.XmlLiteralProcessingInstruction)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralProcessingInstructionTypeDefinition; #endregion #region VB XML Literals - Text [Export] [Name(ClassificationTypeNames.XmlLiteralText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralTextTypeDefinition; #endregion #region Reassigned Variable [Export] [Name(ClassificationTypeNames.ReassignedVariable)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition ReassignedVariableTypeDefinition; #endregion #region Static Symbol [Export] [Name(ClassificationTypeNames.StaticSymbol)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StaticSymbolTypeDefinition; #endregion #region Operator - Overloaded // Operator - Overloaded sets its BaseDefinitions to be Operator so that // in the absence of specific styling they will appear as operators. [Export] [Name(ClassificationTypeNames.OperatorOverloaded)] [BaseDefinition(PredefinedClassificationTypeNames.Operator)] internal readonly ClassificationTypeDefinition OperatorOverloadTypeDefinition; #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.ComponentModel.Composition; using Microsoft.CodeAnalysis.Classification; using Microsoft.VisualStudio.Language.StandardClassification; using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Utilities; namespace Microsoft.CodeAnalysis.Editor.Implementation.Classification { internal sealed class ClassificationTypeDefinitions { #region Preprocessor Text [Export] [Name(ClassificationTypeNames.PreprocessorText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal ClassificationTypeDefinition PreprocessorTextTypeDefinition { get; set; } #endregion #region Punctuation [Export] [Name(ClassificationTypeNames.Punctuation)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal ClassificationTypeDefinition PunctuationTypeDefinition; #endregion #region String - Verbatim [Export] [Name(ClassificationTypeNames.VerbatimStringLiteral)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StringVerbatimTypeDefinition; [Export] [Name(ClassificationTypeNames.StringEscapeCharacter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StringEscapeCharacterTypeDefinition; #endregion #region Keyword - Control // Keyword - Control sets its BaseDefinitions to be Keyword so that // in the absence of specific styling they will appear as keywords. [Export] [Name(ClassificationTypeNames.ControlKeyword)] [BaseDefinition(PredefinedClassificationTypeNames.Keyword)] internal ClassificationTypeDefinition ControlKeywordTypeDefinition; #endregion #region User Types - Classes [Export] [Name(ClassificationTypeNames.ClassName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeClassesTypeDefinition; #endregion #region User Types - Records [Export] [Name(ClassificationTypeNames.RecordClassName)] [BaseDefinition(ClassificationTypeNames.ClassName)] internal readonly ClassificationTypeDefinition UserTypeRecordsTypeDefinition; #endregion #region User Types - Record Structs [Export] [Name(ClassificationTypeNames.RecordStructName)] [BaseDefinition(ClassificationTypeNames.StructName)] internal readonly ClassificationTypeDefinition UserTypeRecordStructsTypeDefinition; #endregion #region User Types - Delegates [Export] [Name(ClassificationTypeNames.DelegateName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeDelegatesTypeDefinition; #endregion #region User Types - Enums [Export] [Name(ClassificationTypeNames.EnumName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeEnumsTypeDefinition; #endregion #region User Types - Interfaces [Export] [Name(ClassificationTypeNames.InterfaceName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeInterfacesTypeDefinition; #endregion #region User Types - Modules [Export] [Name(ClassificationTypeNames.ModuleName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeModulesTypeDefinition; #endregion #region User Types - Structures [Export] [Name(ClassificationTypeNames.StructName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeStructuresTypeDefinition; #endregion #region User Types - Type Parameters [Export] [Name(ClassificationTypeNames.TypeParameterName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition UserTypeTypeParametersTypeDefinition; #endregion // User Members - * set their BaseDefinitions to be Identifier so that // in the absence of specific styling they will appear as identifiers. // Extension Methods are an exception and their base definition is Method // since it is a more specific type of method. #region User Members - Fields [Export] [Name(ClassificationTypeNames.FieldName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersFieldsTypeDefinition; #endregion #region User Members - Enum Memberd [Export] [Name(ClassificationTypeNames.EnumMemberName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersEnumMembersTypeDefinition; #endregion #region User Members - Constants [Export] [Name(ClassificationTypeNames.ConstantName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersConstantsTypeDefinition; #endregion #region User Members - Locals [Export] [Name(ClassificationTypeNames.LocalName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersLocalsTypeDefinition; #endregion #region User Members - Parameters [Export] [Name(ClassificationTypeNames.ParameterName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersParametersTypeDefinition; #endregion #region User Members - Methods [Export] [Name(ClassificationTypeNames.MethodName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersMethodsTypeDefinition; #endregion #region User Members - Extension Methods [Export] [Name(ClassificationTypeNames.ExtensionMethodName)] [BaseDefinition(ClassificationTypeNames.MethodName)] internal readonly ClassificationTypeDefinition UserMembersExtensionMethodsTypeDefinition; #endregion #region User Members - Properties [Export] [Name(ClassificationTypeNames.PropertyName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersPropertiesTypeDefinition; #endregion #region User Members - Events [Export] [Name(ClassificationTypeNames.EventName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersEventsTypeDefinition; #endregion #region User Members - Namespaces [Export] [Name(ClassificationTypeNames.NamespaceName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersNamespacesTypeDefinition; #endregion #region User Members - Labels [Export] [Name(ClassificationTypeNames.LabelName)] [BaseDefinition(PredefinedClassificationTypeNames.Identifier)] internal readonly ClassificationTypeDefinition UserMembersLabelsTypeDefinition; #endregion #region XML Doc Comments - Attribute Name [Export] [Name(ClassificationTypeNames.XmlDocCommentAttributeName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentAttributeNameTypeDefinition; #endregion #region XML Doc Comments - Attribute Quotes [Export] [Name(ClassificationTypeNames.XmlDocCommentAttributeQuotes)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentAttributeQuotesTypeDefinition; #endregion #region XML Doc Comments - Attribute Value [Export] [Name(ClassificationTypeNames.XmlDocCommentAttributeValue)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentAttributeValueTypeDefinition; #endregion #region XML Doc Comments - CData Section [Export] [Name(ClassificationTypeNames.XmlDocCommentCDataSection)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentCDataSectionTypeDefinition; #endregion #region XML Doc Comments - Comment [Export] [Name(ClassificationTypeNames.XmlDocCommentComment)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentCommentTypeDefinition; #endregion #region XML Doc Comments - Delimiter [Export] [Name(ClassificationTypeNames.XmlDocCommentDelimiter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentDelimiterTypeDefinition; #endregion #region XML Doc Comments - Entity Reference [Export] [Name(ClassificationTypeNames.XmlDocCommentEntityReference)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentEntityReferenceTypeDefinition; #endregion #region XML Doc Comments - Name [Export] [Name(ClassificationTypeNames.XmlDocCommentName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentNameTypeDefinition; #endregion #region XML Doc Comments - Processing Instruction [Export] [Name(ClassificationTypeNames.XmlDocCommentProcessingInstruction)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentProcessingInstructionTypeDefinition; #endregion #region XML Doc Comments - Text [Export] [Name(ClassificationTypeNames.XmlDocCommentText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlDocCommentTextTypeDefinition; #endregion #region Regex [Export] [Name(ClassificationTypeNames.RegexComment)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexCommentTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexTextTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexCharacterClass)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexCharacterClassTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexQuantifier)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexQuantifierTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexAnchor)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexAnchorTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexAlternation)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexAlternationTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexOtherEscape)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexOtherEscapeTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexSelfEscapedCharacter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexSelfEscapedCharacterTypeDefinition; [Export] [Name(ClassificationTypeNames.RegexGrouping)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition RegexGroupingTypeDefinition; #endregion #region VB XML Literals - Attribute Name [Export] [Name(ClassificationTypeNames.XmlLiteralAttributeName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralAttributeNameTypeDefinition; #endregion #region VB XML Literals - Attribute Quotes [Export] [Name(ClassificationTypeNames.XmlLiteralAttributeQuotes)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralAttributeQuotesTypeDefinition; #endregion #region VB XML Literals - Attribute Value [Export] [Name(ClassificationTypeNames.XmlLiteralAttributeValue)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralAttributeValueTypeDefinition; #endregion #region VB XML Literals - CData Section [Export] [Name(ClassificationTypeNames.XmlLiteralCDataSection)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralCDataSectionTypeDefinition; #endregion #region VB XML Literals - Comment [Export] [Name(ClassificationTypeNames.XmlLiteralComment)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralCommentTypeDefinition; #endregion #region VB XML Literals - Delimiter [Export] [Name(ClassificationTypeNames.XmlLiteralDelimiter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralDelimiterTypeDefinition; #endregion #region VB XML Literals - Embedded Expression [Export] [Name(ClassificationTypeNames.XmlLiteralEmbeddedExpression)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralEmbeddedExpressionTypeDefinition; #endregion #region VB XML Literals - Entity Reference [Export] [Name(ClassificationTypeNames.XmlLiteralEntityReference)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralEntityReferenceTypeDefinition; #endregion #region VB XML Literals - Name [Export] [Name(ClassificationTypeNames.XmlLiteralName)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralNameTypeDefinition; #endregion #region VB XML Literals - Processing Instruction [Export] [Name(ClassificationTypeNames.XmlLiteralProcessingInstruction)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralProcessingInstructionTypeDefinition; #endregion #region VB XML Literals - Text [Export] [Name(ClassificationTypeNames.XmlLiteralText)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition XmlLiteralTextTypeDefinition; #endregion #region Reassigned Variable [Export] [Name(ClassificationTypeNames.ReassignedVariable)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition ReassignedVariableTypeDefinition; #endregion #region Static Symbol [Export] [Name(ClassificationTypeNames.StaticSymbol)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StaticSymbolTypeDefinition; #endregion #region Operator - Overloaded // Operator - Overloaded sets its BaseDefinitions to be Operator so that // in the absence of specific styling they will appear as operators. [Export] [Name(ClassificationTypeNames.OperatorOverloaded)] [BaseDefinition(PredefinedClassificationTypeNames.Operator)] internal readonly ClassificationTypeDefinition OperatorOverloadTypeDefinition; #endregion } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Tools/ExternalAccess/Razor/Remote/RazorPinnedSolutionInfoWrapper.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; using Microsoft.CodeAnalysis.Remote; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { [DataContract] internal readonly struct RazorPinnedSolutionInfoWrapper { [DataMember(Order = 0)] internal readonly PinnedSolutionInfo UnderlyingObject; public RazorPinnedSolutionInfoWrapper(PinnedSolutionInfo underlyingObject) => UnderlyingObject = underlyingObject; public static implicit operator RazorPinnedSolutionInfoWrapper(PinnedSolutionInfo info) => new(info); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; using Microsoft.CodeAnalysis.Remote; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { [DataContract] internal readonly struct RazorPinnedSolutionInfoWrapper { [DataMember(Order = 0)] internal readonly PinnedSolutionInfo UnderlyingObject; public RazorPinnedSolutionInfoWrapper(PinnedSolutionInfo underlyingObject) => UnderlyingObject = underlyingObject; public static implicit operator RazorPinnedSolutionInfoWrapper(PinnedSolutionInfo info) => new(info); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/CSharp/Portable/ConvertIfToSwitch/CSharpConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.ConvertIfToSwitch { using static SyntaxFactory; internal sealed partial class CSharpConvertIfToSwitchCodeRefactoringProvider { private static readonly Dictionary<BinaryOperatorKind, SyntaxKind> s_operatorMap = new Dictionary<BinaryOperatorKind, SyntaxKind> { { BinaryOperatorKind.LessThan, SyntaxKind.LessThanToken }, { BinaryOperatorKind.GreaterThan, SyntaxKind.GreaterThanToken }, { BinaryOperatorKind.LessThanOrEqual, SyntaxKind.LessThanEqualsToken }, { BinaryOperatorKind.GreaterThanOrEqual, SyntaxKind.GreaterThanEqualsToken }, }; public override SyntaxNode CreateSwitchExpressionStatement(SyntaxNode target, ImmutableArray<AnalyzedSwitchSection> sections, Feature feature) { return ReturnStatement( SwitchExpression( (ExpressionSyntax)target, SeparatedList(sections.Select(section => AsSwitchExpressionArmSyntax(section, feature))))); } private static SwitchExpressionArmSyntax AsSwitchExpressionArmSyntax(AnalyzedSwitchSection section, Feature feature) { if (section.Labels.IsDefault) return SwitchExpressionArm(DiscardPattern(), AsExpressionSyntax(section.Body)); var pattern = AsPatternSyntax(section.Labels[0].Pattern, feature); var whenClause = AsWhenClause(section.Labels[0]); Debug.Assert(whenClause == null || section.Labels.Length == 1, "We shouldn't have guards when we're combining multiple cases into a single arm"); for (var i = 1; i < section.Labels.Length; i++) { var label = section.Labels[i]; Debug.Assert(label.Guards.Length == 0, "We shouldn't have guards when we're combining multiple cases into a single arm"); var nextPattern = AsPatternSyntax(label.Pattern, feature); pattern = BinaryPattern(SyntaxKind.OrPattern, pattern.Parenthesize(), nextPattern.Parenthesize()); } return SwitchExpressionArm(pattern, whenClause, AsExpressionSyntax(section.Body)); } private static ExpressionSyntax AsExpressionSyntax(IOperation operation) => operation switch { IReturnOperation { ReturnedValue: { } value } => (ExpressionSyntax)value.Syntax, IThrowOperation { Exception: { } exception } => ThrowExpression((ExpressionSyntax)exception.Syntax), IBlockOperation op => AsExpressionSyntax(op.Operations.Single()), var v => throw ExceptionUtilities.UnexpectedValue(v.Kind) }; public override SyntaxNode CreateSwitchStatement(IfStatementSyntax ifStatement, SyntaxNode expression, IEnumerable<SyntaxNode> sectionList) { var block = ifStatement.Statement as BlockSyntax; return SwitchStatement( switchKeyword: Token(SyntaxKind.SwitchKeyword).WithTriviaFrom(ifStatement.IfKeyword), openParenToken: ifStatement.OpenParenToken, expression: (ExpressionSyntax)expression, closeParenToken: ifStatement.CloseParenToken.WithPrependedLeadingTrivia(ElasticMarker), openBraceToken: block?.OpenBraceToken ?? Token(SyntaxKind.OpenBraceToken), sections: List(sectionList.Cast<SwitchSectionSyntax>()), closeBraceToken: block?.CloseBraceToken.WithoutLeadingTrivia() ?? Token(SyntaxKind.CloseBraceToken)); } private static WhenClauseSyntax? AsWhenClause(AnalyzedSwitchLabel label) => AsWhenClause(label.Guards .Select(e => e.WalkUpParentheses()) .AggregateOrDefault((prev, current) => BinaryExpression(SyntaxKind.LogicalAndExpression, prev, current))); private static WhenClauseSyntax? AsWhenClause(ExpressionSyntax? expression) => expression is null ? null : WhenClause(expression); public override SyntaxNode AsSwitchLabelSyntax(AnalyzedSwitchLabel label, Feature feature) => CasePatternSwitchLabel( AsPatternSyntax(label.Pattern, feature), AsWhenClause(label), Token(SyntaxKind.ColonToken)); private static PatternSyntax AsPatternSyntax(AnalyzedPattern pattern, Feature feature) => pattern switch { AnalyzedPattern.And p => BinaryPattern(SyntaxKind.AndPattern, AsPatternSyntax(p.LeftPattern, feature).Parenthesize(), AsPatternSyntax(p.RightPattern, feature).Parenthesize()), AnalyzedPattern.Constant p => ConstantPattern(p.ExpressionSyntax), AnalyzedPattern.Source p => p.PatternSyntax, AnalyzedPattern.Type p when feature.HasFlag(Feature.TypePattern) => TypePattern((TypeSyntax)p.IsExpressionSyntax.Right), AnalyzedPattern.Type p => DeclarationPattern((TypeSyntax)p.IsExpressionSyntax.Right, DiscardDesignation()), AnalyzedPattern.Relational p => RelationalPattern(Token(s_operatorMap[p.OperatorKind]), p.Value), var p => throw ExceptionUtilities.UnexpectedValue(p) }; public override IEnumerable<SyntaxNode> AsSwitchSectionStatements(IOperation operation) { var node = operation.Syntax; Debug.Assert(operation.SemanticModel is not null); var requiresBreak = operation.SemanticModel.AnalyzeControlFlow(node).EndPointIsReachable; var requiresBlock = !operation.SemanticModel.AnalyzeDataFlow(node).VariablesDeclared.IsDefaultOrEmpty; var statements = ArrayBuilder<SyntaxNode>.GetInstance(); if (node is BlockSyntax block) { if (block.Statements.Count == 0) { statements.Add(BreakStatement()); } else if (requiresBlock) { statements.Add(requiresBreak ? block.AddStatements(BreakStatement()) : block); } else { statements.AddRange(block.Statements); if (requiresBreak) { statements.Add(BreakStatement().WithLeadingTrivia(block.CloseBraceToken.LeadingTrivia)); } } } else { statements.Add(node); if (requiresBreak) { statements.Add(BreakStatement()); } } return statements.ToArrayAndFree(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.ConvertIfToSwitch { using static SyntaxFactory; internal sealed partial class CSharpConvertIfToSwitchCodeRefactoringProvider { private static readonly Dictionary<BinaryOperatorKind, SyntaxKind> s_operatorMap = new Dictionary<BinaryOperatorKind, SyntaxKind> { { BinaryOperatorKind.LessThan, SyntaxKind.LessThanToken }, { BinaryOperatorKind.GreaterThan, SyntaxKind.GreaterThanToken }, { BinaryOperatorKind.LessThanOrEqual, SyntaxKind.LessThanEqualsToken }, { BinaryOperatorKind.GreaterThanOrEqual, SyntaxKind.GreaterThanEqualsToken }, }; public override SyntaxNode CreateSwitchExpressionStatement(SyntaxNode target, ImmutableArray<AnalyzedSwitchSection> sections, Feature feature) { return ReturnStatement( SwitchExpression( (ExpressionSyntax)target, SeparatedList(sections.Select(section => AsSwitchExpressionArmSyntax(section, feature))))); } private static SwitchExpressionArmSyntax AsSwitchExpressionArmSyntax(AnalyzedSwitchSection section, Feature feature) { if (section.Labels.IsDefault) return SwitchExpressionArm(DiscardPattern(), AsExpressionSyntax(section.Body)); var pattern = AsPatternSyntax(section.Labels[0].Pattern, feature); var whenClause = AsWhenClause(section.Labels[0]); Debug.Assert(whenClause == null || section.Labels.Length == 1, "We shouldn't have guards when we're combining multiple cases into a single arm"); for (var i = 1; i < section.Labels.Length; i++) { var label = section.Labels[i]; Debug.Assert(label.Guards.Length == 0, "We shouldn't have guards when we're combining multiple cases into a single arm"); var nextPattern = AsPatternSyntax(label.Pattern, feature); pattern = BinaryPattern(SyntaxKind.OrPattern, pattern.Parenthesize(), nextPattern.Parenthesize()); } return SwitchExpressionArm(pattern, whenClause, AsExpressionSyntax(section.Body)); } private static ExpressionSyntax AsExpressionSyntax(IOperation operation) => operation switch { IReturnOperation { ReturnedValue: { } value } => (ExpressionSyntax)value.Syntax, IThrowOperation { Exception: { } exception } => ThrowExpression((ExpressionSyntax)exception.Syntax), IBlockOperation op => AsExpressionSyntax(op.Operations.Single()), var v => throw ExceptionUtilities.UnexpectedValue(v.Kind) }; public override SyntaxNode CreateSwitchStatement(IfStatementSyntax ifStatement, SyntaxNode expression, IEnumerable<SyntaxNode> sectionList) { var block = ifStatement.Statement as BlockSyntax; return SwitchStatement( switchKeyword: Token(SyntaxKind.SwitchKeyword).WithTriviaFrom(ifStatement.IfKeyword), openParenToken: ifStatement.OpenParenToken, expression: (ExpressionSyntax)expression, closeParenToken: ifStatement.CloseParenToken.WithPrependedLeadingTrivia(ElasticMarker), openBraceToken: block?.OpenBraceToken ?? Token(SyntaxKind.OpenBraceToken), sections: List(sectionList.Cast<SwitchSectionSyntax>()), closeBraceToken: block?.CloseBraceToken.WithoutLeadingTrivia() ?? Token(SyntaxKind.CloseBraceToken)); } private static WhenClauseSyntax? AsWhenClause(AnalyzedSwitchLabel label) => AsWhenClause(label.Guards .Select(e => e.WalkUpParentheses()) .AggregateOrDefault((prev, current) => BinaryExpression(SyntaxKind.LogicalAndExpression, prev, current))); private static WhenClauseSyntax? AsWhenClause(ExpressionSyntax? expression) => expression is null ? null : WhenClause(expression); public override SyntaxNode AsSwitchLabelSyntax(AnalyzedSwitchLabel label, Feature feature) => CasePatternSwitchLabel( AsPatternSyntax(label.Pattern, feature), AsWhenClause(label), Token(SyntaxKind.ColonToken)); private static PatternSyntax AsPatternSyntax(AnalyzedPattern pattern, Feature feature) => pattern switch { AnalyzedPattern.And p => BinaryPattern(SyntaxKind.AndPattern, AsPatternSyntax(p.LeftPattern, feature).Parenthesize(), AsPatternSyntax(p.RightPattern, feature).Parenthesize()), AnalyzedPattern.Constant p => ConstantPattern(p.ExpressionSyntax), AnalyzedPattern.Source p => p.PatternSyntax, AnalyzedPattern.Type p when feature.HasFlag(Feature.TypePattern) => TypePattern((TypeSyntax)p.IsExpressionSyntax.Right), AnalyzedPattern.Type p => DeclarationPattern((TypeSyntax)p.IsExpressionSyntax.Right, DiscardDesignation()), AnalyzedPattern.Relational p => RelationalPattern(Token(s_operatorMap[p.OperatorKind]), p.Value), var p => throw ExceptionUtilities.UnexpectedValue(p) }; public override IEnumerable<SyntaxNode> AsSwitchSectionStatements(IOperation operation) { var node = operation.Syntax; Debug.Assert(operation.SemanticModel is not null); var requiresBreak = operation.SemanticModel.AnalyzeControlFlow(node).EndPointIsReachable; var requiresBlock = !operation.SemanticModel.AnalyzeDataFlow(node).VariablesDeclared.IsDefaultOrEmpty; var statements = ArrayBuilder<SyntaxNode>.GetInstance(); if (node is BlockSyntax block) { if (block.Statements.Count == 0) { statements.Add(BreakStatement()); } else if (requiresBlock) { statements.Add(requiresBreak ? block.AddStatements(BreakStatement()) : block); } else { statements.AddRange(block.Statements); if (requiresBreak) { statements.Add(BreakStatement().WithLeadingTrivia(block.CloseBraceToken.LeadingTrivia)); } } } else { statements.Add(node); if (requiresBreak) { statements.Add(BreakStatement()); } } return statements.ToArrayAndFree(); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Core/CodeAnalysisTest/FileUtilitiesTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.IO; using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.UnitTests { public class FileUtilitiesTests { [ConditionalFact(typeof(WindowsOnly))] public void IsAbsolute() { Assert.False(PathUtilities.IsAbsolute(null)); Assert.False(PathUtilities.IsAbsolute("")); Assert.False(PathUtilities.IsAbsolute("C")); Assert.False(PathUtilities.IsAbsolute("C:")); Assert.True(PathUtilities.IsAbsolute(@"C:\")); Assert.True(PathUtilities.IsAbsolute(@"C:/")); Assert.True(PathUtilities.IsAbsolute(@"C:\\")); Assert.False(PathUtilities.IsAbsolute(@"C\")); Assert.True(PathUtilities.IsAbsolute(@"\\")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\\S")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\/C")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\/C\")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\\server")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\\server\share")); // UNC Assert.True(PathUtilities.IsAbsolute(@"\\?\C:\share")); // long UNC Assert.False(PathUtilities.IsAbsolute(@"\C")); Assert.False(PathUtilities.IsAbsolute(@"/C")); } [ConditionalFact(typeof(WindowsOnly))] public void GetPathRoot() { Assert.Null(PathUtilities.GetPathRoot(null)); Assert.Equal("", PathUtilities.GetPathRoot("")); Assert.Equal("", PathUtilities.GetPathRoot("C")); Assert.Equal("", PathUtilities.GetPathRoot("abc.txt")); Assert.Equal("C:", PathUtilities.GetPathRoot("C:")); Assert.Equal(@"C:\", PathUtilities.GetPathRoot(@"C:\")); Assert.Equal(@"C:/", PathUtilities.GetPathRoot(@"C:/")); Assert.Equal(@"C:\", PathUtilities.GetPathRoot(@"C:\\")); Assert.Equal(@"C:/", PathUtilities.GetPathRoot(@"C:/\")); Assert.Equal(@"*:/", PathUtilities.GetPathRoot(@"*:/")); Assert.Equal(@"0:/", PathUtilities.GetPathRoot(@"0:/")); Assert.Equal(@"::/", PathUtilities.GetPathRoot(@"::/")); // '/' is an absolute path on unix-like systems switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: case PlatformID.Unix: Assert.Equal("/", PathUtilities.GetPathRoot(@"/")); Assert.Equal(@"/", PathUtilities.GetPathRoot(@"/x")); // Be permissive of either directory separator, just // like we are in other cases Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\")); Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\x")); break; default: Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\")); Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\x")); break; } Assert.Equal(@"\\", PathUtilities.GetPathRoot(@"\\")); Assert.Equal(@"\\x", PathUtilities.GetPathRoot(@"\\x")); Assert.Equal(@"\\x\", PathUtilities.GetPathRoot(@"\\x\")); Assert.Equal(@"\\x\y", PathUtilities.GetPathRoot(@"\\x\y")); Assert.Equal(@"\\\x\y", PathUtilities.GetPathRoot(@"\\\x\y")); Assert.Equal(@"\\\\x\y", PathUtilities.GetPathRoot(@"\\\\x\y")); Assert.Equal(@"\\x\\y", PathUtilities.GetPathRoot(@"\\x\\y")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y/")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y\/")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y\/zzz")); Assert.Equal(@"\\x\y", PathUtilities.GetPathRoot(@"\\x\y")); Assert.Equal(@"\\x\y", PathUtilities.GetPathRoot(@"\\x\y\\")); Assert.Equal(@"\\abc\xyz", PathUtilities.GetPathRoot(@"\\abc\xyz")); Assert.Equal(@"\\server\$c", PathUtilities.GetPathRoot(@"\\server\$c\Public")); // TODO (tomat): long UNC paths // Assert.Equal(@"\\?\C:\", PathUtilities.GetPathRoot(@"\\?\C:\abc\def")); } [ConditionalFact(typeof(WindowsOnly))] public void CombinePaths() { Assert.Equal(@"C:\x/y", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"")); Assert.Equal(@"C:\x/y", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", null)); Assert.Equal(@"C:\x/y", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", null)); Assert.Null(PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\", @"C:\goo")); Assert.Null(PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\", @"C:goo")); Assert.Null(PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\", @"\goo")); Assert.Equal(@"C:\x\y\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x\y", @"goo")); Assert.Equal(@"C:\x/y\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"goo")); Assert.Equal(@"C:\x/y\.\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @".\goo")); Assert.Equal(@"C:\x/y\./goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"./goo")); Assert.Equal(@"C:\x/y\..\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"..\goo")); Assert.Equal(@"C:\x/y\../goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"../goo")); } [ConditionalFact(typeof(WindowsOnly))] public void ResolveRelativePath() { string baseDir = @"X:\rootdir\dir"; string[] noSearchPaths = new string[0]; // absolute path: TestPath(@"C:\abc\def.dll", @"Q:\baz\x.csx", baseDir, noSearchPaths, @"C:\abc\def.dll"); TestPath(@"C:\abc\\\\\def.dll", @"Q:\baz\x.csx", baseDir, noSearchPaths, @"C:\abc\\\\\def.dll"); // root-relative path: TestPath(@"\abc\def.dll", @"Q:\baz\x.csx", baseDir, noSearchPaths, @"Q:\abc\def.dll"); TestPath(@"\abc\def.dll", null, baseDir, noSearchPaths, @"X:\abc\def.dll"); TestPath(@"\abc\def.dll", "goo.csx", null, noSearchPaths, null); // TestPath(@"\abc\def.dll", @"C:goo.csx", null, noSearchPaths, null); // TestPath(@"/abc\def.dll", @"\goo.csx", null, noSearchPaths, null); TestPath(@"/abc\def.dll", null, @"\\x\y\z", noSearchPaths, @"\\x\y\abc\def.dll"); TestPath(@"/abc\def.dll", null, null, noSearchPaths, null); TestPath(@"/**/", null, baseDir, noSearchPaths, @"X:\**/"); TestPath(@"/a/z.txt", null, @"?:\*\<>", noSearchPaths, @"?:\a/z.txt"); // UNC path: TestPath(@"\abc\def.dll", @"\\mymachine\root\x.csx", baseDir, noSearchPaths, @"\\mymachine\root\abc\def.dll"); TestPath(@"\abc\def.dll", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\mymachine\root\abc\def.dll"); TestPath(@"\\abc\def\baz.dll", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\abc\def\baz.dll"); // incomplete UNC paths (considered absolute and returned as they are): TestPath(@"\\", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\"); TestPath(@"\\goo", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\goo"); // long UNC path: // TODO (tomat): // Doesn't work since "?" in paths is not handled by BCL // TestPath(resolver, @"\abc\def.dll", @"\\?\C:\zzz\x.csx", @"\\?\C:\abc\def.dll"); TestPath(@"./def.dll", @"Q:\abc\x.csx", baseDir, noSearchPaths, @"Q:\abc\./def.dll"); TestPath(@"./def.dll", @"Q:\abc\x.csx", baseDir, noSearchPaths, @"Q:\abc\./def.dll"); TestPath(@".", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo"); TestPath(@"..", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo\.."); // doesn't normalize TestPath(@".\", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo\.\"); TestPath(@"..\", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo\..\"); // doesn't normalize // relative base paths: TestPath(@".\y.dll", @"x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\.\y.dll"); TestPath(@".\y.dll", @"goo\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\goo\.\y.dll"); TestPath(@".\y.dll", @".\goo\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\.\goo\.\y.dll"); TestPath(@".\y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\.\y.dll"); // doesn't normalize TestPath(@".\\y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\.\\y.dll"); // doesn't normalize TestPath(@".\/y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\.\/y.dll"); // doesn't normalize TestPath(@"..\y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\..\y.dll"); // doesn't normalize // unqualified relative path, look in base directory: TestPath(@"y.dll", @"x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\y.dll"); TestPath(@"y.dll", @"x.csx", baseDir, new[] { @"Z:\" }, @"X:\rootdir\dir\y.dll"); // drive-relative path (not supported -> null) TestPath(@"C:y.dll", @"x.csx", baseDir, noSearchPaths, null); TestPath("C:\tools\\", null, @"d:\z", noSearchPaths, null); // invalid paths Assert.Equal(PathKind.RelativeToCurrentRoot, PathUtilities.GetPathKind(@"/c:x.dll")); TestPath(@"/c:x.dll", null, @"d:\", noSearchPaths, @"d:\c:x.dll"); Assert.Equal(PathKind.RelativeToCurrentRoot, PathUtilities.GetPathKind(@"/:x.dll")); TestPath(@"/:x.dll", null, @"d:\", noSearchPaths, @"d:\:x.dll"); Assert.Equal(PathKind.Absolute, PathUtilities.GetPathKind(@"//:x.dll")); TestPath(@"//:x.dll", null, @"d:\", noSearchPaths, @"//:x.dll"); Assert.Equal(PathKind.RelativeToDriveDirectory, PathUtilities.GetPathKind(@"c::x.dll")); TestPath(@"c::x.dll", null, @"d:\", noSearchPaths, null); Assert.Equal(PathKind.RelativeToCurrentDirectory, PathUtilities.GetPathKind(@".\:x.dll")); TestPath(@".\:x.dll", null, @"d:\z", noSearchPaths, @"d:\z\.\:x.dll"); Assert.Equal(PathKind.RelativeToCurrentParent, PathUtilities.GetPathKind(@"..\:x.dll")); TestPath(@"..\:x.dll", null, @"d:\z", noSearchPaths, @"d:\z\..\:x.dll"); // empty paths Assert.Equal(PathKind.Empty, PathUtilities.GetPathKind(@"")); TestPath(@"", @"c:\temp", @"d:\z", noSearchPaths, null); Assert.Equal(PathKind.Empty, PathUtilities.GetPathKind(" \t\r\n ")); TestPath(" \t\r\n ", @"c:\temp", @"d:\z", noSearchPaths, null); } private void TestPath(string path, string basePath, string baseDirectory, IEnumerable<String> searchPaths, string expected) { string actual = FileUtilities.ResolveRelativePath(path, basePath, baseDirectory, searchPaths, p => true); Assert.Equal(expected, actual, StringComparer.OrdinalIgnoreCase); } private void TestGetExtension(string path, string expected) { Assert.Equal(expected, PathUtilities.GetExtension(path)); Assert.Equal(expected, Path.GetExtension(path)); } private void TestRemoveExtension(string path, string expected) { Assert.Equal(expected, PathUtilities.RemoveExtension(path)); Assert.Equal(expected, Path.GetFileNameWithoutExtension(path)); } private void TestChangeExtension(string path, string extension, string expected) { Assert.Equal(expected, PathUtilities.ChangeExtension(path, extension)); Assert.Equal(expected, Path.ChangeExtension(path, extension)); } [ConditionalFact(typeof(WindowsOnly))] public void Extension() { TestGetExtension(path: "a.dll", expected: ".dll"); TestGetExtension(path: "a.exe.config", expected: ".config"); TestGetExtension(path: ".goo", expected: ".goo"); TestGetExtension(path: ".goo.dll", expected: ".dll"); TestGetExtension(path: "goo", expected: ""); TestGetExtension(path: "goo.", expected: ""); TestGetExtension(path: "goo..", expected: ""); TestGetExtension(path: "goo...", expected: ""); Assert.Equal(".dll", PathUtilities.GetExtension("*.dll")); TestRemoveExtension(path: "a.dll", expected: "a"); TestRemoveExtension(path: "a.exe.config", expected: "a.exe"); TestRemoveExtension(path: ".goo", expected: ""); TestRemoveExtension(path: ".goo.dll", expected: ".goo"); TestRemoveExtension(path: "goo", expected: "goo"); TestRemoveExtension(path: "goo.", expected: "goo"); TestRemoveExtension(path: "goo..", expected: "goo."); TestRemoveExtension(path: "goo...", expected: "goo.."); Assert.Equal("*", PathUtilities.RemoveExtension("*.dll")); TestChangeExtension(path: "a.dll", extension: ".exe", expected: "a.exe"); TestChangeExtension(path: "a.dll", extension: "exe", expected: "a.exe"); TestChangeExtension(path: "a.dll", extension: "", expected: "a."); TestChangeExtension(path: "a.dll", extension: ".", expected: "a."); TestChangeExtension(path: "a.dll", extension: "..", expected: "a.."); TestChangeExtension(path: "a.dll", extension: "...", expected: "a..."); TestChangeExtension(path: "a.dll", extension: " ", expected: "a. "); TestChangeExtension(path: "a", extension: ".exe", expected: "a.exe"); TestChangeExtension(path: "a.", extension: "exe", expected: "a.exe"); TestChangeExtension(path: "a..", extension: "exe", expected: "a..exe"); TestChangeExtension(path: "a.", extension: "e.x.e", expected: "a.e.x.e"); TestChangeExtension(path: ".", extension: "", expected: "."); TestChangeExtension(path: "..", extension: ".", expected: ".."); TestChangeExtension(path: "..", extension: "..", expected: "..."); TestChangeExtension(path: "", extension: "", expected: ""); TestChangeExtension(path: null, extension: "", expected: null); TestChangeExtension(path: null, extension: null, expected: null); Assert.Equal("*", PathUtilities.RemoveExtension("*.dll")); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.IO; using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.UnitTests { public class FileUtilitiesTests { [ConditionalFact(typeof(WindowsOnly))] public void IsAbsolute() { Assert.False(PathUtilities.IsAbsolute(null)); Assert.False(PathUtilities.IsAbsolute("")); Assert.False(PathUtilities.IsAbsolute("C")); Assert.False(PathUtilities.IsAbsolute("C:")); Assert.True(PathUtilities.IsAbsolute(@"C:\")); Assert.True(PathUtilities.IsAbsolute(@"C:/")); Assert.True(PathUtilities.IsAbsolute(@"C:\\")); Assert.False(PathUtilities.IsAbsolute(@"C\")); Assert.True(PathUtilities.IsAbsolute(@"\\")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\\S")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\/C")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\/C\")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\\server")); // incomplete UNC Assert.True(PathUtilities.IsAbsolute(@"\\server\share")); // UNC Assert.True(PathUtilities.IsAbsolute(@"\\?\C:\share")); // long UNC Assert.False(PathUtilities.IsAbsolute(@"\C")); Assert.False(PathUtilities.IsAbsolute(@"/C")); } [ConditionalFact(typeof(WindowsOnly))] public void GetPathRoot() { Assert.Null(PathUtilities.GetPathRoot(null)); Assert.Equal("", PathUtilities.GetPathRoot("")); Assert.Equal("", PathUtilities.GetPathRoot("C")); Assert.Equal("", PathUtilities.GetPathRoot("abc.txt")); Assert.Equal("C:", PathUtilities.GetPathRoot("C:")); Assert.Equal(@"C:\", PathUtilities.GetPathRoot(@"C:\")); Assert.Equal(@"C:/", PathUtilities.GetPathRoot(@"C:/")); Assert.Equal(@"C:\", PathUtilities.GetPathRoot(@"C:\\")); Assert.Equal(@"C:/", PathUtilities.GetPathRoot(@"C:/\")); Assert.Equal(@"*:/", PathUtilities.GetPathRoot(@"*:/")); Assert.Equal(@"0:/", PathUtilities.GetPathRoot(@"0:/")); Assert.Equal(@"::/", PathUtilities.GetPathRoot(@"::/")); // '/' is an absolute path on unix-like systems switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: case PlatformID.Unix: Assert.Equal("/", PathUtilities.GetPathRoot(@"/")); Assert.Equal(@"/", PathUtilities.GetPathRoot(@"/x")); // Be permissive of either directory separator, just // like we are in other cases Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\")); Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\x")); break; default: Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\")); Assert.Equal(@"\", PathUtilities.GetPathRoot(@"\x")); break; } Assert.Equal(@"\\", PathUtilities.GetPathRoot(@"\\")); Assert.Equal(@"\\x", PathUtilities.GetPathRoot(@"\\x")); Assert.Equal(@"\\x\", PathUtilities.GetPathRoot(@"\\x\")); Assert.Equal(@"\\x\y", PathUtilities.GetPathRoot(@"\\x\y")); Assert.Equal(@"\\\x\y", PathUtilities.GetPathRoot(@"\\\x\y")); Assert.Equal(@"\\\\x\y", PathUtilities.GetPathRoot(@"\\\\x\y")); Assert.Equal(@"\\x\\y", PathUtilities.GetPathRoot(@"\\x\\y")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y/")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y\/")); Assert.Equal(@"\\/x\\/y", PathUtilities.GetPathRoot(@"\\/x\\/y\/zzz")); Assert.Equal(@"\\x\y", PathUtilities.GetPathRoot(@"\\x\y")); Assert.Equal(@"\\x\y", PathUtilities.GetPathRoot(@"\\x\y\\")); Assert.Equal(@"\\abc\xyz", PathUtilities.GetPathRoot(@"\\abc\xyz")); Assert.Equal(@"\\server\$c", PathUtilities.GetPathRoot(@"\\server\$c\Public")); // TODO (tomat): long UNC paths // Assert.Equal(@"\\?\C:\", PathUtilities.GetPathRoot(@"\\?\C:\abc\def")); } [ConditionalFact(typeof(WindowsOnly))] public void CombinePaths() { Assert.Equal(@"C:\x/y", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"")); Assert.Equal(@"C:\x/y", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", null)); Assert.Equal(@"C:\x/y", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", null)); Assert.Null(PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\", @"C:\goo")); Assert.Null(PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\", @"C:goo")); Assert.Null(PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\", @"\goo")); Assert.Equal(@"C:\x\y\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x\y", @"goo")); Assert.Equal(@"C:\x/y\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"goo")); Assert.Equal(@"C:\x/y\.\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @".\goo")); Assert.Equal(@"C:\x/y\./goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"./goo")); Assert.Equal(@"C:\x/y\..\goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"..\goo")); Assert.Equal(@"C:\x/y\../goo", PathUtilities.CombineAbsoluteAndRelativePaths(@"C:\x/y", @"../goo")); } [ConditionalFact(typeof(WindowsOnly))] public void ResolveRelativePath() { string baseDir = @"X:\rootdir\dir"; string[] noSearchPaths = new string[0]; // absolute path: TestPath(@"C:\abc\def.dll", @"Q:\baz\x.csx", baseDir, noSearchPaths, @"C:\abc\def.dll"); TestPath(@"C:\abc\\\\\def.dll", @"Q:\baz\x.csx", baseDir, noSearchPaths, @"C:\abc\\\\\def.dll"); // root-relative path: TestPath(@"\abc\def.dll", @"Q:\baz\x.csx", baseDir, noSearchPaths, @"Q:\abc\def.dll"); TestPath(@"\abc\def.dll", null, baseDir, noSearchPaths, @"X:\abc\def.dll"); TestPath(@"\abc\def.dll", "goo.csx", null, noSearchPaths, null); // TestPath(@"\abc\def.dll", @"C:goo.csx", null, noSearchPaths, null); // TestPath(@"/abc\def.dll", @"\goo.csx", null, noSearchPaths, null); TestPath(@"/abc\def.dll", null, @"\\x\y\z", noSearchPaths, @"\\x\y\abc\def.dll"); TestPath(@"/abc\def.dll", null, null, noSearchPaths, null); TestPath(@"/**/", null, baseDir, noSearchPaths, @"X:\**/"); TestPath(@"/a/z.txt", null, @"?:\*\<>", noSearchPaths, @"?:\a/z.txt"); // UNC path: TestPath(@"\abc\def.dll", @"\\mymachine\root\x.csx", baseDir, noSearchPaths, @"\\mymachine\root\abc\def.dll"); TestPath(@"\abc\def.dll", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\mymachine\root\abc\def.dll"); TestPath(@"\\abc\def\baz.dll", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\abc\def\baz.dll"); // incomplete UNC paths (considered absolute and returned as they are): TestPath(@"\\", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\"); TestPath(@"\\goo", null, @"\\mymachine\root\x.csx", noSearchPaths, @"\\goo"); // long UNC path: // TODO (tomat): // Doesn't work since "?" in paths is not handled by BCL // TestPath(resolver, @"\abc\def.dll", @"\\?\C:\zzz\x.csx", @"\\?\C:\abc\def.dll"); TestPath(@"./def.dll", @"Q:\abc\x.csx", baseDir, noSearchPaths, @"Q:\abc\./def.dll"); TestPath(@"./def.dll", @"Q:\abc\x.csx", baseDir, noSearchPaths, @"Q:\abc\./def.dll"); TestPath(@".", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo"); TestPath(@"..", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo\.."); // doesn't normalize TestPath(@".\", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo\.\"); TestPath(@"..\", @"Q:\goo\x.csx", baseDir, noSearchPaths, @"Q:\goo\..\"); // doesn't normalize // relative base paths: TestPath(@".\y.dll", @"x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\.\y.dll"); TestPath(@".\y.dll", @"goo\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\goo\.\y.dll"); TestPath(@".\y.dll", @".\goo\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\.\goo\.\y.dll"); TestPath(@".\y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\.\y.dll"); // doesn't normalize TestPath(@".\\y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\.\\y.dll"); // doesn't normalize TestPath(@".\/y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\.\/y.dll"); // doesn't normalize TestPath(@"..\y.dll", @"..\x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\..\..\y.dll"); // doesn't normalize // unqualified relative path, look in base directory: TestPath(@"y.dll", @"x.csx", baseDir, noSearchPaths, @"X:\rootdir\dir\y.dll"); TestPath(@"y.dll", @"x.csx", baseDir, new[] { @"Z:\" }, @"X:\rootdir\dir\y.dll"); // drive-relative path (not supported -> null) TestPath(@"C:y.dll", @"x.csx", baseDir, noSearchPaths, null); TestPath("C:\tools\\", null, @"d:\z", noSearchPaths, null); // invalid paths Assert.Equal(PathKind.RelativeToCurrentRoot, PathUtilities.GetPathKind(@"/c:x.dll")); TestPath(@"/c:x.dll", null, @"d:\", noSearchPaths, @"d:\c:x.dll"); Assert.Equal(PathKind.RelativeToCurrentRoot, PathUtilities.GetPathKind(@"/:x.dll")); TestPath(@"/:x.dll", null, @"d:\", noSearchPaths, @"d:\:x.dll"); Assert.Equal(PathKind.Absolute, PathUtilities.GetPathKind(@"//:x.dll")); TestPath(@"//:x.dll", null, @"d:\", noSearchPaths, @"//:x.dll"); Assert.Equal(PathKind.RelativeToDriveDirectory, PathUtilities.GetPathKind(@"c::x.dll")); TestPath(@"c::x.dll", null, @"d:\", noSearchPaths, null); Assert.Equal(PathKind.RelativeToCurrentDirectory, PathUtilities.GetPathKind(@".\:x.dll")); TestPath(@".\:x.dll", null, @"d:\z", noSearchPaths, @"d:\z\.\:x.dll"); Assert.Equal(PathKind.RelativeToCurrentParent, PathUtilities.GetPathKind(@"..\:x.dll")); TestPath(@"..\:x.dll", null, @"d:\z", noSearchPaths, @"d:\z\..\:x.dll"); // empty paths Assert.Equal(PathKind.Empty, PathUtilities.GetPathKind(@"")); TestPath(@"", @"c:\temp", @"d:\z", noSearchPaths, null); Assert.Equal(PathKind.Empty, PathUtilities.GetPathKind(" \t\r\n ")); TestPath(" \t\r\n ", @"c:\temp", @"d:\z", noSearchPaths, null); } private void TestPath(string path, string basePath, string baseDirectory, IEnumerable<String> searchPaths, string expected) { string actual = FileUtilities.ResolveRelativePath(path, basePath, baseDirectory, searchPaths, p => true); Assert.Equal(expected, actual, StringComparer.OrdinalIgnoreCase); } private void TestGetExtension(string path, string expected) { Assert.Equal(expected, PathUtilities.GetExtension(path)); Assert.Equal(expected, Path.GetExtension(path)); } private void TestRemoveExtension(string path, string expected) { Assert.Equal(expected, PathUtilities.RemoveExtension(path)); Assert.Equal(expected, Path.GetFileNameWithoutExtension(path)); } private void TestChangeExtension(string path, string extension, string expected) { Assert.Equal(expected, PathUtilities.ChangeExtension(path, extension)); Assert.Equal(expected, Path.ChangeExtension(path, extension)); } [ConditionalFact(typeof(WindowsOnly))] public void Extension() { TestGetExtension(path: "a.dll", expected: ".dll"); TestGetExtension(path: "a.exe.config", expected: ".config"); TestGetExtension(path: ".goo", expected: ".goo"); TestGetExtension(path: ".goo.dll", expected: ".dll"); TestGetExtension(path: "goo", expected: ""); TestGetExtension(path: "goo.", expected: ""); TestGetExtension(path: "goo..", expected: ""); TestGetExtension(path: "goo...", expected: ""); Assert.Equal(".dll", PathUtilities.GetExtension("*.dll")); TestRemoveExtension(path: "a.dll", expected: "a"); TestRemoveExtension(path: "a.exe.config", expected: "a.exe"); TestRemoveExtension(path: ".goo", expected: ""); TestRemoveExtension(path: ".goo.dll", expected: ".goo"); TestRemoveExtension(path: "goo", expected: "goo"); TestRemoveExtension(path: "goo.", expected: "goo"); TestRemoveExtension(path: "goo..", expected: "goo."); TestRemoveExtension(path: "goo...", expected: "goo.."); Assert.Equal("*", PathUtilities.RemoveExtension("*.dll")); TestChangeExtension(path: "a.dll", extension: ".exe", expected: "a.exe"); TestChangeExtension(path: "a.dll", extension: "exe", expected: "a.exe"); TestChangeExtension(path: "a.dll", extension: "", expected: "a."); TestChangeExtension(path: "a.dll", extension: ".", expected: "a."); TestChangeExtension(path: "a.dll", extension: "..", expected: "a.."); TestChangeExtension(path: "a.dll", extension: "...", expected: "a..."); TestChangeExtension(path: "a.dll", extension: " ", expected: "a. "); TestChangeExtension(path: "a", extension: ".exe", expected: "a.exe"); TestChangeExtension(path: "a.", extension: "exe", expected: "a.exe"); TestChangeExtension(path: "a..", extension: "exe", expected: "a..exe"); TestChangeExtension(path: "a.", extension: "e.x.e", expected: "a.e.x.e"); TestChangeExtension(path: ".", extension: "", expected: "."); TestChangeExtension(path: "..", extension: ".", expected: ".."); TestChangeExtension(path: "..", extension: "..", expected: "..."); TestChangeExtension(path: "", extension: "", expected: ""); TestChangeExtension(path: null, extension: "", expected: null); TestChangeExtension(path: null, extension: null, expected: null); Assert.Equal("*", PathUtilities.RemoveExtension("*.dll")); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.CodeAnalysis.Host { internal interface ICompilationFactoryService : ILanguageService { Compilation CreateCompilation(string assemblyName, CompilationOptions options); Compilation CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type? hostObjectType); CompilationOptions GetDefaultCompilationOptions(); GeneratorDriver CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray<ISourceGenerator> generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray<AdditionalText> additionalTexts); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.CodeAnalysis.Host { internal interface ICompilationFactoryService : ILanguageService { Compilation CreateCompilation(string assemblyName, CompilationOptions options); Compilation CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type? hostObjectType); CompilationOptions GetDefaultCompilationOptions(); GeneratorDriver CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray<ISourceGenerator> generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray<AdditionalText> additionalTexts); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmVendorId.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll #endregion using System; namespace Microsoft.VisualStudio.Debugger.Evaluation { public static class DkmVendorId { public static Guid Microsoft { get { return new Guid("994B45C4-E6E9-11D2-903F-00C04FA302A1"); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll #endregion using System; namespace Microsoft.VisualStudio.Debugger.Evaluation { public static class DkmVendorId { public static Guid Microsoft { get { return new Guid("994B45C4-E6E9-11D2-903F-00C04FA302A1"); } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Interactive/HostProcess/InteractiveHostEntryPoint.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.CodeAnalysis.ErrorReporting; namespace Microsoft.CodeAnalysis.Interactive { internal static class InteractiveHostEntryPoint { private static async Task<int> Main(string[] args) { FatalError.Handler = FailFast.OnFatalException; // Disables Windows Error Reporting for the process, so that the process fails fast. SetErrorMode(GetErrorMode() | ErrorMode.SEM_FAILCRITICALERRORS | ErrorMode.SEM_NOOPENFILEERRORBOX | ErrorMode.SEM_NOGPFAULTERRORBOX); Control? control = null; using (var resetEvent = new ManualResetEventSlim(false)) { var uiThread = new Thread(() => { control = new Control(); control.CreateControl(); resetEvent.Set(); Application.Run(); }); uiThread.SetApartmentState(ApartmentState.STA); uiThread.IsBackground = true; uiThread.Start(); resetEvent.Wait(); } var invokeOnMainThread = new Func<Func<object>, object>(operation => control!.Invoke(operation)); try { await InteractiveHost.Service.RunServerAsync(args, invokeOnMainThread).ConfigureAwait(false); return 0; } catch (Exception e) { Console.Error.WriteLine(e); return 1; } } [DllImport("kernel32", PreserveSig = true)] internal static extern ErrorMode SetErrorMode(ErrorMode mode); [DllImport("kernel32", PreserveSig = true)] internal static extern ErrorMode GetErrorMode(); [Flags] internal enum ErrorMode : int { /// <summary> /// Use the system default, which is to display all error dialog boxes. /// </summary> SEM_FAILCRITICALERRORS = 0x0001, /// <summary> /// The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. /// Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. /// This is to prevent error mode dialogs from blocking the application. /// </summary> SEM_NOGPFAULTERRORBOX = 0x0002, /// <summary> /// The system automatically fixes memory alignment faults and makes them invisible to the application. /// It does this for the calling process and any descendant processes. This feature is only supported by /// certain processor architectures. For more information, see the Remarks section. /// After this value is set for a process, subsequent attempts to clear the value are ignored. /// </summary> SEM_NOALIGNMENTFAULTEXCEPT = 0x0004, /// <summary> /// The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling process. /// </summary> SEM_NOOPENFILEERRORBOX = 0x8000, } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.CodeAnalysis.ErrorReporting; namespace Microsoft.CodeAnalysis.Interactive { internal static class InteractiveHostEntryPoint { private static async Task<int> Main(string[] args) { FatalError.Handler = FailFast.OnFatalException; // Disables Windows Error Reporting for the process, so that the process fails fast. SetErrorMode(GetErrorMode() | ErrorMode.SEM_FAILCRITICALERRORS | ErrorMode.SEM_NOOPENFILEERRORBOX | ErrorMode.SEM_NOGPFAULTERRORBOX); Control? control = null; using (var resetEvent = new ManualResetEventSlim(false)) { var uiThread = new Thread(() => { control = new Control(); control.CreateControl(); resetEvent.Set(); Application.Run(); }); uiThread.SetApartmentState(ApartmentState.STA); uiThread.IsBackground = true; uiThread.Start(); resetEvent.Wait(); } var invokeOnMainThread = new Func<Func<object>, object>(operation => control!.Invoke(operation)); try { await InteractiveHost.Service.RunServerAsync(args, invokeOnMainThread).ConfigureAwait(false); return 0; } catch (Exception e) { Console.Error.WriteLine(e); return 1; } } [DllImport("kernel32", PreserveSig = true)] internal static extern ErrorMode SetErrorMode(ErrorMode mode); [DllImport("kernel32", PreserveSig = true)] internal static extern ErrorMode GetErrorMode(); [Flags] internal enum ErrorMode : int { /// <summary> /// Use the system default, which is to display all error dialog boxes. /// </summary> SEM_FAILCRITICALERRORS = 0x0001, /// <summary> /// The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. /// Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. /// This is to prevent error mode dialogs from blocking the application. /// </summary> SEM_NOGPFAULTERRORBOX = 0x0002, /// <summary> /// The system automatically fixes memory alignment faults and makes them invisible to the application. /// It does this for the calling process and any descendant processes. This feature is only supported by /// certain processor architectures. For more information, see the Remarks section. /// After this value is set for a process, subsequent attempts to clear the value are ignored. /// </summary> SEM_NOALIGNMENTFAULTEXCEPT = 0x0004, /// <summary> /// The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling process. /// </summary> SEM_NOOPENFILEERRORBOX = 0x8000, } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Features/Core/Portable/GenerateType/IGenerateTypeService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.GenerateType { internal interface IGenerateTypeService : ILanguageService { Task<ImmutableArray<CodeAction>> GenerateTypeAsync(Document document, SyntaxNode node, CancellationToken cancellationToken); Task<(INamespaceSymbol, INamespaceOrTypeSymbol, Location)> GetOrGenerateEnclosingNamespaceSymbolAsync(INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken); string GetRootNamespace(CompilationOptions options); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.GenerateType { internal interface IGenerateTypeService : ILanguageService { Task<ImmutableArray<CodeAction>> GenerateTypeAsync(Document document, SyntaxNode node, CancellationToken cancellationToken); Task<(INamespaceSymbol, INamespaceOrTypeSymbol, Location)> GetOrGenerateEnclosingNamespaceSymbolAsync(INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken); string GetRootNamespace(CompilationOptions options); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTypeofTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen { public class CodeGenTypeOfTests : CSharpTestBase { [Fact] public void TestTypeofSimple() { var source = @" class C { static void Main() { System.Console.WriteLine(typeof(C)); } }"; var comp = CompileAndVerify(source, expectedOutput: "C"); comp.VerifyDiagnostics(); comp.VerifyIL("C.Main", @"{ // Code size 16 (0x10) .maxstack 1 IL_0000: ldtoken ""C"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ret }"); } [Fact] public void TestTypeofNonGeneric() { var source = @" namespace Source { class Class { } struct Struct { } enum Enum { e } interface Interface { } class StaticClass { } } class Program { static void Main() { // From source System.Console.WriteLine(typeof(Source.Class)); System.Console.WriteLine(typeof(Source.Struct)); System.Console.WriteLine(typeof(Source.Enum)); System.Console.WriteLine(typeof(Source.Interface)); System.Console.WriteLine(typeof(Source.StaticClass)); // From metadata System.Console.WriteLine(typeof(string)); System.Console.WriteLine(typeof(int)); System.Console.WriteLine(typeof(System.IO.FileMode)); System.Console.WriteLine(typeof(System.IFormattable)); System.Console.WriteLine(typeof(System.Math)); // Special System.Console.WriteLine(typeof(void)); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Source.Class Source.Struct Source.Enum Source.Interface Source.StaticClass System.String System.Int32 System.IO.FileMode System.IFormattable System.Math System.Void"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Main", @"{ // Code size 166 (0xa6) .maxstack 1 IL_0000: ldtoken ""Source.Class"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Source.Struct"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""Source.Enum"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""Source.Interface"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ldtoken ""Source.StaticClass"" IL_0041: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0046: call ""void System.Console.WriteLine(object)"" IL_004b: ldtoken ""string"" IL_0050: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0055: call ""void System.Console.WriteLine(object)"" IL_005a: ldtoken ""int"" IL_005f: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0064: call ""void System.Console.WriteLine(object)"" IL_0069: ldtoken ""System.IO.FileMode"" IL_006e: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0073: call ""void System.Console.WriteLine(object)"" IL_0078: ldtoken ""System.IFormattable"" IL_007d: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0082: call ""void System.Console.WriteLine(object)"" IL_0087: ldtoken ""System.Math"" IL_008c: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0091: call ""void System.Console.WriteLine(object)"" IL_0096: ldtoken ""void"" IL_009b: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_00a0: call ""void System.Console.WriteLine(object)"" IL_00a5: ret }"); } [Fact] public void TestTypeofGeneric() { var source = @" class Class1<T> { } class Class2<T, U> { } class Program { static void Main() { System.Console.WriteLine(typeof(Class1<int>)); System.Console.WriteLine(typeof(Class1<Class1<int>>)); System.Console.WriteLine(typeof(Class2<int, long>)); System.Console.WriteLine(typeof(Class2<Class1<int>, Class1<long>>)); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Class1`1[System.Int32] Class1`1[Class1`1[System.Int32]] Class2`2[System.Int32,System.Int64] Class2`2[Class1`1[System.Int32],Class1`1[System.Int64]]"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Main", @"{ // Code size 61 (0x3d) .maxstack 1 IL_0000: ldtoken ""Class1<int>"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class1<Class1<int>>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""Class2<int, long>"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""Class2<Class1<int>, Class1<long>>"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ret }"); } [Fact] public void TestTypeofTypeParameter() { var source = @" class Class<T> { public static void Print() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(Class<T>)); } public static void Print<U>() { System.Console.WriteLine(typeof(U)); System.Console.WriteLine(typeof(Class<U>)); } } class Program { static void Main() { Class<int>.Print(); Class<Class<int>>.Print(); Class<int>.Print<long>(); Class<Class<int>>.Print<Class<long>>(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" System.Int32 Class`1[System.Int32] Class`1[System.Int32] Class`1[Class`1[System.Int32]] System.Int64 Class`1[System.Int64] Class`1[System.Int64] Class`1[Class`1[System.Int64]]"); comp.VerifyDiagnostics(); comp.VerifyIL("Class<T>.Print", @"{ // Code size 31 (0x1f) .maxstack 1 IL_0000: ldtoken ""T"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class<T>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ret }"); comp.VerifyIL("Class<T>.Print<U>", @"{ // Code size 31 (0x1f) .maxstack 1 IL_0000: ldtoken ""U"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class<U>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ret }"); } [Fact] public void TestTypeofUnboundGeneric() { var source = @" class Class1<T> { } class Class2<T, U> { } class Program { static void Main() { System.Console.WriteLine(typeof(Class1<>)); System.Console.WriteLine(typeof(Class2<,>)); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Class1`1[T] Class2`2[T,U]"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Main", @"{ // Code size 31 (0x1f) .maxstack 1 IL_0000: ldtoken ""Class1<T>"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class2<T, U>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ret }"); } [WorkItem(542581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542581")] [Fact] public void TestTypeofInheritedNestedTypeThroughUnboundGeneric_01() { var source = @" using System; class D<T> : C, I1, I2<T, int> { } interface I1 { } interface I2<T, U> { } class F<T> { public class E {} } class G<T> : F<T>, I1, I2<T, int> { } class H<T, U> { public class E {} } class K<T> : H<T, int>{ } class C { public class E { } static void Main() { Console.WriteLine(typeof(D<>.E)); Console.WriteLine(typeof(D<>).BaseType); var interfaces = typeof(D<>).GetInterfaces(); Console.WriteLine(interfaces[0]); Console.WriteLine(interfaces[1]); Console.WriteLine(typeof(G<>.E)); Console.WriteLine(typeof(G<>).BaseType); interfaces = typeof(G<>).GetInterfaces(); Console.WriteLine(interfaces[0]); Console.WriteLine(interfaces[1]); Console.WriteLine(typeof(K<>.E)); Console.WriteLine(typeof(K<>).BaseType); } }"; var expected = @"C+E C I1 I2`2[T,System.Int32] F`1+E[T] F`1[T] I1 I2`2[T,System.Int32] H`2+E[T,U] H`2[T,System.Int32]"; var comp = CompileAndVerify(source, expectedOutput: expected); comp.VerifyDiagnostics(); } [WorkItem(542581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542581")] [WorkItem(9850, "https://github.com/dotnet/roslyn/issues/9850")] [Fact] public void TestTypeofInheritedNestedTypeThroughUnboundGeneric_02() { var source = @" using System; class C { public class E { } public class E<V> { } static void Main() { var t1 = typeof(D<>.E); Console.WriteLine(t1); var t2 = typeof(F<>.E); var t3 = typeof(G<>.E); Console.WriteLine(t2); Console.WriteLine(t3); Console.WriteLine(t2.Equals(t3)); var t4 = typeof(D<>.E<>); Console.WriteLine(t4); var t5 = typeof(F<>.E<>); var t6 = typeof(G<>.E<>); Console.WriteLine(t5); Console.WriteLine(t6); Console.WriteLine(t5.Equals(t6)); } } class C<U> { public class E { } public class E<V> { } } class D<T> : C { } class F<T> : C<T> { } class G<T> : C<int> { } "; var expected = @"C+E C`1+E[U] C`1+E[U] True C+E`1[V] C`1+E`1[U,V] C`1+E`1[U,V] True"; var comp = CompileAndVerify(source, expectedOutput: expected); comp.VerifyDiagnostics(); } [WorkItem(542581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542581")] [Fact] public void TestTypeofInheritedNestedTypeThroughUnboundGeneric_Attribute() { var source = @" using System; [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] class TestAttribute : Attribute { public TestAttribute(System.Type type){} } class D<T> : C, I1, I2<T, int> { } interface I1 { } interface I2<T, U> { } class F<T> { public class E {} } class G<T> : F<T>, I1, I2<T, int> { } class H<T, U> { public class E {} } class K<T> : H<T, int>{ } [TestAttribute(typeof(D<>))] [TestAttribute(typeof(D<>.E))] [TestAttribute(typeof(G<>))] [TestAttribute(typeof(G<>.E))] [TestAttribute(typeof(K<>))] [TestAttribute(typeof(K<>.E))] class C { public class E { } static void Main() { typeof(C).GetCustomAttributes(false); } }"; var comp = CompileAndVerify(source, expectedOutput: ""); } [Fact] public void TestTypeofArray() { var source = @" class Class1<T> { } class Program { static void Print<U>() { System.Console.WriteLine(typeof(int[])); System.Console.WriteLine(typeof(int[,])); System.Console.WriteLine(typeof(int[][])); System.Console.WriteLine(typeof(U[])); System.Console.WriteLine(typeof(Class1<U>[])); System.Console.WriteLine(typeof(Class1<int>[])); } static void Main() { Print<long>(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" System.Int32[] System.Int32[,] System.Int32[][] System.Int64[] Class1`1[System.Int64][] Class1`1[System.Int32][]"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Print<U>", @"{ // Code size 91 (0x5b) .maxstack 1 IL_0000: ldtoken ""int[]"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""int[,]"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""int[][]"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""U[]"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ldtoken ""Class1<U>[]"" IL_0041: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0046: call ""void System.Console.WriteLine(object)"" IL_004b: ldtoken ""Class1<int>[]"" IL_0050: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0055: call ""void System.Console.WriteLine(object)"" IL_005a: ret }"); } [Fact] public void TestTypeofNested() { var source = @" class Outer<T> { public static void Print() { System.Console.WriteLine(typeof(Inner<>)); System.Console.WriteLine(typeof(Inner<T>)); System.Console.WriteLine(typeof(Inner<int>)); System.Console.WriteLine(typeof(Outer<>.Inner<>)); // System.Console.WriteLine(typeof(Outer<>.Inner<T>)); //CS7003 // System.Console.WriteLine(typeof(Outer<>.Inner<int>)); //CS7003 // System.Console.WriteLine(typeof(Outer<T>.Inner<>)); //CS7003 System.Console.WriteLine(typeof(Outer<T>.Inner<T>)); System.Console.WriteLine(typeof(Outer<T>.Inner<int>)); // System.Console.WriteLine(typeof(Outer<int>.Inner<>)); //CS7003 System.Console.WriteLine(typeof(Outer<int>.Inner<T>)); System.Console.WriteLine(typeof(Outer<int>.Inner<int>)); } class Inner<U> { } } class Program { static void Main() { Outer<long>.Print(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Outer`1+Inner`1[T,U] Outer`1+Inner`1[System.Int64,System.Int64] Outer`1+Inner`1[System.Int64,System.Int32] Outer`1+Inner`1[T,U] Outer`1+Inner`1[System.Int64,System.Int64] Outer`1+Inner`1[System.Int64,System.Int32] Outer`1+Inner`1[System.Int32,System.Int64] Outer`1+Inner`1[System.Int32,System.Int32]"); comp.VerifyDiagnostics(); comp.VerifyIL("Outer<T>.Print", @"{ // Code size 121 (0x79) .maxstack 1 IL_0000: ldtoken ""Outer<T>.Inner<U>"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Outer<T>.Inner<T>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""Outer<T>.Inner<int>"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""Outer<T>.Inner<U>"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ldtoken ""Outer<T>.Inner<T>"" IL_0041: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0046: call ""void System.Console.WriteLine(object)"" IL_004b: ldtoken ""Outer<T>.Inner<int>"" IL_0050: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0055: call ""void System.Console.WriteLine(object)"" IL_005a: ldtoken ""Outer<int>.Inner<T>"" IL_005f: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0064: call ""void System.Console.WriteLine(object)"" IL_0069: ldtoken ""Outer<int>.Inner<int>"" IL_006e: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0073: call ""void System.Console.WriteLine(object)"" IL_0078: ret }"); } [Fact] public void TestTypeofInLambda() { var source = @" using System; public class Outer<T> { public class Inner<U> { public Action Method<V>(V v) { return () => { Console.WriteLine(v); Console.WriteLine(typeof(T)); Console.WriteLine(typeof(U)); Console.WriteLine(typeof(V)); Console.WriteLine(typeof(Outer<>)); Console.WriteLine(typeof(Outer<T>)); Console.WriteLine(typeof(Outer<U>)); Console.WriteLine(typeof(Outer<V>)); Console.WriteLine(typeof(Inner<>)); Console.WriteLine(typeof(Inner<T>)); Console.WriteLine(typeof(Inner<U>)); Console.WriteLine(typeof(Inner<V>)); }; } } } class Program { static void Main() { Action a = new Outer<int>.Inner<char>().Method<byte>(1); a(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" 1 System.Int32 System.Char System.Byte Outer`1[T] Outer`1[System.Int32] Outer`1[System.Char] Outer`1[System.Byte] Outer`1+Inner`1[T,U] Outer`1+Inner`1[System.Int32,System.Int32] Outer`1+Inner`1[System.Int32,System.Char] Outer`1+Inner`1[System.Int32,System.Byte]"); comp.VerifyDiagnostics(); } [WorkItem(541600, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541600")] [Fact] public void TestTypeOfAlias4TypeMemberOfGeneric() { var source = @" using System; using MyTestClass = TestClass<string>; public class TestClass<T> { public enum TestEnum { First = 0, } } public class mem178 { public static int Main() { Console.Write(typeof(MyTestClass.TestEnum)); return 0; } } "; CompileAndVerify(source, expectedOutput: @"TestClass`1+TestEnum[System.String]"); } [WorkItem(541618, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541618")] [Fact] public void TestTypeOfAlias5TypeMemberOfGeneric() { var source = @" using OuterOfString = Outer<string>; using OuterOfInt = Outer<int>; public class Outer<T> { public class Inner<U> { } } public class Program { public static void Main() { System.Console.WriteLine(typeof(OuterOfString.Inner<>) == typeof(OuterOfInt.Inner<>)); } } "; // NOTE: this is the Dev10 output. Change to false if we decide to take a breaking change. CompileAndVerify(source, expectedOutput: @"True"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen { public class CodeGenTypeOfTests : CSharpTestBase { [Fact] public void TestTypeofSimple() { var source = @" class C { static void Main() { System.Console.WriteLine(typeof(C)); } }"; var comp = CompileAndVerify(source, expectedOutput: "C"); comp.VerifyDiagnostics(); comp.VerifyIL("C.Main", @"{ // Code size 16 (0x10) .maxstack 1 IL_0000: ldtoken ""C"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ret }"); } [Fact] public void TestTypeofNonGeneric() { var source = @" namespace Source { class Class { } struct Struct { } enum Enum { e } interface Interface { } class StaticClass { } } class Program { static void Main() { // From source System.Console.WriteLine(typeof(Source.Class)); System.Console.WriteLine(typeof(Source.Struct)); System.Console.WriteLine(typeof(Source.Enum)); System.Console.WriteLine(typeof(Source.Interface)); System.Console.WriteLine(typeof(Source.StaticClass)); // From metadata System.Console.WriteLine(typeof(string)); System.Console.WriteLine(typeof(int)); System.Console.WriteLine(typeof(System.IO.FileMode)); System.Console.WriteLine(typeof(System.IFormattable)); System.Console.WriteLine(typeof(System.Math)); // Special System.Console.WriteLine(typeof(void)); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Source.Class Source.Struct Source.Enum Source.Interface Source.StaticClass System.String System.Int32 System.IO.FileMode System.IFormattable System.Math System.Void"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Main", @"{ // Code size 166 (0xa6) .maxstack 1 IL_0000: ldtoken ""Source.Class"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Source.Struct"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""Source.Enum"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""Source.Interface"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ldtoken ""Source.StaticClass"" IL_0041: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0046: call ""void System.Console.WriteLine(object)"" IL_004b: ldtoken ""string"" IL_0050: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0055: call ""void System.Console.WriteLine(object)"" IL_005a: ldtoken ""int"" IL_005f: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0064: call ""void System.Console.WriteLine(object)"" IL_0069: ldtoken ""System.IO.FileMode"" IL_006e: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0073: call ""void System.Console.WriteLine(object)"" IL_0078: ldtoken ""System.IFormattable"" IL_007d: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0082: call ""void System.Console.WriteLine(object)"" IL_0087: ldtoken ""System.Math"" IL_008c: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0091: call ""void System.Console.WriteLine(object)"" IL_0096: ldtoken ""void"" IL_009b: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_00a0: call ""void System.Console.WriteLine(object)"" IL_00a5: ret }"); } [Fact] public void TestTypeofGeneric() { var source = @" class Class1<T> { } class Class2<T, U> { } class Program { static void Main() { System.Console.WriteLine(typeof(Class1<int>)); System.Console.WriteLine(typeof(Class1<Class1<int>>)); System.Console.WriteLine(typeof(Class2<int, long>)); System.Console.WriteLine(typeof(Class2<Class1<int>, Class1<long>>)); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Class1`1[System.Int32] Class1`1[Class1`1[System.Int32]] Class2`2[System.Int32,System.Int64] Class2`2[Class1`1[System.Int32],Class1`1[System.Int64]]"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Main", @"{ // Code size 61 (0x3d) .maxstack 1 IL_0000: ldtoken ""Class1<int>"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class1<Class1<int>>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""Class2<int, long>"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""Class2<Class1<int>, Class1<long>>"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ret }"); } [Fact] public void TestTypeofTypeParameter() { var source = @" class Class<T> { public static void Print() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(Class<T>)); } public static void Print<U>() { System.Console.WriteLine(typeof(U)); System.Console.WriteLine(typeof(Class<U>)); } } class Program { static void Main() { Class<int>.Print(); Class<Class<int>>.Print(); Class<int>.Print<long>(); Class<Class<int>>.Print<Class<long>>(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" System.Int32 Class`1[System.Int32] Class`1[System.Int32] Class`1[Class`1[System.Int32]] System.Int64 Class`1[System.Int64] Class`1[System.Int64] Class`1[Class`1[System.Int64]]"); comp.VerifyDiagnostics(); comp.VerifyIL("Class<T>.Print", @"{ // Code size 31 (0x1f) .maxstack 1 IL_0000: ldtoken ""T"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class<T>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ret }"); comp.VerifyIL("Class<T>.Print<U>", @"{ // Code size 31 (0x1f) .maxstack 1 IL_0000: ldtoken ""U"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class<U>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ret }"); } [Fact] public void TestTypeofUnboundGeneric() { var source = @" class Class1<T> { } class Class2<T, U> { } class Program { static void Main() { System.Console.WriteLine(typeof(Class1<>)); System.Console.WriteLine(typeof(Class2<,>)); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Class1`1[T] Class2`2[T,U]"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Main", @"{ // Code size 31 (0x1f) .maxstack 1 IL_0000: ldtoken ""Class1<T>"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Class2<T, U>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ret }"); } [WorkItem(542581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542581")] [Fact] public void TestTypeofInheritedNestedTypeThroughUnboundGeneric_01() { var source = @" using System; class D<T> : C, I1, I2<T, int> { } interface I1 { } interface I2<T, U> { } class F<T> { public class E {} } class G<T> : F<T>, I1, I2<T, int> { } class H<T, U> { public class E {} } class K<T> : H<T, int>{ } class C { public class E { } static void Main() { Console.WriteLine(typeof(D<>.E)); Console.WriteLine(typeof(D<>).BaseType); var interfaces = typeof(D<>).GetInterfaces(); Console.WriteLine(interfaces[0]); Console.WriteLine(interfaces[1]); Console.WriteLine(typeof(G<>.E)); Console.WriteLine(typeof(G<>).BaseType); interfaces = typeof(G<>).GetInterfaces(); Console.WriteLine(interfaces[0]); Console.WriteLine(interfaces[1]); Console.WriteLine(typeof(K<>.E)); Console.WriteLine(typeof(K<>).BaseType); } }"; var expected = @"C+E C I1 I2`2[T,System.Int32] F`1+E[T] F`1[T] I1 I2`2[T,System.Int32] H`2+E[T,U] H`2[T,System.Int32]"; var comp = CompileAndVerify(source, expectedOutput: expected); comp.VerifyDiagnostics(); } [WorkItem(542581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542581")] [WorkItem(9850, "https://github.com/dotnet/roslyn/issues/9850")] [Fact] public void TestTypeofInheritedNestedTypeThroughUnboundGeneric_02() { var source = @" using System; class C { public class E { } public class E<V> { } static void Main() { var t1 = typeof(D<>.E); Console.WriteLine(t1); var t2 = typeof(F<>.E); var t3 = typeof(G<>.E); Console.WriteLine(t2); Console.WriteLine(t3); Console.WriteLine(t2.Equals(t3)); var t4 = typeof(D<>.E<>); Console.WriteLine(t4); var t5 = typeof(F<>.E<>); var t6 = typeof(G<>.E<>); Console.WriteLine(t5); Console.WriteLine(t6); Console.WriteLine(t5.Equals(t6)); } } class C<U> { public class E { } public class E<V> { } } class D<T> : C { } class F<T> : C<T> { } class G<T> : C<int> { } "; var expected = @"C+E C`1+E[U] C`1+E[U] True C+E`1[V] C`1+E`1[U,V] C`1+E`1[U,V] True"; var comp = CompileAndVerify(source, expectedOutput: expected); comp.VerifyDiagnostics(); } [WorkItem(542581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542581")] [Fact] public void TestTypeofInheritedNestedTypeThroughUnboundGeneric_Attribute() { var source = @" using System; [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] class TestAttribute : Attribute { public TestAttribute(System.Type type){} } class D<T> : C, I1, I2<T, int> { } interface I1 { } interface I2<T, U> { } class F<T> { public class E {} } class G<T> : F<T>, I1, I2<T, int> { } class H<T, U> { public class E {} } class K<T> : H<T, int>{ } [TestAttribute(typeof(D<>))] [TestAttribute(typeof(D<>.E))] [TestAttribute(typeof(G<>))] [TestAttribute(typeof(G<>.E))] [TestAttribute(typeof(K<>))] [TestAttribute(typeof(K<>.E))] class C { public class E { } static void Main() { typeof(C).GetCustomAttributes(false); } }"; var comp = CompileAndVerify(source, expectedOutput: ""); } [Fact] public void TestTypeofArray() { var source = @" class Class1<T> { } class Program { static void Print<U>() { System.Console.WriteLine(typeof(int[])); System.Console.WriteLine(typeof(int[,])); System.Console.WriteLine(typeof(int[][])); System.Console.WriteLine(typeof(U[])); System.Console.WriteLine(typeof(Class1<U>[])); System.Console.WriteLine(typeof(Class1<int>[])); } static void Main() { Print<long>(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" System.Int32[] System.Int32[,] System.Int32[][] System.Int64[] Class1`1[System.Int64][] Class1`1[System.Int32][]"); comp.VerifyDiagnostics(); comp.VerifyIL("Program.Print<U>", @"{ // Code size 91 (0x5b) .maxstack 1 IL_0000: ldtoken ""int[]"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""int[,]"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""int[][]"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""U[]"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ldtoken ""Class1<U>[]"" IL_0041: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0046: call ""void System.Console.WriteLine(object)"" IL_004b: ldtoken ""Class1<int>[]"" IL_0050: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0055: call ""void System.Console.WriteLine(object)"" IL_005a: ret }"); } [Fact] public void TestTypeofNested() { var source = @" class Outer<T> { public static void Print() { System.Console.WriteLine(typeof(Inner<>)); System.Console.WriteLine(typeof(Inner<T>)); System.Console.WriteLine(typeof(Inner<int>)); System.Console.WriteLine(typeof(Outer<>.Inner<>)); // System.Console.WriteLine(typeof(Outer<>.Inner<T>)); //CS7003 // System.Console.WriteLine(typeof(Outer<>.Inner<int>)); //CS7003 // System.Console.WriteLine(typeof(Outer<T>.Inner<>)); //CS7003 System.Console.WriteLine(typeof(Outer<T>.Inner<T>)); System.Console.WriteLine(typeof(Outer<T>.Inner<int>)); // System.Console.WriteLine(typeof(Outer<int>.Inner<>)); //CS7003 System.Console.WriteLine(typeof(Outer<int>.Inner<T>)); System.Console.WriteLine(typeof(Outer<int>.Inner<int>)); } class Inner<U> { } } class Program { static void Main() { Outer<long>.Print(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" Outer`1+Inner`1[T,U] Outer`1+Inner`1[System.Int64,System.Int64] Outer`1+Inner`1[System.Int64,System.Int32] Outer`1+Inner`1[T,U] Outer`1+Inner`1[System.Int64,System.Int64] Outer`1+Inner`1[System.Int64,System.Int32] Outer`1+Inner`1[System.Int32,System.Int64] Outer`1+Inner`1[System.Int32,System.Int32]"); comp.VerifyDiagnostics(); comp.VerifyIL("Outer<T>.Print", @"{ // Code size 121 (0x79) .maxstack 1 IL_0000: ldtoken ""Outer<T>.Inner<U>"" IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_000a: call ""void System.Console.WriteLine(object)"" IL_000f: ldtoken ""Outer<T>.Inner<T>"" IL_0014: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0019: call ""void System.Console.WriteLine(object)"" IL_001e: ldtoken ""Outer<T>.Inner<int>"" IL_0023: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0028: call ""void System.Console.WriteLine(object)"" IL_002d: ldtoken ""Outer<T>.Inner<U>"" IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0037: call ""void System.Console.WriteLine(object)"" IL_003c: ldtoken ""Outer<T>.Inner<T>"" IL_0041: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0046: call ""void System.Console.WriteLine(object)"" IL_004b: ldtoken ""Outer<T>.Inner<int>"" IL_0050: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0055: call ""void System.Console.WriteLine(object)"" IL_005a: ldtoken ""Outer<int>.Inner<T>"" IL_005f: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0064: call ""void System.Console.WriteLine(object)"" IL_0069: ldtoken ""Outer<int>.Inner<int>"" IL_006e: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)"" IL_0073: call ""void System.Console.WriteLine(object)"" IL_0078: ret }"); } [Fact] public void TestTypeofInLambda() { var source = @" using System; public class Outer<T> { public class Inner<U> { public Action Method<V>(V v) { return () => { Console.WriteLine(v); Console.WriteLine(typeof(T)); Console.WriteLine(typeof(U)); Console.WriteLine(typeof(V)); Console.WriteLine(typeof(Outer<>)); Console.WriteLine(typeof(Outer<T>)); Console.WriteLine(typeof(Outer<U>)); Console.WriteLine(typeof(Outer<V>)); Console.WriteLine(typeof(Inner<>)); Console.WriteLine(typeof(Inner<T>)); Console.WriteLine(typeof(Inner<U>)); Console.WriteLine(typeof(Inner<V>)); }; } } } class Program { static void Main() { Action a = new Outer<int>.Inner<char>().Method<byte>(1); a(); } }"; var comp = CompileAndVerify(source, expectedOutput: @" 1 System.Int32 System.Char System.Byte Outer`1[T] Outer`1[System.Int32] Outer`1[System.Char] Outer`1[System.Byte] Outer`1+Inner`1[T,U] Outer`1+Inner`1[System.Int32,System.Int32] Outer`1+Inner`1[System.Int32,System.Char] Outer`1+Inner`1[System.Int32,System.Byte]"); comp.VerifyDiagnostics(); } [WorkItem(541600, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541600")] [Fact] public void TestTypeOfAlias4TypeMemberOfGeneric() { var source = @" using System; using MyTestClass = TestClass<string>; public class TestClass<T> { public enum TestEnum { First = 0, } } public class mem178 { public static int Main() { Console.Write(typeof(MyTestClass.TestEnum)); return 0; } } "; CompileAndVerify(source, expectedOutput: @"TestClass`1+TestEnum[System.String]"); } [WorkItem(541618, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541618")] [Fact] public void TestTypeOfAlias5TypeMemberOfGeneric() { var source = @" using OuterOfString = Outer<string>; using OuterOfInt = Outer<int>; public class Outer<T> { public class Inner<U> { } } public class Program { public static void Main() { System.Console.WriteLine(typeof(OuterOfString.Inner<>) == typeof(OuterOfInt.Inner<>)); } } "; // NOTE: this is the Dev10 output. Change to false if we decide to take a breaking change. CompileAndVerify(source, expectedOutput: @"True"); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest/Structure/MetadataAsSource/FieldDeclarationStructureTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Structure; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure.MetadataAsSource { public class FieldDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<FieldDeclarationSyntax> { protected override string WorkspaceKind => CodeAnalysis.WorkspaceKind.MetadataAsSource; internal override AbstractSyntaxStructureProvider CreateProvider() => new FieldDeclarationStructureProvider(); [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task NoCommentsOrAttributes() { const string code = @" class Goo { public int $$goo }"; await VerifyNoBlockSpansAsync(code); } [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task WithAttributes() { const string code = @" class Goo { {|hint:{|textspan:[Goo] |}public int $$goo|} }"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task WithCommentsAndAttributes() { const string code = @" class Goo { {|hint:{|textspan:// Summary: // This is a summary. [Goo] |}int $$goo|} }"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task WithCommentsAttributesAndModifiers() { const string code = @" class Goo { {|hint:{|textspan:// Summary: // This is a summary. [Goo] |}public int $$goo|} }"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true)); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Structure; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure.MetadataAsSource { public class FieldDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<FieldDeclarationSyntax> { protected override string WorkspaceKind => CodeAnalysis.WorkspaceKind.MetadataAsSource; internal override AbstractSyntaxStructureProvider CreateProvider() => new FieldDeclarationStructureProvider(); [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task NoCommentsOrAttributes() { const string code = @" class Goo { public int $$goo }"; await VerifyNoBlockSpansAsync(code); } [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task WithAttributes() { const string code = @" class Goo { {|hint:{|textspan:[Goo] |}public int $$goo|} }"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task WithCommentsAndAttributes() { const string code = @" class Goo { {|hint:{|textspan:// Summary: // This is a summary. [Goo] |}int $$goo|} }"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true)); } [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] public async Task WithCommentsAttributesAndModifiers() { const string code = @" class Goo { {|hint:{|textspan:// Summary: // This is a summary. [Goo] |}public int $$goo|} }"; await VerifyBlockSpansAsync(code, Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true)); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Test/Symbol/Symbols/MockNamedTypeSymbol.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.UnitTests { internal class MockNamedTypeSymbol : NamedTypeSymbol, IMockSymbol { private Symbol _container; private readonly string _name; private readonly TypeKind _typeKind; private readonly IEnumerable<Symbol> _children; public void SetContainer(Symbol container) { _container = container; } protected override NamedTypeSymbol WithTupleDataCore(TupleExtraData newData) => throw new NotImplementedException(); public override int Arity { get { return 0; } } internal override bool MangleName { get { return Arity > 0; } } public override ImmutableArray<TypeParameterSymbol> TypeParameters { get { return ImmutableArray.Create<TypeParameterSymbol>(); } } internal override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotationsNoUseSiteDiagnostics { get { return ImmutableArray.Create<TypeWithAnnotations>(); } } public override NamedTypeSymbol ConstructedFrom { get { return this; } } public override string Name { get { return _name; } } internal override bool HasSpecialName { get { throw new NotImplementedException(); } } public override IEnumerable<string> MemberNames { get { throw new NotImplementedException(); } } public override ImmutableArray<Symbol> GetMembers() { return _children.AsImmutable(); } internal override IEnumerable<FieldSymbol> GetFieldsToEmit() { throw new NotImplementedException(); } public override ImmutableArray<Symbol> GetMembers(string name) { return (from sym in _children where sym.Name == name select sym).ToArray().AsImmutableOrNull(); } internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers() { return this.GetMembers(); } internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name) { return this.GetMembers(name); } public override ImmutableArray<NamedTypeSymbol> GetTypeMembers() { return (from sym in _children where sym is NamedTypeSymbol select (NamedTypeSymbol)sym).ToArray().AsImmutableOrNull(); } public override ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int arity) { return (from sym in _children where sym is NamedTypeSymbol && sym.Name == name && ((NamedTypeSymbol)sym).Arity == arity select (NamedTypeSymbol)sym).ToArray().AsImmutableOrNull(); } public override ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name) { return (from sym in _children where sym is NamedTypeSymbol && sym.Name == name select (NamedTypeSymbol)sym).ToArray().AsImmutableOrNull(); } public override TypeKind TypeKind { get { return _typeKind; } } internal override bool IsInterface { get { return _typeKind == TypeKind.Interface; } } public override Symbol ContainingSymbol { get { return null; } } public override ImmutableArray<Location> Locations { get { return ImmutableArray.Create<Location>(); } } public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences { get { return ImmutableArray.Create<SyntaxReference>(); } } public MockNamedTypeSymbol(string name, IEnumerable<Symbol> children, TypeKind kind = TypeKind.Class) { _name = name; _children = children; _typeKind = kind; } public override Accessibility DeclaredAccessibility { get { return Accessibility.Public; } } public override bool IsStatic { get { return false; } } public sealed override bool IsRefLikeType { get { return false; } } public sealed override bool IsReadOnly { get { return false; } } public override bool IsAbstract { get { return false; } } public override bool IsSealed { get { return false; } } public sealed override bool AreLocalsZeroed { get { throw ExceptionUtilities.Unreachable; } } public override bool MightContainExtensionMethods { get { throw new NotImplementedException(); } } internal override NamedTypeSymbol BaseTypeNoUseSiteDiagnostics => throw new NotImplementedException(); internal override ImmutableArray<NamedTypeSymbol> InterfacesNoUseSiteDiagnostics(ConsList<TypeSymbol> basesBeingResolved) { throw new NotImplementedException(); } internal override ImmutableArray<NamedTypeSymbol> GetInterfacesToEmit() { throw new NotImplementedException(); } internal override NamedTypeSymbol GetDeclaredBaseType(ConsList<TypeSymbol> basesBeingResolved) { throw new NotImplementedException(); } internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList<TypeSymbol> basesBeingResolved) { throw new NotImplementedException(); } internal override bool HasCodeAnalysisEmbeddedAttribute => false; internal sealed override ManagedKind GetManagedKind(ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo) => ManagedKind.Managed; internal override bool ShouldAddWinRTMembers { get { return false; } } internal override bool IsWindowsRuntimeImport { get { return false; } } internal override bool IsComImport { get { return false; } } internal sealed override ObsoleteAttributeData ObsoleteAttributeData { get { return null; } } internal override TypeLayout Layout { get { return default(TypeLayout); } } internal override System.Runtime.InteropServices.CharSet MarshallingCharSet { get { return DefaultMarshallingCharSet; } } public override bool IsSerializable { get { return false; } } internal override bool HasDeclarativeSecurity { get { return false; } } internal override IEnumerable<Microsoft.Cci.SecurityAttribute> GetSecurityInformation() { return null; } internal override ImmutableArray<string> GetAppliedConditionalSymbols() { return ImmutableArray<string>.Empty; } internal override AttributeUsageInfo GetAttributeUsageInfo() { return AttributeUsageInfo.Null; } internal sealed override NamedTypeSymbol AsNativeInteger() => throw ExceptionUtilities.Unreachable; internal sealed override NamedTypeSymbol NativeIntegerUnderlyingType => null; internal override bool IsRecord => false; internal override bool IsRecordStruct => false; internal override bool HasPossibleWellKnownCloneMethod() => false; internal override bool IsInterpolatedStringHandlerType => false; internal sealed override IEnumerable<(MethodSymbol Body, MethodSymbol Implemented)> SynthesizedInterfaceMethodImpls() { return SpecializedCollections.EmptyEnumerable<(MethodSymbol Body, MethodSymbol Implemented)>(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.UnitTests { internal class MockNamedTypeSymbol : NamedTypeSymbol, IMockSymbol { private Symbol _container; private readonly string _name; private readonly TypeKind _typeKind; private readonly IEnumerable<Symbol> _children; public void SetContainer(Symbol container) { _container = container; } protected override NamedTypeSymbol WithTupleDataCore(TupleExtraData newData) => throw new NotImplementedException(); public override int Arity { get { return 0; } } internal override bool MangleName { get { return Arity > 0; } } public override ImmutableArray<TypeParameterSymbol> TypeParameters { get { return ImmutableArray.Create<TypeParameterSymbol>(); } } internal override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotationsNoUseSiteDiagnostics { get { return ImmutableArray.Create<TypeWithAnnotations>(); } } public override NamedTypeSymbol ConstructedFrom { get { return this; } } public override string Name { get { return _name; } } internal override bool HasSpecialName { get { throw new NotImplementedException(); } } public override IEnumerable<string> MemberNames { get { throw new NotImplementedException(); } } public override ImmutableArray<Symbol> GetMembers() { return _children.AsImmutable(); } internal override IEnumerable<FieldSymbol> GetFieldsToEmit() { throw new NotImplementedException(); } public override ImmutableArray<Symbol> GetMembers(string name) { return (from sym in _children where sym.Name == name select sym).ToArray().AsImmutableOrNull(); } internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers() { return this.GetMembers(); } internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name) { return this.GetMembers(name); } public override ImmutableArray<NamedTypeSymbol> GetTypeMembers() { return (from sym in _children where sym is NamedTypeSymbol select (NamedTypeSymbol)sym).ToArray().AsImmutableOrNull(); } public override ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int arity) { return (from sym in _children where sym is NamedTypeSymbol && sym.Name == name && ((NamedTypeSymbol)sym).Arity == arity select (NamedTypeSymbol)sym).ToArray().AsImmutableOrNull(); } public override ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name) { return (from sym in _children where sym is NamedTypeSymbol && sym.Name == name select (NamedTypeSymbol)sym).ToArray().AsImmutableOrNull(); } public override TypeKind TypeKind { get { return _typeKind; } } internal override bool IsInterface { get { return _typeKind == TypeKind.Interface; } } public override Symbol ContainingSymbol { get { return null; } } public override ImmutableArray<Location> Locations { get { return ImmutableArray.Create<Location>(); } } public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences { get { return ImmutableArray.Create<SyntaxReference>(); } } public MockNamedTypeSymbol(string name, IEnumerable<Symbol> children, TypeKind kind = TypeKind.Class) { _name = name; _children = children; _typeKind = kind; } public override Accessibility DeclaredAccessibility { get { return Accessibility.Public; } } public override bool IsStatic { get { return false; } } public sealed override bool IsRefLikeType { get { return false; } } public sealed override bool IsReadOnly { get { return false; } } public override bool IsAbstract { get { return false; } } public override bool IsSealed { get { return false; } } public sealed override bool AreLocalsZeroed { get { throw ExceptionUtilities.Unreachable; } } public override bool MightContainExtensionMethods { get { throw new NotImplementedException(); } } internal override NamedTypeSymbol BaseTypeNoUseSiteDiagnostics => throw new NotImplementedException(); internal override ImmutableArray<NamedTypeSymbol> InterfacesNoUseSiteDiagnostics(ConsList<TypeSymbol> basesBeingResolved) { throw new NotImplementedException(); } internal override ImmutableArray<NamedTypeSymbol> GetInterfacesToEmit() { throw new NotImplementedException(); } internal override NamedTypeSymbol GetDeclaredBaseType(ConsList<TypeSymbol> basesBeingResolved) { throw new NotImplementedException(); } internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList<TypeSymbol> basesBeingResolved) { throw new NotImplementedException(); } internal override bool HasCodeAnalysisEmbeddedAttribute => false; internal sealed override ManagedKind GetManagedKind(ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo) => ManagedKind.Managed; internal override bool ShouldAddWinRTMembers { get { return false; } } internal override bool IsWindowsRuntimeImport { get { return false; } } internal override bool IsComImport { get { return false; } } internal sealed override ObsoleteAttributeData ObsoleteAttributeData { get { return null; } } internal override TypeLayout Layout { get { return default(TypeLayout); } } internal override System.Runtime.InteropServices.CharSet MarshallingCharSet { get { return DefaultMarshallingCharSet; } } public override bool IsSerializable { get { return false; } } internal override bool HasDeclarativeSecurity { get { return false; } } internal override IEnumerable<Microsoft.Cci.SecurityAttribute> GetSecurityInformation() { return null; } internal override ImmutableArray<string> GetAppliedConditionalSymbols() { return ImmutableArray<string>.Empty; } internal override AttributeUsageInfo GetAttributeUsageInfo() { return AttributeUsageInfo.Null; } internal sealed override NamedTypeSymbol AsNativeInteger() => throw ExceptionUtilities.Unreachable; internal sealed override NamedTypeSymbol NativeIntegerUnderlyingType => null; internal override bool IsRecord => false; internal override bool IsRecordStruct => false; internal override bool HasPossibleWellKnownCloneMethod() => false; internal override bool IsInterpolatedStringHandlerType => false; internal sealed override IEnumerable<(MethodSymbol Body, MethodSymbol Implemented)> SynthesizedInterfaceMethodImpls() { return SpecializedCollections.EmptyEnumerable<(MethodSymbol Body, MethodSymbol Implemented)>(); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest/ExtractClass/ExtractClassTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.CodeRefactorings.ExtractClass; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; using Microsoft.CodeAnalysis.ExtractClass; using Microsoft.CodeAnalysis.PullMemberUp; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ExtractClass { public class ExtractClassTests : AbstractCSharpCodeActionTest { private Task TestExtractClassAsync( string input, string? expected = null, IEnumerable<(string name, bool makeAbstract)>? dialogSelection = null, bool sameFile = false, bool isClassDeclarationSelection = false, TestParameters testParameters = default) { var service = new TestExtractClassOptionsService(dialogSelection, sameFile, isClassDeclarationSelection); var parametersWithOptionsService = testParameters.WithFixProviderData(service); if (expected is null) { return TestMissingAsync(input, parametersWithOptionsService); } return TestInRegularAndScript1Async( input, expected, parameters: parametersWithOptionsService); } protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace, TestParameters parameters) => new CSharpExtractClassCodeRefactoringProvider((IExtractClassOptionsService)parameters.fixProviderData); [Fact] public async Task TestSingleMethod() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestErrorBaseMethod() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : ErrorBase { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; await TestExtractClassAsync(input); } [Fact] public async Task TestMiscellaneousFiles() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; TestParameters parameters = default; await TestExtractClassAsync(input, testParameters: parameters.WithWorkspaceKind(WorkspaceKind.MiscellaneousFiles)); } [Fact] public async Task TestPartialClass() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> partial class Test { int [||]Method() { return 1 + 1; } } </Document> <Document FilePath=""Test.Other.cs""> partial class Test { int Method2() { return 5; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> partial class Test : MyBase { } </Document> <Document FilePath=""Test.Other.cs""> partial class Test { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } int Method2() { return 5; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method", "Method2")); } [Fact] public async Task TestInNamespace() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace { internal class MyBase { int Method() { return 1 + 1; } } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestInNamespace_FileScopedNamespace1() { var input = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace; internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestAsync( input, expected, CSharpParseOptions.Default, options: Option(CSharpCodeStyleOptions.NamespaceDeclarations, NamespaceDeclarationPreference.FileScoped, NotificationOption2.Silent), fixProviderData: new TestExtractClassOptionsService()); } [Fact] public async Task TestInNamespace_FileScopedNamespace2() { var input = @" <Workspace> <Project Language=""C#"" LanguageVersion=""9""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#"" LanguageVersion=""9""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace { internal class MyBase { int Method() { return 1 + 1; } } }</Document> </Project> </Workspace>"; await TestAsync( input, expected, CSharpParseOptions.Default, options: Option(CSharpCodeStyleOptions.NamespaceDeclarations, NamespaceDeclarationPreference.FileScoped, NotificationOption2.Silent), fixProviderData: new TestExtractClassOptionsService()); } [Fact] public async Task TestInNamespace_FileScopedNamespace3() { var input = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace { internal class MyBase { int Method() { return 1 + 1; } } }</Document> </Project> </Workspace>"; await TestAsync( input, expected, CSharpParseOptions.Default, options: Option(CSharpCodeStyleOptions.NamespaceDeclarations, NamespaceDeclarationPreference.BlockScoped, NotificationOption2.Silent), fixProviderData: new TestExtractClassOptionsService()); } [Fact] public async Task TestAccessibility() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> public class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> public class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">public class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestEvent() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class Test { private event EventHandler [||]Event1; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { private event EventHandler Event1; }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestProperty() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]MyProperty { get; set; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int MyProperty { get; set; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestField() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]MyField; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int MyField; }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestFileHeader() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs"">// this is my document header // that should be copied over class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs"">// this is my document header // that should be copied over class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">// this is my document header // that should be copied over internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestWithInterface() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> interface ITest { int Method(); } class Test : ITest { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> interface ITest { int Method(); } class Test : MyBase, ITest { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [ConditionalFact(AlwaysSkip = "https://github.com/dotnet/roslyn/issues/45977")] public async Task TestRegion() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { #region MyRegion int [||]Method() { return 1 + 1; } void OtherMethiod() { } #endregion } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { #region MyRegion void OtherMethiod() { } #endregion } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { #region MyRegion int Method() { return 1 + 1; } #endregion }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method")); } [Fact] public async Task TestMakeAbstract_SingleMethod() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { override int Method() { return 1 + 1; } } </Document> <Document FilePath=""MyBase.cs"">internal abstract class MyBase { private abstract global::System.Int32 Method(); }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeAbstractSelection("Method")); } [Fact] public async Task TestMakeAbstract_MultipleMethods() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } int Method2() => 2; int Method3() => 3; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { override int Method() { return 1 + 1; } override int Method2() => 2; override int Method3() => 3; } </Document> <Document FilePath=""MyBase.cs"">internal abstract class MyBase { private abstract global::System.Int32 Method(); private abstract global::System.Int32 Method2(); private abstract global::System.Int32 Method3(); }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeAbstractSelection("Method", "Method2", "Method3")); } [Fact] public async Task TestMultipleMethods() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return Method2() + 1; } int Method2() => 1; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return Method2() + 1; } int Method2() => 1; }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method", "Method2")); } [Fact] public async Task TestMultipleMethods_SomeSelected() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return Method2() + 1; } int Method2() => 1; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { int Method() { return Method2() + 1; } } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method2() => 1; }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method2")); } [Fact] public async Task TestSelection_CompleteMethodAndComments() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { [|/// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; }|] } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSelection_PartialMethodAndComments() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { [|/// <summary> /// this is a test method /// </summary> int Method() {|] return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSelection_PartialMethodAndComments2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { /// <summary> /// [|this is a test method /// </summary> int Method() {|] return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSelection_PartialMethodAndComments3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { /// <summary> /// [|this is a test method /// </summary> int Method()|] { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestAttributes() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [||][TestAttribute] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestAttributes2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [||][TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [ConditionalFact(AlwaysSkip = "https://github.com/dotnet/roslyn/issues/45987")] public async Task TestAttributes3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [TestAttribute] [||][TestAttribute2] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [ConditionalFact(AlwaysSkip = "https://github.com/dotnet/roslyn/issues/45987")] public async Task TestAttributes4() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2][||] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSameFile() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { void Method[||]() { } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> internal class MyBase { void Method() { } } class Test : MyBase { } </Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, sameFile: true); } [Fact] public async Task TestClassDeclaration() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test[||] { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class [||]Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> [||]class Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration4() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class[||] Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Comment() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// [|This is a test class /// </summary> class Test|] { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// </summary> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Comment2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// [|</summary> class Test|] { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// </summary> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Comment3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a [|test class /// </summary> class|] Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// </summary> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Attribute() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; public class MyAttribute : Attribute { } [||][MyAttribute] class Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; public class MyAttribute : Attribute { } [MyAttribute] class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">[MyAttribute] internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_SelectWithMembers() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> [|class Test { int Method() { return 1 + 1; } }|] </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_SelectWithMembers2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> [|class Test { int Method() { return 1 + 1; }|] } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } private static IEnumerable<(string name, bool makeAbstract)> MakeAbstractSelection(params string[] memberNames) => memberNames.Select(m => (m, true)); private static IEnumerable<(string name, bool makeAbstract)> MakeSelection(params string[] memberNames) => memberNames.Select(m => (m, false)); private class TestExtractClassOptionsService : IExtractClassOptionsService { private readonly IEnumerable<(string name, bool makeAbstract)>? _dialogSelection; private readonly bool _sameFile; private readonly bool isClassDeclarationSelection; public TestExtractClassOptionsService(IEnumerable<(string name, bool makeAbstract)>? dialogSelection = null, bool sameFile = false, bool isClassDeclarationSelection = false) { _dialogSelection = dialogSelection; _sameFile = sameFile; this.isClassDeclarationSelection = isClassDeclarationSelection; } public string FileName { get; set; } = "MyBase.cs"; public string BaseName { get; set; } = "MyBase"; public Task<ExtractClassOptions?> GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalSymbol, ISymbol? selectedMember) { var availableMembers = originalSymbol.GetMembers().Where(member => MemberAndDestinationValidator.IsMemberValid(member)); IEnumerable<(ISymbol member, bool makeAbstract)> selections; if (_dialogSelection == null) { if (selectedMember is null) { Assert.True(isClassDeclarationSelection); selections = availableMembers.Select(member => (member, makeAbstract: false)); } else { Assert.False(isClassDeclarationSelection); selections = new[] { (selectedMember, false) }; } } else { selections = _dialogSelection.Select(selection => (member: availableMembers.Single(symbol => symbol.Name == selection.name), selection.makeAbstract)); } var memberAnalysis = selections.Select(s => new ExtractClassMemberAnalysisResult( s.member, s.makeAbstract)) .ToImmutableArray(); return Task.FromResult<ExtractClassOptions?>(new ExtractClassOptions(FileName, BaseName, _sameFile, memberAnalysis)); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.CodeRefactorings.ExtractClass; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; using Microsoft.CodeAnalysis.ExtractClass; using Microsoft.CodeAnalysis.PullMemberUp; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ExtractClass { public class ExtractClassTests : AbstractCSharpCodeActionTest { private Task TestExtractClassAsync( string input, string? expected = null, IEnumerable<(string name, bool makeAbstract)>? dialogSelection = null, bool sameFile = false, bool isClassDeclarationSelection = false, TestParameters testParameters = default) { var service = new TestExtractClassOptionsService(dialogSelection, sameFile, isClassDeclarationSelection); var parametersWithOptionsService = testParameters.WithFixProviderData(service); if (expected is null) { return TestMissingAsync(input, parametersWithOptionsService); } return TestInRegularAndScript1Async( input, expected, parameters: parametersWithOptionsService); } protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace, TestParameters parameters) => new CSharpExtractClassCodeRefactoringProvider((IExtractClassOptionsService)parameters.fixProviderData); [Fact] public async Task TestSingleMethod() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestErrorBaseMethod() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : ErrorBase { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; await TestExtractClassAsync(input); } [Fact] public async Task TestMiscellaneousFiles() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; TestParameters parameters = default; await TestExtractClassAsync(input, testParameters: parameters.WithWorkspaceKind(WorkspaceKind.MiscellaneousFiles)); } [Fact] public async Task TestPartialClass() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> partial class Test { int [||]Method() { return 1 + 1; } } </Document> <Document FilePath=""Test.Other.cs""> partial class Test { int Method2() { return 5; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> partial class Test : MyBase { } </Document> <Document FilePath=""Test.Other.cs""> partial class Test { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } int Method2() { return 5; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method", "Method2")); } [Fact] public async Task TestInNamespace() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace { internal class MyBase { int Method() { return 1 + 1; } } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestInNamespace_FileScopedNamespace1() { var input = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace; internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestAsync( input, expected, CSharpParseOptions.Default, options: Option(CSharpCodeStyleOptions.NamespaceDeclarations, NamespaceDeclarationPreference.FileScoped, NotificationOption2.Silent), fixProviderData: new TestExtractClassOptionsService()); } [Fact] public async Task TestInNamespace_FileScopedNamespace2() { var input = @" <Workspace> <Project Language=""C#"" LanguageVersion=""9""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#"" LanguageVersion=""9""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace { internal class MyBase { int Method() { return 1 + 1; } } }</Document> </Project> </Workspace>"; await TestAsync( input, expected, CSharpParseOptions.Default, options: Option(CSharpCodeStyleOptions.NamespaceDeclarations, NamespaceDeclarationPreference.FileScoped, NotificationOption2.Silent), fixProviderData: new TestExtractClassOptionsService()); } [Fact] public async Task TestInNamespace_FileScopedNamespace3() { var input = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test { int [||]Method() { return 1 + 1; } } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#"" LanguageVersion=""10""> <Document FilePath=""Test.cs""> namespace MyNamespace { class Test : MyBase { } } </Document> <Document FilePath=""MyBase.cs"">namespace MyNamespace { internal class MyBase { int Method() { return 1 + 1; } } }</Document> </Project> </Workspace>"; await TestAsync( input, expected, CSharpParseOptions.Default, options: Option(CSharpCodeStyleOptions.NamespaceDeclarations, NamespaceDeclarationPreference.BlockScoped, NotificationOption2.Silent), fixProviderData: new TestExtractClassOptionsService()); } [Fact] public async Task TestAccessibility() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> public class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> public class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">public class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestEvent() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class Test { private event EventHandler [||]Event1; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { private event EventHandler Event1; }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestProperty() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]MyProperty { get; set; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int MyProperty { get; set; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestField() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]MyField; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int MyField; }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestFileHeader() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs"">// this is my document header // that should be copied over class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs"">// this is my document header // that should be copied over class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">// this is my document header // that should be copied over internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestWithInterface() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> interface ITest { int Method(); } class Test : ITest { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> interface ITest { int Method(); } class Test : MyBase, ITest { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [ConditionalFact(AlwaysSkip = "https://github.com/dotnet/roslyn/issues/45977")] public async Task TestRegion() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { #region MyRegion int [||]Method() { return 1 + 1; } void OtherMethiod() { } #endregion } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { #region MyRegion void OtherMethiod() { } #endregion } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { #region MyRegion int Method() { return 1 + 1; } #endregion }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method")); } [Fact] public async Task TestMakeAbstract_SingleMethod() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { override int Method() { return 1 + 1; } } </Document> <Document FilePath=""MyBase.cs"">internal abstract class MyBase { private abstract global::System.Int32 Method(); }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeAbstractSelection("Method")); } [Fact] public async Task TestMakeAbstract_MultipleMethods() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return 1 + 1; } int Method2() => 2; int Method3() => 3; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { override int Method() { return 1 + 1; } override int Method2() => 2; override int Method3() => 3; } </Document> <Document FilePath=""MyBase.cs"">internal abstract class MyBase { private abstract global::System.Int32 Method(); private abstract global::System.Int32 Method2(); private abstract global::System.Int32 Method3(); }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeAbstractSelection("Method", "Method2", "Method3")); } [Fact] public async Task TestMultipleMethods() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return Method2() + 1; } int Method2() => 1; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return Method2() + 1; } int Method2() => 1; }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method", "Method2")); } [Fact] public async Task TestMultipleMethods_SomeSelected() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { int [||]Method() { return Method2() + 1; } int Method2() => 1; } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { int Method() { return Method2() + 1; } } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method2() => 1; }</Document> </Project> </Workspace>"; await TestExtractClassAsync( input, expected, dialogSelection: MakeSelection("Method2")); } [Fact] public async Task TestSelection_CompleteMethodAndComments() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { [|/// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; }|] } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSelection_PartialMethodAndComments() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { [|/// <summary> /// this is a test method /// </summary> int Method() {|] return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSelection_PartialMethodAndComments2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { /// <summary> /// [|this is a test method /// </summary> int Method() {|] return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSelection_PartialMethodAndComments3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { /// <summary> /// [|this is a test method /// </summary> int Method()|] { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestAttributes() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [||][TestAttribute] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestAttributes2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [||][TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [ConditionalFact(AlwaysSkip = "https://github.com/dotnet/roslyn/issues/45987")] public async Task TestAttributes3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [TestAttribute] [||][TestAttribute2] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [ConditionalFact(AlwaysSkip = "https://github.com/dotnet/roslyn/issues/45987")] public async Task TestAttributes4() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class TestAttribute2 : Attribute { } class Test { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2][||] int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; class TestAttribute : Attribute { } class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { /// <summary> /// this is a test method /// </summary> [TestAttribute] [TestAttribute2] int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected); } [Fact] public async Task TestSameFile() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test { void Method[||]() { } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> internal class MyBase { void Method() { } } class Test : MyBase { } </Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, sameFile: true); } [Fact] public async Task TestClassDeclaration() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test[||] { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class [||]Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> [||]class Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration4() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class[||] Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Comment() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// [|This is a test class /// </summary> class Test|] { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// </summary> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Comment2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// [|</summary> class Test|] { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// </summary> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Comment3() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a [|test class /// </summary> class|] Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; /// <summary> /// This is a test class /// </summary> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_Attribute() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; public class MyAttribute : Attribute { } [||][MyAttribute] class Test { int Method() { return 1 + 1; } } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> using System; public class MyAttribute : Attribute { } [MyAttribute] class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">[MyAttribute] internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_SelectWithMembers() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> [|class Test { int Method() { return 1 + 1; } }|] </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } [Fact] public async Task TestClassDeclaration_SelectWithMembers2() { var input = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> [|class Test { int Method() { return 1 + 1; }|] } </Document> </Project> </Workspace>"; var expected = @" <Workspace> <Project Language=""C#""> <Document FilePath=""Test.cs""> class Test : MyBase { } </Document> <Document FilePath=""MyBase.cs"">internal class MyBase { int Method() { return 1 + 1; } }</Document> </Project> </Workspace>"; await TestExtractClassAsync(input, expected, isClassDeclarationSelection: true); } private static IEnumerable<(string name, bool makeAbstract)> MakeAbstractSelection(params string[] memberNames) => memberNames.Select(m => (m, true)); private static IEnumerable<(string name, bool makeAbstract)> MakeSelection(params string[] memberNames) => memberNames.Select(m => (m, false)); private class TestExtractClassOptionsService : IExtractClassOptionsService { private readonly IEnumerable<(string name, bool makeAbstract)>? _dialogSelection; private readonly bool _sameFile; private readonly bool isClassDeclarationSelection; public TestExtractClassOptionsService(IEnumerable<(string name, bool makeAbstract)>? dialogSelection = null, bool sameFile = false, bool isClassDeclarationSelection = false) { _dialogSelection = dialogSelection; _sameFile = sameFile; this.isClassDeclarationSelection = isClassDeclarationSelection; } public string FileName { get; set; } = "MyBase.cs"; public string BaseName { get; set; } = "MyBase"; public Task<ExtractClassOptions?> GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalSymbol, ISymbol? selectedMember) { var availableMembers = originalSymbol.GetMembers().Where(member => MemberAndDestinationValidator.IsMemberValid(member)); IEnumerable<(ISymbol member, bool makeAbstract)> selections; if (_dialogSelection == null) { if (selectedMember is null) { Assert.True(isClassDeclarationSelection); selections = availableMembers.Select(member => (member, makeAbstract: false)); } else { Assert.False(isClassDeclarationSelection); selections = new[] { (selectedMember, false) }; } } else { selections = _dialogSelection.Select(selection => (member: availableMembers.Single(symbol => symbol.Name == selection.name), selection.makeAbstract)); } var memberAnalysis = selections.Select(s => new ExtractClassMemberAnalysisResult( s.member, s.makeAbstract)) .ToImmutableArray(); return Task.FromResult<ExtractClassOptions?>(new ExtractClassOptions(FileName, BaseName, _sameFile, memberAnalysis)); } } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Workspaces/Core/Portable/Classification/SyntaxClassification/ISyntaxClassificationService.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification.Classifiers; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Classification { internal interface ISyntaxClassificationService : ILanguageService { ImmutableArray<ISyntaxClassifier> GetDefaultSyntaxClassifiers(); /// <inheritdoc cref="IClassificationService.AddLexicalClassifications"/> void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="IClassificationService.AddSyntacticClassificationsAsync"/> void AddSyntacticClassifications( SyntaxNode root, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="IClassificationService.AddSemanticClassificationsAsync"/> Task AddSemanticClassificationsAsync(Document document, TextSpan textSpan, Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>> getNodeClassifiers, Func<SyntaxToken, ImmutableArray<ISyntaxClassifier>> getTokenClassifiers, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="AddSemanticClassificationsAsync"/> void AddSemanticClassifications( SemanticModel semanticModel, TextSpan textSpan, Workspace workspace, Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>> getNodeClassifiers, Func<SyntaxToken, ImmutableArray<ISyntaxClassifier>> getTokenClassifiers, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="IClassificationService.AdjustStaleClassification"/> ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan); /// <inheritdoc cref="IClassificationService.ComputeSyntacticChangeRangeAsync"/> TextChangeRange? ComputeSyntacticChangeRange( SyntaxNode oldRoot, SyntaxNode newRoot, TimeSpan timeout, CancellationToken cancellationToken); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification.Classifiers; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Classification { internal interface ISyntaxClassificationService : ILanguageService { ImmutableArray<ISyntaxClassifier> GetDefaultSyntaxClassifiers(); /// <inheritdoc cref="IClassificationService.AddLexicalClassifications"/> void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="IClassificationService.AddSyntacticClassificationsAsync"/> void AddSyntacticClassifications( SyntaxNode root, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="IClassificationService.AddSemanticClassificationsAsync"/> Task AddSemanticClassificationsAsync(Document document, TextSpan textSpan, Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>> getNodeClassifiers, Func<SyntaxToken, ImmutableArray<ISyntaxClassifier>> getTokenClassifiers, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="AddSemanticClassificationsAsync"/> void AddSemanticClassifications( SemanticModel semanticModel, TextSpan textSpan, Workspace workspace, Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>> getNodeClassifiers, Func<SyntaxToken, ImmutableArray<ISyntaxClassifier>> getTokenClassifiers, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); /// <inheritdoc cref="IClassificationService.AdjustStaleClassification"/> ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan); /// <inheritdoc cref="IClassificationService.ComputeSyntacticChangeRangeAsync"/> TextChangeRange? ComputeSyntacticChangeRange( SyntaxNode oldRoot, SyntaxNode newRoot, TimeSpan timeout, CancellationToken cancellationToken); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Scripting/CSharpTest.Desktop/InteractiveSessionReferencesTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable extern alias PortableTestUtils; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Scripting; using Microsoft.CodeAnalysis.Scripting.Hosting; using Microsoft.CodeAnalysis.Scripting.Test; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; using AssertEx = PortableTestUtils::Roslyn.Test.Utilities.AssertEx; using TestBase = PortableTestUtils::Roslyn.Test.Utilities.TestBase; using WorkItemAttribute = PortableTestUtils::Roslyn.Test.Utilities.WorkItemAttribute; using static Microsoft.CodeAnalysis.Scripting.TestCompilationFactory; using static Roslyn.Test.Utilities.TestMetadata; namespace Microsoft.CodeAnalysis.CSharp.Scripting.Test { public class InteractiveSessionReferencesTests : TestBase { private static readonly CSharpCompilationOptions s_signedDll = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_ce65828c82a341f2); private static readonly CSharpCompilationOptions s_signedDll2 = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_ce65828c82a341f2); [Fact] public async Task CompilationChain_GlobalImportsRebinding() { var options = ScriptOptions.Default.AddImports("System.Diagnostics"); var s0 = await CSharpScript.RunAsync("", options); ScriptingTestHelpers.AssertCompilationError(s0, @"Process.GetCurrentProcess()", // (2,1): error CS0103: The name 'Process' does not exist in the current context Diagnostic(ErrorCode.ERR_NameNotInContext, "Process").WithArguments("Process")); var s1 = s0.ContinueWithAsync($"#r \"{typeof(Process).Assembly.Location}\""); var s2 = s1.ContinueWith("Process.GetCurrentProcess()"); Assert.NotNull(s2.Result); } [Fact] public async Task CompilationChain_UsingRebinding_AddReference() { var s0 = await CSharpScript.RunAsync("using System.Diagnostics;"); var newOptions = s0.Script.Options.AddReferences(typeof(Process).Assembly); var s1 = s0.ContinueWithAsync(@"Process.GetCurrentProcess()", newOptions); Assert.NotNull(s1.Result); } [Fact] public async Task CompilationChain_UsingRebinding_Directive() { var s0 = await CSharpScript.RunAsync("using System.Diagnostics;"); var s1 = s0.ContinueWithAsync($@" #r ""{typeof(Process).Assembly.Location}"" Process.GetCurrentProcess()"); Assert.NotNull(s1.Result); } // // General rule for symbol lookup: // // Declaration A in submission S hides declaration B in submission T iff // S precedes T, and A and B can't coexist in the same scope. [Fact] public void CompilationChain_SubmissionSlots() { var s = CSharpScript.RunAsync("using System;"). ContinueWith("using static System.Environment;"). ContinueWith("int x; x = 1;"). ContinueWith("using static System.Math;"). ContinueWith("int goo(int a) { return a + 1; } "); #if false Assert.True(session.executionState.submissions.Length >= 2, "Expected two submissions"); session.executionState.submissions.Aggregate(0, (i, sub) => { Assert.Equal(i < 2, sub != null); return i + 1; }); #endif ScriptingTestHelpers.AssertCompilationError(s, "Version", // (1,1): error CS0229: Ambiguity between 'System.Version' and 'System.Environment.Version' Diagnostic(ErrorCode.ERR_AmbigMember, "Version").WithArguments("System.Version", "System.Environment.Version")); s = s.ContinueWith("new System.Collections.Generic.List<Version>()"); Assert.IsType<List<Version>>(s.Result.ReturnValue); s = s.ContinueWith("Environment.Version"); Assert.Equal(Environment.Version, s.Result.ReturnValue); s = s.ContinueWith("goo(x)"); Assert.Equal(2, s.Result.ReturnValue); s = s.ContinueWith("Sin(0)"); Assert.Equal(0.0, s.Result.ReturnValue); } [Fact] public void SearchPaths1() { var options = ScriptOptions.Default.WithMetadataResolver(ScriptMetadataResolver.Default.WithSearchPaths(RuntimeEnvironment.GetRuntimeDirectory())); var result = CSharpScript.EvaluateAsync($@" #r ""System.Data.dll"" #r ""System"" #r ""{typeof(System.Xml.Serialization.IXmlSerializable).GetTypeInfo().Assembly.Location}"" new System.Data.DataSet() ", options).Result; Assert.True(result is System.Data.DataSet, "Expected DataSet"); } /// <summary> /// Default search paths can be removed. /// </summary> [Fact] public void SearchPaths_RemoveDefault() { // remove default paths: var options = ScriptOptions.Default; var source = @" #r ""System.Data.dll"" new System.Data.DataSet() "; ScriptingTestHelpers.AssertCompilationError(() => CSharpScript.EvaluateAsync(source, options), // (2,1): error CS0006: Metadata file 'System.Data.dll' could not be found // #r "System.Data.dll" Diagnostic(ErrorCode.ERR_NoMetadataFile, @"#r ""System.Data.dll""").WithArguments("System.Data.dll"), // (3,12): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) // new System.Data.DataSet() Diagnostic(ErrorCode.ERR_DottedTypeNameNotFoundInNS, "Data").WithArguments("Data", "System")); } /// <summary> /// Look at base directory (or directory containing #r) before search paths. /// </summary> [Fact] public async Task SearchPaths_BaseDirectory() { var options = ScriptOptions.Default. WithMetadataResolver(new TestMetadataReferenceResolver( pathResolver: new VirtualizedRelativePathResolver(existingFullPaths: new[] { @"C:\dir\x.dll" }, baseDirectory: @"C:\goo\bar"), files: new Dictionary<string, PortableExecutableReference> { { @"C:\dir\x.dll", (PortableExecutableReference)SystemCoreRef } })); var script = CSharpScript.Create(@" #r ""x.dll"" using System.Linq; var x = from a in new[] { 1, 2 ,3 } select a + 1; ", options.WithFilePath(@"C:\dir\a.csx")); var state = await script.RunAsync().ContinueWith<IEnumerable<int>>("x", options.WithFilePath(null)); AssertEx.Equal(new[] { 2, 3, 4 }, state.ReturnValue); } [Fact] public async Task References1() { var options0 = ScriptOptions.Default.AddReferences( typeof(Process).Assembly, typeof(System.Linq.Expressions.Expression).Assembly); var s0 = await CSharpScript.RunAsync<Process>($@" #r ""{typeof(System.Data.DataSet).Assembly.Location}"" #r ""System"" #r ""{typeof(System.Xml.Serialization.IXmlSerializable).Assembly.Location}"" new System.Data.DataSet(); System.Linq.Expressions.Expression.Constant(123); System.Diagnostics.Process.GetCurrentProcess() ", options0); Assert.NotNull(s0.ReturnValue); var options1 = options0.AddReferences(typeof(System.Xml.XmlDocument).Assembly); var s1 = await s0.ContinueWithAsync<System.Xml.XmlDocument>(@" new System.Xml.XmlDocument() ", options1); Assert.NotNull(s1.ReturnValue); var options2 = options1.AddReferences("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); var s2 = await s1.ContinueWithAsync(@" System.Drawing.Color.Coral ", options2); Assert.NotNull(s2.ReturnValue); var options3 = options2.AddReferences(typeof(System.Windows.Forms.Form).Assembly.Location); var s3 = await s2.ContinueWithAsync<System.Windows.Forms.Form>(@" new System.Windows.Forms.Form() ", options3); Assert.NotNull(s3.ReturnValue); } [Fact] public void References2() { var options = ScriptOptions.Default. WithMetadataResolver(ScriptMetadataResolver.Default.WithSearchPaths(RuntimeEnvironment.GetRuntimeDirectory())). AddReferences("System.Core", "System.dll"). AddReferences(typeof(System.Data.DataSet).Assembly); var process = CSharpScript.EvaluateAsync<Process>($@" #r ""{typeof(System.Xml.Serialization.IXmlSerializable).Assembly.Location}"" new System.Data.DataSet(); System.Linq.Expressions.Expression.Constant(123); System.Diagnostics.Process.GetCurrentProcess() ", options).Result; Assert.NotNull(process); } private static readonly Lazy<bool> s_isSystemV2AndV4Available = new Lazy<bool>(() => { string path; return GlobalAssemblyCache.Instance.ResolvePartialName("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", out path) != null && GlobalAssemblyCache.Instance.ResolvePartialName("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", out path) != null; }); [Fact] public void References_Versioning_FxUnification1() { if (!s_isSystemV2AndV4Available.Value) return; var script = CSharpScript.Create($@" #r ""System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" #r ""System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" System.Diagnostics.Process.GetCurrentProcess() "); script.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=2.0.0.0: <superseded>", "System, Version=4.0.0.0", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=4.0.0.0: <implicit>,global", "System.Xml, Version=4.0.0.0: <implicit>,global", "System.Data.SqlXml, Version=4.0.0.0: <implicit>,global", "System.Security, Version=4.0.0.0: <implicit>,global", "System.Core, Version=4.0.0.0: <implicit>,global", "System.Numerics, Version=4.0.0.0: <implicit>,global", "System.Configuration, Version=2.0.0.0: <superseded>", "System.Xml, Version=2.0.0.0: <superseded>", "System.Data.SqlXml, Version=2.0.0.0: <superseded>", "System.Security, Version=2.0.0.0: <superseded>"); Assert.NotNull(script.RunAsync().Result.ReturnValue); } [Fact] public void References_Versioning_FxUnification2() { if (!s_isSystemV2AndV4Available.Value) return; var script0 = CSharpScript.Create($@" #r ""System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" "); var script1 = script0.ContinueWith($@" #r ""System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" "); var script2 = script1.ContinueWith(@" System.Diagnostics.Process.GetCurrentProcess() "); script0.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=2.0.0.0", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=2.0.0.0: <implicit>,global", "System.Xml, Version=2.0.0.0: <implicit>,global", "System.Data.SqlXml, Version=2.0.0.0: <implicit>,global", "System.Security, Version=2.0.0.0: <implicit>,global"); // TODO (https://github.com/dotnet/roslyn/issues/6456): // This is not correct. "global" alias should be recursively applied on all // dependencies of System, V4. The problem is in ResolveReferencedAssembly which considers // System, V2 equivalent to System, V4 and immediately returns, instead of checking if a better match exists. // This is not a problem in csc since it can't have both System, V2 and System, V4 among definitions. script1.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=4.0.0.0", "System, Version=2.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=2.0.0.0: <superseded>", "System.Xml, Version=2.0.0.0: <superseded>", "System.Data.SqlXml, Version=2.0.0.0: <superseded>", "System.Security, Version=2.0.0.0: <superseded>", "System.Configuration, Version=4.0.0.0: <implicit>", "System.Xml, Version=4.0.0.0: <implicit>", "System.Data.SqlXml, Version=4.0.0.0: <implicit>", "System.Security, Version=4.0.0.0: <implicit>", "System.Core, Version=4.0.0.0: <implicit>", "System.Numerics, Version=4.0.0.0: <implicit>"); // TODO (https://github.com/dotnet/roslyn/issues/6456): // "global" alias should be recursively applied on all script2.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=4.0.0.0", "System, Version=2.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=2.0.0.0: <superseded>", "System.Xml, Version=2.0.0.0: <superseded>", "System.Data.SqlXml, Version=2.0.0.0: <superseded>", "System.Security, Version=2.0.0.0: <superseded>", "System.Configuration, Version=4.0.0.0: <implicit>", "System.Xml, Version=4.0.0.0: <implicit>", "System.Data.SqlXml, Version=4.0.0.0: <implicit>", "System.Security, Version=4.0.0.0: <implicit>", "System.Core, Version=4.0.0.0: <implicit>", "System.Numerics, Version=4.0.0.0: <implicit>"); Assert.NotNull(script2.EvaluateAsync().Result); } [Fact] public void References_Versioning_StrongNames1() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C1); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C2); var result = CSharpScript.EvaluateAsync($@" #r ""{c1.Path}"" #r ""{c2.Path}"" new C() ").Result; Assert.NotNull(result); } [Fact] public void References_Versioning_StrongNames2() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C1); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C2); var result = CSharpScript.Create($@" #r ""{c1.Path}"" ").ContinueWith($@" #r ""{c2.Path}"" ").ContinueWith(@" new C() ").EvaluateAsync().Result; Assert.NotNull(result); } [Fact] public void References_Versioning_WeakNames1() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var result = CSharpScript.EvaluateAsync($@" #r ""{c1.Path}"" #r ""{c2.Path}"" new C() ").Result; Assert.NotNull(result); } [Fact] public void References_Versioning_WeakNames2() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var result = CSharpScript.Create($@" #r ""{c1.Path}"" ").ContinueWith($@" #r ""{c2.Path}"" ").ContinueWith(@" new C() ").EvaluateAsync().Result; Assert.NotNull(result); } [Fact] public void References_Versioning_WeakNames3() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var script0 = CSharpScript.Create($@" #r ""{c1.Path}"" var c1 = new C(); "); script0.GetCompilation().VerifyAssemblyVersionsAndAliases( "C, Version=1.0.0.0", "mscorlib, Version=4.0.0.0"); var script1 = script0.ContinueWith($@" #r ""{c2.Path}"" var c2 = new C(); "); script1.GetCompilation().VerifyAssemblyVersionsAndAliases( "C, Version=2.0.0.0", "C, Version=1.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0"); var script2 = script1.ContinueWith(@" c1 = c2; "); script2.GetCompilation().VerifyAssemblyVersionsAndAliases( "C, Version=2.0.0.0", "C, Version=1.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0"); DiagnosticExtensions.VerifyEmitDiagnostics(script2.GetCompilation(), // (2,6): error CS0029: Cannot implicitly convert type 'C [{c2.Path}]' to 'C [{c1.Path}]' Diagnostic(ErrorCode.ERR_NoImplicitConv, "c2").WithArguments($"C [{c2.Path}]", $"C [{c1.Path}]")); } [Fact] public void AssemblyResolution() { var s0 = CSharpScript.RunAsync("var x = new { a = 3 }; x"); var s1 = s0.ContinueWith<Type>("System.Type.GetType(x.GetType().AssemblyQualifiedName, true)"); Assert.Equal(s0.Result.ReturnValue.GetType(), s1.Result.ReturnValue); } [Fact] public void ReferenceToInvalidType() { var badTypeBytes = TestResources.MetadataTests.Invalid.ClassLayout; var badTypeRef = MetadataReference.CreateFromImage(badTypeBytes.AsImmutableOrNull()); // TODO: enable this with our AssemblyLoader: Assembly handler(object _, ResolveEventArgs args) { if (args.Name.StartsWith("b,", StringComparison.Ordinal)) { return Assembly.Load(badTypeBytes); } return null; } AppDomain.CurrentDomain.AssemblyResolve += handler; try { var options = ScriptOptions.Default.AddReferences(badTypeRef); // we shouldn't throw while compiling: var script = CSharpScript.Create("new S1()", options); script.Compile(); Assert.Throws<TypeLoadException>(() => script.EvaluateAsync().GetAwaiter().GetResult()); } finally { AppDomain.CurrentDomain.AssemblyResolve -= handler; } } public class C { public int x = 1; } [Fact] public async Task HostObjectBinding_DuplicateReferences() { var options = ScriptOptions.Default. AddReferences(typeof(C).Assembly, typeof(C).Assembly); var s0 = await CSharpScript.RunAsync<int>("x", options, new C()); var c0 = s0.Script.GetCompilation(); // includes corlib, host type assembly by default: AssertEx.Equal(new[] { typeof(object).GetTypeInfo().Assembly.Location, typeof(C).Assembly.Location, typeof(C).Assembly.Location, typeof(C).Assembly.Location, }, c0.ExternalReferences.SelectAsArray(m => m.Display)); Assert.Equal(1, s0.ReturnValue); var s1 = await s0.ContinueWithAsync($@" #r ""{typeof(C).Assembly.Location}"" #r ""{typeof(C).Assembly.Location}"" x "); Assert.Equal(1, s1.ReturnValue); } [Fact] public async Task MissingRefrencesAutoResolution() { var portableLib = CSharpCompilation.Create( "PortableLib", new[] { SyntaxFactory.ParseSyntaxTree("public class C {}") }, new[] { SystemRuntimePP7Ref }, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var portableLibRef = portableLib.ToMetadataReference(); var loader = new InteractiveAssemblyLoader(); loader.RegisterDependency(Assembly.Load(portableLib.EmitToArray().ToArray())); var s0 = await CSharpScript.Create("new C()", options: ScriptOptions.Default.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync(); var c0 = s0.Script.GetCompilation(); // includes corlib, host type assembly by default: AssertEx.Equal(new[] { typeof(object).GetTypeInfo().Assembly.Location, "PortableLib" }, c0.ExternalReferences.SelectAsArray(m => m.Display)); // System.Runtime, 4.0.0.0 depends on all the assemblies below: AssertEx.Equal(new[] { "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "PortableLib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", }, c0.GetBoundReferenceManager().GetReferencedAssemblies().Select(a => a.Value.Identity.GetDisplayName())); } // https://github.com/dotnet/roslyn/issues/2246 [Fact] public void HostObjectInInMemoryAssembly() { var lib = CreateCSharpCompilation("public class C { public int X = 1, Y = 2; }", new[] { Net451.mscorlib }, "HostLib"); var libImage = lib.EmitToArray(); var libRef = MetadataImageReference.CreateFromImage(libImage); var libAssembly = Assembly.Load(libImage.ToArray()); var globalsType = libAssembly.GetType("C"); var globals = Activator.CreateInstance(globalsType); using (var loader = new InteractiveAssemblyLoader()) { loader.RegisterDependency(libAssembly); var script = CSharpScript.Create<int>( "X+Y", ScriptOptions.Default.WithReferences(libRef), globalsType: globalsType, assemblyLoader: loader); int result = script.RunAsync(globals).Result.ReturnValue; Assert.Equal(3, result); } } [Fact] public async Task SharedLibCopy_Identical_Weak() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib2Name); var libBaseImage = libBase.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); var c4 = s4.Script.GetCompilation(); c4.VerifyAssemblyAliases( lib2Name, lib1Name, "mscorlib", libBaseName + ": <implicit>,global"); var libBaseRefAndSymbol = c4.GetBoundReferenceManager().GetReferencedAssemblies().ToArray()[3]; Assert.Equal(fileBase1.Path, ((PortableExecutableReference)libBaseRefAndSymbol.Key).FilePath); } [Fact] public async Task SharedLibCopy_Identical_Strong() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib2Name); var libBaseImage = libBase.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); var c4 = s4.Script.GetCompilation(); c4.VerifyAssemblyAliases( lib2Name, lib1Name, "mscorlib", libBaseName + ": <implicit>,global"); var libBaseRefAndSymbol = c4.GetBoundReferenceManager().GetReferencedAssemblies().ToArray()[3]; Assert.Equal(fileBase1.Path, ((PortableExecutableReference)libBaseRefAndSymbol.Key).FilePath); } [Fact] public async Task SharedLibCopy_SameVersion_Weak_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName); var libBase2 = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"var l2 = new Lib2();"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_SameVersion_Strong_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"new Lib2().libBase.X"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_SameVersion_StrongWeak_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"new Lib2().libBase.X"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_SameVersion_StrongDifferentPKT_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll2); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"new Lib2().libBase.X"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_DifferentVersion_Weak() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase2.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1().libBase.X;"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"var l2 = new Lib2().libBase.X;"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_DifferentVersion_Strong() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase2.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); Assert.Equal(1, s1.ReturnValue); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); var s3 = await s2.ContinueWithAsync($@"new Lib2().libBase.X"); Assert.Equal(2, s3.ReturnValue); } [Fact, WorkItem(6457, "https://github.com/dotnet/roslyn/issues/6457")] public async Task MissingReferencesReuse() { var source = @" public class C { public System.Diagnostics.Process P; } "; var lib = CSharpCompilation.Create( "Lib", new[] { SyntaxFactory.ParseSyntaxTree(source) }, new[] { Net451.mscorlib, Net451.System }, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var libFile = Temp.CreateFile("lib").WriteAllBytes(lib.EmitToArray()); var s0 = await CSharpScript.RunAsync("C c;", ScriptOptions.Default.WithReferences(libFile.Path)); await s0.ContinueWithAsync("c = new C()"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable extern alias PortableTestUtils; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Scripting; using Microsoft.CodeAnalysis.Scripting.Hosting; using Microsoft.CodeAnalysis.Scripting.Test; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; using AssertEx = PortableTestUtils::Roslyn.Test.Utilities.AssertEx; using TestBase = PortableTestUtils::Roslyn.Test.Utilities.TestBase; using WorkItemAttribute = PortableTestUtils::Roslyn.Test.Utilities.WorkItemAttribute; using static Microsoft.CodeAnalysis.Scripting.TestCompilationFactory; using static Roslyn.Test.Utilities.TestMetadata; namespace Microsoft.CodeAnalysis.CSharp.Scripting.Test { public class InteractiveSessionReferencesTests : TestBase { private static readonly CSharpCompilationOptions s_signedDll = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_ce65828c82a341f2); private static readonly CSharpCompilationOptions s_signedDll2 = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_ce65828c82a341f2); [Fact] public async Task CompilationChain_GlobalImportsRebinding() { var options = ScriptOptions.Default.AddImports("System.Diagnostics"); var s0 = await CSharpScript.RunAsync("", options); ScriptingTestHelpers.AssertCompilationError(s0, @"Process.GetCurrentProcess()", // (2,1): error CS0103: The name 'Process' does not exist in the current context Diagnostic(ErrorCode.ERR_NameNotInContext, "Process").WithArguments("Process")); var s1 = s0.ContinueWithAsync($"#r \"{typeof(Process).Assembly.Location}\""); var s2 = s1.ContinueWith("Process.GetCurrentProcess()"); Assert.NotNull(s2.Result); } [Fact] public async Task CompilationChain_UsingRebinding_AddReference() { var s0 = await CSharpScript.RunAsync("using System.Diagnostics;"); var newOptions = s0.Script.Options.AddReferences(typeof(Process).Assembly); var s1 = s0.ContinueWithAsync(@"Process.GetCurrentProcess()", newOptions); Assert.NotNull(s1.Result); } [Fact] public async Task CompilationChain_UsingRebinding_Directive() { var s0 = await CSharpScript.RunAsync("using System.Diagnostics;"); var s1 = s0.ContinueWithAsync($@" #r ""{typeof(Process).Assembly.Location}"" Process.GetCurrentProcess()"); Assert.NotNull(s1.Result); } // // General rule for symbol lookup: // // Declaration A in submission S hides declaration B in submission T iff // S precedes T, and A and B can't coexist in the same scope. [Fact] public void CompilationChain_SubmissionSlots() { var s = CSharpScript.RunAsync("using System;"). ContinueWith("using static System.Environment;"). ContinueWith("int x; x = 1;"). ContinueWith("using static System.Math;"). ContinueWith("int goo(int a) { return a + 1; } "); #if false Assert.True(session.executionState.submissions.Length >= 2, "Expected two submissions"); session.executionState.submissions.Aggregate(0, (i, sub) => { Assert.Equal(i < 2, sub != null); return i + 1; }); #endif ScriptingTestHelpers.AssertCompilationError(s, "Version", // (1,1): error CS0229: Ambiguity between 'System.Version' and 'System.Environment.Version' Diagnostic(ErrorCode.ERR_AmbigMember, "Version").WithArguments("System.Version", "System.Environment.Version")); s = s.ContinueWith("new System.Collections.Generic.List<Version>()"); Assert.IsType<List<Version>>(s.Result.ReturnValue); s = s.ContinueWith("Environment.Version"); Assert.Equal(Environment.Version, s.Result.ReturnValue); s = s.ContinueWith("goo(x)"); Assert.Equal(2, s.Result.ReturnValue); s = s.ContinueWith("Sin(0)"); Assert.Equal(0.0, s.Result.ReturnValue); } [Fact] public void SearchPaths1() { var options = ScriptOptions.Default.WithMetadataResolver(ScriptMetadataResolver.Default.WithSearchPaths(RuntimeEnvironment.GetRuntimeDirectory())); var result = CSharpScript.EvaluateAsync($@" #r ""System.Data.dll"" #r ""System"" #r ""{typeof(System.Xml.Serialization.IXmlSerializable).GetTypeInfo().Assembly.Location}"" new System.Data.DataSet() ", options).Result; Assert.True(result is System.Data.DataSet, "Expected DataSet"); } /// <summary> /// Default search paths can be removed. /// </summary> [Fact] public void SearchPaths_RemoveDefault() { // remove default paths: var options = ScriptOptions.Default; var source = @" #r ""System.Data.dll"" new System.Data.DataSet() "; ScriptingTestHelpers.AssertCompilationError(() => CSharpScript.EvaluateAsync(source, options), // (2,1): error CS0006: Metadata file 'System.Data.dll' could not be found // #r "System.Data.dll" Diagnostic(ErrorCode.ERR_NoMetadataFile, @"#r ""System.Data.dll""").WithArguments("System.Data.dll"), // (3,12): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) // new System.Data.DataSet() Diagnostic(ErrorCode.ERR_DottedTypeNameNotFoundInNS, "Data").WithArguments("Data", "System")); } /// <summary> /// Look at base directory (or directory containing #r) before search paths. /// </summary> [Fact] public async Task SearchPaths_BaseDirectory() { var options = ScriptOptions.Default. WithMetadataResolver(new TestMetadataReferenceResolver( pathResolver: new VirtualizedRelativePathResolver(existingFullPaths: new[] { @"C:\dir\x.dll" }, baseDirectory: @"C:\goo\bar"), files: new Dictionary<string, PortableExecutableReference> { { @"C:\dir\x.dll", (PortableExecutableReference)SystemCoreRef } })); var script = CSharpScript.Create(@" #r ""x.dll"" using System.Linq; var x = from a in new[] { 1, 2 ,3 } select a + 1; ", options.WithFilePath(@"C:\dir\a.csx")); var state = await script.RunAsync().ContinueWith<IEnumerable<int>>("x", options.WithFilePath(null)); AssertEx.Equal(new[] { 2, 3, 4 }, state.ReturnValue); } [Fact] public async Task References1() { var options0 = ScriptOptions.Default.AddReferences( typeof(Process).Assembly, typeof(System.Linq.Expressions.Expression).Assembly); var s0 = await CSharpScript.RunAsync<Process>($@" #r ""{typeof(System.Data.DataSet).Assembly.Location}"" #r ""System"" #r ""{typeof(System.Xml.Serialization.IXmlSerializable).Assembly.Location}"" new System.Data.DataSet(); System.Linq.Expressions.Expression.Constant(123); System.Diagnostics.Process.GetCurrentProcess() ", options0); Assert.NotNull(s0.ReturnValue); var options1 = options0.AddReferences(typeof(System.Xml.XmlDocument).Assembly); var s1 = await s0.ContinueWithAsync<System.Xml.XmlDocument>(@" new System.Xml.XmlDocument() ", options1); Assert.NotNull(s1.ReturnValue); var options2 = options1.AddReferences("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); var s2 = await s1.ContinueWithAsync(@" System.Drawing.Color.Coral ", options2); Assert.NotNull(s2.ReturnValue); var options3 = options2.AddReferences(typeof(System.Windows.Forms.Form).Assembly.Location); var s3 = await s2.ContinueWithAsync<System.Windows.Forms.Form>(@" new System.Windows.Forms.Form() ", options3); Assert.NotNull(s3.ReturnValue); } [Fact] public void References2() { var options = ScriptOptions.Default. WithMetadataResolver(ScriptMetadataResolver.Default.WithSearchPaths(RuntimeEnvironment.GetRuntimeDirectory())). AddReferences("System.Core", "System.dll"). AddReferences(typeof(System.Data.DataSet).Assembly); var process = CSharpScript.EvaluateAsync<Process>($@" #r ""{typeof(System.Xml.Serialization.IXmlSerializable).Assembly.Location}"" new System.Data.DataSet(); System.Linq.Expressions.Expression.Constant(123); System.Diagnostics.Process.GetCurrentProcess() ", options).Result; Assert.NotNull(process); } private static readonly Lazy<bool> s_isSystemV2AndV4Available = new Lazy<bool>(() => { string path; return GlobalAssemblyCache.Instance.ResolvePartialName("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", out path) != null && GlobalAssemblyCache.Instance.ResolvePartialName("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", out path) != null; }); [Fact] public void References_Versioning_FxUnification1() { if (!s_isSystemV2AndV4Available.Value) return; var script = CSharpScript.Create($@" #r ""System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" #r ""System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" System.Diagnostics.Process.GetCurrentProcess() "); script.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=2.0.0.0: <superseded>", "System, Version=4.0.0.0", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=4.0.0.0: <implicit>,global", "System.Xml, Version=4.0.0.0: <implicit>,global", "System.Data.SqlXml, Version=4.0.0.0: <implicit>,global", "System.Security, Version=4.0.0.0: <implicit>,global", "System.Core, Version=4.0.0.0: <implicit>,global", "System.Numerics, Version=4.0.0.0: <implicit>,global", "System.Configuration, Version=2.0.0.0: <superseded>", "System.Xml, Version=2.0.0.0: <superseded>", "System.Data.SqlXml, Version=2.0.0.0: <superseded>", "System.Security, Version=2.0.0.0: <superseded>"); Assert.NotNull(script.RunAsync().Result.ReturnValue); } [Fact] public void References_Versioning_FxUnification2() { if (!s_isSystemV2AndV4Available.Value) return; var script0 = CSharpScript.Create($@" #r ""System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" "); var script1 = script0.ContinueWith($@" #r ""System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" "); var script2 = script1.ContinueWith(@" System.Diagnostics.Process.GetCurrentProcess() "); script0.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=2.0.0.0", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=2.0.0.0: <implicit>,global", "System.Xml, Version=2.0.0.0: <implicit>,global", "System.Data.SqlXml, Version=2.0.0.0: <implicit>,global", "System.Security, Version=2.0.0.0: <implicit>,global"); // TODO (https://github.com/dotnet/roslyn/issues/6456): // This is not correct. "global" alias should be recursively applied on all // dependencies of System, V4. The problem is in ResolveReferencedAssembly which considers // System, V2 equivalent to System, V4 and immediately returns, instead of checking if a better match exists. // This is not a problem in csc since it can't have both System, V2 and System, V4 among definitions. script1.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=4.0.0.0", "System, Version=2.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=2.0.0.0: <superseded>", "System.Xml, Version=2.0.0.0: <superseded>", "System.Data.SqlXml, Version=2.0.0.0: <superseded>", "System.Security, Version=2.0.0.0: <superseded>", "System.Configuration, Version=4.0.0.0: <implicit>", "System.Xml, Version=4.0.0.0: <implicit>", "System.Data.SqlXml, Version=4.0.0.0: <implicit>", "System.Security, Version=4.0.0.0: <implicit>", "System.Core, Version=4.0.0.0: <implicit>", "System.Numerics, Version=4.0.0.0: <implicit>"); // TODO (https://github.com/dotnet/roslyn/issues/6456): // "global" alias should be recursively applied on all script2.GetCompilation().VerifyAssemblyVersionsAndAliases( "System, Version=4.0.0.0", "System, Version=2.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0", "System.Configuration, Version=2.0.0.0: <superseded>", "System.Xml, Version=2.0.0.0: <superseded>", "System.Data.SqlXml, Version=2.0.0.0: <superseded>", "System.Security, Version=2.0.0.0: <superseded>", "System.Configuration, Version=4.0.0.0: <implicit>", "System.Xml, Version=4.0.0.0: <implicit>", "System.Data.SqlXml, Version=4.0.0.0: <implicit>", "System.Security, Version=4.0.0.0: <implicit>", "System.Core, Version=4.0.0.0: <implicit>", "System.Numerics, Version=4.0.0.0: <implicit>"); Assert.NotNull(script2.EvaluateAsync().Result); } [Fact] public void References_Versioning_StrongNames1() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C1); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C2); var result = CSharpScript.EvaluateAsync($@" #r ""{c1.Path}"" #r ""{c2.Path}"" new C() ").Result; Assert.NotNull(result); } [Fact] public void References_Versioning_StrongNames2() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C1); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes(TestResources.General.C2); var result = CSharpScript.Create($@" #r ""{c1.Path}"" ").ContinueWith($@" #r ""{c2.Path}"" ").ContinueWith(@" new C() ").EvaluateAsync().Result; Assert.NotNull(result); } [Fact] public void References_Versioning_WeakNames1() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var result = CSharpScript.EvaluateAsync($@" #r ""{c1.Path}"" #r ""{c2.Path}"" new C() ").Result; Assert.NotNull(result); } [Fact] public void References_Versioning_WeakNames2() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var result = CSharpScript.Create($@" #r ""{c1.Path}"" ").ContinueWith($@" #r ""{c2.Path}"" ").ContinueWith(@" new C() ").EvaluateAsync().Result; Assert.NotNull(result); } [Fact] public void References_Versioning_WeakNames3() { var c1 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var c2 = Temp.CreateFile(extension: ".dll").WriteAllBytes( CreateCSharpCompilation(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class C {}", new[] { Net451.mscorlib }, assemblyName: "C").EmitToArray()); var script0 = CSharpScript.Create($@" #r ""{c1.Path}"" var c1 = new C(); "); script0.GetCompilation().VerifyAssemblyVersionsAndAliases( "C, Version=1.0.0.0", "mscorlib, Version=4.0.0.0"); var script1 = script0.ContinueWith($@" #r ""{c2.Path}"" var c2 = new C(); "); script1.GetCompilation().VerifyAssemblyVersionsAndAliases( "C, Version=2.0.0.0", "C, Version=1.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0"); var script2 = script1.ContinueWith(@" c1 = c2; "); script2.GetCompilation().VerifyAssemblyVersionsAndAliases( "C, Version=2.0.0.0", "C, Version=1.0.0.0: <superseded>", "mscorlib, Version=4.0.0.0"); DiagnosticExtensions.VerifyEmitDiagnostics(script2.GetCompilation(), // (2,6): error CS0029: Cannot implicitly convert type 'C [{c2.Path}]' to 'C [{c1.Path}]' Diagnostic(ErrorCode.ERR_NoImplicitConv, "c2").WithArguments($"C [{c2.Path}]", $"C [{c1.Path}]")); } [Fact] public void AssemblyResolution() { var s0 = CSharpScript.RunAsync("var x = new { a = 3 }; x"); var s1 = s0.ContinueWith<Type>("System.Type.GetType(x.GetType().AssemblyQualifiedName, true)"); Assert.Equal(s0.Result.ReturnValue.GetType(), s1.Result.ReturnValue); } [Fact] public void ReferenceToInvalidType() { var badTypeBytes = TestResources.MetadataTests.Invalid.ClassLayout; var badTypeRef = MetadataReference.CreateFromImage(badTypeBytes.AsImmutableOrNull()); // TODO: enable this with our AssemblyLoader: Assembly handler(object _, ResolveEventArgs args) { if (args.Name.StartsWith("b,", StringComparison.Ordinal)) { return Assembly.Load(badTypeBytes); } return null; } AppDomain.CurrentDomain.AssemblyResolve += handler; try { var options = ScriptOptions.Default.AddReferences(badTypeRef); // we shouldn't throw while compiling: var script = CSharpScript.Create("new S1()", options); script.Compile(); Assert.Throws<TypeLoadException>(() => script.EvaluateAsync().GetAwaiter().GetResult()); } finally { AppDomain.CurrentDomain.AssemblyResolve -= handler; } } public class C { public int x = 1; } [Fact] public async Task HostObjectBinding_DuplicateReferences() { var options = ScriptOptions.Default. AddReferences(typeof(C).Assembly, typeof(C).Assembly); var s0 = await CSharpScript.RunAsync<int>("x", options, new C()); var c0 = s0.Script.GetCompilation(); // includes corlib, host type assembly by default: AssertEx.Equal(new[] { typeof(object).GetTypeInfo().Assembly.Location, typeof(C).Assembly.Location, typeof(C).Assembly.Location, typeof(C).Assembly.Location, }, c0.ExternalReferences.SelectAsArray(m => m.Display)); Assert.Equal(1, s0.ReturnValue); var s1 = await s0.ContinueWithAsync($@" #r ""{typeof(C).Assembly.Location}"" #r ""{typeof(C).Assembly.Location}"" x "); Assert.Equal(1, s1.ReturnValue); } [Fact] public async Task MissingRefrencesAutoResolution() { var portableLib = CSharpCompilation.Create( "PortableLib", new[] { SyntaxFactory.ParseSyntaxTree("public class C {}") }, new[] { SystemRuntimePP7Ref }, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var portableLibRef = portableLib.ToMetadataReference(); var loader = new InteractiveAssemblyLoader(); loader.RegisterDependency(Assembly.Load(portableLib.EmitToArray().ToArray())); var s0 = await CSharpScript.Create("new C()", options: ScriptOptions.Default.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync(); var c0 = s0.Script.GetCompilation(); // includes corlib, host type assembly by default: AssertEx.Equal(new[] { typeof(object).GetTypeInfo().Assembly.Location, "PortableLib" }, c0.ExternalReferences.SelectAsArray(m => m.Display)); // System.Runtime, 4.0.0.0 depends on all the assemblies below: AssertEx.Equal(new[] { "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "PortableLib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", }, c0.GetBoundReferenceManager().GetReferencedAssemblies().Select(a => a.Value.Identity.GetDisplayName())); } // https://github.com/dotnet/roslyn/issues/2246 [Fact] public void HostObjectInInMemoryAssembly() { var lib = CreateCSharpCompilation("public class C { public int X = 1, Y = 2; }", new[] { Net451.mscorlib }, "HostLib"); var libImage = lib.EmitToArray(); var libRef = MetadataImageReference.CreateFromImage(libImage); var libAssembly = Assembly.Load(libImage.ToArray()); var globalsType = libAssembly.GetType("C"); var globals = Activator.CreateInstance(globalsType); using (var loader = new InteractiveAssemblyLoader()) { loader.RegisterDependency(libAssembly); var script = CSharpScript.Create<int>( "X+Y", ScriptOptions.Default.WithReferences(libRef), globalsType: globalsType, assemblyLoader: loader); int result = script.RunAsync(globals).Result.ReturnValue; Assert.Equal(3, result); } } [Fact] public async Task SharedLibCopy_Identical_Weak() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib2Name); var libBaseImage = libBase.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); var c4 = s4.Script.GetCompilation(); c4.VerifyAssemblyAliases( lib2Name, lib1Name, "mscorlib", libBaseName + ": <implicit>,global"); var libBaseRefAndSymbol = c4.GetBoundReferenceManager().GetReferencedAssemblies().ToArray()[3]; Assert.Equal(fileBase1.Path, ((PortableExecutableReference)libBaseRefAndSymbol.Key).FilePath); } [Fact] public async Task SharedLibCopy_Identical_Strong() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase.ToMetadataReference() }, lib2Name); var libBaseImage = libBase.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBaseImage); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); var c4 = s4.Script.GetCompilation(); c4.VerifyAssemblyAliases( lib2Name, lib1Name, "mscorlib", libBaseName + ": <implicit>,global"); var libBaseRefAndSymbol = c4.GetBoundReferenceManager().GetReferencedAssemblies().ToArray()[3]; Assert.Equal(fileBase1.Path, ((PortableExecutableReference)libBaseRefAndSymbol.Key).FilePath); } [Fact] public async Task SharedLibCopy_SameVersion_Weak_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName); var libBase2 = CreateCSharpCompilation(@" public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"var l2 = new Lib2();"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_SameVersion_Strong_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"new Lib2().libBase.X"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_SameVersion_StrongWeak_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"new Lib2().libBase.X"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_SameVersion_StrongDifferentPKT_DifferentContent() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll2); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"new Lib2().libBase.X"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_DifferentVersion_Weak() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase2.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1().libBase.X;"); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); bool exceptionSeen = false; try { await s2.ContinueWithAsync($@"var l2 = new Lib2().libBase.X;"); } catch (FileLoadException fileLoadEx) when (fileLoadEx.InnerException is InteractiveAssemblyLoaderException) { exceptionSeen = true; } Assert.True(exceptionSeen); } [Fact] public async Task SharedLibCopy_DifferentVersion_Strong() { string libBaseName = "LibBase_" + Guid.NewGuid(); string lib1Name = "Lib1_" + Guid.NewGuid(); string lib2Name = "Lib2_" + Guid.NewGuid(); var libBase1 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class LibBase { public readonly int X = 1; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var libBase2 = CreateCSharpCompilation(@" [assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class LibBase { public readonly int X = 2; } ", new[] { Net451.mscorlib }, libBaseName, s_signedDll); var lib1 = CreateCSharpCompilation(@" public class Lib1 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase1.ToMetadataReference() }, lib1Name); var lib2 = CreateCSharpCompilation(@" public class Lib2 { public LibBase libBase = new LibBase(); } ", new MetadataReference[] { Net451.mscorlib, libBase2.ToMetadataReference() }, lib2Name); var libBase1Image = libBase1.EmitToArray(); var libBase2Image = libBase2.EmitToArray(); var lib1Image = lib1.EmitToArray(); var lib2Image = lib2.EmitToArray(); var root = Temp.CreateDirectory(); var dir1 = root.CreateDirectory("1"); var file1 = dir1.CreateFile(lib1Name + ".dll").WriteAllBytes(lib1Image); var fileBase1 = dir1.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase1Image); var dir2 = root.CreateDirectory("2"); var file2 = dir2.CreateFile(lib2Name + ".dll").WriteAllBytes(lib2Image); var fileBase2 = dir2.CreateFile(libBaseName + ".dll").WriteAllBytes(libBase2Image); var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); Assert.Equal(1, s1.ReturnValue); var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); var s3 = await s2.ContinueWithAsync($@"new Lib2().libBase.X"); Assert.Equal(2, s3.ReturnValue); } [Fact, WorkItem(6457, "https://github.com/dotnet/roslyn/issues/6457")] public async Task MissingReferencesReuse() { var source = @" public class C { public System.Diagnostics.Process P; } "; var lib = CSharpCompilation.Create( "Lib", new[] { SyntaxFactory.ParseSyntaxTree(source) }, new[] { Net451.mscorlib, Net451.System }, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var libFile = Temp.CreateFile("lib").WriteAllBytes(lib.EmitToArray()); var s0 = await CSharpScript.RunAsync("C c;", ScriptOptions.Default.WithReferences(libFile.Path)); await s0.ContinueWithAsync("c = new C()"); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/ExpressionEvaluator/Core/Source/ExpressionCompiler/EESymbolProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Reflection.Metadata; using Microsoft.CodeAnalysis.Symbols; namespace Microsoft.CodeAnalysis.ExpressionEvaluator { internal abstract class EESymbolProvider<TTypeSymbol, TLocalSymbol> where TTypeSymbol : class, ITypeSymbolInternal where TLocalSymbol : class, ILocalSymbolInternal { /// <summary> /// Windows PDB constant signature format. /// </summary> /// <exception cref="BadImageFormatException"></exception> /// <exception cref="UnsupportedSignatureContent"></exception> public abstract TTypeSymbol DecodeLocalVariableType(ImmutableArray<byte> signature); /// <summary> /// Portable PDB constant signature format. /// </summary> /// <exception cref="BadImageFormatException"></exception> /// <exception cref="UnsupportedSignatureContent"></exception> public abstract void DecodeLocalConstant(ref BlobReader reader, out TTypeSymbol type, out ConstantValue value); public abstract TTypeSymbol GetTypeSymbolForSerializedType(string typeName); public abstract TLocalSymbol GetLocalVariable( string? name, int slotIndex, LocalInfo<TTypeSymbol> info, ImmutableArray<bool> dynamicFlagsOpt, ImmutableArray<string?> tupleElementNamesOpt); public abstract TLocalSymbol GetLocalConstant( string name, TTypeSymbol type, ConstantValue value, ImmutableArray<bool> dynamicFlagsOpt, ImmutableArray<string?> tupleElementNamesOpt); /// <exception cref="BadImageFormatException"></exception> public abstract IAssemblySymbolInternal GetReferencedAssembly(AssemblyReferenceHandle handle); /// <exception cref="BadImageFormatException"></exception> public abstract TTypeSymbol GetType(EntityHandle handle); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Immutable; using System.Reflection.Metadata; using Microsoft.CodeAnalysis.Symbols; namespace Microsoft.CodeAnalysis.ExpressionEvaluator { internal abstract class EESymbolProvider<TTypeSymbol, TLocalSymbol> where TTypeSymbol : class, ITypeSymbolInternal where TLocalSymbol : class, ILocalSymbolInternal { /// <summary> /// Windows PDB constant signature format. /// </summary> /// <exception cref="BadImageFormatException"></exception> /// <exception cref="UnsupportedSignatureContent"></exception> public abstract TTypeSymbol DecodeLocalVariableType(ImmutableArray<byte> signature); /// <summary> /// Portable PDB constant signature format. /// </summary> /// <exception cref="BadImageFormatException"></exception> /// <exception cref="UnsupportedSignatureContent"></exception> public abstract void DecodeLocalConstant(ref BlobReader reader, out TTypeSymbol type, out ConstantValue value); public abstract TTypeSymbol GetTypeSymbolForSerializedType(string typeName); public abstract TLocalSymbol GetLocalVariable( string? name, int slotIndex, LocalInfo<TTypeSymbol> info, ImmutableArray<bool> dynamicFlagsOpt, ImmutableArray<string?> tupleElementNamesOpt); public abstract TLocalSymbol GetLocalConstant( string name, TTypeSymbol type, ConstantValue value, ImmutableArray<bool> dynamicFlagsOpt, ImmutableArray<string?> tupleElementNamesOpt); /// <exception cref="BadImageFormatException"></exception> public abstract IAssemblySymbolInternal GetReferencedAssembly(AssemblyReferenceHandle handle); /// <exception cref="BadImageFormatException"></exception> public abstract TTypeSymbol GetType(EntityHandle handle); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationCompletedEvent.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.Diagnostics { /// <summary> /// The last event placed into a compilation's event queue. /// </summary> internal sealed class CompilationCompletedEvent : CompilationEvent { public CompilationCompletedEvent(Compilation compilation) : base(compilation) { } public override string ToString() { return "CompilationCompletedEvent"; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.CodeAnalysis.Diagnostics { /// <summary> /// The last event placed into a compilation's event queue. /// </summary> internal sealed class CompilationCompletedEvent : CompilationEvent { public CompilationCompletedEvent(Compilation compilation) : base(compilation) { } public override string ToString() { return "CompilationCompletedEvent"; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Tools/Source/RunTests/FileUtil.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.IO; namespace RunTests { internal static class FileUtil { /// <summary> /// Ensure a directory with the given name is present. Will be created if necessary. True /// is returned when it is created. /// </summary> internal static bool EnsureDirectory(string directory) { if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); return true; } return false; } /// <summary> /// Delete file if it exists and swallow any potential exceptions. Returns true if the /// file is actually deleted. /// </summary> internal static bool DeleteFile(string filePath) { try { if (File.Exists(filePath)) { File.Delete(filePath); return true; } } catch { // Ignore } return false; } /// <summary> /// Delete directory if it exists and swallow any potential exceptions. Returns true if the /// directory is actually deleted. /// </summary> internal static bool DeleteDirectory(string directory) { try { if (Directory.Exists(directory)) { Directory.Delete(directory, recursive: true); return true; } } catch { // Ignore } return false; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.IO; namespace RunTests { internal static class FileUtil { /// <summary> /// Ensure a directory with the given name is present. Will be created if necessary. True /// is returned when it is created. /// </summary> internal static bool EnsureDirectory(string directory) { if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); return true; } return false; } /// <summary> /// Delete file if it exists and swallow any potential exceptions. Returns true if the /// file is actually deleted. /// </summary> internal static bool DeleteFile(string filePath) { try { if (File.Exists(filePath)) { File.Delete(filePath); return true; } } catch { // Ignore } return false; } /// <summary> /// Delete directory if it exists and swallow any potential exceptions. Returns true if the /// directory is actually deleted. /// </summary> internal static bool DeleteDirectory(string directory) { try { if (Directory.Exists(directory)) { Directory.Delete(directory, recursive: true); return true; } } catch { // Ignore } return false; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/CSharpTest2/Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <StartupObject /> <TargetFramework>net472</TargetFramework> <UseWpf>true</UseWpf> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis.Editor.CSharp.UnitTests</RootNamespace> </PropertyGroup> <ItemGroup Label="Project References"> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" /> <ProjectReference Include="..\..\Compilers\Test\Utilities\CSharp\Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" /> <ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" /> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" /> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" /> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" /> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" /> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" /> <ProjectReference Include="..\..\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj" /> <ProjectReference Include="..\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj" /> <ProjectReference Include="..\TestUtilities\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" /> <ProjectReference Include="..\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" /> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" /> <ProjectReference Include="..\..\Scripting\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Scripting.vbproj" /> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" /> <ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj" /> <ProjectReference Include="..\..\Test\PdbUtilities\Roslyn.Test.PdbUtilities.csproj" /> <ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" /> <ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" /> <ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj" /> <ProjectReference Include="..\..\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging" Version="$(MicrosoftVisualStudioImagingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="$(MicrosoftVisualStudioImagingInterop140DesignTimeVersion)" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <StartupObject /> <TargetFramework>net472</TargetFramework> <UseWpf>true</UseWpf> <OutputType>Library</OutputType> <RootNamespace>Microsoft.CodeAnalysis.Editor.CSharp.UnitTests</RootNamespace> </PropertyGroup> <ItemGroup Label="Project References"> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" /> <ProjectReference Include="..\..\Compilers\Test\Utilities\CSharp\Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" /> <ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" /> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" /> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" /> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" /> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" /> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" /> <ProjectReference Include="..\..\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj" /> <ProjectReference Include="..\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj" /> <ProjectReference Include="..\TestUtilities\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" /> <ProjectReference Include="..\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" /> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" /> <ProjectReference Include="..\..\Scripting\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Scripting.vbproj" /> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" /> <ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj" /> <ProjectReference Include="..\..\Test\PdbUtilities\Roslyn.Test.PdbUtilities.csproj" /> <ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" /> <ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" /> <ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj" /> <ProjectReference Include="..\..\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging" Version="$(MicrosoftVisualStudioImagingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="$(MicrosoftVisualStudioImagingInterop140DesignTimeVersion)" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> </Project>
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/Compilers/CSharp/Portable/FlowAnalysis/AbstractFlowPass_LocalFunctions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Symbols; namespace Microsoft.CodeAnalysis.CSharp { internal partial class AbstractFlowPass<TLocalState, TLocalFunctionState> { internal abstract class AbstractLocalFunctionState { /// <summary> /// This is the state from the local function which makes the /// current state less specific. For example, in nullable analysis /// this would be captured variables that may be nullable after /// calling the local function. When a local function is called, /// this state is <see cref="Join(ref TLocalState, ref TLocalState)"/> /// with the current state. /// </summary> public TLocalState StateFromBottom; /// <summary> /// This is the part of the local function transfer function which /// transfers knowledge additively. For example, in definite /// assignment this would be captured state which is assigned by /// the local function. When a local function is called, this /// state is <see cref="Meet(ref TLocalState, ref TLocalState)"/> /// with the current state. /// </summary> public TLocalState StateFromTop; public AbstractLocalFunctionState(TLocalState stateFromBottom, TLocalState stateFromTop) { StateFromBottom = stateFromBottom; StateFromTop = stateFromTop; } public bool Visited = false; } protected abstract TLocalFunctionState CreateLocalFunctionState(LocalFunctionSymbol symbol); private SmallDictionary<LocalFunctionSymbol, TLocalFunctionState>? _localFuncVarUsages = null; protected TLocalFunctionState GetOrCreateLocalFuncUsages(LocalFunctionSymbol localFunc) { _localFuncVarUsages ??= new SmallDictionary<LocalFunctionSymbol, TLocalFunctionState>(); if (!_localFuncVarUsages.TryGetValue(localFunc, out TLocalFunctionState? usages)) { usages = CreateLocalFunctionState(localFunc); _localFuncVarUsages[localFunc] = usages; } return usages; } public override BoundNode? VisitLocalFunctionStatement(BoundLocalFunctionStatement localFunc) { if (localFunc.Symbol.IsExtern) { // an extern local function is not permitted to have a body and thus shouldn't be flow analyzed return null; } var oldSymbol = this.CurrentSymbol; var localFuncSymbol = localFunc.Symbol; this.CurrentSymbol = localFuncSymbol; var oldPending = SavePending(); // we do not support branches into a lambda // SPEC: The entry point to a local function is always reachable. // Captured variables are definitely assigned if they are definitely assigned on // all branches into the local function. var savedState = this.State; this.State = this.TopState(); Optional<TLocalState> savedNonMonotonicState = NonMonotonicState; if (_nonMonotonicTransfer) { NonMonotonicState = ReachableBottomState(); } if (!localFunc.WasCompilerGenerated) EnterParameters(localFuncSymbol.Parameters); // State changes to captured variables are recorded, as calls to local functions // transition the state of captured variables if the variables have state changes // across all branches leaving the local function var localFunctionState = GetOrCreateLocalFuncUsages(localFuncSymbol); var savedLocalFunctionState = LocalFunctionStart(localFunctionState); var oldPending2 = SavePending(); // If this is an iterator, there's an implicit branch before the first statement // of the function where the enumerable is returned. if (localFuncSymbol.IsIterator) { PendingBranches.Add(new PendingBranch(null, this.State, null)); } VisitAlways(localFunc.Body); RestorePending(oldPending2); // process any forward branches within the lambda body ImmutableArray<PendingBranch> pendingReturns = RemoveReturns(); RestorePending(oldPending); Location? location = null; if (!localFuncSymbol.Locations.IsDefaultOrEmpty) { location = localFuncSymbol.Locations[0]; } LeaveParameters(localFuncSymbol.Parameters, localFunc.Syntax, location); // Intersect the state of all branches out of the local function var stateAtReturn = this.State; foreach (PendingBranch pending in pendingReturns) { this.State = pending.State; BoundNode branch = pending.Branch; // Pass the local function identifier as a location if the branch // is null or compiler generated. LeaveParameters(localFuncSymbol.Parameters, branch?.Syntax, branch?.WasCompilerGenerated == false ? null : location); Join(ref stateAtReturn, ref this.State); } // Record any changes to the state of captured variables if (RecordStateChange( savedLocalFunctionState, localFunctionState, ref stateAtReturn) && localFunctionState.Visited) { // If the sets have changed and we already used the results // of this local function in another computation, the previous // calculations may be invalid. We need to analyze until we // reach a fixed-point. stateChangedAfterUse = true; localFunctionState.Visited = false; } this.State = savedState; NonMonotonicState = savedNonMonotonicState; this.CurrentSymbol = oldSymbol; return null; } private bool RecordStateChange( TLocalFunctionState savedState, TLocalFunctionState currentState, ref TLocalState stateAtReturn) { bool anyChanged = LocalFunctionEnd(savedState, currentState, ref stateAtReturn); anyChanged |= Join(ref currentState.StateFromTop, ref stateAtReturn); if (NonMonotonicState.HasValue) { var value = NonMonotonicState.Value; // Since only state moving up gets stored in the non-monotonic state, // Meet with the stateAtReturn, which records all state changes. If // a state moved up, then down, the final state should be down. Meet(ref value, ref stateAtReturn); anyChanged |= Join(ref currentState.StateFromBottom, ref value); } return anyChanged; } /// <summary> /// Executed at the start of visiting a local function body. The <paramref name="state"/> /// parameter holds the current state information for the local function being visited. To /// save state information across the analysis, return an instance of <typeparamref name="TLocalFunctionState"/>. /// </summary> protected virtual TLocalFunctionState LocalFunctionStart(TLocalFunctionState state) => state; /// <summary> /// Executed after visiting a local function body. The <paramref name="savedState"/> is the /// return value from <see cref="LocalFunctionStart(TLocalFunctionState)"/>. The <paramref name="currentState"/> /// is state information for the local function that was just visited. <paramref name="stateAtReturn"/> is /// the state after visiting the method. /// </summary> protected virtual bool LocalFunctionEnd( TLocalFunctionState savedState, TLocalFunctionState currentState, ref TLocalState stateAtReturn) { return false; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Symbols; namespace Microsoft.CodeAnalysis.CSharp { internal partial class AbstractFlowPass<TLocalState, TLocalFunctionState> { internal abstract class AbstractLocalFunctionState { /// <summary> /// This is the state from the local function which makes the /// current state less specific. For example, in nullable analysis /// this would be captured variables that may be nullable after /// calling the local function. When a local function is called, /// this state is <see cref="Join(ref TLocalState, ref TLocalState)"/> /// with the current state. /// </summary> public TLocalState StateFromBottom; /// <summary> /// This is the part of the local function transfer function which /// transfers knowledge additively. For example, in definite /// assignment this would be captured state which is assigned by /// the local function. When a local function is called, this /// state is <see cref="Meet(ref TLocalState, ref TLocalState)"/> /// with the current state. /// </summary> public TLocalState StateFromTop; public AbstractLocalFunctionState(TLocalState stateFromBottom, TLocalState stateFromTop) { StateFromBottom = stateFromBottom; StateFromTop = stateFromTop; } public bool Visited = false; } protected abstract TLocalFunctionState CreateLocalFunctionState(LocalFunctionSymbol symbol); private SmallDictionary<LocalFunctionSymbol, TLocalFunctionState>? _localFuncVarUsages = null; protected TLocalFunctionState GetOrCreateLocalFuncUsages(LocalFunctionSymbol localFunc) { _localFuncVarUsages ??= new SmallDictionary<LocalFunctionSymbol, TLocalFunctionState>(); if (!_localFuncVarUsages.TryGetValue(localFunc, out TLocalFunctionState? usages)) { usages = CreateLocalFunctionState(localFunc); _localFuncVarUsages[localFunc] = usages; } return usages; } public override BoundNode? VisitLocalFunctionStatement(BoundLocalFunctionStatement localFunc) { if (localFunc.Symbol.IsExtern) { // an extern local function is not permitted to have a body and thus shouldn't be flow analyzed return null; } var oldSymbol = this.CurrentSymbol; var localFuncSymbol = localFunc.Symbol; this.CurrentSymbol = localFuncSymbol; var oldPending = SavePending(); // we do not support branches into a lambda // SPEC: The entry point to a local function is always reachable. // Captured variables are definitely assigned if they are definitely assigned on // all branches into the local function. var savedState = this.State; this.State = this.TopState(); Optional<TLocalState> savedNonMonotonicState = NonMonotonicState; if (_nonMonotonicTransfer) { NonMonotonicState = ReachableBottomState(); } if (!localFunc.WasCompilerGenerated) EnterParameters(localFuncSymbol.Parameters); // State changes to captured variables are recorded, as calls to local functions // transition the state of captured variables if the variables have state changes // across all branches leaving the local function var localFunctionState = GetOrCreateLocalFuncUsages(localFuncSymbol); var savedLocalFunctionState = LocalFunctionStart(localFunctionState); var oldPending2 = SavePending(); // If this is an iterator, there's an implicit branch before the first statement // of the function where the enumerable is returned. if (localFuncSymbol.IsIterator) { PendingBranches.Add(new PendingBranch(null, this.State, null)); } VisitAlways(localFunc.Body); RestorePending(oldPending2); // process any forward branches within the lambda body ImmutableArray<PendingBranch> pendingReturns = RemoveReturns(); RestorePending(oldPending); Location? location = null; if (!localFuncSymbol.Locations.IsDefaultOrEmpty) { location = localFuncSymbol.Locations[0]; } LeaveParameters(localFuncSymbol.Parameters, localFunc.Syntax, location); // Intersect the state of all branches out of the local function var stateAtReturn = this.State; foreach (PendingBranch pending in pendingReturns) { this.State = pending.State; BoundNode branch = pending.Branch; // Pass the local function identifier as a location if the branch // is null or compiler generated. LeaveParameters(localFuncSymbol.Parameters, branch?.Syntax, branch?.WasCompilerGenerated == false ? null : location); Join(ref stateAtReturn, ref this.State); } // Record any changes to the state of captured variables if (RecordStateChange( savedLocalFunctionState, localFunctionState, ref stateAtReturn) && localFunctionState.Visited) { // If the sets have changed and we already used the results // of this local function in another computation, the previous // calculations may be invalid. We need to analyze until we // reach a fixed-point. stateChangedAfterUse = true; localFunctionState.Visited = false; } this.State = savedState; NonMonotonicState = savedNonMonotonicState; this.CurrentSymbol = oldSymbol; return null; } private bool RecordStateChange( TLocalFunctionState savedState, TLocalFunctionState currentState, ref TLocalState stateAtReturn) { bool anyChanged = LocalFunctionEnd(savedState, currentState, ref stateAtReturn); anyChanged |= Join(ref currentState.StateFromTop, ref stateAtReturn); if (NonMonotonicState.HasValue) { var value = NonMonotonicState.Value; // Since only state moving up gets stored in the non-monotonic state, // Meet with the stateAtReturn, which records all state changes. If // a state moved up, then down, the final state should be down. Meet(ref value, ref stateAtReturn); anyChanged |= Join(ref currentState.StateFromBottom, ref value); } return anyChanged; } /// <summary> /// Executed at the start of visiting a local function body. The <paramref name="state"/> /// parameter holds the current state information for the local function being visited. To /// save state information across the analysis, return an instance of <typeparamref name="TLocalFunctionState"/>. /// </summary> protected virtual TLocalFunctionState LocalFunctionStart(TLocalFunctionState state) => state; /// <summary> /// Executed after visiting a local function body. The <paramref name="savedState"/> is the /// return value from <see cref="LocalFunctionStart(TLocalFunctionState)"/>. The <paramref name="currentState"/> /// is state information for the local function that was just visited. <paramref name="stateAtReturn"/> is /// the state after visiting the method. /// </summary> protected virtual bool LocalFunctionEnd( TLocalFunctionState savedState, TLocalFunctionState currentState, ref TLocalState stateAtReturn) { return false; } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/TestUtilities2/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <OutputType>Library</OutputType> <TargetFramework>net472</TargetFramework> <UseWpf>true</UseWpf> <RootNamespace></RootNamespace> <IsShipping>false</IsShipping> </PropertyGroup> <ItemGroup Label="Project References"> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" /> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" /> <ProjectReference Include="..\..\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" /> <ProjectReference Include="..\..\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj" /> <ProjectReference Include="..\..\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" /> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" /> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" /> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" /> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" /> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" /> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" /> <ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" /> <ProjectReference Include="..\..\Compilers\Test\Utilities\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Test.Utilities.vbproj" /> <ProjectReference Include="..\TestUtilities\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Composition" Version="$(MicrosoftVisualStudioCompositionVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Platform.VSEditor" Version="$(MicrosoftVisualStudioPlatformVSEditorVersion)" /> <PackageReference Include="Microsoft.VisualStudio.InteractiveWindow" Version="$(MicrosoftVisualStudioInteractiveWindowVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Editor" Version="$(MicrosoftVisualStudioEditorVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging" Version="$(MicrosoftVisualStudioImagingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="$(MicrosoftVisualStudioImagingInterop140DesignTimeVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Interop" Version="$(MicrosoftVisualStudioInteropVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(MicrosoftVisualStudioLanguageIntellisenseVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Language.CallHierarchy" Version="$(MicrosoftVisualStudioLanguageCallHierarchyVersion)" /> <!-- Microsoft.VisualStudio.Platform.VSEditor references Microsoft.VisualStudio.Text.Internal since it's needed at runtime; we want to insure we are using it _only_ for runtime dependencies and not anything compile time --> <PackageReference Include="Microsoft.VisualStudio.Text.Internal" Version="$(MicrosoftVisualStudioTextInternalVersion)" IncludeAssets="runtime" /> <PackageReference Include="Microsoft.VisualStudio.Text.UI" Version="$(MicrosoftVisualStudioTextUIVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.UI.Wpf" Version="$(MicrosoftVisualStudioTextUIWpfVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Utilities" Version="$(MicrosoftVisualStudioUtilitiesVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Validation" Version="$(MicrosoftVisualStudioValidationVersion)" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.CodeAnalysis.Editor" /> <Import Include="Microsoft.CodeAnalysis.Shared.Extensions" /> <Import Include="Roslyn.Test.Utilities" /> <Import Include="System.Threading.Tasks"/> <Import Include="System.Xml.Linq" /> <Import Include="Xunit" /> </ItemGroup> <ItemGroup> <Folder Include="My Project\" /> </ItemGroup> </Project>
<?xml version="1.0" encoding="utf-8"?> <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <OutputType>Library</OutputType> <TargetFramework>net472</TargetFramework> <UseWpf>true</UseWpf> <RootNamespace></RootNamespace> <IsShipping>false</IsShipping> </PropertyGroup> <ItemGroup Label="Project References"> <ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" /> <ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" /> <ProjectReference Include="..\..\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" /> <ProjectReference Include="..\..\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj" /> <ProjectReference Include="..\..\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj" /> <ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" /> <ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj" /> <ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" /> <ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" /> <ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" /> <ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" /> <ProjectReference Include="..\..\EditorFeatures\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" /> <ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" /> <ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" /> <ProjectReference Include="..\..\Compilers\Test\Utilities\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Test.Utilities.vbproj" /> <ProjectReference Include="..\TestUtilities\Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Composition" Version="$(MicrosoftVisualStudioCompositionVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Platform.VSEditor" Version="$(MicrosoftVisualStudioPlatformVSEditorVersion)" /> <PackageReference Include="Microsoft.VisualStudio.InteractiveWindow" Version="$(MicrosoftVisualStudioInteractiveWindowVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Editor" Version="$(MicrosoftVisualStudioEditorVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging" Version="$(MicrosoftVisualStudioImagingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="$(MicrosoftVisualStudioImagingInterop140DesignTimeVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Interop" Version="$(MicrosoftVisualStudioInteropVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(MicrosoftVisualStudioLanguageIntellisenseVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Language.CallHierarchy" Version="$(MicrosoftVisualStudioLanguageCallHierarchyVersion)" /> <!-- Microsoft.VisualStudio.Platform.VSEditor references Microsoft.VisualStudio.Text.Internal since it's needed at runtime; we want to insure we are using it _only_ for runtime dependencies and not anything compile time --> <PackageReference Include="Microsoft.VisualStudio.Text.Internal" Version="$(MicrosoftVisualStudioTextInternalVersion)" IncludeAssets="runtime" /> <PackageReference Include="Microsoft.VisualStudio.Text.UI" Version="$(MicrosoftVisualStudioTextUIVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Text.UI.Wpf" Version="$(MicrosoftVisualStudioTextUIWpfVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Utilities" Version="$(MicrosoftVisualStudioUtilitiesVersion)" /> <PackageReference Include="Microsoft.VisualStudio.Validation" Version="$(MicrosoftVisualStudioValidationVersion)" /> </ItemGroup> <ItemGroup> <InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> <InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.CodeAnalysis.Editor" /> <Import Include="Microsoft.CodeAnalysis.Shared.Extensions" /> <Import Include="Roslyn.Test.Utilities" /> <Import Include="System.Threading.Tasks"/> <Import Include="System.Xml.Linq" /> <Import Include="Xunit" /> </ItemGroup> <ItemGroup> <Folder Include="My Project\" /> </ItemGroup> </Project>
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/EditorFeatures/VisualBasicTest/Formatting/VisualBasicNewDocumentFormattingServiceTests.vb
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.CodeStyle Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Test.Utilities.Formatting Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Formatting Public Class VisualBasicNewDocumentFormattingServiceTests Inherits AbstractNewDocumentFormattingServiceTests Protected Overrides ReadOnly Property Language As String = LanguageNames.VisualBasic Protected Overrides Function CreateTestWorkspace(testCode As String, parseOptions As ParseOptions) As TestWorkspace Return TestWorkspace.CreateVisualBasic(testCode, parseOptions) End Function <Fact> Public Async Function TestFileBanners() As Task Await TestAsync( testCode:="Imports System Namespace Goo End Namespace", expected:="' This is a banner. Imports System Namespace Goo End Namespace", options:={(CodeStyleOptions2.FileHeaderTemplate, "This is a banner.")}) End Function <Fact> Public Async Function TestOrganizeUsings() As Task Await TestAsync( testCode:="Imports Aaa Imports System Namespace Goo End Namespace", expected:="Imports System Imports Aaa Namespace Goo End Namespace") End Function End Class End Namespace
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.CodeStyle Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Test.Utilities.Formatting Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Formatting Public Class VisualBasicNewDocumentFormattingServiceTests Inherits AbstractNewDocumentFormattingServiceTests Protected Overrides ReadOnly Property Language As String = LanguageNames.VisualBasic Protected Overrides Function CreateTestWorkspace(testCode As String, parseOptions As ParseOptions) As TestWorkspace Return TestWorkspace.CreateVisualBasic(testCode, parseOptions) End Function <Fact> Public Async Function TestFileBanners() As Task Await TestAsync( testCode:="Imports System Namespace Goo End Namespace", expected:="' This is a banner. Imports System Namespace Goo End Namespace", options:={(CodeStyleOptions2.FileHeaderTemplate, "This is a banner.")}) End Function <Fact> Public Async Function TestOrganizeUsings() As Task Await TestAsync( testCode:="Imports Aaa Imports System Namespace Goo End Namespace", expected:="Imports System Imports Aaa Namespace Goo End Namespace") End Function End Class End Namespace
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/IntegrationTest/TestUtilities/InProcess/ObjectBrowserWindow_InProc.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Microsoft.VisualStudio.Shell.Interop; namespace Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess { internal class ObjectBrowserWindow_InProc : InProcComponent { public static ObjectBrowserWindow_InProc Create() => new ObjectBrowserWindow_InProc(); public bool CloseWindow() { return InvokeOnUIThread(cancellationToken => { var uiShell = GetGlobalService<SVsUIShell, IVsUIShell>(); if (ErrorHandler.Failed(uiShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFrameOnly, new Guid(ToolWindowGuids.ObjectBrowser), out var frame))) { return false; } ErrorHandler.ThrowOnFailure(frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave)); return true; }); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using Microsoft.VisualStudio.Shell.Interop; namespace Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess { internal class ObjectBrowserWindow_InProc : InProcComponent { public static ObjectBrowserWindow_InProc Create() => new ObjectBrowserWindow_InProc(); public bool CloseWindow() { return InvokeOnUIThread(cancellationToken => { var uiShell = GetGlobalService<SVsUIShell, IVsUIShell>(); if (ErrorHandler.Failed(uiShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFrameOnly, new Guid(ToolWindowGuids.ObjectBrowser), out var frame))) { return false; } ErrorHandler.ThrowOnFailure(frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave)); return true; }); } } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Core/Test/CodeModel/AbstractCodeModelObjectTests.FunctionData.vb
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel Partial Public MustInherit Class AbstractCodeModelObjectTests(Of TCodeModelObject As Class) Protected Class FunctionData Public Property Name As String Public Property Kind As EnvDTE.vsCMFunction = EnvDTE.vsCMFunction.vsCMFunctionFunction Public Property Type As Object Public Property Position As Object = 0 Public Property Access As EnvDTE.vsCMAccess = EnvDTE.vsCMAccess.vsCMAccessDefault Public Property Location As Object End Class End Class End Namespace
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel Partial Public MustInherit Class AbstractCodeModelObjectTests(Of TCodeModelObject As Class) Protected Class FunctionData Public Property Name As String Public Property Kind As EnvDTE.vsCMFunction = EnvDTE.vsCMFunction.vsCMFunctionFunction Public Property Type As Object Public Property Position As Object = 0 Public Property Access As EnvDTE.vsCMAccess = EnvDTE.vsCMAccess.vsCMAccessDefault Public Property Location As Object End Class End Class End Namespace
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Core/Def/Implementation/FindReferences/NameMetadata.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using Roslyn.Utilities; namespace Microsoft.VisualStudio.LanguageServices.FindUsages { internal class NameMetadata { public string? Name { get; } public NameMetadata(IDictionary<string, object> data) => this.Name = (string?)data.GetValueOrDefault(nameof(Name)); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using Roslyn.Utilities; namespace Microsoft.VisualStudio.LanguageServices.FindUsages { internal class NameMetadata { public string? Name { get; } public NameMetadata(IDictionary<string, object> data) => this.Name = (string?)data.GetValueOrDefault(nameof(Name)); } }
-1
dotnet/roslyn
55,484
Remove obsolete UnitTesting and Razor External Access APIs
tmat
2021-08-06T23:36:46Z
2021-08-10T20:32:36Z
909e6dc8eda8ee5898b4e1339c512c44970bcff6
3d0d94801b78fd6d22afb36d26c834f5056e7e62
Remove obsolete UnitTesting and Razor External Access APIs.
./src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyCommandHandler.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Generic; using System.ComponentModel.Composition; using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.CodeAnalysis.Editor.Host; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.Notification; using Microsoft.CodeAnalysis.SymbolMapping; using Microsoft.VisualStudio.Commanding; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; using Microsoft.VisualStudio.Utilities; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.Implementation.CallHierarchy { [Export(typeof(ICommandHandler))] [ContentType(ContentTypeNames.CSharpContentType)] [ContentType(ContentTypeNames.VisualBasicContentType)] [Name("CallHierarchy")] [Order(After = PredefinedCommandHandlerNames.DocumentationComments)] internal class CallHierarchyCommandHandler : ICommandHandler<ViewCallHierarchyCommandArgs> { private readonly IThreadingContext _threadingContext; private readonly ICallHierarchyPresenter _presenter; private readonly CallHierarchyProvider _provider; public string DisplayName => EditorFeaturesResources.Call_Hierarchy; [ImportingConstructor] [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] public CallHierarchyCommandHandler( IThreadingContext threadingContext, [ImportMany] IEnumerable<ICallHierarchyPresenter> presenters, CallHierarchyProvider provider) { _threadingContext = threadingContext; _presenter = presenters.FirstOrDefault(); _provider = provider; } public bool ExecuteCommand(ViewCallHierarchyCommandArgs args, CommandExecutionContext context) { using (var waitScope = context.OperationContext.AddScope(allowCancellation: true, EditorFeaturesResources.Computing_Call_Hierarchy_Information)) { var cancellationToken = context.OperationContext.UserCancellationToken; var document = args.SubjectBuffer.CurrentSnapshot.GetFullyLoadedOpenDocumentInCurrentContextWithChanges( context.OperationContext, _threadingContext); if (document == null) { return true; } var workspace = document.Project.Solution.Workspace; var semanticModel = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken); var caretPosition = args.TextView.Caret.Position.BufferPosition.Position; var symbolUnderCaret = SymbolFinder.FindSymbolAtPositionAsync(semanticModel, caretPosition, workspace, cancellationToken) .WaitAndGetResult(cancellationToken); if (symbolUnderCaret != null) { // Map symbols so that Call Hierarchy works from metadata-as-source var mappingService = document.Project.Solution.Workspace.Services.GetService<ISymbolMappingService>(); var mapping = mappingService.MapSymbolAsync(document, symbolUnderCaret, cancellationToken).WaitAndGetResult(cancellationToken); if (mapping.Symbol != null) { var node = _provider.CreateItemAsync(mapping.Symbol, mapping.Project, SpecializedCollections.EmptyEnumerable<Location>(), cancellationToken).WaitAndGetResult(cancellationToken); if (node != null) { _presenter.PresentRoot((CallHierarchyItem)node); return true; } } } // Haven't found suitable hierarchy -> caret wasn't on symbol that can have call hierarchy. // // We are about to show a modal UI dialog so we should take over the command execution // wait context. That means the command system won't attempt to show its own wait dialog // and also will take it into consideration when measuring command handling duration. waitScope.Context.TakeOwnership(); var notificationService = document.Project.Solution.Workspace.Services.GetService<INotificationService>(); notificationService.SendNotification(EditorFeaturesResources.Cursor_must_be_on_a_member_name, severity: NotificationSeverity.Information); } return true; } public CommandState GetCommandState(ViewCallHierarchyCommandArgs args) => CommandState.Available; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.Collections.Generic; using System.ComponentModel.Composition; using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.CodeAnalysis.Editor.Host; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.Notification; using Microsoft.CodeAnalysis.SymbolMapping; using Microsoft.VisualStudio.Commanding; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; using Microsoft.VisualStudio.Utilities; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.Implementation.CallHierarchy { [Export(typeof(ICommandHandler))] [ContentType(ContentTypeNames.CSharpContentType)] [ContentType(ContentTypeNames.VisualBasicContentType)] [Name("CallHierarchy")] [Order(After = PredefinedCommandHandlerNames.DocumentationComments)] internal class CallHierarchyCommandHandler : ICommandHandler<ViewCallHierarchyCommandArgs> { private readonly IThreadingContext _threadingContext; private readonly ICallHierarchyPresenter _presenter; private readonly CallHierarchyProvider _provider; public string DisplayName => EditorFeaturesResources.Call_Hierarchy; [ImportingConstructor] [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] public CallHierarchyCommandHandler( IThreadingContext threadingContext, [ImportMany] IEnumerable<ICallHierarchyPresenter> presenters, CallHierarchyProvider provider) { _threadingContext = threadingContext; _presenter = presenters.FirstOrDefault(); _provider = provider; } public bool ExecuteCommand(ViewCallHierarchyCommandArgs args, CommandExecutionContext context) { using (var waitScope = context.OperationContext.AddScope(allowCancellation: true, EditorFeaturesResources.Computing_Call_Hierarchy_Information)) { var cancellationToken = context.OperationContext.UserCancellationToken; var document = args.SubjectBuffer.CurrentSnapshot.GetFullyLoadedOpenDocumentInCurrentContextWithChanges( context.OperationContext, _threadingContext); if (document == null) { return true; } var workspace = document.Project.Solution.Workspace; var semanticModel = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken); var caretPosition = args.TextView.Caret.Position.BufferPosition.Position; var symbolUnderCaret = SymbolFinder.FindSymbolAtPositionAsync(semanticModel, caretPosition, workspace, cancellationToken) .WaitAndGetResult(cancellationToken); if (symbolUnderCaret != null) { // Map symbols so that Call Hierarchy works from metadata-as-source var mappingService = document.Project.Solution.Workspace.Services.GetService<ISymbolMappingService>(); var mapping = mappingService.MapSymbolAsync(document, symbolUnderCaret, cancellationToken).WaitAndGetResult(cancellationToken); if (mapping.Symbol != null) { var node = _provider.CreateItemAsync(mapping.Symbol, mapping.Project, SpecializedCollections.EmptyEnumerable<Location>(), cancellationToken).WaitAndGetResult(cancellationToken); if (node != null) { _presenter.PresentRoot((CallHierarchyItem)node); return true; } } } // Haven't found suitable hierarchy -> caret wasn't on symbol that can have call hierarchy. // // We are about to show a modal UI dialog so we should take over the command execution // wait context. That means the command system won't attempt to show its own wait dialog // and also will take it into consideration when measuring command handling duration. waitScope.Context.TakeOwnership(); var notificationService = document.Project.Solution.Workspace.Services.GetService<INotificationService>(); notificationService.SendNotification(EditorFeaturesResources.Cursor_must_be_on_a_member_name, severity: NotificationSeverity.Information); } return true; } public CommandState GetCommandState(ViewCallHierarchyCommandArgs args) => CommandState.Available; } }
-1