提交 040137d1 编写于 作者: G Gen Lu

Add IRaiseEventExpression

上级 a005d688
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26405.2 VisualStudioVersion = 15.0.26918.3
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
EndProject EndProject
...@@ -159,7 +158,6 @@ Global ...@@ -159,7 +158,6 @@ Global
src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4 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\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*{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\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\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13
...@@ -169,7 +167,6 @@ Global ...@@ -169,7 +167,6 @@ Global
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13 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\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\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 src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 4
EndGlobalSection EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -473,4 +470,7 @@ Global ...@@ -473,4 +470,7 @@ Global
{0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} {0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {B20208C3-D3A6-4020-A274-6BE3786D29FB}
{E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {B20208C3-D3A6-4020-A274-6BE3786D29FB}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {706EC4A2-BB2B-42C8-B824-B428E5F57717}
EndGlobalSection
EndGlobal EndGlobal
...@@ -292,14 +292,13 @@ private IPlaceholderExpression CreateBoundDeconstructValuePlaceholderOperation(B ...@@ -292,14 +292,13 @@ private IPlaceholderExpression CreateBoundDeconstructValuePlaceholderOperation(B
return new PlaceholderExpression(_semanticModel, syntax, type, constantValue, isImplicit); return new PlaceholderExpression(_semanticModel, syntax, type, constantValue, isImplicit);
} }
private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall) private IHasArgumentsExpression CreateBoundCallOperation(BoundCall boundCall)
{ {
IMethodSymbol targetMethod = boundCall.Method; IMethodSymbol targetMethod = boundCall.Method;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(((object)boundCall.Method == null || boundCall.Method.IsStatic) ? null : boundCall.ReceiverOpt)); SyntaxNode syntax = boundCall.Syntax;
bool isVirtual = (object)boundCall.Method != null && ITypeSymbol type = boundCall.Type;
boundCall.ReceiverOpt != null && Optional<object> constantValue = ConvertToOptional(boundCall.ConstantValue);
(boundCall.Method.IsVirtual || boundCall.Method.IsAbstract || boundCall.Method.IsOverride) && bool isImplicit = boundCall.WasCompilerGenerated;
!boundCall.ReceiverOpt.SuppressVirtualCalls;
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() => Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() =>
{ {
return DeriveArguments( return DeriveArguments(
...@@ -316,11 +315,21 @@ private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall) ...@@ -316,11 +315,21 @@ private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall)
boundCall.Syntax, boundCall.Syntax,
boundCall.InvokedAsExtensionMethod); boundCall.InvokedAsExtensionMethod);
}); });
SyntaxNode syntax = boundCall.Syntax;
ITypeSymbol type = boundCall.Type; if (targetMethod.MethodKind == MethodKind.DelegateInvoke && boundCall.ReceiverOpt?.Kind == BoundKind.EventAccess)
Optional<object> constantValue = ConvertToOptional(boundCall.ConstantValue); {
bool isImplicit = boundCall.WasCompilerGenerated; Lazy<IEventReferenceExpression> eventReference = new Lazy<IEventReferenceExpression>(() => (IEventReferenceExpression)Create(boundCall.ReceiverOpt));
return new LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); return new LazyRaiseEventExpression(eventReference, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
}
else
{
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(((object)boundCall.Method == null || boundCall.Method.IsStatic) ? null : boundCall.ReceiverOpt));
bool isVirtual = (object)boundCall.Method != null &&
boundCall.ReceiverOpt != null &&
(boundCall.Method.IsVirtual || boundCall.Method.IsAbstract || boundCall.Method.IsOverride) &&
!boundCall.ReceiverOpt.SuppressVirtualCalls;
return new LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
}
} }
private ILocalReferenceExpression CreateBoundLocalOperation(BoundLocal boundLocal) private ILocalReferenceExpression CreateBoundLocalOperation(BoundLocal boundLocal)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities; using Roslyn.Test.Utilities;
...@@ -35,7 +36,7 @@ void M() ...@@ -35,7 +36,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 't.MyEvent += Handler') IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 't.MyEvent += Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 't.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 't.MyEvent')
Instance Receiver: ILocalReferenceExpression: t (OperationKind.LocalReferenceExpression, Type: Test) (Syntax: 't') Instance Receiver: ILocalReferenceExpression: t (OperationKind.LocalReferenceExpression, Type: Test) (Syntax: 't')
Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler') Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler')
...@@ -72,7 +73,7 @@ void M() ...@@ -72,7 +73,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventRemove)) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 't.MyEvent -= null') IEventAssignmentExpression (EventRemove) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 't.MyEvent -= null')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 't.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 't.MyEvent')
Instance Receiver: ILocalReferenceExpression: t (OperationKind.LocalReferenceExpression, Type: Test) (Syntax: 't') Instance Receiver: ILocalReferenceExpression: t (OperationKind.LocalReferenceExpression, Type: Test) (Syntax: 't')
Handler: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventHandler, Constant: null) (Syntax: 'null') Handler: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventHandler, Constant: null) (Syntax: 'null')
...@@ -113,7 +114,7 @@ void M() ...@@ -113,7 +114,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 'Test.MyEvent += Handler') IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 'Test.MyEvent += Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'Test.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'Test.MyEvent')
Instance Receiver: null Instance Receiver: null
Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler') Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler')
...@@ -153,7 +154,7 @@ void M() ...@@ -153,7 +154,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventRemove)) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 'Test.MyEvent -= Handler') IEventAssignmentExpression (EventRemove) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 'Test.MyEvent -= Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'Test.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'Test.MyEvent')
Instance Receiver: null Instance Receiver: null
Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler') Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler')
...@@ -194,7 +195,7 @@ void M() ...@@ -194,7 +195,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: 't.MyEvent += Handler') IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: 't.MyEvent += Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler, IsInvalid) (Syntax: 't.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler, IsInvalid) (Syntax: 't.MyEvent')
Instance Receiver: ILocalReferenceExpression: t (OperationKind.LocalReferenceExpression, Type: Test, IsInvalid) (Syntax: 't') Instance Receiver: ILocalReferenceExpression: t (OperationKind.LocalReferenceExpression, Type: Test, IsInvalid) (Syntax: 't')
Handler: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventHandler, IsInvalid) (Syntax: 'Handler') Handler: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventHandler, IsInvalid) (Syntax: 'Handler')
...@@ -239,7 +240,7 @@ void M() ...@@ -239,7 +240,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: 't.MyEvent += Handler') IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: 't.MyEvent += Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler, IsInvalid) (Syntax: 't.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler, IsInvalid) (Syntax: 't.MyEvent')
Instance Receiver: null Instance Receiver: null
Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler') Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler')
...@@ -283,7 +284,7 @@ void M() ...@@ -283,7 +284,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: 'Test.MyEvent += Handler') IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: 'Test.MyEvent += Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler, IsInvalid) (Syntax: 'Test.MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler, IsInvalid) (Syntax: 'Test.MyEvent')
Instance Receiver: IOperation: (OperationKind.None, IsInvalid) (Syntax: 'Test') Instance Receiver: IOperation: (OperationKind.None, IsInvalid) (Syntax: 'Test')
Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler') Handler: IMethodReferenceExpression: void C.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler')
...@@ -323,7 +324,7 @@ void M() ...@@ -323,7 +324,7 @@ void M()
} }
"; ";
string expectedOperationTree = @" string expectedOperationTree = @"
IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 'MyEvent += Handler') IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: System.Void) (Syntax: 'MyEvent += Handler')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'MyEvent') Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'MyEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: Test) (Syntax: 'MyEvent') Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: Test) (Syntax: 'MyEvent')
Handler: IMethodReferenceExpression: void Test.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler') Handler: IMethodReferenceExpression: void Test.Handler(System.Object sender, System.EventArgs e) (OperationKind.MethodReferenceExpression, Type: System.EventHandler) (Syntax: 'Handler')
...@@ -337,5 +338,157 @@ void M() ...@@ -337,5 +338,157 @@ void M()
VerifyOperationTreeAndDiagnosticsForTest<AssignmentExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics); VerifyOperationTreeAndDiagnosticsForTest<AssignmentExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
} }
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void RaiseInstanceEvent()
{
string source = @"
using System;
class Test
{
public event EventHandler MyEvent;
void M()
{
/*<bind>*/MyEvent(this, null)/*<bind>*/;
}
}
";
string expectedOperationTree = @"
IRaiseEventExpression (OperationKind.RaiseEventExpression, Type: System.Void) (Syntax: 'MyEvent(this, null)')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'MyEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: Test) (Syntax: 'MyEvent')
Arguments(2):
IArgument (ArgumentKind.Explicit, Matching Parameter: sender) (OperationKind.Argument) (Syntax: 'this')
IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'this')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null)
Operand: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: Test) (Syntax: 'this')
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: 'null')
IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventArgs, Constant: null) (Syntax: 'null')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null)
Operand: ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: '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)
";
var expectedDiagnostics = Array.Empty<DiagnosticDescription>();
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void RaiseStaticEvent()
{
string source = @"
using System;
class Test
{
public static event EventHandler MyEvent;
void M()
{
/*<bind>*/MyEvent(this, null)/*<bind>*/;
}
}
";
string expectedOperationTree = @"
IRaiseEventExpression (OperationKind.RaiseEventExpression, Type: System.Void) (Syntax: 'MyEvent(this, null)')
Event Reference: IEventReferenceExpression: event System.EventHandler Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.EventHandler) (Syntax: 'MyEvent')
Instance Receiver: null
Arguments(2):
IArgument (ArgumentKind.Explicit, Matching Parameter: sender) (OperationKind.Argument) (Syntax: 'this')
IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'this')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null)
Operand: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: Test) (Syntax: 'this')
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: 'null')
IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.EventArgs, Constant: null) (Syntax: 'null')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null)
Operand: ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: '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)
";
var expectedDiagnostics = Array.Empty<DiagnosticDescription>();
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void RaiseUndefinedEvent()
{
string source = @"
using System;
class Test
{
public event EventHandler MyEvent;
void M()
{
/*<bind>*/MyEvent.Invoke(this, null)/*<bind>*/;
}
}
";
string expectedOperationTree = @"
Actual: IInvocationExpression ( ? ?.()) (OperationKind.InvocationExpression, Type: ?, IsInvalid) (Syntax: 'MyEvent2(this, null)')
Instance Receiver: IInvalidExpression (OperationKind.InvalidExpression, Type: ?, IsInvalid) (Syntax: 'MyEvent2')
Children(0)
Arguments(2):
IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument) (Syntax: 'this')
IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: Test) (Syntax: 'this')
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: null) (OperationKind.Argument) (Syntax: 'null')
ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: '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)
";
var expectedDiagnostics = Array.Empty<DiagnosticDescription>();
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void RaiseStaticEventWithExtraArgument()
{
string source = @"
using System;
class Test
{
public static event Action MyEvent;
void M()
{
/*<bind>*/MyEvent(0)/*<bind>*/;
}
}
";
string expectedOperationTree = @"
IRaiseEventExpression (OperationKind.RaiseEventExpression, Type: System.Void, IsInvalid) (Syntax: 'MyEvent(0)')
Event Reference: IEventReferenceExpression: event System.Action Test.MyEvent (Static) (OperationKind.EventReferenceExpression, Type: System.Action, IsInvalid) (Syntax: 'MyEvent')
Instance Receiver: null
Arguments(1):
IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument) (Syntax: '0')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0')
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)
";
var expectedDiagnostics = new[] {
// file.cs(10,19): error CS1593: Delegate 'Action' does not take 1 arguments
// /*<bind>*/MyEvent(0)/*<bind>*/;
Diagnostic(ErrorCode.ERR_BadDelArgCount, "MyEvent").WithArguments("System.Action", "1").WithLocation(10, 19)
};
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
} }
} }
...@@ -2629,6 +2629,84 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> ins ...@@ -2629,6 +2629,84 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> ins
protected override ImmutableArray<IArgument> ArgumentsInEvaluationOrderImpl => _lazyArgumentsInEvaluationOrder.Value; protected override ImmutableArray<IArgument> ArgumentsInEvaluationOrderImpl => _lazyArgumentsInEvaluationOrder.Value;
} }
/// <summary>
/// Represents a C# or VB raise event expression.
/// </summary>
internal abstract partial class BaseRaiseEventExpression : Operation, IHasArgumentsExpression, IRaiseEventExpression
{
protected BaseRaiseEventExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.RaiseEventExpression, semanticModel, syntax, type, constantValue, isImplicit)
{
}
protected abstract IEventReferenceExpression EventReferenceImpl { get; }
protected abstract ImmutableArray<IArgument> ArgumentsInEvaluationOrderImpl { get; }
public override IEnumerable<IOperation> Children
{
get
{
yield return EventReference;
foreach (var argumentsInEvaluationOrder in ArgumentsInEvaluationOrder)
{
yield return argumentsInEvaluationOrder;
}
}
}
/// <summary>
/// Reference to the event to be raised.
/// </summary>
public IEventReferenceExpression EventReference => Operation.SetParentOperation(EventReferenceImpl, this);
public ImmutableArray<IArgument> ArgumentsInEvaluationOrder => Operation.SetParentOperation(ArgumentsInEvaluationOrderImpl, this);
public override void Accept(OperationVisitor visitor)
{
visitor.VisitRaiseEventExpression(this);
}
public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
return visitor.VisitRaiseEventExpression(this, argument);
}
}
/// <summary>
/// Represents a C# or VB raise event expression.
/// </summary>
internal sealed partial class RaiseEventExpression : BaseRaiseEventExpression, IHasArgumentsExpression, IRaiseEventExpression
{
public RaiseEventExpression(IEventReferenceExpression eventReference, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(semanticModel, syntax, type, constantValue, isImplicit)
{
EventReferenceImpl = eventReference;
ArgumentsInEvaluationOrderImpl = argumentsInEvaluationOrder;
}
protected override IEventReferenceExpression EventReferenceImpl { get; }
protected override ImmutableArray<IArgument> ArgumentsInEvaluationOrderImpl { get; }
}
/// <summary>
/// Represents a C# or VB raise event expression.
/// </summary>
internal sealed partial class LazyRaiseEventExpression : BaseRaiseEventExpression, IHasArgumentsExpression, IRaiseEventExpression
{
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) :
base(semanticModel, syntax, type, constantValue, isImplicit)
{
_lazyEventReference = eventReference;
_lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder;
}
protected override IEventReferenceExpression EventReferenceImpl => _lazyEventReference.Value;
protected override ImmutableArray<IArgument> ArgumentsInEvaluationOrderImpl => _lazyArgumentsInEvaluationOrder.Value;
}
/// <summary> /// <summary>
/// Represents an expression that tests if a value is of a specific type. /// Represents an expression that tests if a value is of a specific type.
/// </summary> /// </summary>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents a raise event expression.
/// </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
{
/// <summary>
/// Reference to the event to be raised.
/// </summary>
IEventReferenceExpression EventReference { get; }
}
}
...@@ -151,6 +151,8 @@ public enum OperationKind ...@@ -151,6 +151,8 @@ public enum OperationKind
DynamicInvocationExpression = 0x127, DynamicInvocationExpression = 0x127,
/// <summary>Indicates an <see cref="IDynamicIndexerAccessExpression"/>.</summary> /// <summary>Indicates an <see cref="IDynamicIndexerAccessExpression"/>.</summary>
DynamicIndexerAccessExpression = 0x128, DynamicIndexerAccessExpression = 0x128,
/// <summary>Indicates an <see cref="IRaiseEventExpression"/>.</summary>
RaiseEventExpression = 0x129,
// Expressions that occur only in C#. // Expressions that occur only in C#.
......
...@@ -487,6 +487,11 @@ public virtual void VisitTupleExpression(ITupleExpression operation) ...@@ -487,6 +487,11 @@ public virtual void VisitTupleExpression(ITupleExpression operation)
{ {
DefaultVisit(operation); DefaultVisit(operation);
} }
public virtual void VisitRaiseEventExpression(IRaiseEventExpression operation)
{
DefaultVisit(operation);
}
} }
/// <summary> /// <summary>
...@@ -980,5 +985,10 @@ public virtual TResult VisitTupleExpression(ITupleExpression operation, TArgumen ...@@ -980,5 +985,10 @@ public virtual TResult VisitTupleExpression(ITupleExpression operation, TArgumen
{ {
return DefaultVisit(operation, argument); return DefaultVisit(operation, argument);
} }
public virtual TResult VisitRaiseEventExpression(IRaiseEventExpression operation, TArgument argument)
{
return DefaultVisit(operation, argument);
}
} }
} }
...@@ -69,10 +69,10 @@ Microsoft.CodeAnalysis.OperationKind.ConversionExpression = 258 -> Microsoft.Cod ...@@ -69,10 +69,10 @@ Microsoft.CodeAnalysis.OperationKind.ConversionExpression = 258 -> Microsoft.Cod
Microsoft.CodeAnalysis.OperationKind.DeclarationPattern = 1038 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DeclarationPattern = 1038 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DecrementExpression = 520 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DecrementExpression = 520 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DefaultValueExpression = 512 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DefaultValueExpression = 512 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicIndexerAccessExpression = 296 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicInvocationExpression = 295 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DynamicInvocationExpression = 295 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicMemberReferenceExpression = 294 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DynamicMemberReferenceExpression = 294 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicObjectCreationExpression = 293 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DynamicObjectCreationExpression = 293 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicIndexerAccessExpression = 296 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.EmptyStatement = 9 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.EmptyStatement = 9 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.EventAssignmentExpression = 283 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.EventAssignmentExpression = 283 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.EventReferenceExpression = 268 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.EventReferenceExpression = 268 -> Microsoft.CodeAnalysis.OperationKind
...@@ -108,6 +108,7 @@ Microsoft.CodeAnalysis.OperationKind.ParameterReferenceExpression = 262 -> Micro ...@@ -108,6 +108,7 @@ Microsoft.CodeAnalysis.OperationKind.ParameterReferenceExpression = 262 -> Micro
Microsoft.CodeAnalysis.OperationKind.ParenthesizedExpression = 282 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ParenthesizedExpression = 282 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.PropertyInitializer = 1027 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.PropertyInitializer = 1027 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.PropertyReferenceExpression = 266 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.PropertyReferenceExpression = 266 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.RaiseEventExpression = 297 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.ReturnStatement = 11 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ReturnStatement = 11 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SimpleAssignmentExpression = 280 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.SimpleAssignmentExpression = 280 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SwitchCase = 1033 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.SwitchCase = 1033 -> Microsoft.CodeAnalysis.OperationKind
...@@ -249,9 +250,9 @@ Microsoft.CodeAnalysis.Semantics.IDeclarationPattern.DeclaredSymbol.get -> Micro ...@@ -249,9 +250,9 @@ Microsoft.CodeAnalysis.Semantics.IDeclarationPattern.DeclaredSymbol.get -> Micro
Microsoft.CodeAnalysis.Semantics.IDefaultCaseClause Microsoft.CodeAnalysis.Semantics.IDefaultCaseClause
Microsoft.CodeAnalysis.Semantics.IDefaultValueExpression Microsoft.CodeAnalysis.Semantics.IDefaultValueExpression
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement Microsoft.CodeAnalysis.Semantics.IDoLoopStatement
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.IgnoredCondition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.DoLoopKind.get -> Microsoft.CodeAnalysis.Semantics.DoLoopKind Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.DoLoopKind.get -> Microsoft.CodeAnalysis.Semantics.DoLoopKind
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.IgnoredCondition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression
Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression.Arguments.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation> Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression.Arguments.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation
...@@ -281,18 +282,18 @@ Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression ...@@ -281,18 +282,18 @@ Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.Field.get -> Microsoft.CodeAnalysis.IFieldSymbol Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.Field.get -> Microsoft.CodeAnalysis.IFieldSymbol
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.IsDeclaration.get -> bool Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.IsDeclaration.get -> bool
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.Collection.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.Collection.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForLoopStatement Microsoft.CodeAnalysis.Semantics.IForLoopStatement
Microsoft.CodeAnalysis.Semantics.IForLoopStatement.AtLoopBottom.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation> Microsoft.CodeAnalysis.Semantics.IForLoopStatement.AtLoopBottom.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Before.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation> Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Before.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement Microsoft.CodeAnalysis.Semantics.IForToLoopStatement
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.InitialValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.InitialValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LimitValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LimitValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation 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.IForToLoopStatement.StepValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression
Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Semantics.IArgument> Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Semantics.IArgument>
...@@ -328,8 +329,8 @@ Microsoft.CodeAnalysis.Semantics.IIsPatternExpression ...@@ -328,8 +329,8 @@ Microsoft.CodeAnalysis.Semantics.IIsPatternExpression
Microsoft.CodeAnalysis.Semantics.IIsPatternExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IIsPatternExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IIsPatternExpression.Pattern.get -> Microsoft.CodeAnalysis.Semantics.IPattern Microsoft.CodeAnalysis.Semantics.IIsPatternExpression.Pattern.get -> Microsoft.CodeAnalysis.Semantics.IPattern
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression Microsoft.CodeAnalysis.Semantics.IIsTypeExpression
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsType.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsNotTypeExpression.get -> bool Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsNotTypeExpression.get -> bool
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsType.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.Operand.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.Operand.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ILabeledStatement Microsoft.CodeAnalysis.Semantics.ILabeledStatement
Microsoft.CodeAnalysis.Semantics.ILabeledStatement.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol Microsoft.CodeAnalysis.Semantics.ILabeledStatement.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol
...@@ -380,6 +381,8 @@ Microsoft.CodeAnalysis.Semantics.IPropertyInitializer ...@@ -380,6 +381,8 @@ Microsoft.CodeAnalysis.Semantics.IPropertyInitializer
Microsoft.CodeAnalysis.Semantics.IPropertyInitializer.InitializedProperty.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IPropertyInitializer.InitializedProperty.get -> Microsoft.CodeAnalysis.IPropertySymbol
Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression
Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol 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.IRangeCaseClause Microsoft.CodeAnalysis.Semantics.IRangeCaseClause
Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MaximumValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MaximumValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MinimumValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MinimumValue.get -> Microsoft.CodeAnalysis.IOperation
...@@ -439,9 +442,9 @@ Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind ...@@ -439,9 +442,9 @@ Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.BitwiseNegation = 1 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.BitwiseNegation = 1 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.False = 6 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.False = 6 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Invalid = 255 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Invalid = 255 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Not = 2 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Minus = 4 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Minus = 4 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Not = 2 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Plus = 3 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Plus = 3 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.True = 5 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.True = 5 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.SyntaxList<TNode>.SyntaxList(System.Collections.Generic.IEnumerable<TNode> nodes) -> void Microsoft.CodeAnalysis.SyntaxList<TNode>.SyntaxList(System.Collections.Generic.IEnumerable<TNode> nodes) -> void
...@@ -541,6 +544,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitParenthesizedExpr ...@@ -541,6 +544,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitParenthesizedExpr
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitPatternCaseClause(Microsoft.CodeAnalysis.Semantics.IPatternCaseClause operation) -> void 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.VisitPropertyInitializer(Microsoft.CodeAnalysis.Semantics.IPropertyInitializer operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitPropertyReferenceExpression(Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression 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.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause 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.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void
...@@ -621,6 +625,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.Vi ...@@ -621,6 +625,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>.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>.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>.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>.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause 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>.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 virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation, TArgument argument) -> TResult
......
...@@ -68,6 +68,8 @@ Namespace Microsoft.CodeAnalysis.Semantics ...@@ -68,6 +68,8 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return boundNode.Syntax.Parent.Kind() = SyntaxKind.AddHandlerStatement OrElse Return boundNode.Syntax.Parent.Kind() = SyntaxKind.AddHandlerStatement OrElse
boundNode.Syntax.Parent.Kind() = SyntaxKind.RemoveHandlerStatement OrElse boundNode.Syntax.Parent.Kind() = SyntaxKind.RemoveHandlerStatement OrElse
boundNode.Syntax.Parent.Kind() = SyntaxKind.RaiseEventAccessorStatement boundNode.Syntax.Parent.Kind() = SyntaxKind.RaiseEventAccessorStatement
Case BoundKind.FieldAccess
Return boundNode.Syntax.Parent.Kind() = SyntaxKind.RaiseEventStatement
End Select End Select
Return False Return False
...@@ -1241,7 +1243,7 @@ Namespace Microsoft.CodeAnalysis.Semantics ...@@ -1241,7 +1243,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End Function End Function
Private Function CreateBoundRaiseEventStatementOperation(boundRaiseEventStatement As BoundRaiseEventStatement) As IExpressionStatement Private Function CreateBoundRaiseEventStatementOperation(boundRaiseEventStatement As BoundRaiseEventStatement) As IExpressionStatement
Dim expression As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundRaiseEventStatement.EventInvocation)) Dim expression As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() GetRaiseEventExpression(boundRaiseEventStatement))
Dim syntax As SyntaxNode = boundRaiseEventStatement.Syntax Dim syntax As SyntaxNode = boundRaiseEventStatement.Syntax
Dim type As ITypeSymbol = Nothing Dim type As ITypeSymbol = Nothing
Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)()
......
...@@ -276,6 +276,47 @@ Namespace Microsoft.CodeAnalysis.Semantics ...@@ -276,6 +276,47 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim adds = statement.Kind = BoundKind.AddHandlerStatement Dim adds = statement.Kind = BoundKind.AddHandlerStatement
Return New EventAssignmentExpression( Return New EventAssignmentExpression(
eventReference, Create(statement.Handler), adds:=adds, semanticModel:=_semanticModel, syntax:=statement.Syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=statement.WasCompilerGenerated) 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)
' Return an operation for invalid raise event expression
If eventInvocation Is Nothing OrElse eventInvocation.ReceiverOpt Is Nothing OrElse eventInvocation.ReceiverOpt.Kind <> BoundKind.FieldAccess
Debug.Assert(raiseEventStatement.HasErrors)
Return Create(raiseEventStatement.EventInvocation)
End If
Dim eventSymbol = raiseEventStatement.EventSymbol
Dim eventFieldAccess = CType(eventInvocation.ReceiverOpt, BoundFieldAccess)
Debug.Assert(eventFieldAccess.FieldSymbol.AssociatedSymbol = eventSymbol)
Dim instance As Lazy(Of IOperation) = New Lazy(Of IOperation)(
Function()
If eventSymbol.IsShared Then
Return Nothing
Else
Return Create(eventFieldAccess.ReceiverOpt)
End If
End Function)
Dim constantValue As [Optional](Of Object) = ConvertToOptional(eventFieldAccess.ConstantValueOpt)
Dim EventReference As Lazy(Of IEventReferenceExpression) = New Lazy(Of IEventReferenceExpression)(Function() As IEventReferenceExpression
Return New LazyEventReferenceExpression(eventSymbol,
instance,
eventSymbol,
_semanticModel,
eventFieldAccess.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 End Function
Friend Class Helper Friend Class Helper
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. ' 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.Test.Utilities Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
...@@ -29,7 +29,7 @@ End Class]]>.Value ...@@ -29,7 +29,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'AddHandler ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'AddHandler ... AddressOf M')
Expression: IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'AddHandler ... AddressOf M') Expression: IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'AddHandler ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: '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') Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M') Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M')
...@@ -62,7 +62,7 @@ End Class]]>.Value ...@@ -62,7 +62,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RemoveHandl ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RemoveHandl ... AddressOf M')
Expression: IEventAssignmentExpression (EventRemove)) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'RemoveHandl ... AddressOf M') Expression: IEventAssignmentExpression (EventRemove) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'RemoveHandl ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: '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') Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEvent')
Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M') Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M')
...@@ -95,7 +95,7 @@ End Class]]>.Value ...@@ -95,7 +95,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'AddHandler ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'AddHandler ... AddressOf M')
Expression: IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'AddHandler ... AddressOf M') Expression: IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'AddHandler ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent') Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: null Instance Receiver: null
Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M') Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M')
...@@ -128,7 +128,7 @@ End Class]]>.Value ...@@ -128,7 +128,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RemoveHandl ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'RemoveHandl ... AddressOf M')
Expression: IEventAssignmentExpression (EventRemove)) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'RemoveHandl ... AddressOf M') Expression: IEventAssignmentExpression (EventRemove) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'RemoveHandl ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent') Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: null Instance Receiver: null
Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M') Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M')
...@@ -161,7 +161,7 @@ End Class]]>.Value ...@@ -161,7 +161,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'RemoveHandl ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'RemoveHandl ... AddressOf M')
Expression: IEventAssignmentExpression (EventRemove)) (OperationKind.EventAssignmentExpression, Type: null, IsInvalid) (Syntax: 'RemoveHandl ... AddressOf M') Expression: IEventAssignmentExpression (EventRemove) (OperationKind.EventAssignmentExpression, Type: null, IsInvalid) (Syntax: 'RemoveHandl ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent') Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'TestEvent')
Instance Receiver: null Instance Receiver: null
Handler: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Action, IsInvalid) (Syntax: 'AddressOf M') Handler: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Action, IsInvalid) (Syntax: 'AddressOf M')
...@@ -196,7 +196,7 @@ Class TestClass ...@@ -196,7 +196,7 @@ Class TestClass
End Class]]>.Value End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'AddHandler ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'AddHandler ... AddressOf M')
Expression: IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'AddHandler ... AddressOf M') Expression: IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: null) (Syntax: 'AddHandler ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'Me.TestEvent') Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (Static) (OperationKind.EventReferenceExpression, Type: System.Action) (Syntax: 'Me.TestEvent')
Instance Receiver: null Instance Receiver: null
Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M') Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M')
...@@ -232,7 +232,7 @@ Class TestClass ...@@ -232,7 +232,7 @@ Class TestClass
End Class]]>.Value End Class]]>.Value
Dim expectedOperationTree = <![CDATA[ Dim expectedOperationTree = <![CDATA[
IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'AddHandler ... AddressOf M') IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'AddHandler ... AddressOf M')
Expression: IEventAssignmentExpression (EventAdd)) (OperationKind.EventAssignmentExpression, Type: null, IsInvalid) (Syntax: 'AddHandler ... AddressOf M') Expression: IEventAssignmentExpression (EventAdd) (OperationKind.EventAssignmentExpression, Type: null, IsInvalid) (Syntax: 'AddHandler ... AddressOf M')
Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action, IsInvalid) (Syntax: 'TestClass.TestEvent') Event Reference: IEventReferenceExpression: Event TestClass.TestEvent As System.Action (OperationKind.EventReferenceExpression, Type: System.Action, IsInvalid) (Syntax: 'TestClass.TestEvent')
Instance Receiver: IOperation: (OperationKind.None, IsInvalid) (Syntax: 'TestClass') Instance Receiver: IOperation: (OperationKind.None, IsInvalid) (Syntax: 'TestClass')
Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M') Handler: IOperation: (OperationKind.None) (Syntax: 'AddressOf M')
...@@ -247,5 +247,173 @@ BC30469: Reference to a non-shared member requires an object reference. ...@@ -247,5 +247,173 @@ BC30469: Reference to a non-shared member requires an object reference.
]]>.Value ]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of AddRemoveHandlerStatementSyntax)(source, expectedOperationTree, expectedDiagnostics) VerifyOperationTreeAndDiagnosticsForTest(Of AddRemoveHandlerStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseInstanceEvent()
Dim source = <![CDATA[
Imports System
Class TestClass
Event TestEvent As Action
Sub M()
RaiseEvent TestEvent()'BIND:"RaiseEvent TestEvent()"
End Sub
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)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of RaiseEventStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseSharedEvent()
Dim source = <![CDATA[
Imports System
Class TestClass
Shared Event TestEvent As Action
Sub M()
RaiseEvent TestEvent()'BIND:"RaiseEvent TestEvent()"
End Sub
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)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of RaiseEventStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseInstanceEventWithExtraArgument()
Dim source = <![CDATA[
Imports System
Class TestClass
Event TestEvent As Action
Sub M()
RaiseEvent TestEvent(1)'BIND:"RaiseEvent TestEvent(1)"
End Sub
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')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30057: Too many arguments to 'Public Event TestEvent As Action'.
RaiseEvent TestEvent(1)'BIND:"RaiseEvent TestEvent(1)"
~
]]>.Value
Debugger.Launch()
VerifyOperationTreeAndDiagnosticsForTest(Of RaiseEventStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseUndefinedEvent()
Dim source = <![CDATA[
Imports System
Class TestClass
Event TestEvent As Action
Sub M()
RaiseEvent TestEvent2()'BIND:"RaiseEvent TestEvent2()"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IInvalidStatement (OperationKind.InvalidStatement, IsInvalid) (Syntax: 'RaiseEvent TestEvent2()')
Children(1):
IInvalidExpression (OperationKind.InvalidExpression, Type: ?, IsInvalid) (Syntax: 'TestEvent2')
Children(0)
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30451: 'TestEvent2' is not declared. It may be inaccessible due to its protection level.
RaiseEvent TestEvent2()'BIND:"RaiseEvent TestEvent2()"
~~~~~~~~~~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of RaiseEventStatementSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseEventThroughField1()
Dim source = <![CDATA[
Imports System
Class TestClass
Event TestEvent As Action
Sub M()
TestEventEvent()'BIND:"TestEventEvent()"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IInvocationExpression (virtual Sub System.Action.Invoke()) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'TestEventEvent()')
Instance Receiver: IFieldReferenceExpression: TestClass.TestEventEvent As System.Action (OperationKind.FieldReferenceExpression, Type: System.Action) (Syntax: 'TestEventEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEventEvent')
Arguments(0)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of InvocationExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub RaiseEventThroughField2()
Dim source = <![CDATA[
Imports System
Class TestClass
Event TestEvent As Action
Sub M()
TestEventEvent.Invoke()'BIND:"TestEventEvent.Invoke()"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IInvocationExpression (virtual Sub System.Action.Invoke()) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'TestEventEvent.Invoke()')
Instance Receiver: IFieldReferenceExpression: TestClass.TestEventEvent As System.Action (OperationKind.FieldReferenceExpression, Type: System.Action) (Syntax: 'TestEventEvent')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: TestClass) (Syntax: 'TestEventEvent')
Arguments(0)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of InvocationExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
End Class End Class
End Namespace End Namespace
...@@ -829,7 +829,6 @@ public override void VisitEventAssignmentExpression(IEventAssignmentExpression o ...@@ -829,7 +829,6 @@ public override void VisitEventAssignmentExpression(IEventAssignmentExpression o
{ {
var kindStr = operation.Adds ? "EventAdd" : "EventRemove"; var kindStr = operation.Adds ? "EventAdd" : "EventRemove";
LogString($"{nameof(IEventAssignmentExpression)} ({kindStr})"); LogString($"{nameof(IEventAssignmentExpression)} ({kindStr})");
LogString(")");
LogCommonPropertiesAndNewLine(operation); LogCommonPropertiesAndNewLine(operation);
Visit(operation.EventReference, header: "Event Reference"); Visit(operation.EventReference, header: "Event Reference");
...@@ -1432,6 +1431,15 @@ public override void VisitPatternCaseClause(IPatternCaseClause operation) ...@@ -1432,6 +1431,15 @@ public override void VisitPatternCaseClause(IPatternCaseClause operation)
Visit(operation.GuardExpression, "Guard Expression"); Visit(operation.GuardExpression, "Guard Expression");
} }
public override void VisitRaiseEventExpression(IRaiseEventExpression operation)
{
LogString(nameof(IRaiseEventExpression));
LogCommonPropertiesAndNewLine(operation);
Visit(operation.EventReference, header: "Event Reference");
VisitArguments(operation);
}
#endregion #endregion
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册