language icon indicating copy to clipboard operation
language copied to clipboard

Partial classes - feature proposal

Open kevmoo opened this issue 6 years ago • 7 comments

A proposal to address request https://github.com/dart-lang/language/issues/252

Pending PR: https://github.com/dart-lang/language/pull/680

kevmoo avatar Nov 11 '19 23:11 kevmoo

Inspiration: https://github.com/jaredpar/csharplang/blob/partial/proposals/extending-partial-methods.md

kevmoo avatar May 20 '20 18:05 kevmoo

Love this feature. Metaprogramming and code-gen is being discussed in #1482 and I'm working on the second version of my proposal (initially #1507) and the idea of where does the code go and how can it be interacted with from other libraries is a big one. My driving principle is that generated code in a .g.dart file should behave the same as though it were hand-written in regular .dart file.

PS: I'm in favor of partial class X instead of class X partial. It fits better with mixin, abstract, extension, and var which describe the declaration itself instead of implements, extends, and on, which only slightly modify the declaration (and thus go after).

Levi-Lesches avatar Apr 07 '21 18:04 Levi-Lesches

Love this feature

insinfo avatar Sep 15 '21 12:09 insinfo

I opened #1753 to discuss how modules might revive the discussion around partial classes by answering some fundamental question, and how code-generation boosts the need for this feature.

Levi-Lesches avatar Sep 15 '21 19:09 Levi-Lesches

@munificent – I'm MORE than happy to close this out and defer to https://github.com/dart-lang/language/blob/master/working/augmentation-libraries/feature-specification.md – just say the word! 😄

kevmoo avatar Oct 29 '21 23:10 kevmoo

This would be great for protobuf as an example because then like C# the classes can be adorned with partial and then we can do things like add interfaces to the classes generated which can be vital when protobuf doesn't support generics but you want to know that a response type has a specific set of properties on it to work with (i.e. totalCount for paging etc.)

JohnGalt1717 avatar Sep 14 '22 01:09 JohnGalt1717

@JohnGalt1717 not sure about your use case specifically, but you might want to look into extensions. Also:

I'm MORE than happy to close this out and defer to https://github.com/dart-lang/language/blob/master/working/augmentation-libraries/feature-specification.md – just say the word! 😄

@munificent ^

Levi-Lesches avatar Sep 14 '22 21:09 Levi-Lesches