-
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
Added support to normalize auto properties on a single line. #49495
Conversation
Added more tests including init accessor and initializers Changed two existing tests to reflect the changes
Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
in general, the appraoch is good. just needs more clarity :) |
No functional changes
@CyrusNajmabadi I see errors in the Linux/OSX builds but have no idea why. Do they depend on my PR? |
Yes, you're failing some test in Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests. This should also trigger in the other tests to state what test actually failed. |
I see them locally. They are |
…use of the auto-properties formatting is now different: TestSpacingOnNullableDatetimeType, TestSpacingOnNullableIntType
Yup. If it's adjusting the behavior for just these new constructs, that would be fine. Thanks! :) |
The check was easy and made sense, so I proceeded. Thank you |
You're welcome! Thank you for the PR :) |
Apparently there is another set of tests suffering from this changes, but this time I run the test locally and they succeeded.
Fail message:
@CyrusNajmabadi do you have suggestions? |
This is not on you. @jaredpar we have a determinism failure as per:
How do you generally handle this? |
I am trying to re-trigger the tests because I saw the failed test is the following one and I can't see how this PR could affect it.
|
In the future, just let us know and don't use commits to retrigger. We'll take a look and retrigger if necessary. |
Sorry, I did it because it failed multiple times last week for random reasons (but not becuse of the PR) and I committed the requested changes in the middle of US festivities. |
No worries, just letting you know for the future. |
=> node is AccessorListSyntax accessorList && | ||
accessorList.Parent is BasePropertyDeclarationSyntax basePropertyDeclarationSyntax && | ||
HasInitializer(basePropertyDeclarationSyntax); |
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.
=> node is AccessorListSyntax accessorList && | |
accessorList.Parent is BasePropertyDeclarationSyntax basePropertyDeclarationSyntax && | |
HasInitializer(basePropertyDeclarationSyntax); | |
=> node is AccessorListSyntax && | |
node.Parent is PropertyDeclarationSyntax property && | |
property.Initializer != null; |
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.
@CyrusNajmabadi Are you sure about this?
This prevents any initializers outside the properties (if they will ever exists)
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.
@AlekseyTs what do you think about this?
I was searching to avoid looking for properties on purpose so that any derived class from BasePropertyDeclarationSyntax
having an accessor fit in the inline formatting.
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.
what do you think about this?
I am fine with the code and names as it is.
In reply to: 534376783 [](ancestors = 534376783)
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.
This prevents any initializers outside the properties (if they will ever exists)
your existing code already prevents taht as you do a type check for PropertyDeclarationSyntax yourself in HasInitializer.
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.
your existing code already prevents taht as you do a type check for PropertyDeclarationSyntax yourself in HasInitializer.
Sure, but is well identified in that point. Currently I can't do differently because properties arei the only one allowed.
Could in the future be possible, let's say, for indexers to be initialized, the changes would be limited to a single point and this function would work correctly.
I don't see how the current version could cause problems. Let me know if you want me to change it anyway, so that I can send the commit before night (here). Thanks
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.
the changes would be limited to a single point and this function would work correctly.
that is true with the change i suggested as well. in both cases we will need to update the code. so might as well have hte code be correct and precise for the trees we have today.
Let me know if you want me to change it anyway
Yes please :)
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.
Okay, and what about the method names?
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.
i'll defer to Aleksey's judgement on those :)
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.
@AlekseyTs I committed all the required changes but not the method renaming.
It's up to you now :)
tests LGTM. code is almost there. If you would like someone to pick this up to complete this @raffaeler i would be happy to help. If you'd prefer to finish it yourself, that's 100% ok. I just dont' want you to burn out from all the nitpicking i give :) THanks! |
no problems, thanks. At this point I want to see the end :)
Since I startyed renaming on my side, I am not committing your suggestions to avoid merging. That's all, but thanks :) |
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 (commit 17)
@dotnet/roslyn-compiler For the second review. Note, when merging this PR we need to squash commits and adjust the commit title to reflect the broader impact of this change. |
@dotnet/roslyn-compiler For the second review of a small community PR. Note, when merging this PR we need to squash commits and adjust the commit title to reflect the broader impact of this change. |
@dotnet/roslyn-compiler For the second review of a small community PR. Note, when merging this PR we need to squash commits and adjust the commit title to reflect the broader impact of this change. |
@raffaeler Thanks for the contribution. |
Thank you @AlekseyTs and @CyrusNajmabadi :) |
The discussion started here: #49468
The work consisted in:
The following comparisons shows the results of the actual tests, before and after this PR.