-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix enum property missing allow rename
- Loading branch information
Showing
4 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#[typeshare] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ObjectNamedA { | ||
depends_on: String, | ||
age: i32, | ||
some_string_value: String, | ||
} | ||
|
||
#[typeshare] | ||
#[derive(Serialize, Deserialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub enum DimensionFitValue { | ||
WrapContent, | ||
FitHeight, | ||
} | ||
|
||
#[typeshare] | ||
#[derive(Serialize, Deserialize)] | ||
#[serde(tag = "type", content = "value", rename_all = "kebab-case")] | ||
pub enum DimensionValue { | ||
FixedSize(f32), | ||
Percentage(f32), | ||
Fit(DimensionFitValue), | ||
} |
38 changes: 38 additions & 0 deletions
38
core/data/tests/csharp_without_naming_convention/output.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
public class ObjectNamedA { | ||
[JsonProperty(Required = Required.Always)] | ||
public string dependsOn { get; set; } | ||
[JsonProperty(Required = Required.Always)] | ||
public int age { get; set; } | ||
[JsonProperty(Required = Required.Always)] | ||
public string someStringValue { get; set; } | ||
} | ||
|
||
public enum DimensionFitValue | ||
{ | ||
[EnumMember(Value = "wrap-content")] | ||
WrapContent, | ||
|
||
[EnumMember(Value = "fit-height")] | ||
FitHeight, | ||
|
||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(fixed-size), "fixed-size")] | ||
[JsonSubtypes.KnownSubType(typeof(percentage), "percentage")] | ||
[JsonSubtypes.KnownSubType(typeof(fit), "fit")] | ||
public abstract record DimensionValue | ||
{ | ||
public record FixedSize(float Value) : DimensionValue(); | ||
public record Percentage(float Value) : DimensionValue(); | ||
public record Fit(DimensionFitValue Value) : DimensionValue(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters