Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/Mapster/TypeAdapterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,35 @@ private CompileArgument GetCompileArgument(TypeTuple tuple, MapType mapType, Com
};
}

public void Compile()
public void Compile(bool failFast = true)
{
var exceptions = new List<Exception>();
var keys = RuleMap.Keys.ToList();

foreach (var key in keys)
{
if (key.Source == typeof(void))
continue;
_mapDict[key] = Compiler(CreateMapExpression(key, MapType.Map));
_mapToTargetDict[key] = Compiler(CreateMapExpression(key, MapType.MapToTarget));
try
{
if (key.Source == typeof(void))
continue;

_mapDict[key] = Compiler(CreateMapExpression(key, MapType.Map));
_mapToTargetDict[key] = Compiler(CreateMapExpression(key, MapType.MapToTarget));
}
catch (Exception ex)
{
if (failFast)
{
throw;
}

exceptions.Add(ex);
}
}

if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
}
}

Expand Down