This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tree = CSharpSyntaxTree.ParseText(@" | |
| class MyClass | |
| { | |
| int myField = 0; | |
| public int MyProperty {get; set;} | |
| public void MyMethod() { } | |
| }"); | |
| var Mscorlib = PortableExecutableReference.CreateFromAssembly(typeof(object).Assembly); | |
| var compilation = CSharpCompilation.Create("MyCompilation", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyClass | |
| { | |
| int myField1, myField2, myField3; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tree = CSharpSyntaxTree.ParseText(@" | |
| class MyClass | |
| class MyClass | |
| { | |
| int myField1, myField2, myField3; | |
| }"); | |
| var Mscorlib = PortableExecutableReference.CreateFromAssembly(typeof(object).Assembly); | |
| var compilation = CSharpCompilation.Create("MyCompilation", | |
| syntaxTrees: new[] { tree }, references: new[] { Mscorlib }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tree = CSharpSyntaxTree.ParseText(@" | |
| public class Sample | |
| { | |
| public void Foo() | |
| { | |
| int[] outerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; | |
| for (int index = 0; index < 10; index++) | |
| { | |
| int[] innerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; | |
| index = index + 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Sample | |
| { | |
| public void Foo() | |
| { | |
| int[] outerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; | |
| for (int index = 0; index < 10; index++) | |
| { | |
| int[] innerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; | |
| index = index + 2; | |
| outerArray[index - 1] = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Sample | |
| { | |
| public void Foo() | |
| { | |
| int[] outerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; | |
| for (int index = 0; index < 10; index++) | |
| { | |
| int[] innerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; | |
| index = index + 2; | |
| outerArray[index - 1] = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Sample | |
| { | |
| public void Foo() | |
| { | |
| int[] outerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; | |
| for (int index = 0; index < 10; index++) | |
| { | |
| int[] innerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; | |
| index = index + 2; | |
| outerArray[index - 1] = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tree = CSharpSyntaxTree.ParseText(@" | |
| public class Sample | |
| { | |
| public void Foo() | |
| { | |
| int[] outerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; | |
| for (int index = 0; index < 10; index++) | |
| { | |
| int[] innerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; | |
| index = index + 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tree = CSharpSyntaxTree.ParseText(@" | |
| class C | |
| { | |
| void M() | |
| { | |
| int variable = 0; | |
| //Does not bind to a symbol (as there is no class called MissingClass) | |
| //but it is not a true nameof expression | |
| MissingClass.nameof(x); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var nameOfExpression = SyntaxFactory.LocalDeclarationStatement( | |
| SyntaxFactory.VariableDeclaration( | |
| SyntaxFactory.PredefinedType( | |
| SyntaxFactory.Token( | |
| SyntaxKind.StringKeyword))) | |
| .WithVariables( | |
| SyntaxFactory.SingletonSeparatedList<VariableDeclaratorSyntax>( | |
| SyntaxFactory.VariableDeclarator( | |
| SyntaxFactory.Identifier( | |
| @"result")) |