I'm looking up AutoMapper code now (evaluating it for one of projects I'm working on), and, frankly speaking, I'm quite surprised:
- The library API is based on a single static access point (
Mapper
type), so generally any of its methods must be thread safe
- But I didn't find ANY evidence of this in code.
All I was able to find is this issue, but even the statement made there seems incorrect: if Map
doesn't use thread-safe data structures internally, it can't be considered as thread-safe as well, if I'm going to call CreateMap
in non-concurrent context, but concurrently with Map
.
I.e. the only possible usage pattern of AutoMapper in e.g. ASP.NET MVC application is:
lock (mapperLock) {
... Mapper.AnyMethod(...) ...
}
Obviously, if I'm correct, that's a huge lack.
So I have two questions:
- Am I correct?
- If yes, what's the best alternative to AutoMapper that doesn't have this issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…