Skip to content

Conversation

@DoctorKrolic
Copy link
Contributor

@DoctorKrolic DoctorKrolic commented Mar 1, 2023

Fixes: dotnet/roslyn#65921 (Does not fix that issue)

Started a new project recently and it was extreamly annoying to add that additional line every single time I create an item. In all codebases I've seen there is always a line break between namespace and type declaration

@DoctorKrolic DoctorKrolic requested a review from a team as a code owner March 1, 2023 18:45
@ghost ghost added the Area-Infrastructure label Mar 1, 2023
@vlada-shubina vlada-shubina added the Area-Common templates Covers templates in the repo (classlib, console, common item templates) label Mar 2, 2023
@vlada-shubina vlada-shubina requested a review from baronfel March 2, 2023 17:39
@vlada-shubina
Copy link
Member

@baronfel do you have an opinion on this? the change looks for better to me.

@baronfel
Copy link
Member

baronfel commented Mar 2, 2023

Yes, this LGTM.

Copy link
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

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

Thanks

@vlada-shubina
Copy link
Member

@YuliiaKovalova let's backport it to 7.0.3xx too.

@DoctorKrolic
Copy link
Contributor Author

Question from me: Will this affect item templates in Visual Studio? Does it use template engine from this repo?

@JanKrivanek
Copy link
Member

@JanKrivanek
Copy link
Member

Question from me: Will this affect item templates in Visual Studio? Does it use template engine from this repo?

Unfortunately not in the current version (VS uses .vstempaltes for those). This should change soon (I cannot comment on the timing/version though)

@YuliiaKovalova
Copy link
Member

Question from me: Will this affect item templates in Visual Studio? Does it use template engine from this repo?

The was a discussion about it, but we faced an ambiguity between these project items and already existing ones in VS.
@phenning, do you have any updates here?

@YuliiaKovalova
Copy link
Member

It might be good idea to make the same change in project templates as well: https://github.com/dotnet/sdk/tree/8af67162055b50507b5b8743d199828a144275b9/template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content

Long run solution: dotnet/templating#5505

@GangWang01 , could you add these changes?

@GangWang01
Copy link
Member

It might be good idea to make the same change in project templates as well: https://github.com/dotnet/sdk/tree/8af67162055b50507b5b8743d199828a144275b9/template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content
Long run solution: dotnet/templating#5505

@GangWang01 , could you add these changes?

@YuliiaKovalova Sure. Made the change in #30972 and #30973.

@phenning
Copy link
Member

phenning commented Mar 3, 2023

Question from me: Will this affect item templates in Visual Studio? Does it use template engine from this repo?

The was a discussion about it, but we faced an ambiguity between these project items and already existing ones in VS. @phenning, do you have any updates here?

This is on the backlog, but we don’t have a planned release as of yet for the new templates.

@DoctorKrolic
Copy link
Contributor Author

Can this be merged? Also if you plan to backport this change to 7.0.3, I assume you'll do it yourselves, right?

@YuliiaKovalova
Copy link
Member

YuliiaKovalova commented Mar 6, 2023

Can this be merged? Also if you plan to backport this change to 7.0.3, I assume you'll do it yourselves, right?

Yes, we will port it.

Thank you for your contribution!

@YuliiaKovalova YuliiaKovalova merged commit 43efc3b into dotnet:main Mar 6, 2023
@DoctorKrolic DoctorKrolic deleted the add-template-newline branch March 6, 2023 08:55
@nazarkryp
Copy link

you're claiming that this was merged almost year ago, but the problem still persists

@DoctorKrolic
Copy link
Contributor Author

Unfortunatelly, there are 2 different template engines in .NET CLI and VS. This PR applies to .NET CLI (e.g. dotnet new class), but not to VS. There is no point in keeping a VS issue in any .NET repository since it is internal to VS codebase

@phenning
Copy link
Member

I just noticed that the Visual Studio template actually uses a block scope namespace by default:

namespace $rootnamespace$
{
    public class $safeitemrootname$
    {
    }
}

So, it appears that the fixup is being applied by Roslyn after the template's creation does not inject an extra space. Although, this does work as expected with ASP.NET Core projects. I wonder if the fixup is being applied differently between ASP.NET Core and non ASP.NET Core C# projects.

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

Labels

Area-Common templates Covers templates in the repo (classlib, console, common item templates) Area-Infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a blank line between a namespace and a class declaration when creating new item

8 participants