简体   繁体   中英

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.

I have simmilar problem in my solution. By using ADK i found reason in my case. Resharper get all cpu perfomance. Point by point i exclude some features from it, and in result find decision.

Turn Off Resharper IntelliSense, allow work Visual Studio native IntelliSense.

Resharper menu -> Option -> Environment -> IntelliSense -> General

Set radio to Visual Studio.

After work with Autommaper CS file, i turn it back.


No idea what the matter of this, but i`m guess it Automapper new reflection engine, after update Automapper from 3.1.1 version i got this problem.

But now my CPU on 3-5% level.

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

I have exactly the same experience when I start editing the Automapper config cs file. My config file is even smaller (~170 lines of code). Visual Studio starts taking up more than 50% CPU and everything slows down. I'm using VS2015 (Professional) and, in addition, have resharper 10 installed. Automapper version is 4.2.1.

I have the same problem since 4.2 I upgraded to 5.1 still same issue seems to be with intellisense or maybe Reshapper?

Anytime you try to do a ForMember like below and the CPU goes up to 50%+ to the point where it takes 30 seconds to type 1 character, I usually have to shutdown visual studio and reopen its making AutoMapper unusable. Or I have to load the file in text editor Mode, but then I lose all the nice intellisense.

Example Code:

Mapper.Initialize(cfg => { cfg.CreateMap() .ForMember(dest => dest.OrderNumber, opts => opts.MapFrom(src => $"{src.OrderReferenceNumber}"))

};

I have experienced the same issue (Visual Studio 2015 Update 3, AutoMapper 4.2.1, Resharper 2016.1.2).

After installing the cumulative servicing update for Microsoft Visual Studio 2015 Update 3 ( KB3165756 ), and upgrading to Resharper 2016.2, the issue is less severe, but it still exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM