maui icon indicating copy to clipboard operation
maui copied to clipboard

MAUI templates should respect tabs/spaces preferences like other templates

Open BretJohnson opened this issue 2 years ago • 2 comments

Description

When creating a new MAUI app or adding a page, based on the MAUI app/item template, it should uses spaces instead of tabs if the VS editor preferences are set to use spaces (which is the default, I believe). Other templates seem to do this.

Steps to Reproduce

  1. In VS, go to Tools/Options/Text Editor/C#/Tabs and ensure that the preference is set to use spaces (the default, believe)
  2. Do File / New Project / MAUI App. Note that it uses tabs. Expected: Should respect editor preference, spaces here.

For comparison, do File / New Project ASP.NET Core Web App, switching the VS IDE options between tabs and spaces. Note that it adjusts dynamically, respecting the formatting preference. Formatting preferences like indent = 8 with spaces are respected too.

I'm not sure how the other templates achieve this, but hopefully there's some easy, built in mechanism to make it work.

Link to public reproduction project repository

n/a

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS, Other (Tizen, Linux, etc. not supported by Microsoft directly)

Affected platform versions

all

Did you find any workaround?

Workaround: manually reformat.

Relevant log output

No response

BretJohnson avatar Mar 09 '23 06:03 BretJohnson

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

ghost avatar Mar 09 '23 18:03 ghost

I pinged Phil Henning to better understand the cause / fix here. And he said this is an issue with solution templates (which are rare) but not with project templates (much more common). Switching the MAUI app template to a project template would fix it, which is something Phil suggested before since it doesn't need to be a solution template (just has a single project) and is more like other templates. See below for changes to do that.

So that's probably a good idea for the MAUI app template (though we'd need to test). For the Blazor template and other templates with multiple projects, we'd have to keep them as solution.

the changes to the template.json would be pretty simple, just change the type and add a projectOutput with a condition for  the sln file so that it only gets written for CLI, similar to blazor: (without the Hosted condition though) https://github.com/dotnet/aspnetcore/blob/9c7db555f5c8b7069347b9c62976bd951afba4a0/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/.template.config/template.json#L31

BretJohnson avatar Mar 09 '23 23:03 BretJohnson