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

.NET 6 templates for iOS, macOS, tvOS, & MacCatalyst #10741

Merged
merged 1 commit into from
Mar 2, 2021

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Feb 26, 2021

Context: https://docs.microsoft.com/dotnet/core/tutorials/cli-templates-create-template-pack
Context: https://github.com/dotnet/templating/wiki
Context: dotnet/designs#120
Fixes: #10252

To implement templates in a .NET workload:

  1. Make .nupkg files that follow the structure of the dotnet new
    templating system, using $(PackageType) of Template.
  2. Install the .nupkg files in in dotnet/template-packs/
  3. Update WorkloadManifest.json, to be part of the workload:
"Microsoft.@[email protected]": {
  "kind": "template",
  "version": "@VERSION@"
}

These are a starting point, for what I would consider the minimum for
the xamarin-macios repo to provide for now:

Template Name                                 Short Name      Language    Tags
--------------------------------------------  --------------  ----------  ----------------------
iOS Controller template                       ios-controller  [C#]        iOS
iOS Application                               ios             [C#]        iOS
iOS Class library                             ioslib          [C#]        iOS
macOS Application                             macos           [C#]        macOS
MacCatalyst Application                       maccatalyst     [C#]        macOS/Catalyst
tvOS Application                              tvos            [C#]        tvOS

We will probably need PM input on what the final templates will be.

To use these, you might do:

$ mkdir MyApp && cd MyApp
$ dotnet new ios
$ dotnet new ios-controller --name LoginController --namespace MyApp

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

🎉 All 182 tests passed 🎉

Pipeline on Agent XAMBOT-1095'

public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
Copy link
Member

Choose a reason for hiding this comment

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

Do template code need to use a specific coding style? Or will they be reformatted according to the user's settings when they're instantiated?

Copy link
Member Author

@jonathanpeppers jonathanpeppers Mar 1, 2021

Choose a reason for hiding this comment

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

There is a dotnet format tool: https://www.hanselman.com/blog/editorconfig-code-formatting-from-the-command-line-with-net-cores-dotnet-format-global-tool

I tested this, I copied the .editorconfig from xamarin-android, then did:

% dotnet new ios
% dotnet format

When I saw other templates, they all use VS Windows coding style -- but I guess it could really be any style? I think dotnet format would fix up anything.

Copy link
Member

Choose a reason for hiding this comment

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

That tools looks pretty amazing!

Its mere existence makes me vote towards having the templates use our own coding style (in which case the coding style is wrong in some of the new files - I guess you could run dotnet format locally in the template directory and that'll fix it 😄 )

@spouliot spouliot added the not-notes-worthy Ignore for release notes label Mar 1, 2021
Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

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

How does it compare with what we ship today ? https://github.com/xamarin/xamarin-templates

This should not fix (close) the dotnet issue until the work is completed (or we risk losing track of the task)

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// create a new window instance based on the screen size
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Copy link
Contributor

Choose a reason for hiding this comment

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

source code format is inconsistent, e.g. space before (

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I dotnet format every template to use default VS settings?

Or should I dotnet format using the .editorconfig in xamarin-macios?

Copy link
Contributor

Choose a reason for hiding this comment

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

as much as I'd like to use our (mono) style it's likely best to follow VS[4m] style used for other templates

dotnet/Microsoft.iOS.Templates/ios/Info.plist Show resolved Hide resolved
@jonathanpeppers
Copy link
Member Author

How does it compare with what we ship today ? https://github.com/xamarin/xamarin-templates

@spouliot I got these files from here ^^ I should have put that in the commit message. I didn't change anything (intentionally) other than port them to .NET 6.

For the Mac template I created a new project in latest VS Mac -- I didn't find a Mac template in xamarin-templates.

@jonathanpeppers
Copy link
Member Author

@spouliot as for the issues, I think this one should close #10252, as I think it is matching parity with what Android had for .NET 6 Preview 1.

I filed new issues to "finish" the templates:

Context: https://docs.microsoft.com/dotnet/core/tutorials/cli-templates-create-template-pack
Context: https://github.com/dotnet/templating/wiki
Context: dotnet/designs#120
Fixes: xamarin#10252

To implement templates in a .NET workload:

1. Make `.nupkg` files that follow the structure of the `dotnet new`
   templating system, using `$(PackageType)` of `Template`.
2. Install the `.nupkg` files in in `dotnet/template-packs/`
3. Update `WorkloadManifest.json`, to be part of the workload:

    "Microsoft.@platform@.Templates": {
      "kind": "template",
      "version": "@Version@"
    }

These are a starting point, for what I would consider the minimum for
the xamarin-macios repo to provide for now:

    Template Name                                 Short Name      Language    Tags
    --------------------------------------------  --------------  ----------  ----------------------
    iOS Controller template                       ios-controller  [C#]        iOS
    iOS Application                               ios             [C#]        iOS
    iOS Class library                             ioslib          [C#]        iOS
    macOS Application                             macos           [C#]        macOS
    MacCatalyst Application                       maccatalyst     [C#]        macOS/Catalyst
    tvOS Application                              tvos            [C#]        tvOS

We will probably need PM input on what the final templates will be.

To use these, you might do:

    $ mkdir MyApp && cd MyApp
    $ dotnet new ios
    $ dotnet new ios-controller --name LoginController --namespace MyApp

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
@jonathanpeppers
Copy link
Member Author

Latest changes:

  • Ran dotnet format on all the templates using this repo's .editorconfig.
    • I had to manually rename any *.designer.cs file so they would be formatted, too. (I think I got them all)
  • I updated the tags on MacCatalyst:
Template Name                                 Short Name      Language    Tags
--------------------------------------------  --------------  ----------  ----------------------
iOS Controller template                       ios-controller  [C#]        iOS
iOS Application                               ios             [C#]        iOS
iOS Class library                             ioslib          [C#]        iOS
macOS Application                             macos           [C#]        macOS
MacCatalyst Application                       maccatalyst     [C#]        macOS/Catalyst
tvOS Application                              tvos            [C#]        tvOS

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

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

👏

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

🎉 All 182 tests passed 🎉

Pipeline on Agent XAMBOT-1099'

@jonathanpeppers jonathanpeppers merged commit 11ca5a8 into xamarin:main Mar 2, 2021
@jonathanpeppers jonathanpeppers deleted the dotnet-templates branch March 2, 2021 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-notes-worthy Ignore for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET 6: add base templates to match Android
6 participants