提交 be5e470c 编写于 作者: M Manish Vasani

Address feedback and represent VB GetType as ITypeOfExpression and also revert...

Address feedback and represent VB GetType as ITypeOfExpression and also revert unintentional change to solution file
上级 9ef6950a
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.8
VisualStudioVersion = 15.0.26405.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
EndProject
......@@ -158,6 +159,7 @@ Global
src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{8ce3a581-2969-4864-a803-013e9d977c3a}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13
......@@ -167,6 +169,7 @@ Global
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*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\Compilers\Core\CommandLine\CommandLine.projitems*{e3cd2895-76a8-4d11-a316-ea67cb5ea42c}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -470,7 +473,4 @@ Global
{0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {B20208C3-D3A6-4020-A274-6BE3786D29FB}
{E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {B20208C3-D3A6-4020-A274-6BE3786D29FB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7EE533BB-45F7-44C7-BEA2-29E32F6A850C}
EndGlobalSection
EndGlobal
......@@ -123,6 +123,8 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return CreateBoundTernaryConditionalExpressionOperation(DirectCast(boundNode, BoundTernaryConditionalExpression))
Case BoundKind.TypeOf
Return CreateBoundTypeOfOperation(DirectCast(boundNode, BoundTypeOf))
Case BoundKind.GetType
Return CreateBoundGetTypeOperation(DirectCast(boundNode, BoundGetType))
Case BoundKind.ObjectCreationExpression
Return CreateBoundObjectCreationExpressionOperation(DirectCast(boundNode, BoundObjectCreationExpression))
Case BoundKind.ObjectInitializerExpression
......@@ -590,6 +592,15 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return New LazyIsTypeExpression(operand, isType, isNotTypeExpression, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundGetTypeOperation(boundGetType As BoundGetType) As ITypeOfExpression
Dim typeOperand As ITypeSymbol = boundGetType.SourceType.Type
Dim syntax As SyntaxNode = boundGetType.Syntax
Dim type As ITypeSymbol = boundGetType.Type
Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundGetType.ConstantValueOpt)
Dim isImplicit As Boolean = boundGetType.WasCompilerGenerated
Return New TypeOfExpression(typeOperand, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundLateInvocationOperation(boundLateInvocation As BoundLateInvocation) As IOperation
Dim expression As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundLateInvocation.Member))
Dim arguments As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))(
......
......@@ -558,7 +558,8 @@ IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax:
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
IArgument (ArgumentKind.Explicit, Matching Parameter: y) (OperationKind.Argument) (Syntax: 'GetType(Integer)')
IOperation: (OperationKind.None) (Syntax: 'GetType(Integer)')
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type) (Syntax: 'GetType(Integer)')
TypeOperand: System.Int32
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
......@@ -576,7 +577,8 @@ IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax:
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
IArgument (ArgumentKind.Explicit, Matching Parameter: y) (OperationKind.Argument) (Syntax: 'GetType(Object)')
IOperation: (OperationKind.None) (Syntax: 'GetType(Object)')
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type) (Syntax: 'GetType(Object)')
TypeOperand: System.Object
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
Partial Public Class IOperationTests
Inherits SemanticModelTestBase
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestGetType()
Dim source = <![CDATA[
Imports System
Class C
Sub M(t As Type)
t = GetType(Integer)'BIND:"GetType(Integer)"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type) (Syntax: 'GetType(Integer)')
TypeOperand: System.Int32
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of GetTypeExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestGetType_NonPrimitiveTypeArgument()
Dim source = <![CDATA[
Imports System
Class C
Sub M(t As Type)
t = GetType(C)'BIND:"GetType(C)"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type) (Syntax: 'GetType(C)')
TypeOperand: C
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of GetTypeExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestGetType_ErrorTypeArgument()
Dim source = <![CDATA[
Imports System
Class C
Sub M(t As Type)
t = GetType(UndefinedType)'BIND:"GetType(UndefinedType)"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'GetType(UndefinedType)')
TypeOperand: UndefinedType
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30002: Type 'UndefinedType' is not defined.
t = GetType(UndefinedType)'BIND:"GetType(UndefinedType)"
~~~~~~~~~~~~~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of GetTypeExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestGetType_IdentifierArgument()
Dim source = <![CDATA[
Imports System
Class C
Sub M(t As Type)
t = GetType(t)'BIND:"GetType(t)"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'GetType(t)')
TypeOperand: t
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30002: Type 't' is not defined.
t = GetType(t)'BIND:"GetType(t)"
~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of GetTypeExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestGetType_ExpressionArgument()
Dim source = <![CDATA[
Imports System
Class C
Sub M(t As Type)
t = GetType(M2())'BIND:"GetType(M2())"
End Sub
Function M2() As Type
Return Nothing
End Function
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'GetType(M2())')
TypeOperand: M2()
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30002: Type 'M2' is not defined.
t = GetType(M2())'BIND:"GetType(M2())"
~~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of GetTypeExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestGetType_MissingArgument()
Dim source = <![CDATA[
Imports System
Class C
Sub M(t As Type)
t = GetType()'BIND:"GetType()"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'GetType()')
TypeOperand: ?
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30182: Type expected.
t = GetType()'BIND:"GetType()"
~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of GetTypeExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册