Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update template to use TFM-based sources; enabled latest lang features #5609

Merged
merged 1 commit into from
Sep 1, 2021

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Aug 30, 2021

(cherry picked from commit ee658c4 / #5547)

Fixes #5074

Proposed changes

  • Enable implicit global usigns
  • Enable file-based namespaces

Regression?

  • No, new functionality

Risk

  • Minimal

Test methodology

Manually create various apps and verify the expected content

dotnet new -i C:\Development\winforms\pkg\Microsoft.Dotnet.WinForms.ProjectTemplates\content\WinFormsApplication-CSharp
cd .. && md template1 && cd template1 && dotnet new winforms  && code . 
cd .. && md template2 && cd template2 && dotnet new winforms -f net6.0 && code . 
cd .. && md template3 && cd template3 && dotnet new winforms -f net5.0 && code . 
cd .. && md template4 && cd template4 && dotnet new winforms -f netcoreapp3.1 && code . 

dotnet new -i C:\Development\winforms\pkg\Microsoft.Dotnet.WinForms.ProjectTemplates\content\WinFormsControlLibrary-CSharp
cd .. && md template12 && cd template12 && dotnet new winformscontrollib && code . 
cd .. && md template22 && cd template22 && dotnet new winformscontrollib -f net6.0 && code . 
cd .. && md template32 && cd template32 && dotnet new winformscontrollib -f net5.0 && code . 
cd .. && md template42 && cd template42 && dotnet new winformscontrollib -f netcoreapp3.1 && code . 

dotnet new -i C:\Development\dotnet-winforms\pkg\Microsoft.Dotnet.WinForms.ProjectTemplates\content\WinFormsLibrary-CSharp
cd .. && md template01 && cd template01 && dotnet new winformslib  && code . 
cd .. && md template21 && cd template21 && dotnet new winformslib -f net6.0 && code . 
cd .. && md template31 && cd template31 && dotnet new winformslib -f net5.0 && code . 
cd .. && md template41 && cd template41 && dotnet new winformslib -f netcoreapp3.1 && code .

Microsoft Reviewers: Open in CodeFlow

@RussKie RussKie requested a review from a team as a code owner August 30, 2021 09:39
@ghost ghost assigned RussKie Aug 30, 2021
@RussKie
Copy link
Member Author

RussKie commented Aug 30, 2021

@Pilchie seeking approval to take into RC2.

@DamianEdwards this essentially wraps our templating story.

@RussKie RussKie added the Servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria label Aug 30, 2021
@RussKie RussKie linked an issue Aug 30, 2021 that may be closed by this pull request
Copy link
Member

@Pilchie Pilchie left a comment

Choose a reason for hiding this comment

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

Need @DamianEdwards' signoff here.

<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">FrameworkParameter-windows</TargetFramework>
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride-windows</TargetFramework>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WinFormsApplication1</RootNamespace>
<LangVersion Condition="'$(langVersion)' != ''">$(ProjectLanguageVersion)</LangVersion>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want this to show up in the project file.

Copy link
Member

Choose a reason for hiding this comment

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

Also, has a lower case l

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a command line argument and aligns with this:

"langVersion": {
"type": "parameter",
"datatype": "text",
"description": "Sets langVersion in the created project file",
"defaultValue": "",
"replaces": "$(ProjectLanguageVersion)",
"displayName": "Language Version"
},

The command line args are case sensitive:
image

There's an open tracking issue for this dotnet/templating#3237


#endif
#if (csharpFeature_FileScopedNamespaces)
namespace Company.WinFormsApplication1;
Copy link
Member

Choose a reason for hiding this comment

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

I thought the decision was not to use these in the templates, and have the VS option apply formatting to decide which form to use?

Copy link
Member

Choose a reason for hiding this comment

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

For templates that aren't splitting their identity based on TFM and accept a language version parameter (like these), yes, I believe that was the decision.

Copy link
Member Author

Choose a reason for hiding this comment

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

These changes were suggested to us by the dotnet/templating team and aligns with changes made in that repo (e.g. dotnet/templating#3454).

Copy link
Member

Choose a reason for hiding this comment

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

@Pilchie @KathleenDollard was it that item templates would keep using block-scoped namespace declarations, but the project templates that had an option to change the language version would selectively apply file-scoped when the version was high-enough (or not specified) perhaps?

@Pilchie
Copy link
Member

Pilchie commented Aug 31, 2021

@davidwengier - do you know what the conclusion was for templates and file scoped namespaces?

@davidwengier
Copy link
Contributor

@davidwengier - do you know what the conclusion was for templates and file scoped namespaces?

In current dogfood builds, Roslyn will reformat namespaces (and other things) for any new file that is added, based on a users preferences.

@RussKie RussKie removed the Servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria label Aug 31, 2021
@RussKie
Copy link
Member Author

RussKie commented Aug 31, 2021

So any further objections?

@DamianEdwards
Copy link
Member

@RussKie no I think you're good to go.

@RussKie RussKie merged commit a88ff3f into dotnet:release/6.0 Sep 1, 2021
@RussKie RussKie deleted the template-changes branch September 1, 2021 03:56
RussKie added a commit to RussKie/winforms that referenced this pull request Sep 7, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants