Skip to content

Conversation

@RussKie
Copy link
Contributor

@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 vlada-shubina August 30, 2021 09:39
@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
Contributor 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.

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
Contributor 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

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
Contributor 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
Member

@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
Contributor 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

Development

Successfully merging this pull request may close these issues.

Update implicit global usings feature WinForms project templates use latest C# language idioms Update C# templates with global usings

5 participants