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:
Kamron Batman 2021-08-20 22:46:13 -07:00 committed by GitHub
parent 1d916fe2df
commit c2f28f9a98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,9 +38,10 @@ namespace SerializationGenerator
foreach (var serializableProperty in properties)
{
var type = compilation.GetTypeByMetadataName(serializableProperty.Type)?.IsValueType == true
|| SymbolMetadata.IsPrimitiveFromTypeDisplayString(serializableProperty.Type)
? $"{serializableProperty.Type}?" : serializableProperty.Type;
var propertyType = serializableProperty.Type;
var type = compilation.GetTypeByMetadataName(propertyType)?.IsValueType == true
|| SymbolMetadata.IsPrimitiveFromTypeDisplayString(propertyType) && propertyType != "bool"
? $"{propertyType}?" : propertyType;
source.AppendLine($"{indent} internal readonly {type} {serializableProperty.Name};");
}
@ -90,7 +91,7 @@ namespace SerializationGenerator
// Special case
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
{