EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

JetBrains - Rider Support

Open bbakermmc opened this issue 7 years ago • 22 comments

Any chance of getting Rider support?

EF.Reverse.POCO.Core.ttinclude(1,1) : error CS1519: Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration
EF.Reverse.POCO.Core.ttinclude(1,12) : error CS1001: Compiling transformation: Identifier expected
EF.Reverse.POCO.Core.ttinclude(1,6) : error CS1520: Compiling transformation: Method must have a return type
EF.Reverse.POCO.Core.ttinclude(1,6) : error CS0501: Compiling transformation: 'GeneratedTextTransformation.GeneratedTextTransformation()' must declare a body because it is not marked abstract, extern, or partial

bbakermmc avatar Apr 27 '18 02:04 bbakermmc

Thanks. I didn't know Rider support visual studio extensions. Once EF Core is out of the way, I shall take a look.

sjh37 avatar Apr 27 '18 08:04 sjh37

They don't. But it was easy enough to reference the DLLs/file needed.

I made a copy of this file and put it in the same folder as the TT. https://github.com/aspnet/EntityFramework6/blob/master/src/EFTools/EntityDesign/TextTemplates/Includes/EF6.Utility.CS.ttinclude

Removed this line: <#@ CleanupBehavior Processor="T4VSHost" CleanupAfterProcessingTemplate="true" #>

Updated the path of these directories to my my VS2017 install folder:

<#@ assembly name="VERSIONED_VSCOMNTOOLS_ENV_VAR..\IDE\EntityFramework.dll" #>
<#@ assembly name="VERSIONED_VSCOMNTOOLS_ENV_VAR..\IDE\Microsoft.Data.Entity.Design.dll" #>

bbakermmc avatar Apr 27 '18 13:04 bbakermmc

Good progress so far. Got a version of the generator working for Rider yesterday. Problems:

  • Running T4 templates in Rider with folder names having spaces in them.
  • Heavily spaced output. There were 2 blank lines between each line being output.

A Rider developer who specializes in T4 is going to contact me to see if these can be solved.

sjh37 avatar May 19 '20 09:05 sjh37

For the double spaces are you using writeline and then a blank line after? I havent looked at t4 since they added it. I have both VS and Rider so so I reluctantly use VS at times for some things.

bbakermmc avatar May 19 '20 15:05 bbakermmc

@bbakermmc Same identical code for both VS and Rider, two different outputs, one is neat and tidy, and one has blank lines. The following was generated using Rider. Rider Northwind.zip

I'll have a play and see why it's doing that when I get a moment.

sjh37 avatar May 19 '20 15:05 sjh37

My question was about the tt file, are you using a writeline and then a new line after? image

bbakermmc avatar May 19 '20 15:05 bbakermmc

I think it's not worth investigating why there are additional empty lines. It's probably the implementation of the generator on Rider side, that is not ideal.

matkoch avatar May 19 '20 16:05 matkoch

Rider is usually pretty good about user feedback and fixes, you could post an issue.

bbakermmc avatar May 19 '20 16:05 bbakermmc

It has been reported. What I meant is that it’s not worth trying to fix/investigate here :)

On Tue 19. May 2020 at 18:47, bbakermmc [email protected] wrote:

Rider is usually pretty good about user feedback and fixes, you could post an issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/issues/412#issuecomment-630944117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGGB7VJMQO7N75ZS3MXVHLRSKZYNANCNFSM4E5GYEKA .

matkoch avatar May 19 '20 16:05 matkoch

I have created a temporary GitHub project for Rider so I can work with @kirillgla and get it working :-)

sjh37 avatar May 20 '20 14:05 sjh37

@kirillgla Double spacing is coming from rider executing the {{mustache}} templates within the generator. Note the extra \n in the image below.

Top = VisualStudio Bottom = Rider

image

I split the data from the {{mustache}} template by using:

Code.AddRange(code.Split(new[] { Environment.NewLine }, StringSplitOptions.None));
// Environment.NewLine = '\r\n'

However, this leaves lots of \n when running template in Rider. I could strip these out, but it would be good to know why it's happening and have it fixed at source within Rider.

sjh37 avatar May 21 '20 17:05 sjh37

In order to get the output looking the same, I've added some code to remove the extra \n generated in Rider. However, I'd still like to see Rider fixed.

See this changeset.

sjh37 avatar May 21 '20 17:05 sjh37

Added Rider bugs:

sjh37 avatar May 21 '20 17:05 sjh37

My team of 10 is very interested in having this working in Rider. I finally showed our Visual Studio users the way.

I'll take a look at the "temporary" project, but the readme is lacking instruction at the time of this comment.

keeehlan avatar Nov 03 '21 18:11 keeehlan

Thanks @kehlankrumme git clone https://github.com/sjh37/EfrpgRider.git

  1. Open EFRPG-Rider.sln in Rider.
  2. Open RiderNorthwind.tt
  3. Edit the name of the database you want to use in line 19 Settings.ConnectionString
  4. Save
  5. Right click on RiderNorthwind.tt and select Run.
  6. Take a look at the code generated in RiderNorthwind.cs

I too have both VS and Rider, and running the output in Rider version 2021.2.1 I can see that some lines are still double spaced and some are normal. So there is a mix. It has to be something simple.

Inside of RiderNorthwind.tt search for Fix for Rider to see the 2 touch points I started to look at. I could be {{mustache}} processing related too.

sjh37 avatar Nov 03 '21 21:11 sjh37

Changing the template

        public override string Usings()
        {
            return @"
{{#each this}}
using {{this}};{{#newline}}
{{/each}}";
        }

to

        public override string Usings()
        {
            return @"{{#each this}}using {{this}};{{#newline}}{{/each}}";
        }

Stopped the multi-lines in Rider for the usings. So it look to be down to how the T4 template is being read by Rider as newlines are creeping in. I think this can be solved without too much trouble.

sjh37 avatar Nov 03 '21 22:11 sjh37

I have fixed the extra new lines being generated in the output. Last step is to sort out removing the use of EF6.Utility.CS.ttinclude within the template for VisualStudio as Rider does not like this.

sjh37 avatar Nov 03 '21 23:11 sjh37

Thanks @kehlankrumme git clone https://github.com/sjh37/EfrpgRider.git

  1. Open EFRPG-Rider.sln in Rider.
  2. Open RiderNorthwind.tt
  3. Edit the name of the database you want to use in line 19 Settings.ConnectionString
  4. Save
  5. Right click on RiderNorthwind.tt and select Run.
  6. Take a look at the code generated in RiderNorthwind.cs

I too have both VS and Rider, and running the output in Rider version 2021.2.1 I can see that some lines are still double spaced and some are normal. So there is a mix. It has to be something simple.

Inside of RiderNorthwind.tt search for Fix for Rider to see the 2 touch points I started to look at. I could be {{mustache}} processing related too.

Just getting back to this almost a year later.

Are there instructions for running this in a working setup?

For example, we are currently updating our entity model using an existing .tt file that has some customizations in it. It's already configured to run against our database and produce the POCOs in our solution.

We would like to be able to continue using this workflow, but in Rider instead of Visual Studio.

keeehlan avatar Oct 18 '22 23:10 keeehlan

Hi @keeehlan It's a real problem. I would have to split the generator into two separate products, one for Rider and one for VisualStudio. This is required for old style .csproj files which list the files to compile, To edit those the generator makes use of EnvDTE which does not exist in Rider. .NetCore uses the new SDK style .csproj and does not use EnvDTE. I either have to split the product into two, two separate installers, or remove support for legacy .csproj projects. For now, you still have to open the .sln in Visual Studio and save the <database>.tt file to generate the files, then pop back to Rider.

sjh37 avatar Oct 19 '22 09:10 sjh37

@sjh37 What's the status of the Rider extension?

I believe support for legacy .csproj files can be dropped as any .NET framework 4.5+ project can be easily migrated to SDK-style projects (including those using EF6). MS already provides tooling to convert .csproj files (https://dotnet.microsoft.com/en-us/platform/upgrade-assistant, https://github.com/dotnet/try-convert - this requires .NET 5).

savornicesei avatar Jan 21 '24 14:01 savornicesei

Excellent news, thanks @savornicesei. That means that old-style .csproj can be dropped, and Rider could now be supported!

sjh37 avatar Jan 22 '24 09:01 sjh37

@sjh37 You could release a v3.9.0-legacy extension (with Legacy in name or something appropriate) so that devs can still use v3.9 on legacy projects and move forward with the generator on SDK-projects only.

savornicesei avatar Jan 22 '24 09:01 savornicesei