cezarypiatek / MappingGenerator

:arrows_counterclockwise: "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
MIT License
1.03k stars 119 forks source link

Inconsistent behaviour #142

Closed bdaniel7 closed 3 years ago

bdaniel7 commented 3 years ago

Thanks for this life saving nuget! :))

I'm using the nuget version with Rider. And in some situations it works, in some, it doesn't. I use Alt + Enter.

It's ok.

works

It should display the Initialize with local variables and use the properties of the class.

doesnt-work

Also, it doesn't show the Implement Clone method when I select/set the cursor on the class name.

cezarypiatek commented 3 years ago

Ad1. I need to check that, can you provide a sample solution? Ad2. "Implement Clone metho" - I don't provide such functionality. You probably confused MappingGenerator with something else.

bdaniel7 commented 3 years ago

Ad2. In the project wiki there is a paragraph

bdaniel7 commented 3 years ago

I added this project https://github.com/bdaniel7/MappingGeneratorTest

So if there is a ":" right after the class name, like when derived or implementing an interface, the Implement clone method menu doesn't appear. If there is a space between class name and ":", the menu appears.

And Initialize with local values menu appears but doesn't generate anything, Initialize with sample values menu appears and generates the dummy values.

cezarypiatek commented 3 years ago

Oh, sorry. I totally forgot that I implemented this clone-related feature 😄

Thanks for a sample solution, I will check that later and I will let you know.

cezarypiatek commented 3 years ago

I don't see any problem with "Implement clone" options, works fine in any "space" configuration.

5eAmDaeUDq

Tested on Rider 2020.2.1 image

You can also trigger this action directly on the clone method signature:

AYemK47BZP

cezarypiatek commented 3 years ago

"Initialize with local values" - this action is using only local variables and method parameters. It's not using enclosing type members. This is the current behavior.

bdaniel7 commented 3 years ago

Ok, I'm getting the menu when I have the cursor on the class name. Previously I had the cursor just at the end of class name. But when I try to invoke the action, the IDE freezes. I have to close it from Task Manager. I'm using Rider 2020.2.4

cezarypiatek commented 3 years ago

How large is your solution and how complex is the cloned class?

bdaniel7 commented 3 years ago

Some classes have around 750 lines, including curly braces and empty lines. Other classes have 45 or 75 lines, with just 2 to 10 properties. And some IEquatable<> implementation.

cezarypiatek commented 3 years ago

does it hang on that sample solution too?

bdaniel7 commented 3 years ago

Nope.

cezarypiatek commented 3 years ago

So I guess this is due to solution size. This problem is already reported here https://github.com/cezarypiatek/MappingGenerator/issues/115

I tried to profile MappinGenerator several times but I wasn't able to find anything suspicions. Without real example I'm not able to diagnose this problem.

There are a few async operations which are run synchronously, I need to rewrite it and we will see if that can help.

bdaniel7 commented 3 years ago

Alright, in the meantime I will try a workaround.

cezarypiatek commented 3 years ago

@bdaniel7 might I ask you to test it once again using v1.19.452?

bdaniel7 commented 3 years ago

First, the compilation for the entire solution became waaay slower - when using dotnet watch run. Even when just a file is modified. Which makes the CPU and the fans go crazy... Then, I got all kinds of warnings that I didn't get before, and that I had to disable with VSTHRD200,VSTHRD103,VSTHRD002,VSTHRD110,VSTHRD003.

cezarypiatek commented 3 years ago

Thanks for quick reply. It's my mistake, the analyzers were referenced incorrectly, should be fixed in v1.19.454

cezarypiatek commented 3 years ago

I'm closing this issue. The case with performance can be tracked here #115