Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

Ensure template files end with newline and add validation test

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Fix template files missing trailing newlines

Description

GitHub tooling complains when files don't end with a newline. Fixed 375 template files across source code, CSS, configuration files, and localization files by adding trailing newlines.

Added NewlineEndingTest:

  • Validates all template files end with newline (LF/0x0a)
  • Mirrors existing ByteOrderMarkTest pattern
  • Excludes third-party libraries (wwwroot/lib/*)

Fixed files:

  • 4 source files: .fs, .razor
  • 5 CSS files
  • 17 configuration files: template.json, dotnetcli.host.json, ide.host.json, strings.json
  • 349 localization files: templatestrings.*.json in .template.config/localize/*

Merge conflict resolution:

  • Updated 13 RazorClassLibrary-CSharp localization files with latest translations from main branch while ensuring newline endings
Original prompt

This section details on the original issue you should resolve

<issue_title>NIT: Returns in project template files</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

NIT, so only if interested ......

GH complains about files not ending on a blank line (i.e., LF on the last code line). The BWA template has at least one example ...

https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Pages/NotFound.razor

[Edit the file to witness it.]

Do you want to go through and confirm/update any files for this?

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response</issue_description>

<agent_instructions>Prepare a PR. Be sensible and avoid any file that shouldn't get this treatment, indicate so in your summary (which files you didn't change and the reason). We should also include a check similar to the one that we have for BOM on files.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@ilonatommy @guardrex, just to clarify, are you suggesting here that we should always have a blank line in our template files? @javiercn @guardrex thanks for the clarification.

I think if this is the case, we would probably treat it similarly to the BOM and make sure that every file has the line ending and that we have tests that validate they get generated with it.

@guardrex any examples where GH is complaining? I imagine you mean copilot.</comment_new>
<comment_new>@javiercn
Hmm, not sure if this is a manual thing or if has been caused by .gitattributes.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 18, 2025 13:16
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing blank lines in project template files Ensure template files end with newline and add validation test Dec 18, 2025
Copilot AI requested a review from javiercn December 18, 2025 13:25
@javiercn javiercn marked this pull request as ready for review December 26, 2025 12:46
@javiercn javiercn requested a review from a team as a code owner December 26, 2025 12:46
Copilot AI review requested due to automatic review settings December 26, 2025 12:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses GitHub tooling complaints about files not ending with newlines by fixing 26 template files and adding a validation test to prevent future occurrences.

Key Changes:

  • Added NewlineEndingTest that validates all template files end with a newline (LF/0x0a), mirroring the existing ByteOrderMarkTest pattern
  • Fixed 26 template files across source code (.fs, .razor), CSS, and configuration files (template.json, dotnetcli.host.json, ide.host.json, strings.json)
  • Excluded third-party libraries (wwwroot/lib/*) and auto-generated localization files (.template.config/localize/*) from validation

Reviewed changes

Copilot reviewed 1 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ProjectTemplates/test/Templates.Tests/NewlineEndingTest.cs New test class that validates template files end with newline; checks multiple file types and excludes third-party/auto-generated content
src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Program.fs Added trailing newline to F# source file
src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/template.json Added trailing newline to template configuration
src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/ide.host.json Added trailing newline to IDE host configuration
src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/dotnetcli.host.json Added trailing newline to dotnet CLI host configuration
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/zh-Hant/strings.json Added trailing newline to Traditional Chinese localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/zh-Hans/strings.json Added trailing newline to Simplified Chinese localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/tr/strings.json Added trailing newline to Turkish localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/ru/strings.json Added trailing newline to Russian localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/pt-BR/strings.json Added trailing newline to Brazilian Portuguese localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/pl/strings.json Added trailing newline to Polish localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/ko/strings.json Added trailing newline to Korean localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/ja/strings.json Added trailing newline to Japanese localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/it/strings.json Added trailing newline to Italian localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/fr/strings.json Added trailing newline to French localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/es/strings.json Added trailing newline to Spanish localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/dotnetcli.host.json Added trailing newline to dotnet CLI host configuration
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/de/strings.json Added trailing newline to German localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/cs/strings.json Added trailing newline to Czech localization strings
src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/wwwroot/css/site.css Added trailing newline to F# starter web CSS file
src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/wwwroot/css/site.css Added trailing newline to C# starter web CSS file
src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/wwwroot/css/site.css Added trailing newline to Razor Pages CSS file
src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/wwwroot/css/app.css Added trailing newline to WebAssembly app CSS file
src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Pages/NotFound.razor Added trailing newline to WebAssembly NotFound page
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/wwwroot/app.css Added trailing newline to Blazor Web app CSS file
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Pages/NotFound.razor Added trailing newline to Blazor NotFound page
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1.Client/_Imports.razor Added trailing newline to Blazor client imports file

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
@javiercn
Copy link
Member

@copilot fix the merge conflicts

…zation files

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 29, 2025

@copilot fix the merge conflicts

Fixed merge conflicts by updating 13 RazorClassLibrary-CSharp localization files with the latest translations from main and ensuring they all end with newlines. Changes committed in fb131bb.

@javiercn javiercn merged commit 9cb6424 into main Dec 30, 2025
25 checks passed
@javiercn javiercn deleted the copilot/fix-blank-line-in-templates branch December 30, 2025 10:28
@dotnet-policy-service dotnet-policy-service bot added this to the 11.0-preview1 milestone Dec 30, 2025
Copy link

@Ma202010 Ma202010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NIT: Returns in project template files

4 participants