Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to IOperation test dumper #18464

Merged
merged 8 commits into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ static void Test2(int y, params int[] x)
var nodes = tree.GetRoot().DescendantNodes().OfType<InvocationExpressionSyntax>().ToArray();

compilation.VerifyOperationTree(nodes[0], expectedOperationTree:
@"IInvocationExpression (static void Cls.Test1(params System.Int32[] x)) (OperationKind.InvocationExpression, Type: System.Void)
IArgument (Matching Parameter: x) (OperationKind.Argument)
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Int32[], Constant: null)
ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null)");
@"IInvocationExpression (static void Cls.Test1(params System.Int32[] x)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Test1(null)')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'null')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Int32[], Constant: null) (Syntax: 'null')
ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null')");

compilation.VerifyOperationTree(nodes[1], expectedOperationTree:
@"IInvocationExpression (static void Cls.Test2(System.Int32 y, params System.Int32[] x)) (OperationKind.InvocationExpression, Type: System.Void, IsInvalid)
IArgument (Matching Parameter: y) (OperationKind.Argument)
IObjectCreationExpression (Constructor: System.Object..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Object)
IArgument (Matching Parameter: x) (OperationKind.Argument)
ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null)");
@"IInvocationExpression (static void Cls.Test2(System.Int32 y, params System.Int32[] x)) (OperationKind.InvocationExpression, Type: System.Void, IsInvalid) (Syntax: 'Test2(new o ... ct(), null)')
Arguments(2): IArgument (Matching Parameter: y) (OperationKind.Argument) (Syntax: 'new object()')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguments(2): IArgument (Matching Parameter: y) (OperationKind.Argument) (Syntax: 'new object()') [](start = 2, length = 97)

It might be more readable to start the first argument on the new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll leave that as a separate change..

IObjectCreationExpression (Constructor: System.Object..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Object) (Syntax: 'new object()')
IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'null')
ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null')");
}

[Fact]
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/Compilers/Test/Utilities/CSharp/SemanticModelTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ protected string GetOperationTreeForTest<TSyntaxNode>(CSharpCompilation compilat
return operation != null ? OperationTreeVerifier.GetOperationTree(operation) : null;
}

protected string GetOperationTreeForTest<TSyntaxNode>(string testSrc, string expectedOperationTree, CSharpParseOptions parseOptions = null)
protected string GetOperationTreeForTest<TSyntaxNode>(string testSrc, string expectedOperationTree, CSharpCompilationOptions compilationOptions = null, CSharpParseOptions parseOptions = null)
where TSyntaxNode : SyntaxNode
{
var compilation = CreateCompilationWithMscorlib(testSrc, new[] { SystemCoreRef }, parseOptions: parseOptions);
var compilation = CreateCompilationWithMscorlib(testSrc, new[] { SystemCoreRef }, options: compilationOptions ?? TestOptions.ReleaseDll, parseOptions: parseOptions);
return GetOperationTreeForTest<TSyntaxNode>(compilation);
}

Expand All @@ -250,10 +250,10 @@ protected void VerifyOperationTreeForTest<TSyntaxNode>(CSharpCompilation compila
OperationTreeVerifier.Verify(expectedOperationTree, actualOperationTree);
}

protected void VerifyOperationTreeForTest<TSyntaxNode>(string testSrc, string expectedOperationTree, CSharpParseOptions parseOptions = null)
protected void VerifyOperationTreeForTest<TSyntaxNode>(string testSrc, string expectedOperationTree, CSharpCompilationOptions compilationOptions = null, CSharpParseOptions parseOptions = null)
where TSyntaxNode : SyntaxNode
{
var actualOperationTree = GetOperationTreeForTest<TSyntaxNode>(testSrc, expectedOperationTree, parseOptions);
var actualOperationTree = GetOperationTreeForTest<TSyntaxNode>(testSrc, expectedOperationTree, compilationOptions, parseOptions);
OperationTreeVerifier.Verify(expectedOperationTree, actualOperationTree);
}

Expand All @@ -265,10 +265,10 @@ protected void VerifyOperationTreeAndDiagnosticsForTest<TSyntaxNode>(CSharpCompi
VerifyOperationTreeForTest<TSyntaxNode>(compilation, expectedOperationTree);
}

protected void VerifyOperationTreeAndDiagnosticsForTest<TSyntaxNode>(string testSrc, string expectedOperationTree, DiagnosticDescription[] expectedDiagnostics, CSharpParseOptions parseOptions = null)
protected void VerifyOperationTreeAndDiagnosticsForTest<TSyntaxNode>(string testSrc, string expectedOperationTree, DiagnosticDescription[] expectedDiagnostics, CSharpCompilationOptions compilationOptions = null, CSharpParseOptions parseOptions = null)
where TSyntaxNode : SyntaxNode
{
var compilation = CreateCompilationWithMscorlib(testSrc, new[] { SystemCoreRef }, parseOptions: parseOptions);
var compilation = CreateCompilationWithMscorlib(testSrc, new[] { SystemCoreRef }, options: compilationOptions ?? TestOptions.ReleaseDll, parseOptions: parseOptions);
VerifyOperationTreeAndDiagnosticsForTest<TSyntaxNode>(compilation, expectedOperationTree, expectedDiagnostics);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ Public MustInherit Class SemanticModelTestBase : Inherits BasicTestBase
Return If(operation IsNot Nothing, OperationTreeVerifier.GetOperationTree(operation), Nothing)
End Function

Friend Function GetOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0) As String
Friend Function GetOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, Optional compilationOptions As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0) As String
Dim fileName = "a.vb"
Dim syntaxTree = Parse(testSrc, fileName, parseOptions)
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:={SystemRef, SystemCoreRef})
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:={SystemRef, SystemCoreRef}, options:=If(compilationOptions, TestOptions.ReleaseDll))
Return GetOperationTreeForTest(Of TSyntaxNode)(compilation, fileName, which)
End Function

Expand All @@ -178,13 +178,13 @@ Public MustInherit Class SemanticModelTestBase : Inherits BasicTestBase
OperationTreeVerifier.Verify(expectedOperationTree, actualOperationTree)
End Sub

Friend Sub VerifyOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, expectedOperationTree As String, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Dim actualOperationTree = GetOperationTreeForTest(Of TSyntaxNode)(testSrc, parseOptions, which)
Friend Sub VerifyOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, expectedOperationTree As String, Optional compilationOptions As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Dim actualOperationTree = GetOperationTreeForTest(Of TSyntaxNode)(testSrc, compilationOptions, parseOptions, which)
OperationTreeVerifier.Verify(expectedOperationTree, actualOperationTree)
End Sub

Friend Sub VerifyNoOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Dim actualOperationTree = GetOperationTreeForTest(Of TSyntaxNode)(testSrc, parseOptions, which)
Friend Sub VerifyNoOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, Optional compilationOptions As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Dim actualOperationTree = GetOperationTreeForTest(Of TSyntaxNode)(testSrc, compilationOptions, parseOptions, which)
Assert.Null(actualOperationTree)
End Sub

Expand All @@ -193,10 +193,10 @@ Public MustInherit Class SemanticModelTestBase : Inherits BasicTestBase
VerifyOperationTreeForTest(Of TSyntaxNode)(compilation, fileName, expectedOperationTree, which)
End Sub

Friend Sub VerifyOperationTreeAndDiagnosticsForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, expectedOperationTree As String, expectedDiagnostics As String, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Friend Sub VerifyOperationTreeAndDiagnosticsForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, expectedOperationTree As String, expectedDiagnostics As String, Optional compilationOptions As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Dim fileName = "a.vb"
Dim syntaxTree = Parse(testSrc, fileName, parseOptions)
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:={SystemRef, SystemCoreRef})
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:={SystemRef, SystemCoreRef}, options:=If(compilationOptions, TestOptions.ReleaseDll))
VerifyOperationTreeAndDiagnosticsForTest(Of TSyntaxNode)(compilation, fileName, expectedOperationTree, expectedDiagnostics, which)
End Sub

Expand Down
Loading