Skip to content

Inconsistency: "Blank serial names are prohibited" #2104

@BenWoodworth

Description

@BenWoodworth

Currently the @SerialName annotation allows blank names, but the serial descriptor constructors/builders do not

I noticed this when migrating an existing @Serializable @SerialName("") class from the auto-generated serializer to a custom one.

These throw:

  • SerialDescriptor
  • PrimitiveSerialDescriptor
  • buildSerialDescriptor
  • buildClassSerialDescriptor

But this does not:

@Serializable
@SerialName("")
data class MyClass(val a: String)

// {"":{a:"MyClass"}}
println(StringifiedNbt.encodeToString(MyClass("MyClass")))

I can see why maybe it should be disallowed all around, since e.g. class serial names are useful in error messages, but I thought I should post the issue to poke at what really should be allowed.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions