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

Semantic snippets - propg and propi snippets #65979

Merged
merged 13 commits into from
Feb 3, 2023

Conversation

DoctorKrolic
Copy link
Contributor

Abstracted a lot of logic for property generation. In theory, it now allows to generate any kind of auto property, even with different get accessor.

On top of new abstractions added 2 snippets:

  • propg is a replacement of an old snippet. It generates property like public int MyProperty { get; private set; }. The only thing I changed is that when this snippet is executed in interface, it doesn't generate private set accessor, because it leads to compiler error. If a user executes propg snippet in interface I am 99% sure he wants just a get accessor
  • propi is a new snippet I invented "on the fly". Usage of init properties has grown over years and after required modifier from C# 11 I assume it would grow even more. I don't see valid reasons against adding init-only property snippet then

Abstracted property snippet tests as well. There are now 11 basic cases and an ability to override any special case behaviour like it is done for propg inside an interface.

I got a bit carried away, so unfortunately the first commit is bit large and could be 100% splitted into smaller parts, sorry for that!

@DoctorKrolic DoctorKrolic requested a review from a team as a code owner December 13, 2022 20:32
@ghost ghost added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Dec 13, 2022
@DoctorKrolic
Copy link
Contributor Author

Can I get a review here? @akhera99 ?

@akhera99
Copy link
Member

Can I get a review here? @akhera99 ?

Looking!

Copy link
Member

@akhera99 akhera99 left a comment

Choose a reason for hiding this comment

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

Looks good to me other than the things noted!

@akhera99 akhera99 merged commit 7f33738 into dotnet:main Feb 3, 2023
@ghost ghost added this to the Next milestone Feb 3, 2023
@akhera99
Copy link
Member

akhera99 commented Feb 3, 2023

Merged, thanks for the contribution!

@DoctorKrolic DoctorKrolic deleted the new-property-snippets branch February 3, 2023 19:52
333fred added a commit to 333fred/roslyn that referenced this pull request Feb 6, 2023
* upstream/main: (547 commits)
  Add VerifyMethodBody helper as a replacement of VerifyIL (dotnet#66536)
  don't offer rename for ctor snippet (dotnet#66704)
  Get `ConditionalAttribute` type only once per compilation
  Convert language-specific option types to records (dotnet#66633)
  Enable MSBuild COMM log (dotnet#66708)
  ⚡️Share AssemblyloadTestFixture on Framework (dotnet#66684)
  NRT
  Don't overwrite binary logs in CI (dotnet#66683)
  Fix 'Generate Enum Member' to work in a 'Color Color' case.
  Find bitwise operators accessed through logical operators in FAR
  Semantic snippets - `propg` and `propi` snippets (dotnet#65979)
  NRT
  Properly classify aliases in quick info
  Fix
  Add tests
  Add support for finding collection initialiers with FAR
  Do not suggest replacing lambda with method group if the invoked mehod has `Conditional` attribute
  Revert "Record added node output states as new (dotnet#61575)" (dotnet#66696)
  Record added node output states as new (dotnet#61575)
  Fix formatting issue with convert-to-full-prop
  ...
@RikkiGibson RikkiGibson modified the milestones: Next, 17.6 P2 Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants