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
CSharpSyntaxGenerator does not support adding interface members with a default implementation #53605
Comments
This is about SyntaxGenerator not SourceGenerator. |
Sorry about that. Fixed the content of the issue since you already fixed the title. |
Assigning to Cyrus to review the API |
This is challenging as we've always supported generating interface members by taking a normal member and just adding it to an interface. We toss things like the bodies in this case. So it's very likely that code exists that depends on that behavior. So it could be extremely problematic to change that now. It's not clear what a viable approach would be here except maybe to allow AddMembers to specify some new behaviors here that can be opted into. |
Version Used: 3.9.0-3.final. The failing code is in
main
atroslyn/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
Lines 771 to 796 in 17facfa
Steps to Reproduce:
SyntaxGenerator
namedgenerator
as part of a code-fix running in C#, anIMethodSymbol
namedmethod
, and aSyntaxNode
nameddeclaration
that represents aninterface
, run the following snippet:Expected Behavior:
The generated code in
declaration
will have a method based onmethod
that has the following body:Actual Behavior:
The generated code will have an interface member declaration with no body.
Based on the code in Roslyn linked above, this bug will be hit for properties, indexers, and event declarations as well.
This is blocking providing the code fixes as part of dotnet/runtime#41529
The text was updated successfully, but these errors were encountered: