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:
parent
eb4e3ac070
commit
510d2e006b
32 changed files with 185 additions and 378 deletions
|
|
@ -203,7 +203,8 @@ namespace SerializationGenerator
|
|||
fieldOrPropertySymbol,
|
||||
order,
|
||||
allAttributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
classSymbol
|
||||
);
|
||||
|
||||
serializablePropertySet.Add(serializableProperty);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
@ -44,7 +45,8 @@ namespace SerializableMigration
|
|||
arrayTypeSymbol.ElementType,
|
||||
0,
|
||||
attributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
parentSymbol
|
||||
);
|
||||
|
||||
var length = serializableArrayType.RuleArguments.Length;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
@ -47,7 +48,8 @@ namespace SerializableMigration
|
|||
setTypeSymbol,
|
||||
0,
|
||||
attributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
parentSymbol
|
||||
);
|
||||
|
||||
var length = serializableSetType.RuleArguments.Length;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
@ -47,7 +48,8 @@ namespace SerializableMigration
|
|||
typeArguments[0],
|
||||
0,
|
||||
attributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
parentSymbol
|
||||
);
|
||||
|
||||
var valueSerializedProperty = SerializableMigrationRulesEngine.GenerateSerializableProperty(
|
||||
|
|
@ -56,7 +58,8 @@ namespace SerializableMigration
|
|||
typeArguments[1],
|
||||
1,
|
||||
attributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
parentSymbol
|
||||
);
|
||||
|
||||
// Key
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
@ -47,7 +48,8 @@ namespace SerializableMigration
|
|||
listTypeSymbol,
|
||||
0,
|
||||
attributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
parentSymbol
|
||||
);
|
||||
|
||||
var length = serializableListType.RuleArguments.Length;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace SerializableMigration
|
|||
ISymbol symbol,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol,
|
||||
out string[] ruleArguments
|
||||
)
|
||||
{
|
||||
|
|
@ -41,7 +42,7 @@ namespace SerializableMigration
|
|||
}
|
||||
|
||||
if (symbol is not INamedTypeSymbol namedTypeSymbol ||
|
||||
!namedTypeSymbol.HasGenericReaderCtor(compilation, out var requiresParent))
|
||||
!namedTypeSymbol.HasGenericReaderCtor(compilation, parentSymbol, out var requiresParent))
|
||||
{
|
||||
ruleArguments = null;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ namespace SerializableMigration
|
|||
ISymbol fieldOrPropertySymbol,
|
||||
int order,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol = default
|
||||
)
|
||||
{
|
||||
string propertyName;
|
||||
|
|
@ -78,7 +79,8 @@ namespace SerializableMigration
|
|||
propertyType,
|
||||
order,
|
||||
attributes,
|
||||
serializableTypes
|
||||
serializableTypes,
|
||||
parentSymbol
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +90,8 @@ namespace SerializableMigration
|
|||
ISymbol propertyType,
|
||||
int order,
|
||||
ImmutableArray<AttributeData> attributes,
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes
|
||||
ImmutableArray<INamedTypeSymbol> serializableTypes,
|
||||
ISymbol? parentSymbol = default
|
||||
)
|
||||
{
|
||||
foreach (var rule in Rules.Values)
|
||||
|
|
@ -98,6 +101,7 @@ namespace SerializableMigration
|
|||
propertyType,
|
||||
attributes,
|
||||
serializableTypes,
|
||||
parentSymbol,
|
||||
out var ruleArguments
|
||||
))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue