fix(codegen): Fixes bool in migration structs (#709)
* Fixes bool? not being a valid type for save flag property migrations. * Fixes wrong SaveFlag type used in the if check for boolean save flags.
This commit is contained in:
parent
1d916fe2df
commit
c2f28f9a98
1 changed files with 5 additions and 4 deletions
|
|
@ -38,9 +38,10 @@ namespace SerializationGenerator
|
||||||
|
|
||||||
foreach (var serializableProperty in properties)
|
foreach (var serializableProperty in properties)
|
||||||
{
|
{
|
||||||
var type = compilation.GetTypeByMetadataName(serializableProperty.Type)?.IsValueType == true
|
var propertyType = serializableProperty.Type;
|
||||||
|| SymbolMetadata.IsPrimitiveFromTypeDisplayString(serializableProperty.Type)
|
var type = compilation.GetTypeByMetadataName(propertyType)?.IsValueType == true
|
||||||
? $"{serializableProperty.Type}?" : serializableProperty.Type;
|
|| SymbolMetadata.IsPrimitiveFromTypeDisplayString(propertyType) && propertyType != "bool"
|
||||||
|
? $"{propertyType}?" : propertyType;
|
||||||
|
|
||||||
source.AppendLine($"{indent} internal readonly {type} {serializableProperty.Name};");
|
source.AppendLine($"{indent} internal readonly {type} {serializableProperty.Name};");
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +91,7 @@ namespace SerializationGenerator
|
||||||
// Special case
|
// Special case
|
||||||
if (property.Type == "bool")
|
if (property.Type == "bool")
|
||||||
{
|
{
|
||||||
source.AppendLine($"{innerIndent}{property.Name} = (saveFlags & SaveFlag.{property.Name}) != 0;");
|
source.AppendLine($"{innerIndent}{property.Name} = (saveFlags & V{migration.Version}SaveFlag.{property.Name}) != 0;");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue