Bug 20144 - AXML files unaffected by XML code formatting settings
Summary: AXML files unaffected by XML code formatting settings
Status: CONFIRMED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Android Designer ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: master
Assignee: Stephen Shaw
URL:
Depends on:
Blocks:
 
Reported: 2014-05-29 11:38 UTC by Adam Patridge
Modified: 2018-02-15 01:09 UTC (History)
7 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Showing identical issues in AXML designer source and Source Code Editor (445.82 KB, image/gif)
2014-07-03 15:31 UTC, Adam Patridge
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 20144 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Adam Patridge 2014-05-29 11:38:07 UTC
I can't seem to change any code formatting settings that will affect tab usage in Android AXML files.

I've got a bunch of AXML files in a project that are using 4 spaces instead of tabs. (Even new AXML files in Xamarin Studio seem to use spaces by default.) Unfortunately, Xamarin Studio wants to use real tab characters whenever I modify indenting in source-mode for an AXML file, and I cannot seem to change that preference. It seems as if AXML files are not affected by XML code formatting settings.

Steps:
1. Spin up new Android Application
2. Set XML files to use spaces instead of tabs (e.g., check "Convert tabs to spaces" and/or setting the document/attribute "indent string" to spaces)
3. Open /Resources/layout/Main.axml
4. Switch to Source editing mode
5. Increase indent on any line (tag or wrapped attribute)

Actual:
It seems that a tab character will always be used for increasing indent in AXML files, no matter what settings are used in Preferences (or solution-/project-level) for XML code formatting.

Expected:
Xamarin Studio would just use any XML code formatting for AXML files as well.
Comment 1 Mikayla Hutchinson [MSFT] 2014-05-30 01:54:00 UTC
What version of XS? Where did you set the policy?
Comment 2 Mike Krüger 2014-05-30 04:57:20 UTC
Works for .xml files but fails for .xaml.

For me it looks like the android designer is using a custom editor or broken extension chain ?

It seems that the  Project isn't set for for the SourceEditorView. 

Btw. I would've recommended not implementing an own editor component ... it's hard to get that right. We not just adding the designer as a subview ?
Comment 3 Adam Patridge 2014-05-30 08:38:24 UTC
In this case, I'm running version 5.0 (build 878).

At various times I've tried setting the policy at the application level (Xamarin Studio -> Preferences), the solution level, and the project level (all under Source Code -> Code Formatting -> XML document). However you try to set it, in the "XML document" section, there are two spots that look like they would allow for tab settings in XML: Text Style -> Whitespace and XML Format -> Document -> Indent string (combined with XML Format -> Attributes -> Attributes indent string).
Comment 4 Jérémie Laval 2014-07-03 14:40:07 UTC
It' s probably because the default AXML editor is not a well-linked editor.

Can you confirm your policy work if instead of opening the layout in the designer and then clicking on "Source" you instead open it up by right-clicking it and "Open With > Source Code Editor"
Comment 5 Adam Patridge 2014-07-03 15:31:19 UTC
Created attachment 7272 [details]
Showing identical issues in AXML designer source and Source Code Editor
Comment 6 Adam Patridge 2014-07-03 15:34:03 UTC
Sorry for the double email. I slipped and forgot to comment with that image upload.

TL;DR: Source Code Editor on an AXML file doesn't seem to help.

Here's the walkthrough of what is shown in the GIF:

Starts with solution text formatting settings to show what is set in this new project. I set XML to 2 spaces (and XML tab to "  ", though it seems irrelevant) and text to 3 spaces to see which was going to be used.

The Test.axml window is opened by Source Code Editor and Main.axml is opened by viewing source from the designer.

Despite both tab settings as spaces, inserting a tab in either window inserts an actual tab character rather than spaces.

Finally, I show what happens (in both windows, only shown in one) when choosing to format the document. That was just an oddity I noticed, but it may not be related to this bug directly.
Comment 7 Nate Cook 2015-12-31 16:32:25 UTC
No update on this? Same issue with the Xamarin Studio 6 preview 3. It's kind of pointless to customize XML formatting settings if they don't apply to 90% of the XML files we edit (Android layout files). Why does this bug still have a status of NEEDINFO?
Comment 9 Jon Douglas [MSFT] 2017-07-17 22:58:29 UTC
I can CONFIRM that axml files seem to be ignored by XML policies in Visual Studio for Mac 7.1 Preview.

I also attempted to rename the axml file to an xml extension, but the policy doesn't seem to work either. In all scenarios it seems to insert a full tab when my tab is set to 1-3 characters.

I then made sure I created a new project as per the warning mentioning that these changes will only occur in a new project.

I also tried to adjust the per project policies, but between the XML document, Android layout, and Text file custom policies, I am not seeing anything change in the Android Designer. It all seems to be the default 4 spaces regardless of a custom policy.

Thus I'm marking this issue as CONFIRMED
Comment 10 Stephen Shaw 2017-07-21 15:33:13 UTC
There are some changes coming in the future that should help enable us to fix this bug.