@@ -1074,7 +1074,7 @@ private string CompileEncodeField(TypeBase type, string target, int depth = 0, i
10741074 _ => throw new ArgumentOutOfRangeException ( )
10751075 } ,
10761076 DefinedType dt when Schema . Definitions [ dt . Name ] is EnumDefinition ed =>
1077- CompileEncodeField ( ed . ScalarType , $ "{ As ( PrefixNamespace ( dt . Name . ToPascalCase ( ) ) , TypeName ( ed . ScalarType ) , target ) } ", depth , indentDepth ) ,
1077+ CompileEncodeField ( ed . ScalarType , $ "( { TypeName ( ed . ScalarType ) } ) { target } ", depth , indentDepth ) ,
10781078 DefinedType dt =>
10791079 $ "{ PrefixNamespace ( dt . Name . ToPascalCase ( ) ) } .__EncodeInto({ target } , ref writer);",
10801080 _ => throw new InvalidOperationException ( $ "CompileEncodeField: { type } ")
@@ -1134,7 +1134,7 @@ private string CompileDecodeField(TypeBase type, string target, int depth = 0)
11341134 "}" ,
11351135 ScalarType st => $ "{ target } = { ReadBaseType ( st . BaseType ) } ;",
11361136 DefinedType dt when Schema . Definitions [ dt . Name ] is EnumDefinition ed =>
1137- $ "{ target } = { As ( TypeName ( ed . ScalarType ) , PrefixNamespace ( dt . Name . ToPascalCase ( ) ) , ReadBaseType ( ed . BaseType ) ) } ;",
1137+ $ "{ target } = ( { PrefixNamespace ( dt . Name . ToPascalCase ( ) ) } ) { ReadBaseType ( ed . BaseType ) } ;",
11381138 DefinedType dt =>
11391139 $ "{ target } = { PrefixNamespace ( dt . Name . ToPascalCase ( ) ) } .__DecodeFrom(ref reader);",
11401140 _ => throw new InvalidOperationException ( $ "CompileDecodeField: { type } ")
@@ -1352,11 +1352,6 @@ private string TypeName(in TypeBase type, string arraySizeVar = "")
13521352 } ;
13531353 }
13541354
1355- private static string As ( string from , string to , string value )
1356- {
1357- return $ "System.Runtime.CompilerServices.Unsafe.As<{ from } , { to } >(ref System.Runtime.CompilerServices.Unsafe.AsRef({ value } ))";
1358- }
1359-
13601355 public override string Alias { get => "cs" ; set => throw new NotImplementedException ( ) ; }
13611356 public override string Name { get => "C#" ; set => throw new NotImplementedException ( ) ; }
13621357
0 commit comments