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

Add C# Support #155

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add C# Support #155

wants to merge 6 commits into from

Conversation

dandro
Copy link

@dandro dandro commented Feb 19, 2024

Overview

Add support for C# version 11 with NewtonsoftJson as/serialization/deserialization library.

Important Notes

  • C# does not have a Unit type, and hence, it results in an error when the target language is C#
  • C# 11 does not support aliases, and hence, it results in an error when the target language is C#
  • C# has strong naming conventions that are followed in the implementation by design. This breaks Serde renaming in some cases. Therefore, I added a configuration flag so the user can turn C# naming conventions off in favour of the Serde renaming feature.

Testing

I've added snapshot tests to most cases except when the Unit type or Aliases are needed, as this is not supported in C#.

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.
@sanjanadesai27
Copy link

👋🏼 We're currently holding off on including support for new languages as we're in the process of a large refactor to modularize languages.

@dandro
Copy link
Author

dandro commented Jun 28, 2024

👋🏼 We're currently holding off on including support for new languages as we're in the process of a large refactor to modularize languages.

No worries. Yes, I've seen many changes and I am trying to keep up with them so the PR can be reviewed when you have a chance. What would be the rough timeline of the refactoring? Is there anything I could do to help get this in?

charlespierce and others added 5 commits July 23, 2024 16:36
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants