Browse Source

Fix nullable value being serialized as non-nullable

pull/100/head
Meivyn 5 months ago
parent
commit
be3a02d53f
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      IPA.Loader/Config/Stores/GeneratedStoreImpl/Serialization.cs

+ 5
- 2
IPA.Loader/Config/Stores/GeneratedStoreImpl/Serialization.cs View File

@ -52,16 +52,19 @@ namespace IPA.Config.Stores
il.MarkLabel(passedNull);
}
if (member.IsNullable)
if (member is { IsNullable: true, HasConverter: false })
il.Emit(OpCodes.Call, member.Nullable_Value.GetGetMethod());
var memberConversionType = member.ConversionType;
var targetType = GetExpectedValueTypeForType(memberConversionType);
if (member.HasConverter)
{
using var stlocal = GetLocal.Allocate(memberConversionType);
using var stlocal = GetLocal.Allocate(member.IsNullable ? member.Type : memberConversionType);
using var valLocal = GetLocal.Allocate(typeof(Value));
if (member.IsNullable)
il.Emit(OpCodes.Ldloc_S, valueTypeLocal.Local);
il.Emit(OpCodes.Stloc, stlocal);
il.BeginExceptionBlock();
il.Emit(OpCodes.Ldsfld, member.ConverterField);


Loading…
Cancel
Save