Partial classes - feature proposal
A proposal to address request https://github.com/dart-lang/language/issues/252
Pending PR: https://github.com/dart-lang/language/pull/680
Inspiration: https://github.com/jaredpar/csharplang/blob/partial/proposals/extending-partial-methods.md
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).
Love this feature
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.
@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! 😄
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 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 ^