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 120 forks source link

Support For JetBrains Rider #85

Closed thall90 closed 5 years ago

thall90 commented 5 years ago

This plugin was an indispensable part of my everyday development while developing using Visual Studio. However, now that I've switched to JetBrains Rider, I really miss the functionality that this plugin provided.

Do you have any intentions of creating a Rider plugin port for this tool?

cezarypiatek commented 5 years ago

Hi,

This is the same problem as with VSCode #83. However, as I know, Rider supports also Code Refactorings from NuGet packages. I will try to release a nuget package with Mapping Generator in the next week. I will let you know when it is ready.

thall90 commented 5 years ago

That's incredible! Thank you!

Also, if there are any contributions that could accelerate this process, I would love to help!

cezarypiatek commented 5 years ago

Ok, I've updated the NuGet package, Can you test it? Especially mapping between collections.

thall90 commented 5 years ago

Sure thing! I'll let you know once I've done so

thall90 commented 5 years ago

I've added the NuGet package to my project, I'm not seeing any of the context actions. Is the mechanism for generating a mapping different when using the NuGet variant?

cezarypiatek commented 5 years ago

What version of the Rider are you using? Refactoring options should be available in the menu triggered by the alt+enter shortcut.

thall90 commented 5 years ago

I'm using version 2019.2. I'm not seeing any of the mapping function actions in the alt+enter menu.

cezarypiatek commented 5 years ago

Can you provide the sample code?

cezarypiatek commented 5 years ago

image

image

cezarypiatek commented 5 years ago

@thall90 do you still experience a problem with Rider? I observed that after updating nuget package restart is required to load a new version.

thall90 commented 5 years ago

@cezarypiatek I apologize for the delay in getting back to you. After installing the package and restarting Rider, I am indeed able to access the Mapping actions from the alt+enter context menu.

Testing with the following classes: `public class TestMapOrigin { public Guid TestId { get; set; }

        public string TestName { get; set; }

        public bool IsActive { get; set; }

        public ICollection<Guid> IdCollection { get; set; }
    }

public class TestMapDestination { public Guid TestId { get; private set; }

        public string TestName { get; private set; }

        public bool IsActive { get; private set; }

        public ICollection<Guid> IdCollection { get; private set; }

        public TestMapDestination(
            Guid testId,
            string testName,
            bool isActive,
            ICollection<Guid> idCollection)
        {
            TestId = testId;
            TestName = testName;
            IsActive = isActive;
            IdCollection = idCollection;
        }
    }`

I achieved the following result:

public static TestMapDestination Map( this TestMapOrigin inputDTO) { return new TestMapDestination(testId: inputDTO.TestId, testName: inputDTO.TestName, isActive: inputDTO.IsActive, idCollection: inputDTO.IdCollection); }

I was also able to achieve positive object initializer results with public setters on the TestDestination class.

I would say that this package is good-to-go!

Thank you so much for your help, and for your consistent, prompt responses.

cezarypiatek commented 5 years ago

@thall90 thanks for your time and confirming that MappingGenerator works on Rider.