Skip to content

Error whis CultureInfo #995

Description

@JessyParis

When upgrading from 10.0.7 to 10.0.10; I get the error hereunder. It seems that Mapster has a problem with CultureInfo.
Every class that has this property "public CultureInfo currentCulture { get; set; } = new("fr-FR");" gerenates an error when Mapster tries to map it, even if this property is not in the destination class for the mapping.
It works fine whis Mapster v10.0.7

System.TypeInitializationException: The type initializer for 'Mapster.TypeAdapter2' threw an exception. ---> Mapster.CompileException: Error while compiling source=System.Globalization.TextInfo destination=System.Globalization.TextInfo type=Map ---> System.InvalidOperationException: No default constructor for type 'TextInfo', please use 'ConstructUsing' or 'MapWith' at Mapster.Adapters.BaseAdapter.CreateInstantiationExpression(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.ClassAdapter.CreateInstantiationExpression(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.BaseAdapter.CreateBlockExpressionBody(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.BaseAdapter.CreateExpressionBody(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.ClassAdapter.CreateExpressionBody(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.BaseAdapter.CreateAdaptFunc(CompileArgument arg) at Mapster.TypeAdapterConfig.CreateMapExpression(CompileArgument arg) --- End of inner exception stack trace --- at Mapster.TypeAdapterConfig.CreateMapExpression(CompileArgument arg) at Mapster.TypeAdapterConfig.CreateMapExpression(TypeTuple tuple, MapType mapType) at Mapster.TypeAdapterConfig.<GetMapFunction>b__63_0(TypeTuple tuple) at Mapster.TypeAdapterConfig.<>c__DisplayClass60_01.b__0(TypeTuple types)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Mapster.TypeAdapterConfig.AddToHash[T](ConcurrentDictionary2 hash, TypeTuple key, Func2 func)
at Mapster.TypeAdapterConfig.GetMapFunction(Type sourceType, Type destinationType)
at Mapster.TypeAdapterConfig.GetMapFunctionTSource,TDestination
at Mapster.TypeAdapter2..cctor() --- End of inner exception stack trace --- at lambda_method12399(Closure, CultureInfo) at lambda_method12399(Closure, CultureInfo) at lambda_method12399(Closure, CultureInfo) at lambda_method12396(Closure, DataTable) at lambda_method12393(Closure, SAGEDocument) at lambda_method12392(Closure, ICollection1)
at lambda_method3439(Closure, Entite)
at MapsterMapper.Mapper.Map[TSource,TDestination](TSource source)
at eVaSys.Controllers.EntiteController.Get(Int32 id) in C:\Sources\Repos\eVaSys\eVaSys.Server\Controllers\EntiteController.cs:line 122
at lambda_method6886(Closure, Object, Object[])
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions