Open bbakermmc opened 6 years ago
Thanks. I didn't know Rider support visual studio extensions. Once EF Core is out of the way, I shall take a look.
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" #>
Good progress so far. Got a version of the generator working for Rider yesterday. Problems:
A Rider developer who specializes in T4 is going to contact me to see if these can be solved.
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 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.
My question was about the tt file, are you using a writeline and then a new line after?
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.
Rider is usually pretty good about user feedback and fixes, you could post an issue.
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 notifications@github.com 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 .
I have created a temporary GitHub project for Rider so I can work with @kirillgla and get it working :-)
@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
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.
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.
Added Rider bugs:
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.
Thanks @kehlankrumme
git clone https://github.com/sjh37/EfrpgRider.git
EFRPG-Rider.sln
in Rider.RiderNorthwind.tt
Settings.ConnectionString
RiderNorthwind.tt
and select Run
.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.
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.
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.
Thanks @kehlankrumme
git clone https://github.com/sjh37/EfrpgRider.git
- Open
EFRPG-Rider.sln
in Rider.- Open
RiderNorthwind.tt
- Edit the name of the database you want to use in line 19
Settings.ConnectionString
- Save
- Right click on
RiderNorthwind.tt
and selectRun
.- 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 forFix 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.
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 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).
Excellent news, thanks @savornicesei. That means that old-style .csproj
can be dropped, and Rider could now be supported!
@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.
Any chance of getting Rider support?