Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoMapper CS File Extremely Slow in Visual Studio 2015

I have a solution with 7 or 8 projects, none of which contain anything particularly exciting and all perform as well as you would expect (and indeed as well as other projects I have used on my current machine).

However, whenever I open either one of the AutoMapper MappingConfiguration files, Visual Studio grinds to halt, moving the cursor one space takes minutes at a time and trying to write code results in lots of swearing - lots and lots and lots of swearing.

It seems to only be this MappingConfig.cs file. It is isn't even that large - maybe 30 mappings (cfg.CreateMap<Bar,Foo>();) and in total 350 lines of code.

Has anyone experienced slowing of Visual Studio whilst using AutoMapper?

AutoMapper is 4.2 I believe and I am using Visual Studio 2015 Community Edition.

like image 290
glosrob Avatar asked May 29 '16 17:05

glosrob


Video Answer


1 Answers

I experienced the same thing and reported an issue to the Github repo.

https://github.com/AutoMapper/AutoMapper/issues/2217

They saw this as a VS issue but I got a nice answer for AutoMapper 5.0 <. Use AutoMapper Profile Instances so that you can split the configuration to many separate files. This gives some real performance gains instead of having everything in one file.

https://github.com/AutoMapper/AutoMapper/wiki/Configuration#profile-instances

like image 171
Ogglas Avatar answered Sep 30 '22 10:09

Ogglas