roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Semantic snippets - `propg` and `propi` snippets

Open DoctorKrolic opened this issue 2 years ago • 0 comments

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 avatar Dec 13 '22 20:12 DoctorKrolic