-
Notifications
You must be signed in to change notification settings - Fork 99
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
Allow swift decorator constraints to apply to generics #173
Allow swift decorator constraints to apply to generics #173
Conversation
Will we ever want to apply different decorators to the generics? i.e. |
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 change LGTM! I'm not familiar with Swift, but would we need to do similar logic in write_enum
? This block seems to be doing essentially the same as what you replaced in write_struct
.
Yup I'll update that as well. |
…s-generics Allow swift decorator constraints to apply to generics Support CSharp Create basic language implementation. Start adding tests. Add snapshot tests Update slice type to map to IEnumerable instead of Array. Drop support for Unit type and return an error. Support anonymous structs Update slice of user type test snapshot Support namespace option Support serialization with json attributes Remove EnumLabel and use EnumMember attribute instead. Update all test snapshots according to the new changes. C# without naming convention option Add required attribute For newtonsoft json to require a non optional property, the property has to have the required attribute. Otherwise, it allows it to be null and a default value is provided.
Update: yes, there is a case where we don't want to apply the same decorators to both the struct and its generic type. We often want structs to be Identifiable, but do not want to place that restriction on the generic type. We should look at a mechanism to define separate decorators for the struct itself, and the generic type. |
@charlespierce unfortunately, this can break any code with generics that don't need the same constraints as the struct itself. e.g. the generic type doesn't need Identifiable, but the struct does. @darrell-roberts is working on a fix to allow separate designation of generic constraint decorators, so please coordinate with him on getting the fix in soon, or consider rolling back this one. Thanks. |
…s-generics Allow swift decorator constraints to apply to generics Support CSharp Create basic language implementation. Start adding tests. Add snapshot tests Update slice type to map to IEnumerable instead of Array. Drop support for Unit type and return an error. Support anonymous structs Update slice of user type test snapshot Support namespace option Support serialization with json attributes Remove EnumLabel and use EnumMember attribute instead. Update all test snapshots according to the new changes. C# without naming convention option Add required attribute For newtonsoft json to require a non optional property, the property has to have the required attribute. Otherwise, it allows it to be null and a default value is provided.
…s-generics Allow swift decorator constraints to apply to generics Support CSharp Create basic language implementation. Start adding tests. Add snapshot tests Update slice type to map to IEnumerable instead of Array. Drop support for Unit type and return an error. Support anonymous structs Update slice of user type test snapshot Support namespace option Support serialization with json attributes Remove EnumLabel and use EnumMember attribute instead. Update all test snapshots according to the new changes. C# without naming convention option Add required attribute For newtonsoft json to require a non optional property, the property has to have the required attribute. Otherwise, it allows it to be null and a default value is provided.
…s-generics Allow swift decorator constraints to apply to generics Support CSharp Create basic language implementation. Start adding tests. Add snapshot tests Update slice type to map to IEnumerable instead of Array. Drop support for Unit type and return an error. Support anonymous structs Update slice of user type test snapshot Support namespace option Support serialization with json attributes Remove EnumLabel and use EnumMember attribute instead. Update all test snapshots according to the new changes. C# without naming convention option Add required attribute For newtonsoft json to require a non optional property, the property has to have the required attribute. Otherwise, it allows it to be null and a default value is provided.
Allow
#[typeshare(swift = "Constraint")]
to be applied to generic members.Example in included test case.