提交 5a9fecd7 编写于 作者: R Remy Willems

Rabase onto post-dev15

上级 94c1483b
......@@ -22,7 +22,7 @@ public partial class ImplementInterfaceTests : AbstractCSharpDiagnosticProviderB
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new CSharpImplementInterfaceCodeFixProvider());
private static readonly Dictionary<OptionKey, object> AllOptionsOff =
private static readonly Dictionary<OptionKey, object> s_allOptionsOff =
new Dictionary<OptionKey, object>
{
{ CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CodeStyleOptions.FalseWithNoneEnforcement },
......@@ -33,7 +33,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
{ CSharpCodeStyleOptions.PreferExpressionBodiedOperators, CodeStyleOptions.FalseWithNoneEnforcement }
};
private static readonly Dictionary<OptionKey, object> AllOptionsOn =
private static readonly Dictionary<OptionKey, object> s_allOptionsOn =
new Dictionary<OptionKey, object>
{
{ CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CodeStyleOptions.TrueWithNoneEnforcement },
......@@ -44,7 +44,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
{ CSharpCodeStyleOptions.PreferExpressionBodiedOperators, CodeStyleOptions.TrueWithNoneEnforcement }
};
private static readonly Dictionary<OptionKey, object> AccessorOptionsOn =
private static readonly Dictionary<OptionKey, object> s_accessorOptionsOn =
new Dictionary<OptionKey, object>
{
{ CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CodeStyleOptions.FalseWithNoneEnforcement },
......@@ -62,7 +62,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
bool withScriptOption = false)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
index, compareTokens, options: AllOptionsOff, withScriptOption: withScriptOption);
index, compareTokens, options: s_allOptionsOff, withScriptOption: withScriptOption);
}
internal async Task TestWithAllCodeStyleOptionsOnAsync(
......@@ -72,7 +72,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
bool withScriptOption = false)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
index, compareTokens, options: AllOptionsOn, withScriptOption: withScriptOption);
index, compareTokens, options: s_allOptionsOn, withScriptOption: withScriptOption);
}
internal async Task TestWithAccessorCodeStyleOptionsOnAsync(
......@@ -82,7 +82,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
bool withScriptOption = false)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
index, compareTokens, options: AccessorOptionsOn, withScriptOption: withScriptOption);
index, compareTokens, options: s_accessorOptionsOn, withScriptOption: withScriptOption);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
......@@ -2453,6 +2453,63 @@ A a
count: 2);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestImplementEventThroughMember()
{
await TestAsync(@"
interface IFoo
{
event System.EventHandler E;
}
class CanFoo : IFoo
{
public event EventHandler E;
}
class HasCanFoo : [|IFoo|]
{
CanFoo canFoo;
}",
@"
using System;
interface IFoo
{
event System.EventHandler E;
}
class CanFoo : IFoo
{
public event EventHandler E;
}
class HasCanFoo : IFoo
{
CanFoo canFoo;
public event EventHandler E
{
add
{
((IFoo)canFoo).E += value;
}
remove
{
((IFoo)canFoo).E -= value;
}
}
}", index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestImplementEventThroughExplicitMember()
{
await TestAsync(
@"interface IFoo { event System . EventHandler E ; } class CanFoo : IFoo { event IFoo.EventHandler E; } class HasCanFoo : [|IFoo|] { CanFoo canFoo; } ",
@"using System ; interface IFoo { event System . EventHandler E ; } class CanFoo : IFoo { event IFoo.EventHandler E; } class HasCanFoo : IFoo { CanFoo canFoo; public event EventHandler E { add { ((IFoo)canFoo).E += value; } remove { ((IFoo)canFoo).E -= value; } } } ",
index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestImplementEvent()
{
......
......@@ -7,15 +7,11 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.VisualBasic;
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
using CS = Microsoft.CodeAnalysis.CSharp;
using VB = Microsoft.CodeAnalysis.VisualBasic;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeGeneration
......@@ -272,6 +268,112 @@ public async Task AddSealedDelegateType()
parameters: Parameters(Parameter(typeof(string), "s")));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)]
public async Task AddEvent()
{
var input = "Class [|C|] \n End Class";
var expected = "Class C \n Public Event E As Action \n End Class";
await TestAddEventAsync(input, expected,
codeGenerationOptions: new CodeGenerationOptions(addImports: false));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)]
public async Task AddEventWithAccessorAndImplementsClause()
{
var input = "Class [|C|] \n End Class";
var expected = @"
Class C
Public Custom Event E As ComponentModel.PropertyChangedEventHandler Implements ComponentModel.INotifyPropertyChanged.PropertyChanged
AddHandler ( value As ComponentModel . PropertyChangedEventHandler )
End AddHandler
RemoveHandler ( value As ComponentModel . PropertyChangedEventHandler )
End RemoveHandler
RaiseEvent ( sender As Object , e As ComponentModel . PropertyChangedEventArgs )
End RaiseEvent
End Event
End Class";
Func<SemanticModel, IEventSymbol> getExplicitInterfaceEvent = semanticModel =>
{
var parameterSymbols = SpecializedCollections.EmptyList<AttributeData>();
return new CodeGenerationEventSymbol(GetTypeSymbol(typeof(System.ComponentModel.INotifyPropertyChanged))(semanticModel), null,
Accessibility.Public,
default(DeclarationModifiers),
GetTypeSymbol(typeof(System.ComponentModel.PropertyChangedEventHandler))(semanticModel),
null,
nameof(System.ComponentModel.INotifyPropertyChanged.PropertyChanged), null, null, null);
};
await TestAddEventAsync(input, expected,
addMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(SpecializedCollections.EmptyList<AttributeData>(), Accessibility.NotApplicable, SpecializedCollections.EmptyList<SyntaxNode>()),
explicitInterfaceSymbol: getExplicitInterfaceEvent,
type: typeof(System.ComponentModel.PropertyChangedEventHandler),
codeGenerationOptions: new CodeGenerationOptions(addImports: false));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)]
public async Task AddEventWithAddAccessor()
{
var input = @"
Class [|C|]
End Class";
var expected = @"
Class C
Public Custom Event E As Action
AddHandler(value As Action)
End AddHandler
RemoveHandler(value As Action)
End RemoveHandler
RaiseEvent()
End RaiseEvent
End Event
End Class";
await TestAddEventAsync(input, expected,
addMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(SpecializedCollections.EmptyList<AttributeData>(), Accessibility.NotApplicable, SpecializedCollections.EmptyList<SyntaxNode>()),
codeGenerationOptions: new CodeGenerationOptions(addImports: false));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)]
public async Task AddEventWithAccessors()
{
var input = @"
Class [|C|]
End Class";
var expected = @"
Class C
Public Custom Event E As Action
AddHandler(value As Action)
Console.WriteLine(0)
End AddHandler
RemoveHandler(value As Action)
Console.WriteLine(1)
End RemoveHandler
RaiseEvent()
Console.WriteLine(2)
End RaiseEvent
End Event
End Class";
var addStatements = new List<SyntaxNode>() { VB.SyntaxFactory.ParseExecutableStatement("Console.WriteLine(0)") };
var removeStatements = new List<SyntaxNode>() { VB.SyntaxFactory.ParseExecutableStatement("Console.WriteLine(1)") };
var raiseStatements = new List<SyntaxNode>() { VB.SyntaxFactory.ParseExecutableStatement("Console.WriteLine(2)") };
await TestAddEventAsync(input, expected,
addMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(
SpecializedCollections.EmptyList<AttributeData>(), Accessibility.NotApplicable, addStatements),
removeMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(
SpecializedCollections.EmptyList<AttributeData>(), Accessibility.NotApplicable, removeStatements),
raiseMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(
SpecializedCollections.EmptyList<AttributeData>(), Accessibility.NotApplicable, raiseStatements),
codeGenerationOptions: new CodeGenerationOptions(addImports: false));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)]
public async Task AddMethodToClass()
{
......
......@@ -333,7 +333,7 @@ public partial class CodeGenerationTests
DeclarationModifiers modifiers = default(DeclarationModifiers),
IList<Func<SemanticModel, IParameterSymbol>> parameters = null,
Type type = null,
IEventSymbol explicitInterfaceSymbol = null,
Func<SemanticModel, IEventSymbol> explicitInterfaceSymbol = null,
IMethodSymbol addMethod = null,
IMethodSymbol removeMethod = null,
IMethodSymbol raiseMethod = null,
......@@ -351,7 +351,7 @@ public partial class CodeGenerationTests
accessibility,
modifiers,
typeSymbol,
explicitInterfaceSymbol,
explicitInterfaceSymbol?.Invoke(context.SemanticModel),
name,
addMethod,
removeMethod,
......@@ -664,12 +664,12 @@ private static IList<ISymbol> GetSymbols(IList<Func<SemanticModel, ISymbol>> mem
null, accessibility, modifiers, GetTypeSymbol(type)(s), name);
}
private static Func<SemanticModel, ITypeSymbol> GetTypeSymbol(Type type)
private static Func<SemanticModel, INamedTypeSymbol> GetTypeSymbol(Type type)
{
return GetTypeSymbol(type.FullName);
}
private static Func<SemanticModel, ITypeSymbol> GetTypeSymbol(string typeMetadataName)
private static Func<SemanticModel, INamedTypeSymbol> GetTypeSymbol(string typeMetadataName)
{
return s => s == null ? null : s.Compilation.GetTypeByMetadataName(typeMetadataName);
}
......
......@@ -1594,6 +1594,51 @@ Class C
End Class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Async Function TestImplementThroughMemberEvent() As Task
Await TestAsync("
Imports System.ComponentModel
Class Worker
Implements INotifyPropertyChanged
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
End Class
Class Boss
Implements [|INotifyPropertyChanged|]
Private worker As Worker
End Class", "
Imports System.ComponentModel
Class Worker
Implements INotifyPropertyChanged
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
End Class
Class Boss
Implements INotifyPropertyChanged
Private worker As Worker
Public Custom Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
AddHandler(value As PropertyChangedEventHandler)
AddHandler DirectCast(worker, INotifyPropertyChanged).PropertyChanged, value
End AddHandler
RemoveHandler(value As PropertyChangedEventHandler)
RemoveHandler DirectCast(worker, INotifyPropertyChanged).PropertyChanged, value
End RemoveHandler
RaiseEvent(sender As Object, e As PropertyChangedEventArgs)
End RaiseEvent
End Event
End Class", index:=1)
End Function
<WorkItem(543588, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543588")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Async Function TestNameSimplifyGenericType() As Task
......
......@@ -389,7 +389,7 @@ private static bool IsUnexpressibleTypeParameter(ITypeParameterSymbol typeParame
var useExplicitInterfaceSymbol = generateInvisibly || !Service.CanImplementImplicitly;
var accessibility = member.Name == memberName || generateAbstractly
? Accessibility.Public
? Accessibility.Public
: Accessibility.Private;
if (member.Kind == SymbolKind.Method)
......@@ -419,13 +419,34 @@ private static bool IsUnexpressibleTypeParameter(ITypeParameterSymbol typeParame
modifiers: modifiers,
explicitInterfaceSymbol: useExplicitInterfaceSymbol ? @event : null,
name: memberName,
addMethod: generateInvisibly ? accessor : null,
removeMethod: generateInvisibly ? accessor : null);
addMethod: GetAddOrRemoveMethod(generateInvisibly, accessor, memberName, factory.AddEventHandler),
removeMethod: GetAddOrRemoveMethod(generateInvisibly, accessor, memberName, factory.RemoveEventHandler));
}
return null;
}
private IMethodSymbol GetAddOrRemoveMethod(bool generateInvisibly,
IMethodSymbol accessor,
string memberName,
Func<SyntaxNode, SyntaxNode, SyntaxNode> createAddOrRemoveHandler)
{
if (ThroughMember != null)
{
var factory = Document.GetLanguageService<SyntaxGenerator>();
var throughExpression = CreateThroughExpression(factory);
var statement = factory.ExpressionStatement(createAddOrRemoveHandler(
factory.MemberAccessExpression(throughExpression, memberName), factory.IdentifierName("value")));
return CodeGenerationSymbolFactory.CreateAccessorSymbol(
attributes: null,
accessibility: Accessibility.NotApplicable,
statements: SpecializedCollections.SingletonList(statement));
}
return generateInvisibly ? accessor : null;
}
private SyntaxNode CreateThroughExpression(SyntaxGenerator factory)
{
var through = ThroughMember.IsStatic
......
......@@ -2543,7 +2543,7 @@ private static TNode AddMissingTokens<TNode>(TNode node, bool recurse)
private class AddMissingTokensRewriter : CSharpSyntaxRewriter
{
private readonly bool _recurse;
private bool firstVisit = true;
private bool _firstVisit = true;
public AddMissingTokensRewriter(bool recurse)
{
......@@ -2552,12 +2552,12 @@ public AddMissingTokensRewriter(bool recurse)
public override SyntaxNode Visit(SyntaxNode node)
{
if (!_recurse && !firstVisit)
if (!_recurse && !_firstVisit)
{
return node;
}
firstVisit = false;
_firstVisit = false;
return base.Visit(node);
}
......@@ -3454,6 +3454,16 @@ internal override bool IsRegularOrDocComment(SyntaxTrivia trivia)
#region Statements and Expressions
public override SyntaxNode AddEventHandler(SyntaxNode @event, SyntaxNode handler)
{
return SyntaxFactory.AssignmentExpression(SyntaxKind.AddAssignmentExpression, (ExpressionSyntax)@event, Parenthesize(handler));
}
public override SyntaxNode RemoveEventHandler(SyntaxNode @event, SyntaxNode handler)
{
return SyntaxFactory.AssignmentExpression(SyntaxKind.SubtractAssignmentExpression, (ExpressionSyntax)@event, Parenthesize(handler));
}
public override SyntaxNode AwaitExpression(SyntaxNode expression)
{
return SyntaxFactory.AwaitExpression((ExpressionSyntax)expression);
......
......@@ -434,6 +434,22 @@ public void TestLocalDeclarationStatements()
VerifySyntax<LocalDeclarationStatementSyntax>(_g.LocalDeclarationStatement("y", _g.IdentifierName("z")), "var y = z;");
}
[Fact]
public void TestAddHandlerExpressions()
{
VerifySyntax<AssignmentExpressionSyntax>(
_g.AddEventHandler(_g.IdentifierName("@event"), _g.IdentifierName("handler")),
"@event += (handler)");
}
[Fact]
public void TestSubtractHandlerExpressions()
{
VerifySyntax<AssignmentExpressionSyntax>(
_g.RemoveEventHandler(_g.IdentifierName("@event"),
_g.IdentifierName("handler")), "@event -= (handler)");
}
[Fact]
public void TestAwaitExpressions()
{
......
......@@ -309,6 +309,16 @@ public SyntaxNode ParameterDeclaration(IParameterSymbol symbol, SyntaxNode initi
setAccessorStatements);
}
/// <summary>
/// Creates a statement that adds the given handler to the given event.
/// </summary>
public abstract SyntaxNode AddEventHandler(SyntaxNode @event, SyntaxNode handler);
/// <summary>
/// Creates a statement that removes the given handler from the given event.
/// </summary>
public abstract SyntaxNode RemoveEventHandler(SyntaxNode @event, SyntaxNode handler);
/// <summary>
/// Creates an event declaration.
/// </summary>
......
......@@ -38,8 +38,10 @@ Microsoft.CodeAnalysis.Workspace.DocumentActiveContextChanged -> System.EventHan
Microsoft.CodeAnalysis.Workspace.RaiseDocumentActiveContextChangedEventAsync(Microsoft.CodeAnalysis.Text.SourceTextContainer sourceTextContainer, Microsoft.CodeAnalysis.DocumentId oldActiveContextDocumentId, Microsoft.CodeAnalysis.DocumentId newActiveContextDocumentId) -> System.Threading.Tasks.Task
Microsoft.CodeAnalysis.XmlDocumentationProvider
Microsoft.CodeAnalysis.XmlDocumentationProvider.XmlDocumentationProvider() -> void
abstract Microsoft.CodeAnalysis.Editing.SyntaxGenerator.AddEventHandler(Microsoft.CodeAnalysis.SyntaxNode event, Microsoft.CodeAnalysis.SyntaxNode handler) -> Microsoft.CodeAnalysis.SyntaxNode
abstract Microsoft.CodeAnalysis.Editing.SyntaxGenerator.GetSwitchSections(Microsoft.CodeAnalysis.SyntaxNode switchStatement) -> System.Collections.Generic.IReadOnlyList<Microsoft.CodeAnalysis.SyntaxNode>
abstract Microsoft.CodeAnalysis.Editing.SyntaxGenerator.InsertSwitchSections(Microsoft.CodeAnalysis.SyntaxNode switchStatement, int index, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode> switchSections) -> Microsoft.CodeAnalysis.SyntaxNode
abstract Microsoft.CodeAnalysis.Editing.SyntaxGenerator.RemoveEventHandler(Microsoft.CodeAnalysis.SyntaxNode event, Microsoft.CodeAnalysis.SyntaxNode handler) -> Microsoft.CodeAnalysis.SyntaxNode
abstract Microsoft.CodeAnalysis.Editing.SyntaxGenerator.ThrowExpression(Microsoft.CodeAnalysis.SyntaxNode expression) -> Microsoft.CodeAnalysis.SyntaxNode
abstract Microsoft.CodeAnalysis.XmlDocumentationProvider.GetSourceStream(System.Threading.CancellationToken cancellationToken) -> System.IO.Stream
const Microsoft.CodeAnalysis.Tags.WellKnownTags.Assembly = "Assembly" -> string
......
......@@ -4,6 +4,7 @@ Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeGeneration
Imports Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationHelpers
Imports Microsoft.CodeAnalysis.Editing
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
......@@ -74,7 +75,65 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
Private Function GenerateEventDeclarationWorker([event] As IEventSymbol,
destination As CodeGenerationDestination,
options As CodeGenerationOptions) As DeclarationStatementSyntax
' TODO(cyrusn): Handle Add/Remove/Raise events
If options.GenerateMethodBodies AndAlso
([event].AddMethod IsNot Nothing OrElse [event].RemoveMethod IsNot Nothing OrElse [event].RaiseMethod IsNot Nothing) Then
Return GenerateCustomEventDeclarationWorker([event], destination, options)
Else
Return GenerateNotCustomEventDeclarationWorker([event], destination, options)
End If
End Function
Private Function GenerateCustomEventDeclarationWorker(
[event] As IEventSymbol,
destination As CodeGenerationDestination,
options As CodeGenerationOptions) As DeclarationStatementSyntax
Dim addStatements = If(
[event].AddMethod Is Nothing,
New SyntaxList(Of StatementSyntax),
GenerateStatements([event].AddMethod))
Dim removeStatements = If(
[event].RemoveMethod Is Nothing,
New SyntaxList(Of StatementSyntax),
GenerateStatements([event].RemoveMethod))
Dim raiseStatements = If(
[event].RaiseMethod Is Nothing,
New SyntaxList(Of StatementSyntax),
GenerateStatements([event].RaiseMethod))
Dim generator As VisualBasicSyntaxGenerator = New VisualBasicSyntaxGenerator()
Dim invoke = DirectCast([event].Type, INamedTypeSymbol)?.DelegateInvokeMethod
Dim parameters = If(
invoke IsNot Nothing,
invoke.Parameters.Select(Function(p) generator.ParameterDeclaration(p)),
Nothing)
Dim result = DirectCast(generator.CustomEventDeclarationWithRaise(
[event].Name,
generator.TypeExpression([event].Type),
[event].DeclaredAccessibility,
DeclarationModifiers.From([event]),
parameters,
addStatements,
removeStatements,
raiseStatements), EventBlockSyntax)
result = DirectCast(
result.WithAttributeLists(GenerateAttributeBlocks([event].GetAttributes(), options)),
EventBlockSyntax)
result = DirectCast(result.WithModifiers(GenerateModifiers([event], destination, options)), EventBlockSyntax)
Dim explicitInterface = [event].ExplicitInterfaceImplementations.FirstOrDefault()
If (explicitInterface IsNot Nothing)
result = result.WithEventStatement(
result.EventStatement.WithImplementsClause(GenerateImplementsClause(explicitInterface)))
End If
Return result
End Function
Private Function GenerateNotCustomEventDeclarationWorker(
[event] As IEventSymbol,
destination As CodeGenerationDestination,
options As CodeGenerationOptions) As EventStatementSyntax
Dim eventType = TryCast([event].Type, INamedTypeSymbol)
If eventType.IsDelegateType() AndAlso eventType.AssociatedSymbol IsNot Nothing Then
' This is a declaration style event like "Event E(x As String)". This event will
......
......@@ -22,6 +22,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
#Region "Expressions and Statements"
Public Overrides Function AddEventHandler([event] As SyntaxNode, handler As SyntaxNode) As SyntaxNode
Return SyntaxFactory.AddHandlerStatement(CType([event], ExpressionSyntax), CType(handler, ExpressionSyntax))
End Function
Public Overrides Function RemoveEventHandler([event] As SyntaxNode, handler As SyntaxNode) As SyntaxNode
Return SyntaxFactory.RemoveHandlerStatement(CType([event], ExpressionSyntax), CType(handler, ExpressionSyntax))
End Function
Public Overrides Function AwaitExpression(expression As SyntaxNode) As SyntaxNode
Return SyntaxFactory.AwaitExpression(DirectCast(expression, ExpressionSyntax))
End Function
......@@ -3415,16 +3423,27 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
End Function
Public Overrides Function CustomEventDeclaration(
name As String, type As SyntaxNode,
Optional accessibility As Accessibility = Accessibility.NotApplicable,
Optional modifiers As DeclarationModifiers = Nothing,
Optional parameters As IEnumerable(Of SyntaxNode) = Nothing,
Optional addAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing,
Optional removeAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing) As SyntaxNode
Return CustomEventDeclarationWithRaise(name, type, accessibility, modifiers, parameters, addAccessorStatements, removeAccessorStatements)
End Function
Public Function CustomEventDeclarationWithRaise(
name As String,
type As SyntaxNode,
Optional accessibility As Accessibility = Accessibility.NotApplicable,
Optional modifiers As DeclarationModifiers = Nothing,
Optional parameters As IEnumerable(Of SyntaxNode) = Nothing,
Optional addAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing,
Optional removeAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing) As SyntaxNode
Optional removeAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing,
Optional raiseAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing) As SyntaxNode
Dim accessors = New List(Of AccessorBlockSyntax)()
Dim raiseAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing
If modifiers.IsAbstract Then
addAccessorStatements = Nothing
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册