@@ -179,11 +179,7 @@ impl Language for CSharp {
179179 writeln ! ( w, "\n }}\n " )
180180 }
181181 RustEnum :: Algebraic { shared, .. } => {
182- write_discriminated_union_json_attributes (
183- w,
184- e,
185- self . without_csharp_naming_convention ,
186- ) ?;
182+ write_discriminated_union_json_attributes ( w, e) ?;
187183 write ! (
188184 w,
189185 "public abstract record {}{} \n {{" ,
@@ -207,11 +203,7 @@ impl Language for CSharp {
207203 }
208204}
209205
210- fn write_discriminated_union_json_attributes (
211- w : & mut dyn Write ,
212- e : & RustEnum ,
213- with_rename : bool ,
214- ) -> io:: Result < ( ) > {
206+ fn write_discriminated_union_json_attributes ( w : & mut dyn Write , e : & RustEnum ) -> io:: Result < ( ) > {
215207 match e {
216208 RustEnum :: Algebraic {
217209 tag_key,
@@ -220,16 +212,18 @@ fn write_discriminated_union_json_attributes(
220212 } => {
221213 writeln ! ( w, "[JsonConverter(typeof(JsonSubtypes), \" {}\" )]" , tag_key) ?;
222214 let case_attributes = shared. variants . iter ( ) . map ( |v| {
223- let case_name = match v {
215+ let ( case_name, renamed ) = match v {
224216 RustEnumVariant :: AnonymousStruct { shared, .. } => {
225- get_property_name ( with_rename, shared)
217+ ( & shared. id . original , & shared. id . renamed )
218+ }
219+ RustEnumVariant :: Unit ( shared) => ( & shared. id . original , & shared. id . renamed ) ,
220+ RustEnumVariant :: Tuple { shared, .. } => {
221+ ( & shared. id . original , & shared. id . renamed )
226222 }
227- RustEnumVariant :: Unit ( shared) => get_property_name ( with_rename, shared) ,
228- RustEnumVariant :: Tuple { shared, .. } => get_property_name ( with_rename, shared) ,
229223 } ;
230224 format ! (
231- "[JsonSubtypes.KnownSubType(typeof({0}), \" {0 }\" )]" ,
232- case_name,
225+ "[JsonSubtypes.KnownSubType(typeof({0}), \" {1 }\" )]" ,
226+ case_name, renamed
233227 )
234228 } ) ;
235229
@@ -239,17 +233,6 @@ fn write_discriminated_union_json_attributes(
239233 }
240234}
241235
242- fn get_property_name (
243- with_rename : bool ,
244- shared : & crate :: rust_types:: RustEnumVariantShared ,
245- ) -> & String {
246- if with_rename {
247- & shared. id . renamed
248- } else {
249- & shared. id . original
250- }
251- }
252-
253236impl CSharp {
254237 fn write_enum_variants ( & mut self , w : & mut dyn Write , e : & RustEnum ) -> io:: Result < ( ) > {
255238 match e {
@@ -331,7 +314,11 @@ impl CSharp {
331314 write ! (
332315 w,
333316 "\t public record {}({}{}Inner{} {}): {}{}();" ,
334- shared. id. renamed,
317+ if self . without_csharp_naming_convention {
318+ & shared. id. renamed
319+ } else {
320+ & shared. id. original
321+ } ,
335322 e. shared( ) . id. original,
336323 shared. id. original,
337324 generics,
0 commit comments