public void OnlyOneParse() { var underlyingTree = SyntaxFactory.ParseSyntaxTree( @" using System; class C { public B X(B b) { return b; } C(){} } " ); var foreignType = SyntaxFactory.ParseSyntaxTree( @" public class B { public int member(string s) { return s.Length; } B(){} } " ); var countedTree = new CountedSyntaxTree(foreignType); var compilation = CreateCompilation( new SyntaxTree[] { underlyingTree, countedTree }, skipUsesIsNullable: true, options: TestOptions.ReleaseDll ); var type = compilation.Assembly.GlobalNamespace.GetTypeMembers().First(); Assert.Equal(1, countedTree.AccessCount); // parse once to build the decl table // We shouldn't need to go back to syntax to get info about the member names. var memberNames = type.MemberNames; Assert.Equal(1, countedTree.AccessCount); // Getting the interfaces will cause us to do some more binding of the current type. var interfaces = type.Interfaces(); Assert.Equal(1, countedTree.AccessCount); // Now bind the members. var method = (MethodSymbol)type.GetMembers().First(); Assert.Equal(1, countedTree.AccessCount); // Once we have the method, we shouldn't need to go back to syntax again. var returnType = method.ReturnTypeWithAnnotations; Assert.Equal(1, countedTree.AccessCount); var parameterType = method.Parameters.Single(); Assert.Equal(1, countedTree.AccessCount); }
public Reference( CountedSyntaxTree countedSyntaxTree, SyntaxReference syntaxReference ) { _countedSyntaxTree = countedSyntaxTree; _underlyingSyntaxReference = syntaxReference; }
public void OnlyOneParse_WithReservedTypeName() { var underlyingTree = SyntaxFactory.ParseSyntaxTree(@" using System; class c { public b X(b b1) { return b1; } c(){} } "); var foreignType = SyntaxFactory.ParseSyntaxTree(@" public class b { public int member(string s) { return s.Length; } b(){} } "); var countedTree = new CountedSyntaxTree(foreignType); var compilation = CreateCompilation(new SyntaxTree[] { underlyingTree, countedTree }, skipUsesIsNullable: true, options: TestOptions.ReleaseDll); var type = compilation.Assembly.GlobalNamespace.GetTypeMembers().First(); Assert.Equal(1, countedTree.AccessCount); var memberNames = type.MemberNames; Assert.Equal(1, countedTree.AccessCount); var interfaces = type.Interfaces(); Assert.Equal(1, countedTree.AccessCount); var method = (MethodSymbol)type.GetMembers().First(); Assert.Equal(1, countedTree.AccessCount); var returnType = method.ReturnTypeWithAnnotations; Assert.Equal(1, countedTree.AccessCount); var parameterType = method.Parameters.Single(); Assert.Equal(1, countedTree.AccessCount); }
public Reference(CountedSyntaxTree countedSyntaxTree, SyntaxReference syntaxReference) { this.countedSyntaxTree = countedSyntaxTree; this.underlyingSyntaxReference = syntaxReference; }
public void OnlyOneParse() { var underlyingTree = SyntaxFactory.ParseSyntaxTree(@" using System; class C { public B X(B b) { return b; } C(){} } "); var foriegnType = SyntaxFactory.ParseSyntaxTree(@" public class B { public int member(string s) { return s.Length; } B(){} } "); var countedTree = new CountedSyntaxTree(foriegnType); var compilation = CreateCompilationWithMscorlib(new SyntaxTree[] { underlyingTree, countedTree }); var type = compilation.Assembly.GlobalNamespace.GetTypeMembers().First(); Assert.Equal(1, countedTree.AccessCount); // parse once to build the decl table // We shouldn't need to go back to syntax to get info about the member names. var memberNames = type.MemberNames; Assert.Equal(1, countedTree.AccessCount); // Getting the interfaces will cause us to do some more binding of the current type. var interfaces = type.Interfaces; Assert.Equal(1, countedTree.AccessCount); // Now bind the members. var method = (MethodSymbol)type.GetMembers().First(); Assert.Equal(1, countedTree.AccessCount); // Once we have the method, we shouldn't need to go back to syntax again. var returnType = method.ReturnType; Assert.Equal(1, countedTree.AccessCount); var parameterType = method.Parameters.Single(); Assert.Equal(1, countedTree.AccessCount); }
public Reference(CountedSyntaxTree countedSyntaxTree, SyntaxReference syntaxReference) { _countedSyntaxTree = countedSyntaxTree; _underlyingSyntaxReference = syntaxReference; }