T4 template creates additional new lines on some PCs

When using T4 classes for an entity framework, there are several developers who generate classes with one additional new line for each generated line. I am wondering if this is some parameter that needs to be changed so that their generated T4 files look like the generated files from other developers. As an example of what I'm talking about: (specific names removed, but you should see the difference in the number of new lines generated from the same * .tt file.)

( Update:) The problem also arises in other T4 templates, and not just in EF. Both computers use TextTemplatingFileGenerator as a custom T4 tool.)

T4 output from my PC:

public virtual DbSet<GeneratedObject1> GeneratedObject1 { get; set; } public virtual DbSet<GeneratedObject2> GeneratedObject2 { get; set; } public virtual int SomeMethod1(Nullable<int> inParameter) { var localParameter = inParameter.HasValue ? new ObjectParameter("SomePropertyName", inParameter) : new ObjectParameter("SomePropertyName", typeof(int)); return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SomeMethod1", localParameter); } public virtual int SomeMethod2(Nullable<int> inParameter) { var localParameter = inParameter.HasValue ? new ObjectParameter("SomePropertyName", inParameter) : new ObjectParameter("SomePropertyName", typeof(int)); return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SomeMethod2", localParameter); } 

T4 is output from your PC:

 public virtual DbSet<GeneratedObject1> GeneratedObject1 { get; set; } public virtual DbSet<GeneratedObject2> GeneratedObject2 { get; set; } public virtual int SomeMethod1(Nullable<int> inParameter) { var localParameter = inParameter.HasValue ? new ObjectParameter("SomePropertyName", inParameter) : new ObjectParameter("SomePropertyName", typeof(int)); return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SomeMethod1", localParameter); } public virtual int SomeMethod2(Nullable<int> inParameter) { var localParameter = inParameter.HasValue ? new ObjectParameter("SomePropertyName", inParameter) : new ObjectParameter("SomePropertyName", typeof(int)); return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SomeMethod2", localParameter); } 

Edit:

(About the same text in the file.) My file: My file

Their file: Their file

+10
c # t4
source share
1 answer

What @ ralf.w. was the solution to this problem. The line endings in the .tt files on the problem computer were LF , and this leads to the creation of additional lines when the conversion tool is running. The correct line endings must be CR LF . As soon as we changed the line ending in the .tt files, the output files were generated properly. I also changed the line termination options in Git to check as-is, commit as-is. This question contains some information about what the line ending options mean and where they can be changed.

Notepad ++ was used to convert problematic .tt files to CR LF (we didn't have many.) Go to EditEOL ConversionWindows (CR LF)

+13
source share

All Articles