fix(core): Fixes accounts and moves it to codegen (#644)

- [X] Fixes TimeSpan not working with codegen
- [X] Fixes bad check for generic classes with a serialize method and deserialize ctor
- [X] Moves Accounts to codegen so it is versioned
- [X] Fixes deserialization of old Accounts with no version variable.
- [X] Fixes deserialize seek not doing anything. 🙈 
- [X] Adds Email to serialization
This commit is contained in:
Kamron Batman 2021-06-05 19:39:16 -07:00 committed by GitHub
parent ac4d349caa
commit 75db56edc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 378 additions and 464 deletions

View file

@ -34,7 +34,7 @@ namespace SerializableMigration
out string[] ruleArguments
)
{
if (symbol.IsIpAddress(compilation))
if (symbol.IsIpAddress(compilation) || symbol.IsTimeSpan(compilation))
{
ruleArguments = Array.Empty<string>();
return true;
@ -91,6 +91,7 @@ namespace SerializableMigration
var argument = property.RuleArguments.Length >= 1 ? property.RuleArguments[0] : null;
const string ipAddress = SymbolMetadata.IPADDRESS_CLASS;
const string timeSpan = SymbolMetadata.TIMESPAN_STRUCT;
const string date = "System.DateTime";
var readMethod = property.Type switch
@ -111,7 +112,8 @@ namespace SerializableMigration
"decimal" => "ReadDecimal",
date when argument == "DeltaTime" => "ReadDeltaTime",
date => "ReadDateTime",
ipAddress => "ReadIPAddress"
ipAddress => "ReadIPAddress",
timeSpan => "ReadTimeSpan"
};
var readArgument = readMethod == "ReadString" && argument == "InternString" ? "true" : "";

View file

@ -15,6 +15,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using SerializationGenerator;
@ -63,7 +64,7 @@ namespace SerializableMigration
var argument = property.RuleArguments.Length >= 1 &&
property.RuleArguments[0] == "DeserializationRequiresParent" ? ", this" : "";
source.AppendLine($"{indent}{propertyName} = new {property.Type}(reader{argument})");
source.AppendLine($"{indent}{propertyName} = new {property.Type}(reader{argument});");
}
public void GenerateSerializationMethod(StringBuilder source, string indent, SerializableProperty property)