-
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.
Merge branch 'feature/csharp' of github.com:dandro/typeshare into fea…
…ture/csharp Update snapshots
- Loading branch information
Showing
47 changed files
with
1,499 additions
and
54 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
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
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
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; | ||
|
||
/** Generated type representing the anonymous struct variant `List` of the `AnonymousStructWithRename` Rust enum */ | ||
public class AnonymousStructWithRenameListInner { | ||
public IEnumerable<string> list { get; set; } | ||
} | ||
|
||
/** Generated type representing the anonymous struct variant `LongFieldNames` of the `AnonymousStructWithRename` Rust enum */ | ||
public class AnonymousStructWithRenameLongFieldNamesInner { | ||
public string some_long_field_name { get; set; } | ||
public bool and { get; set; } | ||
public IEnumerable<string> but_one_more { get; set; } | ||
} | ||
|
||
/** Generated type representing the anonymous struct variant `KebabCase` of the `AnonymousStructWithRename` Rust enum */ | ||
public class AnonymousStructWithRenameKebabCaseInner { | ||
public IEnumerable<string> another-list { get; set; } | ||
public string camelCaseStringField { get; set; } | ||
public bool something-else { get; set; } | ||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(List), "List")] | ||
[JsonSubtypes.KnownSubType(typeof(LongFieldNames), "LongFieldNames")] | ||
[JsonSubtypes.KnownSubType(typeof(KebabCase), "KebabCase")] | ||
public abstract record AnonymousStructWithRename | ||
{ | ||
public record list(AnonymousStructWithRenameListInner Content): AnonymousStructWithRename(); | ||
public record longFieldNames(AnonymousStructWithRenameLongFieldNamesInner Content): AnonymousStructWithRename(); | ||
public record kebabCase(AnonymousStructWithRenameKebabCaseInner Content): AnonymousStructWithRename(); | ||
} | ||
|
||
|
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,29 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
public class ItemDetailsFieldValue { | ||
public string Hello { get; set; } | ||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "t")] | ||
[JsonSubtypes.KnownSubType(typeof(String), "String")] | ||
[JsonSubtypes.KnownSubType(typeof(Number), "Number")] | ||
[JsonSubtypes.KnownSubType(typeof(NumberArray), "NumberArray")] | ||
[JsonSubtypes.KnownSubType(typeof(ReallyCoolType), "ReallyCoolType")] | ||
[JsonSubtypes.KnownSubType(typeof(ArrayReallyCoolType), "ArrayReallyCoolType")] | ||
[JsonSubtypes.KnownSubType(typeof(DictionaryReallyCoolType), "DictionaryReallyCoolType")] | ||
public abstract record AdvancedColors | ||
{ | ||
public record String(string C) : AdvancedColors(); | ||
public record Number(int C) : AdvancedColors(); | ||
public record NumberArray(IEnumerable<int> C) : AdvancedColors(); | ||
public record ReallyCoolType(ItemDetailsFieldValue C) : AdvancedColors(); | ||
public record ArrayReallyCoolType(IEnumerable<ItemDetailsFieldValue> C) : AdvancedColors(); | ||
public record DictionaryReallyCoolType(IDictionary<string, ItemDetailsFieldValue> C) : AdvancedColors(); | ||
} | ||
|
||
|
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,48 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Company.Domain.Models; | ||
|
||
/** Struct comment */ | ||
public class ItemDetailsFieldValue { | ||
} | ||
|
||
/** Enum comment */ | ||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(String), "String")] | ||
[JsonSubtypes.KnownSubType(typeof(Number), "Number")] | ||
[JsonSubtypes.KnownSubType(typeof(UnsignedNumber), "UnsignedNumber")] | ||
[JsonSubtypes.KnownSubType(typeof(NumberArray), "NumberArray")] | ||
[JsonSubtypes.KnownSubType(typeof(ReallyCoolType), "ReallyCoolType")] | ||
public abstract record AdvancedColors | ||
{ | ||
/** This is a case comment */ | ||
public record String(string Content) : AdvancedColors(); | ||
public record Number(int Content) : AdvancedColors(); | ||
public record UnsignedNumber(uint Content) : AdvancedColors(); | ||
public record NumberArray(IEnumerable<int> Content) : AdvancedColors(); | ||
/** Comment on the last element */ | ||
public record ReallyCoolType(ItemDetailsFieldValue Content) : AdvancedColors(); | ||
} | ||
|
||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(String), "String")] | ||
[JsonSubtypes.KnownSubType(typeof(Number), "Number")] | ||
[JsonSubtypes.KnownSubType(typeof(NumberArray), "NumberArray")] | ||
[JsonSubtypes.KnownSubType(typeof(ReallyCoolType), "ReallyCoolType")] | ||
public abstract record AdvancedColors2 | ||
{ | ||
/** This is a case comment */ | ||
public record String(string Content) : AdvancedColors2(); | ||
public record Number(int Content) : AdvancedColors2(); | ||
public record NumberArray(IEnumerable<int> Content) : AdvancedColors2(); | ||
/** Comment on the last element */ | ||
public record ReallyCoolType(ItemDetailsFieldValue Content) : AdvancedColors2(); | ||
} | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
core/data/tests/can_generate_algebraic_enum_with_skipped_variants/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,17 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(A), "A")] | ||
[JsonSubtypes.KnownSubType(typeof(C), "C")] | ||
public abstract record SomeEnum | ||
{ | ||
public record A(): SomeEnum(); | ||
public record C(int Content) : SomeEnum(); | ||
} | ||
|
||
|
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,18 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
/** This is a comment. */ | ||
public enum Colors | ||
{ | ||
Red, | ||
|
||
Blue, | ||
|
||
Green, | ||
|
||
} | ||
|
20 changes: 20 additions & 0 deletions
20
core/data/tests/can_generate_empty_algebraic_enum/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,20 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
public class AddressDetails { | ||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(FixedAddress), "FixedAddress")] | ||
[JsonSubtypes.KnownSubType(typeof(NoFixedAddress), "NoFixedAddress")] | ||
public abstract record Address | ||
{ | ||
public record FixedAddress(AddressDetails Content) : Address(); | ||
public record NoFixedAddress(): Address(); | ||
} | ||
|
||
|
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,69 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantA), "VariantA")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantB), "VariantB")] | ||
public abstract record GenericEnum<TA, TB> | ||
{ | ||
public record VariantA(TA Content) : GenericEnum<TA, TB>(); | ||
public record VariantB(TB Content) : GenericEnum<TA, TB>(); | ||
} | ||
|
||
|
||
public class StructUsingGenericEnum { | ||
public GenericEnum<string, short> EnumField { get; set; } | ||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantC), "VariantC")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantD), "VariantD")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantE), "VariantE")] | ||
public abstract record GenericEnumUsingGenericEnum<T> | ||
{ | ||
public record VariantC(GenericEnum<T, T> Content) : GenericEnumUsingGenericEnum<T>(); | ||
public record VariantD(GenericEnum<string, IDictionary<string, T>> Content) : GenericEnumUsingGenericEnum<T>(); | ||
public record VariantE(GenericEnum<string, uint> Content) : GenericEnumUsingGenericEnum<T>(); | ||
} | ||
|
||
|
||
/** Generated type representing the anonymous struct variant `VariantF` of the `GenericEnumsUsingStructVariants` Rust enum */ | ||
public class GenericEnumsUsingStructVariantsVariantFInner<T> { | ||
public T Action { get; set; } | ||
} | ||
|
||
/** Generated type representing the anonymous struct variant `VariantG` of the `GenericEnumsUsingStructVariants` Rust enum */ | ||
public class GenericEnumsUsingStructVariantsVariantGInner<T, TU> { | ||
public T Action { get; set; } | ||
public TU Response { get; set; } | ||
} | ||
|
||
/** Generated type representing the anonymous struct variant `VariantH` of the `GenericEnumsUsingStructVariants` Rust enum */ | ||
public class GenericEnumsUsingStructVariantsVariantHInner { | ||
public int NonGeneric { get; set; } | ||
} | ||
|
||
/** Generated type representing the anonymous struct variant `VariantI` of the `GenericEnumsUsingStructVariants` Rust enum */ | ||
public class GenericEnumsUsingStructVariantsVariantIInner<T, TU> { | ||
public IEnumerable<T> Vec { get; set; } | ||
public MyType<T, TU> Action { get; set; } | ||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "type")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantF), "VariantF")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantG), "VariantG")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantH), "VariantH")] | ||
[JsonSubtypes.KnownSubType(typeof(VariantI), "VariantI")] | ||
public abstract record GenericEnumsUsingStructVariants<T, TU> | ||
{ | ||
public record VariantF(GenericEnumsUsingStructVariantsVariantFInner<T> Content): GenericEnumsUsingStructVariants<T, TU>(); | ||
public record VariantG(GenericEnumsUsingStructVariantsVariantGInner<T, TU> Content): GenericEnumsUsingStructVariants<T, TU>(); | ||
public record VariantH(GenericEnumsUsingStructVariantsVariantHInner Content): GenericEnumsUsingStructVariants<T, TU>(); | ||
public record VariantI(GenericEnumsUsingStructVariantsVariantIInner<T, TU> Content): GenericEnumsUsingStructVariants<T, TU>(); | ||
} | ||
|
||
|
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,11 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
public class SomeStruct { | ||
public uint FieldA { get; set; } | ||
} | ||
|
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,22 @@ | ||
#nullable enable | ||
|
||
using System.Reflection; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System.Runtime.Serialization; | ||
|
||
/** | ||
* This is a comment. | ||
* Continued lovingly here | ||
*/ | ||
public enum Colors | ||
{ | ||
Red, | ||
|
||
Blue, | ||
|
||
/** Green is a cool color */ | ||
Green, | ||
|
||
} | ||
|
Oops, something went wrong.