Skip to content
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

Enable a default implementation of an interface event to be provided as part of its declaration. #18183

Merged

Conversation

AlekseyTs
Copy link
Contributor

@dotnet/roslyn-compiler Please review.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler Please review.


Validate2(compilation2.SourceModule);
compilation2.VerifyDiagnostics();
CompileAndVerify(compilation2, verify: false, symbolValidator: Validate2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if I asked already: should we track updating PEVerify to understand the newly produced assemblies?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEVerify doesn't even handle C# 7 constructs. We should track that work, but I don't expect it will be in scope of completing and shipping this language feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tracked in #17952.

);

ValidateEventImplementation_501(compilation1.SourceModule, "Test1");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I missed it, but I didn't see the happy path run end-to-end (CompileAndVerify with expectedOutput).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you didn't miss it. At the moment tests cannot target runtime that supports the feature. Tracked in #17952 as well. We verify symbols for now.

Assert.Equal("I1", test2Result.Interfaces.Single().ToTestDisplayString());
ValidateEventImplementation_501(m, "Test2");
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember there is a special kind of events for windows runtime. Is it worth covering too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to cover them eventually, tracked in #17952.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, other than the minor issues noted.


compilation1.VerifyDiagnostics(
// (6,12): error CS0073: An add or remove accessor must have a body
// add;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right.

Copy link
Contributor Author

@AlekseyTs AlekseyTs Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels fine to me and is not caused by the change. Abstract events must omit accessors list. Non-abstract custom events must provide bodies for both accessors. This behavior feels reasonable to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagnostic seems to complain about the add;, but you're saying it complains about the remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean now, yes the comment is out of sync with the test scenario. I'll adjust it.

Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);

compilation1.VerifyDiagnostics(
// (4,32): error CS0106: The modifier 'static' is not valid for this item
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it was not your intent to support it yet, but the appropriate diagnostic here should be that 'static' in an interface is not supported in language version '7'; use language version '7.1'. Please add a PROTOTYPE comment noting that will need to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature MD file clearly states that static members in interfaces are not supported (by explicitly listing what is supported). I do not think there is a good reason to add a PROTOTYPE comment to duplicate that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me put it this way: this test contradicts the feature specification. You should not add tests that ensure that the feature implementation behaves in a way contrary to the feature specification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am adding tests to test the current state of the feature, my expectations. What spec says is irrelevant, until I claim that the relevant portion of the spec is implemented.

@AlekseyTs AlekseyTs merged commit e9eb5d6 into dotnet:features/DefaultInterfaceImplementation Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants