-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support public, internal, private, static, virtual, sealed, abstract, and extern modifiers with interface events. #19080
Conversation
… and extern modifiers with interface events.
Assert.False(p01.IsSealed); | ||
Assert.False(p01.IsStatic); | ||
Assert.False(p01.IsExtern); | ||
Assert.False(p01.IsOverride); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider adding a VerifyModifiers(MethodSymbol, DeclarationModifiers)
helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened an issue #19116.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I agree with Chuck that investing in some test helpers would be worth it and will help with readability.
@dotnet/roslyn-compiler Please review, need a second sign-off. |
@@ -80,6 +80,11 @@ internal SourceFieldLikeEventSymbol(SourceMemberContainerTypeSymbol containingTy | |||
// Don't initialize this.type - we'll just use the type of the field (which is lazy and handles var) | |||
} | |||
|
|||
if (inInterfaceType && !this.IsAbstract && !this.IsExtern) | |||
{ | |||
diagnostics.Add(ErrorCode.ERR_EventNeedsBothAccessors, this.Locations[0], this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an error?
Because non-abstract, non-extern events should declare both accessors with implementation.
ValidateAccessor(p1.AddMethod); | ||
ValidateAccessor(p1.RemoveMethod); | ||
|
||
void ValidateAccessor(MethodSymbol acessor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: accessor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: accessor
Thanks, will fix throughout the file in the next PR.
System.Console.WriteLine(""get_P1""); | ||
} | ||
remove | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: accessor
LGTM |
@dotnet/roslyn-compiler Please review.