Open bugrakosen opened 4 years ago
Hi, can you provide a sample code on which this refactoring causes the described issue?
Here is sample codes.
public class BaseDTO
{
public int Id { get; set; }
public DateTime InsertedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
}
public class MenuDTO : BaseDTO
{
public int SubMenuId { get; set; }
public string ImagePath { get; set; }
public List<ProductMenuDTO> ProductMenus { get; set; }
public List<MenuLangDTO> MenuLangs { get; set; }
}
public abstract class BaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public DateTime InsertedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
public DateTime? DeletedDate { get; set; }
public bool Active { get; set; }
}
public class Menu : BaseEntity
{
/// <value> An above menu of this menu in the hierarchy </value>
public int SubMenuId { get; set; }
/// <value> Image of menu. </value>
public string ImagePath { get; set; }
/// <value> List of ProductMenu which is related. For lazy loading. </value>
public virtual IEnumerable<ProductMenu> ProductMenus { get; set; }
/// <value> List of MenuLang which is related. For lazy loading. </value>
public virtual IEnumerable<MenuLang> MenuLangs { get; set; }
}
public async Task AddAsync(MenuDTO menuDTO)
{
if (menuDTO == null) throw new NullReferenceException("Entity bos olamaz.");
await _menuRepository.AddAsync(
new Menu
{
//I want to use mapping generator here.
}).ConfigureAwait(false);
}
My project line count is over than 50.000 lines. When i install mapping generator on 40.000 lines. And it works fine. However, as the number of lines increased, visual studio started to slow when Mapping Generator enabled.
I have the same issue too. When i run the tool it is working and finally it recommending me this(also it is taking long time):
Don't use the recursive.
But i have to do it because of table relations on entity framework. Is there a option to set a deep value for mapping to prevent this problem? These are my classes:
public class Product : BaseEntity
{
public double Name{ get; set; }
public int Count{ get; set; }
[ForeignKey("Category")]
public int CategoryId { get; set; }
public virtual Category Category{ get; set; }
}
public class Category: BaseEntity
{
public double Name{ get; set; }
public virtual IEnumerable<Product> Products{ get; set; }
}
@bugrakosen, thanks for providing sample code. Honestly, I will have time around the weekend to take a look at this issue.
In terms of large codebase - IMHO tools should never support that because this will be a countenance for bad practices. My advice is to keep the codebase as small as possible - extract as much as possible to external packages. Divide and conquer :)
@bugrakosen @M-Clk is it still an issue with the latest MappingGenerator?
I tested it in a small project and its worked fine. But yes it is the same issue in large project with latest MappingGenerator. @cezarypiatek
I also tested it and it's the same. Thanks @cezarypiatek for your effort. I hope you fix it. When I have time, I'll try to fix this error and contribute.
@bugrakosen I spent some time looking at it but honestly, I'm not able to spot the culprit. I suspected that this performance issue might be caused by semanticModel.LookupSymbols
but I found out it's used for IntelliSense by VS so it should be super fast. There are a couple of blocking calls to async API - maybe that's the issue. I will try to get rid of them in the next version of MappingGenerator
@bugrakosen @M-Clk might I ask you to test it once again using v1.19.452?
I've tried and it's the same. I waited for 5 minutes to be initialize variables but it didn't initialize. I think it's not your extension's problem. My models are so nested and project is too big. I'm using your extension on other smaller projects and it works fine. Thank you for effort again. @cezarypiatek
I finally managed to track down the source of the performance issues. The slow down was caused by the post-processing run by VS on the generated code. The fix should be available in the next version of MappingGenerator planned for June 2021.
Hi @bugrakosen, @M-Clk A new version with the fix has been released. Please update your MappingGeneration installation. If you are still experiencing performance issue, then please report it in the new IssueTracker https://github.com/cezarypiatek/MappingGeneratorIssueTracker
I will try ASAP. Thank you
When i click "Initiliaze with local variables" or "Initiliaze with sample values" gets stuck like same as in the picture with every model in my project. And when extension enabled on VS2019 excessively reduces performance.
I've already tried reinstall.
VS2019 version : 16.5.4
This is so awesome tool so i want to use it. Thanks for helping.