TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

Scaffold EF Core models using Handlebars templates.
MIT License
208 stars 53 forks source link

[Bug] Line Characters in Generated Comments #144

Closed ExusAltimus closed 3 years ago

ExusAltimus commented 3 years ago

Describe the bug If there is a new line character in the extended properties of a column / table, the default .hbs / CSharpEntityTypeGenerator doesn't account for this and leaves the generated models with syntax errors due to the new line not being commented out.

Expected behavior Split the string into lines and loop through each commenting the line out

To Reproduce Have an extended property with a newline character

Screenshots Capture

ErikEJ commented 3 years ago

This is a battle hardened implementation:

https://github.com/dotnet/efcore/pull/22937

tonysneed commented 3 years ago

@ErikEJ If XML comments are enabled in EF Core 5.0, then I having them in my tool seems redundant. How does one enable generation of comments using the dotnet-ef CLI? They don't seem to be enabled by default.

ErikEJ commented 3 years ago

@tonysneed XML comments are generated in EF Core 5! https://github.com/dotnet/efcore/blob/release/5.0/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs#L261 - they are generated by default in EF Core 6! https://github.com/dotnet/efcore/blob/main/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs#L264

tonysneed commented 3 years ago

How do you enable comments in EF Core 5? How do you disable them in EF Core 6? Is there a CLI parameter?

ErikEJ commented 3 years ago

Magic!

No, I override the linked class and use that overridden class with my EF Core 5 scaffolding tool.

There is no option to turn it off.