提交 dc923ba4 编写于 作者: C CyrusNajmabadi

Fix generation of events in interfaces.

上级 8ccaa4e1
......@@ -4083,7 +4083,7 @@ private void ParseParameterModifiers(SyntaxListBuilder modifiers)
}
}
private MemberDeclarationSyntax ParseEventDeclarationWithAccessors(
private EventDeclarationSyntax ParseEventDeclarationWithAccessors(
SyntaxListBuilder<AttributeListSyntax> attributes,
SyntaxListBuilder modifiers,
SyntaxToken eventToken,
......@@ -4206,7 +4206,7 @@ private void ParseParameterModifiers(SyntaxListBuilder modifiers)
}
}
private MemberDeclarationSyntax ParseEventFieldDeclaration(
private EventFieldDeclarationSyntax ParseEventFieldDeclaration(
SyntaxListBuilder<AttributeListSyntax> attributes,
SyntaxListBuilder modifiers,
SyntaxToken eventToken,
......
......@@ -733,18 +733,18 @@ internal override SyntaxNode AsInterfaceMember(SyntaxNode m)
.WithModifiers(default(SyntaxTokenList))
.WithAccessorList(WithoutBodies(indexer.AccessorList));
// convert event into field event
case SyntaxKind.EventDeclaration:
var ev = (EventDeclarationSyntax)member;
return ev
.WithModifiers(default(SyntaxTokenList))
.WithAccessorList(WithoutBodies(ev.AccessorList));
return this.EventDeclaration(
ev.Identifier.ValueText,
ev.Type,
Accessibility.NotApplicable,
DeclarationModifiers.None);
// convert event field into event
case SyntaxKind.EventFieldDeclaration:
var ef = (EventFieldDeclarationSyntax)member;
this.GetAccessibilityAndModifiers(ef.Modifiers, out acc, out modifiers);
var ep = this.CustomEventDeclaration(this.GetName(ef), this.ClearTrivia(this.GetType(ef)), acc, modifiers, parameters: null, addAccessorStatements: null, removeAccessorStatements: null);
return this.AsInterfaceMember(ep);
return ef.WithModifiers(default(SyntaxTokenList));
// convert field into property
case SyntaxKind.FieldDeclaration:
......
......@@ -1212,11 +1212,11 @@ public void TestInterfaceDeclarations()
VerifySyntax<InterfaceDeclarationSyntax>(
_g.InterfaceDeclaration("i", members: new[] { _g.CustomEventDeclaration("ep", _g.IdentifierName("t"), accessibility: Accessibility.Public, modifiers: DeclarationModifiers.Static) }),
"interface i\r\n{\r\n event t ep\r\n {\r\n add;\r\n remove;\r\n }\r\n}");
"interface i\r\n{\r\n event t ep;\r\n}");
VerifySyntax<InterfaceDeclarationSyntax>(
_g.InterfaceDeclaration("i", members: new[] { _g.EventDeclaration("ef", _g.IdentifierName("t"), accessibility: Accessibility.Public, modifiers: DeclarationModifiers.Static) }),
"interface i\r\n{\r\n event t ef\r\n {\r\n add;\r\n remove;\r\n }\r\n}");
"interface i\r\n{\r\n event t ef;\r\n}");
VerifySyntax<InterfaceDeclarationSyntax>(
_g.InterfaceDeclaration("i", members: new[] { _g.FieldDeclaration("f", _g.IdentifierName("t"), accessibility: Accessibility.Public, modifiers: DeclarationModifiers.Sealed) }),
......@@ -1677,11 +1677,7 @@ public void TestInterfaceDeclarationWithEventFromSymbol()
_g.Declaration(_emptyCompilation.GetTypeByMetadataName("System.ComponentModel.INotifyPropertyChanged")),
@"public interface INotifyPropertyChanged
{
event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged
{
add;
remove;
}
event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
}");
}
#endregion
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册