fix(codegen): Fixes bulk order deed hue and codegens (#647)

- [X] Codegens some Bulk Order stuff
- [X] Fixes deserializing with a class that requires the parent as a constructor argument


Closes #641
Closes #623
This commit is contained in:
Kamron Batman 2021-06-11 19:51:03 -07:00 committed by GitHub
parent eb4e3ac070
commit 510d2e006b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 185 additions and 378 deletions

View file

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;
@ -66,7 +67,12 @@ namespace SerializationGenerator
symbol is INamedTypeSymbol namedSymbol &&
symbols.Contains(namedSymbol, SymbolEqualityComparer.Default);
public static bool HasGenericReaderCtor(this INamedTypeSymbol symbol, Compilation compilation, out bool requiresParent)
public static bool HasGenericReaderCtor(
this INamedTypeSymbol symbol,
Compilation compilation,
ISymbol? parentSymbol,
out bool requiresParent
)
{
var genericReaderInterface = compilation.GetTypeByMetadataName(GENERIC_READER_INTERFACE);
var genericCtor = symbol.Constructors.FirstOrDefault(
@ -76,7 +82,7 @@ namespace SerializationGenerator
SymbolEqualityComparer.Default.Equals(m.Parameters[0].Type, genericReaderInterface)
);
requiresParent = genericCtor?.Parameters.Length == 2 && SymbolEqualityComparer.Default.Equals(genericCtor.Parameters[1].Type, symbol);
requiresParent = genericCtor?.Parameters.Length == 2 && SymbolEqualityComparer.Default.Equals(genericCtor.Parameters[1].Type, parentSymbol);
return genericCtor != null;
}