-
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
Expression body syntax for accessors, ctor and finalize #8594
Conversation
- src\Tools\Source\CompilerGeneratorTools\Source\CSharpSyntaxGenerator\SourceWriter.cs Change DetermineMinimalOptionalField to output more default fields, so that BlockSyntax and ArrowExpressionClauseSyntax are allowed for AccessorDeclarationSyntax in Syntax.xml. That also changed the definition in Syntax.xml.Generated.cs for "public static CatchClauseSyntax CatchClause()"
tag @dotnet/roslyn-compiler Thanks for you contribution, just to set expectations, this has to be approved by the language design committee before we'll merge this in. The jobs have run, and there's test failures:
These will need to be resolved, if the tests are now expecting a behavior that has changed, either update them or delete them if they know longer make sense. |
@dotnet-bot test eta please |
…nstead of ERR_SemiOrLBraceExpected
…43ERR_SemiOrLBraceExpected()
Can anyone who has more experience than me shed a light on the windows tests are often hanging at the end? I think that there may be a race condition, but I have no idea where to look for it. |
@dotnet-bot retest prtest/win/dbg/unit64 please |
As my implementation has changed some of the shipped APIs, I have overloaded those methods with the old signature in SyntaxFactory.cs (for statics) and PropertyDeclarationSyntax.cs (for instances). I dunno if that is right. Is there another place? |
@lachbaer the one API issue I saw glancing through that needed to be updated was the removal of this call:
We need to maintain binary compat hence can't remove this. It's fine for this to be implemented by just chaining into the new version that you added though. |
|
…re for CatchClause()
I've fixed that issue with CatchClause(). |
@lachbaer Is there any ambiguity that |
@davkean Do you still have this noted? |
@davkean No, we do not have a sponsor for this, and it has not yet been discussed in the LDM. We have other more urgent issues. This was discussed in the original draft design of |
@lachbaer I am done with review pass. I haven't looked at test changes because it looks like some of the new or existing tests are failing. |
@AlekseyTs Thank you very much! |
The tests fail, because the feature must be enabled for them now. |
@jaredpar @davkean @gafter @AlekseyTs Action a = delegate () { DoSomething(); };
Action a = delegate () => DoSomething();
Action a = () => DoSomething(); I know that this is somehow redundant to lambdas, but it would allow for "expression syntax everywhere", at least everywhere where a method block body is allowed, meaning that there will be no exception where this is not allowed. |
@gafter Could you bring the question above to the next LDM? |
GetOrAddModelIfContains(constructorDecl.Body, span); | ||
GetOrAddModelIfContains(constructorDecl.Initializer, span) ?? | ||
GetOrAddModelIfContains(expressionBody, span) ?? | ||
GetOrAddModelIfContains(constructorDecl.Body, span); | ||
} | ||
|
||
case SyntaxKind.DestructorDeclaration: |
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.
Is the Destructor
case now the same as the MethodDeclaration
case?
@lachbaer @gafter @MadsTorgersen I don't think we should add expression bodies to the existing anonymous delegate syntax, but I think if we add a way to ignore parameters in lambda syntax there's no reason for anyone to ever use it again (and we can finally declare it "deprecated"). |
Agree with @agocke. The anonymous delegate syntax is a construct we don't want to invest in further. Would instead like to separately consider a way to make lambdas capable of having the ignore parameter list feature. |
@agocke @jaredpar I think you are right. I had a look at it and I think that it is not worth the effort to put in it. Anonymous delegates don't have much similarity to the changes done here. Regarding the ignore parameter list, do you intend to omit the Action act =
void => {
DoSome();
Things();
};
// methods:
public DateTime GetRandomDate(void) => _randomDate.Next(); In my opinion that looks much better than |
…ged unshipped API Shortened SyntaxExtensions.cs
Giving to @jaredpar for reassignment |
Hey @lachbaer, First wanted to apologize for going silent on this PR after the work you put into it. The team ended up getting swamped on a number of issues and this fell off of my radar. Again my apologies. On a better note though we have a bit more time in our schedule than originally anticipated. We’ve decided to allocate some of that time to getting this feature into C# 7.0. @gafter has already taken this PR, gotten it up to date with master and will be sending out a PR shortly to move it into a feature branch. The code needs to move there temporarily so we can finish off some of the IDE, ENC work involved before merging back into master. Hoping to complete this work in the next week in order to get it ready for the next preview. Thanks again for your contribution! |
This PR has been revised as #13543 |
@AndyGerlicher You have some automation that just removed a label from this PR. Please figure out what is doing that and cause it to stop. |
Allowing
=>
arrow operator onget
,set
,add
andremove
accessors.(Proposal #7881)