cezarypiatek / MappingGeneratorIssueTracker

This is a issue tracker for MappingGenerator
2 stars 0 forks source link

Huge graph #8

Closed maleet closed 2 years ago

maleet commented 2 years ago

Thanks for this amazing tool!

Anyway... I have huge entity framework object graph and need to implement Clone. as there are many loop kind of relationships then mapping in Rider and also in Visual Studio just collapses. TimeOut in Rider or just endless generation progressbar in Visual Studio. It would be create to specify depth on recursion in generation. As my daily IDE is Rider then some kind of global options for generation would be great there

cezarypiatek commented 2 years ago

Hi @maleet

Thanks for your feedback. Right now MappingGenerator is missing UI Configurator for the "Implement clone method" action which might solve the performance problem here - UI configurator allows for extracting repeatable parts to separate methods. I will try to add this configurator over the weekend.

cezarypiatek commented 2 years ago

I made a review of CloneEngine and it turned out that it was still using SyntaxGenerator which is a well-known performance killer. I rewrote the necessary parts of the CloneEngine and it was released as v2021.10.33. I will be appreciated if you could try the latest version and let me know if the issue is gone. Any other feedback related to the cloning feature is welcome.

maleet commented 2 years ago

I updated the extension and also nuget. In Rider it's still timeouts in 2 minutes. In Visual studio there's this endless progress: image

Are the free version and Pro different in generation way? I get the Clone code in preview windows... As I'm looking for arguments to buy license (main argument would be that it works in my case) then I don't have Pro... so I just can preview changes.

maleet commented 2 years ago

Oh... I got stacktrace for outofmemory:

System.OutOfMemoryException : Exception of type 'System.OutOfMemoryException' was thrown. at System.String.InternalSubString(Int32 startIndex,Int32 length) at System.String.Substring(Int32 startIndex,Int32 length) at MappingGenerator.Mappings.NameHelper.<>c.b4_1(String x) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.String.Join(String separator,IEnumerable1 values) at MappingGenerator.Mappings.NameHelper.ToLocalVariableName(String proposalLocalName) at MappingGenerator.Mappings.SourceFinders.ObjectMembersMappingSourceFinder..ctor(AnnotatedType sourceType,SyntaxNode sourceGlobalAccessor,ImmutableList`1 alreadyScanned) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>c__DisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.CreateMappingLambdaAsync(String lambdaParameterName,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,MappingPath mappingPath,MappingContext mappingContext,Func2 enrichInputExpression) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConvertExpression(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext,Boolean useConvert,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,ExpressionSyntax whereFilter,Boolean isReadonlyCollection,Boolean whereFilterCanBeNull) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.MapCollections(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.CreateMappingLambdaAsync(String lambdaParameterName,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,MappingPath mappingPath,MappingContext mappingContext,Func2 enrichInputExpression) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConvertExpression(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext,Boolean useConvert,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,ExpressionSyntax whereFilter,Boolean isReadonlyCollection,Boolean whereFilterCanBeNull) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.MapCollections(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.CreateMappingLambdaAsync(String lambdaParameterName,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,MappingPath mappingPath,MappingContext mappingContext,Func2 enrichInputExpression) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConvertExpression(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext,Boolean useConvert,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,ExpressionSyntax whereFilter,Boolean isReadonlyCollection,Boolean whereFilterCanBeNull) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.MapCollections(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.CreateMappingLambdaAsync(String lambdaParameterName,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,MappingPath mappingPath,MappingContext mappingContext,Func2 enrichInputExpression) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConvertExpression(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext,Boolean useConvert,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,ExpressionSyntax whereFilter,Boolean isReadonlyCollection,Boolean whereFilterCanBeNull) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.MapCollections(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.CreateMappingLambdaAsync(String lambdaParameterName,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,MappingPath mappingPath,MappingContext mappingContext,Func2 enrichInputExpression) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConvertExpression(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext,Boolean useConvert,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,ExpressionSyntax whereFilter,Boolean isReadonlyCollection,Boolean whereFilterCanBeNull) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.MapCollections(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.CreateMappingLambdaAsync(String lambdaParameterName,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,MappingPath mappingPath,MappingContext mappingContext,Func2 enrichInputExpression) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConvertExpression(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext,Boolean useConvert,AnnotatedType sourceListElementType,AnnotatedType targetListElementType,ExpressionSyntax whereFilter,Boolean isReadonlyCollection,Boolean whereFilterCanBeNull) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.MapCollections(MappingElement source,AnnotatedType targetListType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.CollectionToCollectionExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapUsingSimpleAssignment(TargetHolder targetHolder,IMappingMatcher mappingMatcher,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.MappingEngine.AddInitializerWithMapping(ObjectCreationExpressionSyntax objectCreationExpression,IMappingMatcher mappingMatcher,ITypeSymbol createdObjectTyp,MappingContext mappingContext,MappingPath mappingPath,IFiniteSourceFinder finiteSourceFinder) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.<>cDisplayClass6_0.b0(SourceMappingElement s) at MappingGenerator.Mappings.GeneratedCustomConversionExtensions.AddGeneratedConversion(MappingContext mappingContext,SourceMappingElement source,AnnotatedType targetType,Func2 factory,Boolean forceExtraction) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.ResolveConversionBetweenComplexTypes(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.CloneObjectExpressionConverter.TryToCreateMappingExpression(SourceMappingElement source,AnnotatedType targetType,MappingPath mappingPath,MappingContext mappingContext,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ComplexObjectToComplexObjectExpressionConverter.CreateConversion(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.Converters.ConvertersExtensions.ConvertExpression(IReadOnlyList1 converters,SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingEngine.MapExpression(SourceMappingElement source,AnnotatedType targetType,MappingContext mappingContext,MappingPath mappingPath,Boolean allowForCustomConversions,Boolean rootMapping) at MappingGenerator.Mappings.MappingImplementors.IdentityMappingMethodImplementor.GenerateImplementation(IMethodSymbol methodSymbol,SyntaxGenerator generator,SemanticModel semanticModel,MappingContext mappingContext) at MappingGenerator.Mappings.MappingImplementorEngine.GenerateMappingStatements(IMethodSymbol methodSymbol,SyntaxGenerator generator,SemanticModel semanticModel,MappingContext mappingContext,IMappingMethodImplementor mappingMethodImplementor) at MappingGenerator.Mappings.MappingImplementorEngine.GenerateMappingBlock(IMethodSymbol methodSymbol,SyntaxGenerator generator,SemanticModel semanticModel,MappingContext mappingContext,IMappingMethodImplementor mappingMethodImplementor) at async MappingGenerator.Features.Refactorings.MappingGeneratorRefactoring.GenerateMappingMethodBodyCustom() at async MappingGenerator.Features.Refactorings.MappingGeneratorRefactoring.<>cDisplayClass8_0.b0() at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync() at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync() at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync() at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetOperationsCoreAsync() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Roslyn.Utilities.TaskExtensions.WaitAndGetResult_CanCallOnBackground[T](Task1 task,CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorker(Func1 getFromDocument,IProgressTracker progressTracker,CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.<>c__DisplayClass22_0.b__0() at Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformAction(IExtensionManager extensionManager,Object extension,Action action)

maleet commented 2 years ago

I think this is related to complex type? Then it would be this:

[ComplexType] public class ExpressionFormula : IExpressionFormula, IEquatable, IComparable, IComparable { public ExpressionFormula() { }

    public ExpressionFormula(string formula, string comments = null, string externalFormula = null)
    {
        Formula = formula ?? "";
        Comments = comments;
        ExternalFormula = externalFormula;
    }

    public ExpressionFormula(double formula, string comments = null, string externalFormula = null) : this(formula.ToString(CultureInfo.InvariantCulture), comments, externalFormula)
    {
    }

    public ExpressionFormula(decimal formula, string comments = null, string externalFormula = null) : this(formula.ToString(CultureInfo.InvariantCulture), comments, externalFormula)
    {
    }

    public ExpressionFormula(bool formula, string comments = null, string externalFormula = null) : this(formula.ToString(), comments, externalFormula)
    {
    }

    public ExpressionFormula((bool value, string parsedFormula) tuple) : this(tuple.value, tuple.parsedFormula)
    {
    }

    public ExpressionFormula((bool value, string parsedFormula, string unit) tuple) : this(tuple.value, tuple.parsedFormula)
    {
    }

    [NotMapped]
    [JsonProperty("Formula", NamingStrategyType = typeof(DefaultNamingStrategy))]
    public string Formula { get; set; }

    [NotMapped] public string Comments { get; set; }

    [NotMapped] public string ExternalFormula { get; set; }

    [MaxLength(2147483645)]
    public string SerializedValue
    {
        get
        {
            var list = new string[3];
            list[0] = Escape(Formula);
            if (!string.IsNullOrEmpty(Comments))
            {
                list[0] = list[0] ?? "";
                list[1] = Escape(Comments);
            }

            if (!string.IsNullOrEmpty(ExternalFormula))
            {
                list[0] = list[0] ?? "";
                list[1] = list[1] ?? "";
                list[2] = Escape(ExternalFormula);
            }

            var list1 = list.Where(s => s != null).ToList();
            return (list1.Any() ? list1.Join(";") : null).NullIfEmpty();
        }
        // ReSharper disable once UnusedMember.Global
        set
        {
            Formula = null;
            Comments = null;
            ExternalFormula = null;
            // ('F5\;Gh\;HF');('F5\;Gh\;HF')
            if (!string.IsNullOrEmpty(value))
            {
                var strings = value.Replace(@"\;", "?!?").Split(";");

                Formula = Unescape(strings.FirstOrDefault());
                Comments = Unescape(strings.Skip(1).FirstOrDefault());
                ExternalFormula = Unescape(strings.Skip(2).FirstOrDefault());
            }
        }
    }

    private string Escape(string formula)
    {
        return formula?.Replace(";", @"\;");
    }

    private string Unescape(string value)
    {
        return value?.Replace(@"?!?", ";").NullIfEmpty();
    }

    public override string ToString()
    {
        return Formula;
    }

    public bool IsValid()
    {
        return Formula != false.ToString(CultureInfo.InvariantCulture);
    }

    public ExpressionFormula GetValueOrDefault(string defaultValue)
    {
        if (HasFormula())
            return this;
        Formula = defaultValue;
        return this;
    }

    public bool HasFormula()
    {
        return !string.IsNullOrWhiteSpace(Formula);
    }

    public decimal? ToNumeric(decimal? defaultValue = null)
    {
        return Formula.ToDecimal(defaultValue);
    }

    public decimal ToNumeric(decimal defaultValue)
    {
        return Formula.ToDecimal(defaultValue).GetValueOrDefault(defaultValue);
    }

    public ExpressionFormula Clone()
    {
        return new ExpressionFormula()
        {
            Comments = Comments,
            Formula = Formula,
            ExternalFormula = ExternalFormula
        };
    }

    public bool Equals(ExpressionFormula other)
    {
        if (ReferenceEquals(this, other)) return true;
        return Formula == other?.Formula && Comments == other?.Comments && ExternalFormula == other?.ExternalFormula;
    }

    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj)) return false;
        if (ReferenceEquals(this, obj)) return true;
        if (obj.GetType() != this.GetType()) return false;
        return Equals((ExpressionFormula) obj);
    }

    public override int GetHashCode()
    {
        return HashCode.Combine(Formula, Comments, ExternalFormula);
    }

    public static bool operator ==(ExpressionFormula left, ExpressionFormula right)
    {
        return left?.Equals(right) == true || right?.Equals(left) == true;
    }

    public static bool operator !=(ExpressionFormula left, ExpressionFormula right)
    {
        return !(right?.Equals(left) == true || left?.Equals(right) == true);
    }

    public int CompareTo(ExpressionFormula other)
    {
        if (ReferenceEquals(this, other)) return 0;
        if (ReferenceEquals(null, other)) return 1;
        var formulaComparison = string.Compare(Formula, other.Formula, StringComparison.Ordinal);
        if (formulaComparison != 0) return formulaComparison;
        var commentsComparison = string.Compare(Comments, other.Comments, StringComparison.Ordinal);
        if (commentsComparison != 0) return commentsComparison;
        return string.Compare(ExternalFormula, other.ExternalFormula, StringComparison.Ordinal);
    }

    public int CompareTo(object obj)
    {
        if (ReferenceEquals(null, obj)) return 1;
        if (ReferenceEquals(this, obj)) return 0;
        return obj is ExpressionFormula other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(ExpressionFormula)}");
    }

    public static bool operator <(ExpressionFormula left, ExpressionFormula right)
    {
        return Comparer<ExpressionFormula>.Default.Compare(left, right) < 0;
    }

    public static bool operator >(ExpressionFormula left, ExpressionFormula right)
    {
        return Comparer<ExpressionFormula>.Default.Compare(left, right) > 0;
    }

    public static bool operator <=(ExpressionFormula left, ExpressionFormula right)
    {
        return Comparer<ExpressionFormula>.Default.Compare(left, right) <= 0;
    }

    public static bool operator >=(ExpressionFormula left, ExpressionFormula right)
    {
        return Comparer<ExpressionFormula>.Default.Compare(left, right) >= 0;
    }
}
cezarypiatek commented 2 years ago

Could you share (privately) your complete model?

maleet commented 2 years ago

I tried to extract problematic model and ended up with working one :D MappingGenerator generated 50 000 lines of code in Rider. If it's matter of outofmemory then it's not easy to have repro. I can't send whole solution (some client contracts don't allow that). Maybe I can still send this extracted model and there is some use of my extracting work... :) e-mail address?

cezarypiatek commented 2 years ago

50k lines seem way tooo much. I will appreciate for sharing extracted part - cezarypiatek[at]live.com

maleet commented 2 years ago

50K is without optimizing as everything is cloned inline and repeating objects are generated again and again.

cezarypiatek commented 2 years ago

so probably adding UI Configurator with an option to extract repeatable mapping to function should solve the problem, anyway I would like to take a look at the model...