提交 700099b8 编写于 作者: G Gen Lu

Change IRaiseEventExpressionn to IRaiseEventStatement

上级 55eea6c4
......@@ -2546,7 +2546,7 @@ public LazyInvalidStatement(Lazy<ImmutableArray<IOperation>> children, SemanticM
/// <summary>
/// Represents a C# or VB method invocation.
/// </summary>
internal abstract partial class BaseInvocationExpression : Operation, IHasArgumentsExpression, IInvocationExpression
internal abstract partial class BaseInvocationExpression : Operation, IHasArguments, IInvocationExpression
{
protected BaseInvocationExpression(IMethodSymbol targetMethod, bool isVirtual, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.InvocationExpression, semanticModel, syntax, type, constantValue, isImplicit)
......@@ -2600,7 +2600,7 @@ public override void Accept(OperationVisitor visitor)
/// <summary>
/// Represents a C# or VB method invocation.
/// </summary>
internal sealed partial class InvocationExpression : BaseInvocationExpression, IHasArgumentsExpression, IInvocationExpression
internal sealed partial class InvocationExpression : BaseInvocationExpression, IHasArguments, IInvocationExpression
{
public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(targetMethod, isVirtual, semanticModel, syntax, type, constantValue, isImplicit)
......@@ -2616,7 +2616,7 @@ internal sealed partial class InvocationExpression : BaseInvocationExpression, I
/// <summary>
/// Represents a C# or VB method invocation.
/// </summary>
internal sealed partial class LazyInvocationExpression : BaseInvocationExpression, IHasArgumentsExpression, IInvocationExpression
internal sealed partial class LazyInvocationExpression : BaseInvocationExpression, IHasArguments, IInvocationExpression
{
private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInEvaluationOrder;
......@@ -2633,12 +2633,12 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> ins
}
/// <summary>
/// Represents a VB raise event expression.
/// Represents a VB raise event statement.
/// </summary>
internal abstract partial class BaseRaiseEventExpression : Operation, IHasArgumentsExpression, IRaiseEventExpression
internal abstract partial class BaseRaiseEventStatement : Operation, IHasArguments, IRaiseEventStatement
{
protected BaseRaiseEventExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.RaiseEventExpression, semanticModel, syntax, type, constantValue, isImplicit)
protected BaseRaiseEventStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.RaiseEventStatement, semanticModel, syntax, type, constantValue, isImplicit)
{
}
......@@ -2665,20 +2665,20 @@ public override IEnumerable<IOperation> Children
public override void Accept(OperationVisitor visitor)
{
visitor.VisitRaiseEventExpression(this);
visitor.VisitRaiseEventStatement(this);
}
public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
return visitor.VisitRaiseEventExpression(this, argument);
return visitor.VisitRaiseEventStatement(this, argument);
}
}
/// <summary>
/// Represents a VB raise event expression.
/// Represents a VB raise event statement.
/// </summary>
internal sealed partial class RaiseEventExpression : BaseRaiseEventExpression, IHasArgumentsExpression, IRaiseEventExpression
internal sealed partial class RaiseEventStatement : BaseRaiseEventStatement, IHasArguments, IRaiseEventStatement
{
public RaiseEventExpression(IEventReferenceExpression eventReference, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
public RaiseEventStatement(IEventReferenceExpression eventReference, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(semanticModel, syntax, type, constantValue, isImplicit)
{
EventReferenceImpl = eventReference;
......@@ -2691,14 +2691,14 @@ internal sealed partial class RaiseEventExpression : BaseRaiseEventExpression, I
}
/// <summary>
/// Represents a VB raise event expression.
/// Represents a VB raise event statement.
/// </summary>
internal sealed partial class LazyRaiseEventExpression : BaseRaiseEventExpression, IHasArgumentsExpression, IRaiseEventExpression
internal sealed partial class LazyRaiseEventStatement : BaseRaiseEventStatement, IHasArguments, IRaiseEventStatement
{
private readonly Lazy<IEventReferenceExpression> _lazyEventReference;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInEvaluationOrder;
public LazyRaiseEventExpression(Lazy<IEventReferenceExpression> eventReference, Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
public LazyRaiseEventStatement(Lazy<IEventReferenceExpression> eventReference, Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(semanticModel, syntax, type, constantValue, isImplicit)
{
_lazyEventReference = eventReference;
......@@ -3302,7 +3302,7 @@ public LazyCoalesceExpression(Lazy<IOperation> expression, Lazy<IOperation> when
/// <summary>
/// Represents a new/New expression.
/// </summary>
internal abstract partial class BaseObjectCreationExpression : Operation, IHasArgumentsExpression, IObjectCreationExpression
internal abstract partial class BaseObjectCreationExpression : Operation, IHasArguments, IObjectCreationExpression
{
protected BaseObjectCreationExpression(IMethodSymbol constructor, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.ObjectCreationExpression, semanticModel, syntax, type, constantValue, isImplicit)
......@@ -3351,7 +3351,7 @@ public override void Accept(OperationVisitor visitor)
/// <summary>
/// Represents a new/New expression.
/// </summary>
internal sealed partial class ObjectCreationExpression : BaseObjectCreationExpression, IHasArgumentsExpression, IObjectCreationExpression
internal sealed partial class ObjectCreationExpression : BaseObjectCreationExpression, IHasArguments, IObjectCreationExpression
{
public ObjectCreationExpression(IMethodSymbol constructor, IObjectOrCollectionInitializerExpression initializer, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(constructor, semanticModel, syntax, type, constantValue, isImplicit)
......@@ -3367,7 +3367,7 @@ internal sealed partial class ObjectCreationExpression : BaseObjectCreationExpre
/// <summary>
/// Represents a new/New expression.
/// </summary>
internal sealed partial class LazyObjectCreationExpression : BaseObjectCreationExpression, IHasArgumentsExpression, IObjectCreationExpression
internal sealed partial class LazyObjectCreationExpression : BaseObjectCreationExpression, IHasArguments, IObjectCreationExpression
{
private readonly Lazy<IObjectOrCollectionInitializerExpression> _lazyInitializer;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInEvaluationOrder;
......@@ -3782,7 +3782,7 @@ internal sealed partial class LazyPropertyInitializer : BasePropertyInitializer,
/// <summary>
/// Represents a reference to a property.
/// </summary>
internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression
internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IPropertyReferenceExpression, IHasArguments
{
protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(member, OperationKind.PropertyReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
......@@ -3827,7 +3827,7 @@ public override void Accept(OperationVisitor visitor)
/// <summary>
/// Represents a reference to a property.
/// </summary>
internal sealed partial class PropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression
internal sealed partial class PropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArguments
{
public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(property, member, semanticModel, syntax, type, constantValue, isImplicit)
......@@ -3851,7 +3851,7 @@ public override void Accept(OperationVisitor visitor)
/// <summary>
/// Represents a reference to a property.
/// </summary>
internal sealed partial class LazyPropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression
internal sealed partial class LazyPropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArguments
{
private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInEvaluationOrder;
......
......@@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IHasArgumentsExpression : IOperation
public interface IHasArguments : IOperation
{
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order.
......
......@@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IInvocationExpression : IHasArgumentsExpression
public interface IInvocationExpression : IHasArguments
{
/// <summary>
/// Method to be invoked.
......
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IObjectCreationExpression : IHasArgumentsExpression
public interface IObjectCreationExpression : IHasArguments
{
/// <summary>
/// Constructor to be invoked on the created instance.
......
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IPropertyReferenceExpression : IMemberReferenceExpression, IHasArgumentsExpression
public interface IPropertyReferenceExpression : IMemberReferenceExpression, IHasArguments
{
/// <summary>
/// Referenced property.
......
......@@ -3,13 +3,13 @@
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents a raise event expression.
/// Represents a raise event statement.
/// </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 IRaiseEventExpression : IHasArgumentsExpression
public interface IRaiseEventStatement : IHasArguments
{
/// <summary>
/// Reference to the event to be raised.
......
......@@ -481,9 +481,9 @@ public override IOperation VisitTranslatedQueryExpression(ITranslatedQueryExpres
return new TranslatedQueryExpression(Visit(operation.Expression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitRaiseEventExpression(IRaiseEventExpression operation, object argument)
public override IOperation VisitRaiseEventStatement(IRaiseEventStatement operation, object argument)
{
return new RaiseEventExpression(Visit(operation.EventReference), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new RaiseEventStatement(Visit(operation.EventReference), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
}
}
......@@ -64,6 +64,8 @@ public enum OperationKind
// https://github.com/dotnet/roslyn/issues/22005
// /// <summary>Indicates an <see cref="IWithStatement"/>.</summary>
// WithStatement = 0x52,
/// <summary>Indicates an <see cref="IRaiseEventStatement"/>.</summary>
RaiseEventStatement = 0x53,
// Expressions
......@@ -176,8 +178,8 @@ public enum OperationKind
/// <summary>Indicates an <see cref="IOmittedArgumentExpression"/>.</summary>
OmittedArgumentExpression = 0x300,
/// <summary>Indicates an <see cref="IRaiseEventExpression"/>.</summary>
RaiseEventExpression = 0x301,
// Unused 0x301
// https://github.com/dotnet/roslyn/issues/21294
// /// <summary>Indicates an <see cref="IPlaceholderExpression"/>.</summary>
......
......@@ -485,7 +485,7 @@ public virtual void VisitTranslatedQueryExpression(ITranslatedQueryExpression op
DefaultVisit(operation);
}
public virtual void VisitRaiseEventExpression(IRaiseEventExpression operation)
public virtual void VisitRaiseEventStatement(IRaiseEventStatement operation)
{
DefaultVisit(operation);
}
......@@ -980,7 +980,7 @@ public virtual TResult VisitTranslatedQueryExpression(ITranslatedQueryExpression
return DefaultVisit(operation, argument);
}
public virtual TResult VisitRaiseEventExpression(IRaiseEventExpression operation, TArgument argument)
public virtual TResult VisitRaiseEventStatement(IRaiseEventStatement operation, TArgument argument)
{
return DefaultVisit(operation, argument);
}
......
......@@ -116,7 +116,7 @@ Microsoft.CodeAnalysis.OperationKind.ParameterReferenceExpression = 262 -> Micro
Microsoft.CodeAnalysis.OperationKind.ParenthesizedExpression = 282 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.PropertyInitializer = 1027 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.PropertyReferenceExpression = 266 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.RaiseEventExpression = 769 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.RaiseEventStatement = 83 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.ReturnStatement = 11 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SimpleAssignmentExpression = 280 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SizeOfExpression = 514 -> Microsoft.CodeAnalysis.OperationKind
......@@ -321,8 +321,8 @@ Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LimitValue.get -> Microsoft
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.StepValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression
Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Semantics.IArgument>
Microsoft.CodeAnalysis.Semantics.IHasArguments
Microsoft.CodeAnalysis.Semantics.IHasArguments.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Semantics.IArgument>
Microsoft.CodeAnalysis.Semantics.IHasOperatorMethodExpression
Microsoft.CodeAnalysis.Semantics.IHasOperatorMethodExpression.OperatorMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol
Microsoft.CodeAnalysis.Semantics.IHasOperatorMethodExpression.UsesOperatorMethod.get -> bool
......@@ -407,8 +407,8 @@ Microsoft.CodeAnalysis.Semantics.IPropertyInitializer
Microsoft.CodeAnalysis.Semantics.IPropertyInitializer.InitializedProperty.get -> Microsoft.CodeAnalysis.IPropertySymbol
Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression
Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol
Microsoft.CodeAnalysis.Semantics.IRaiseEventExpression
Microsoft.CodeAnalysis.Semantics.IRaiseEventExpression.EventReference.get -> Microsoft.CodeAnalysis.Semantics.IEventReferenceExpression
Microsoft.CodeAnalysis.Semantics.IRaiseEventStatement
Microsoft.CodeAnalysis.Semantics.IRaiseEventStatement.EventReference.get -> Microsoft.CodeAnalysis.Semantics.IEventReferenceExpression
Microsoft.CodeAnalysis.Semantics.IRangeCaseClause
Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MaximumValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MinimumValue.get -> Microsoft.CodeAnalysis.IOperation
......@@ -585,7 +585,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitParenthesizedExpr
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitPatternCaseClause(Microsoft.CodeAnalysis.Semantics.IPatternCaseClause operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitPropertyInitializer(Microsoft.CodeAnalysis.Semantics.IPropertyInitializer operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitPropertyReferenceExpression(Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRaiseEventExpression(Microsoft.CodeAnalysis.Semantics.IRaiseEventExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRaiseEventStatement(Microsoft.CodeAnalysis.Semantics.IRaiseEventStatement operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void
......@@ -675,7 +675,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.Vi
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitPatternCaseClause(Microsoft.CodeAnalysis.Semantics.IPatternCaseClause operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitPropertyInitializer(Microsoft.CodeAnalysis.Semantics.IPropertyInitializer operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitPropertyReferenceExpression(Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitRaiseEventExpression(Microsoft.CodeAnalysis.Semantics.IRaiseEventExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitRaiseEventStatement(Microsoft.CodeAnalysis.Semantics.IRaiseEventStatement operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation, TArgument argument) -> TResult
......
......@@ -1317,13 +1317,57 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundRaiseEventStatementOperation(boundRaiseEventStatement As BoundRaiseEventStatement) As IExpressionStatement
Dim expression As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() GetRaiseEventExpression(boundRaiseEventStatement))
Private Function CreateBoundRaiseEventStatementOperation(boundRaiseEventStatement As BoundRaiseEventStatement) As IOperation
Dim syntax As SyntaxNode = boundRaiseEventStatement.Syntax
Dim type As ITypeSymbol = Nothing
Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)()
Dim isImplicit As Boolean = boundRaiseEventStatement.WasCompilerGenerated
Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit)
Dim eventInvocation = TryCast(boundRaiseEventStatement.EventInvocation, BoundCall)
' Return an invalid statement for invalid raise event statement
If eventInvocation Is Nothing OrElse eventInvocation.ReceiverOpt Is Nothing
Debug.Assert(boundRaiseEventStatement.HasErrors)
Dim children As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))(Function() ImmutableArray.Create(Of IOperation)(Create(boundRaiseEventStatement.EventInvocation)))
return New LazyInvalidStatement(children, _semanticModel, syntax, type, constantValue, isImplicit)
End If
Dim receiver = eventInvocation.ReceiverOpt
Dim eventSymbol = boundRaiseEventStatement.EventSymbol
Dim eventReferenceSyntax = receiver.Syntax
Dim eventReferenceType As ITypeSymbol = eventSymbol.Type
Dim eventReferenceConstantValue As [Optional](Of Object) = ConvertToOptional(receiver.ConstantValueOpt)
dim eventReferenceIsImplicit as Boolean = eventInvocation.WasCompilerGenerated
Dim boundInstance As BoundNode
If receiver.Kind = BoundKind.FieldAccess
Dim eventFieldAccess = CType(eventInvocation.ReceiverOpt, BoundFieldAccess)
Debug.Assert(eventFieldAccess.FieldSymbol.AssociatedSymbol = eventSymbol)
boundInstance = eventFieldAccess.ReceiverOpt
Else
boundInstance = receiver
End If
Dim eventReferenceInstance As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() If(eventSymbol.IsShared, Nothing, Create(boundInstance)))
Dim EventReference As Lazy(Of IEventReferenceExpression) = New Lazy(Of IEventReferenceExpression)(Function() As IEventReferenceExpression
Return New LazyEventReferenceExpression(eventSymbol,
eventReferenceInstance,
eventSymbol,
_semanticModel,
eventReferenceSyntax,
eventReferenceType,
eventReferenceConstantValue,
eventReferenceIsImplicit)
End Function)
Dim argumentsInEvaluationOrder As Lazy(Of ImmutableArray(Of IArgument)) = New Lazy(Of ImmutableArray(Of IArgument))(
Function()
Return DeriveArguments(eventInvocation.Arguments, eventInvocation.Method.Parameters)
End Function)
Return New LazyRaiseEventStatement(eventReference, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundAddHandlerStatementOperation(boundAddHandlerStatement As BoundAddHandlerStatement) As IExpressionStatement
......
......@@ -269,50 +269,6 @@ Namespace Microsoft.CodeAnalysis.Semantics
eventReference, Create(statement.Handler), adds:=adds, semanticModel:=_semanticModel, syntax:=statement.Syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=statement.WasCompilerGenerated)
End Function
Private Function GetRaiseEventExpression(raiseEventStatement As BoundRaiseEventStatement) As IOperation
Dim eventInvocation = TryCast(raiseEventStatement.EventInvocation, BoundCall)
Dim eventSymbol = raiseEventStatement.EventSymbol
' Return an operation for invalid raise event expression
If eventInvocation Is Nothing OrElse eventInvocation.ReceiverOpt Is Nothing
Debug.Assert(raiseEventStatement.HasErrors)
Return Create(raiseEventStatement.EventInvocation)
End If
Dim receiver = eventInvocation.ReceiverOpt
Dim syntax = receiver.Syntax
Dim constantValue As [Optional](Of Object) = ConvertToOptional(receiver.ConstantValueOpt)
Dim boundInstance As BoundNode
If receiver.Kind = BoundKind.FieldAccess
Dim eventFieldAccess = CType(eventInvocation.ReceiverOpt, BoundFieldAccess)
Debug.Assert(eventFieldAccess.FieldSymbol.AssociatedSymbol = eventSymbol)
boundInstance = eventFieldAccess.ReceiverOpt
Else
boundInstance = receiver
End If
Dim instance As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() If(eventSymbol.IsShared, Nothing, Create(boundInstance)))
Dim EventReference As Lazy(Of IEventReferenceExpression) = New Lazy(Of IEventReferenceExpression)(Function() As IEventReferenceExpression
Return New LazyEventReferenceExpression(eventSymbol,
instance,
eventSymbol,
_semanticModel,
syntax,
eventSymbol.Type,
constantValue,
eventInvocation.WasCompilerGenerated)
End Function)
Dim argumentsInEvaluationOrder As Lazy(Of ImmutableArray(Of IArgument)) = New Lazy(Of ImmutableArray(Of IArgument))(
Function()
Return DeriveArguments(eventInvocation.Arguments, eventInvocation.Method.Parameters)
End Function)
Return New LazyRaiseEventExpression(eventReference, argumentsInEvaluationOrder, _semanticModel, syntax:=eventInvocation.Syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=eventInvocation.WasCompilerGenerated)
End Function
Friend Class Helper
Friend Shared Function DeriveUnaryOperatorKind(operatorKind As VisualBasic.UnaryOperatorKind) As UnaryOperatorKind
Select Case operatorKind And VisualBasic.UnaryOperatorKind.OpMask
......
......@@ -24,11 +24,45 @@ Class TestClass
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RaiseEvent TestEvent()')
Expression: IRaiseEventExpression (OperationKind.RaiseEventExpression, Type: null) (Syntax: 'RaiseEvent TestEvent()')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Arguments(0)
IRaiseEventStatement (OperationKind.RaiseEventStatement) (Syntax: 'RaiseEvent TestEvent()')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Arguments(0)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of RaiseEventStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseInstanceEventWithArguments()
Dim source = <![CDATA[
Imports System
Class TestClass
Public Event MyEvent(x As String, y As Integer)
Sub M()
RaiseEvent MyEvent(y:=1, x:=String.Empty)'BIND:"RaiseEvent MyEvent(y:=1, x:=String.Empty)"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IRaiseEventStatement (OperationKind.RaiseEventStatement) (Syntax: 'RaiseEvent ... ring.Empty)')
Event Reference: IEventReferenceExpression: Event TestClass.MyEvent(x As System.String, y As System.Int32) (OperationKind.EventReferenceExpression, Type: TestClass.MyEventEventHandler) (Syntax: 'MyEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'MyEvent')
Arguments(2):
IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'x:=String.Empty')
IFieldReferenceExpression: System.String.Empty As System.String (Static) (OperationKind.FieldReferenceExpression, Type: System.String) (Syntax: 'String.Empty')
Instance Receiver: null
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: 'y:=1')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1')
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)
]]>.Value
Dim expectedDiagnostics = String.Empty
......@@ -51,11 +85,10 @@ Class TestClass
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RaiseEvent TestEvent()')
Expression: IRaiseEventExpression (OperationKind.RaiseEventExpression, Type: null) (Syntax: 'RaiseEvent TestEvent()')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: null
Arguments(0)
IRaiseEventStatement (OperationKind.RaiseEventStatement) (Syntax: 'RaiseEvent TestEvent()')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: null
Arguments(0)
]]>.Value
Dim expectedDiagnostics = String.Empty
......@@ -78,11 +111,15 @@ Class TestClass
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'RaiseEvent TestEvent(1)')
Expression: IInvalidExpression (OperationKind.InvalidExpression, Type: System.Void, IsInvalid) (Syntax: 'RaiseEvent TestEvent(1)')
Children(2):
IOperation: (OperationKind.None, IsInvalid) (Syntax: 'RaiseEvent TestEvent(1)')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1, IsInvalid) (Syntax: '1')
IInvalidStatement (OperationKind.InvalidStatement, IsInvalid) (Syntax: 'RaiseEvent TestEvent(1)')
Children(1):
IInvalidExpression (OperationKind.InvalidExpression, Type: System.Void, IsInvalid) (Syntax: 'RaiseEvent TestEvent(1)')
Children(2):
IOperation: (OperationKind.None, IsInvalid) (Syntax: 'RaiseEvent TestEvent(1)')
Children(1):
IFieldReferenceExpression: TestClass.TestEventEvent As System.Action (OperationKind.FieldReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1, IsInvalid) (Syntax: '1')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
......@@ -199,11 +236,56 @@ Class TestClass
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RaiseEvent TestEvent()')
Expression: IRaiseEventExpression (OperationKind.RaiseEventExpression, Type: null) (Syntax: 'RaiseEvent TestEvent()')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Arguments(0)
IRaiseEventStatement (OperationKind.RaiseEventStatement) (Syntax: 'RaiseEvent TestEvent()')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Arguments(0)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of RaiseEventStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseCustomEventWithArguments()
Dim source = <![CDATA[
Imports System
Class TestClass
Public Custom Event TestEvent As Eventhandler
AddHandler(value As Eventhandler)
End AddHandler
RemoveHandler(value As Eventhandler)
End RemoveHandler
RaiseEvent(sender As Object, e As EventArgs)
End RaiseEvent
End Event
Sub M()
RaiseEvent TestEvent(Nothing, Nothing)'BIND:"RaiseEvent TestEvent(Nothing, Nothing)"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IRaiseEventStatement (OperationKind.RaiseEventStatement) (Syntax: 'RaiseEvent ... g, Nothing)')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.EventHandler (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'TestEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Arguments(2):
IArgument (ArgumentKind.Explicit, Matching Parameter: sender) (OperationKind.Argument) (Syntax: 'Nothing')
IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object, Constant: null) (Syntax: 'Nothing')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'Nothing')
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: e) (OperationKind.Argument) (Syntax: 'Nothing')
IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventArgs, Constant: null) (Syntax: 'Nothing')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'Nothing')
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)
]]>.Value
Dim expectedDiagnostics = String.Empty
......
......@@ -644,7 +644,7 @@ public override void VisitInvocationExpression(IInvocationExpression operation)
VisitArguments(operation);
}
private void VisitArguments(IHasArgumentsExpression operation)
private void VisitArguments(IHasArguments operation)
{
VisitArray(operation.ArgumentsInEvaluationOrder, "Arguments", logElementCount: true);
}
......@@ -1441,9 +1441,9 @@ public override void VisitTranslatedQueryExpression(ITranslatedQueryExpression o
Visit(operation.Expression, "Expression");
}
public override void VisitRaiseEventExpression(IRaiseEventExpression operation)
public override void VisitRaiseEventStatement(IRaiseEventStatement operation)
{
LogString(nameof(IRaiseEventExpression));
LogString(nameof(IRaiseEventStatement));
LogCommonPropertiesAndNewLine(operation);
Visit(operation.EventReference, header: "Event Reference");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册