Skip to content

Commit

Permalink
Normalize wrappers and fix broken float codegen (#200)
Browse files Browse the repository at this point in the history
* Normalize all wrappers to exclude state and no longer be records (following prior commits)

* Fix generator to reference correct type name for float32 type
  • Loading branch information
AlgorithmsAreCool authored Oct 16, 2024
1 parent 8633dc0 commit 4777246
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/generator/Wrappers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ readonly partial struct {{wrapperName}} { }
SpecialType.System_Int32 => "Int32Wrap",
SpecialType.System_Int64 => "Int64Wrap",
SpecialType.System_String => "StringWrap",
SpecialType.System_Single => "FloatWrap",
SpecialType.System_Single => "SingleWrap",
SpecialType.System_Double => "DoubleWrap",
SpecialType.System_Decimal => "DecimalWrap",
_ => null
Expand Down
14 changes: 7 additions & 7 deletions src/serde/Wrappers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Serde;
void ISerialize<T>.Serialize(T value, ISerializer serializer) => value.Serialize(value, serializer);
}

public readonly partial record struct BoolWrap
public readonly partial struct BoolWrap
: ISerialize<bool>, IDeserialize<bool>
{
public static ISerdeInfo SerdeInfo { get; } = Serde.SerdeInfo.MakePrimitive(s_typeName);
Expand Down Expand Up @@ -168,7 +168,7 @@ private sealed class SerdeVisitor : IDeserializeVisitor<long>
}
}

public readonly record struct SingleWrap : ISerialize<float>, IDeserialize<float>
public readonly struct SingleWrap : ISerialize<float>, IDeserialize<float>
{
public static ISerdeInfo SerdeInfo { get; } = Serde.SerdeInfo.MakePrimitive("float");
public void Serialize(float value, ISerializer serializer)
Expand All @@ -177,7 +177,7 @@ public static float Deserialize(IDeserializer deserializer)
=> deserializer.ReadFloat();
}

public readonly partial record struct DoubleWrap
public readonly partial struct DoubleWrap
: ISerialize<double>, IDeserialize<double>
{
public static ISerdeInfo SerdeInfo { get; } = Serde.SerdeInfo.MakePrimitive("double");
Expand Down Expand Up @@ -263,7 +263,7 @@ private ArgumentOutOfRangeException GetOOR(int index)

public static class NullableWrap
{
public readonly partial record struct SerializeImpl<T, TWrap> : ISerialize<T?>
public readonly partial struct SerializeImpl<T, TWrap> : ISerialize<T?>
where T : struct
where TWrap : struct, ISerialize<T>
{
Expand All @@ -281,7 +281,7 @@ public static class NullableWrap
}
}

public readonly partial record struct DeserializeImpl<T, TWrap>
public readonly partial struct DeserializeImpl<T, TWrap>
: IDeserialize<T?>
where T : struct
where TWrap : IDeserialize<T>
Expand Down Expand Up @@ -311,7 +311,7 @@ private sealed class Visitor : IDeserializeVisitor<T?>

public static class NullableRefWrap
{
public readonly partial record struct SerializeImpl<T, TWrap> : ISerialize<T?>
public readonly partial struct SerializeImpl<T, TWrap> : ISerialize<T?>
where T : class
where TWrap : struct, ISerialize<T>
{
Expand All @@ -330,7 +330,7 @@ public static class NullableRefWrap
}
}

public readonly partial record struct DeserializeImpl<T, TWrap>(T? Value)
public readonly partial struct DeserializeImpl<T, TWrap>
: IDeserialize<T?>
where T : class
where TWrap : IDeserialize<T>
Expand Down

0 comments on commit 4777246

Please sign in to comment.