New add-in: XAML Styler - looking for feedback!

ben.laceyben.lacey USMember ✭✭

If you used to work on XAML projects, maybe in Windows Phone or WPF, you might have used the excellent XAML Styler Visual Studio extension that turns messy XAML into wonderously-formatted, readable XAML.

I've ported over this add-in to Xamarin Studio, and I'm after your feedback on whether it installs and works on your machines before it's uploaded to the add-in gallery! Download and install the mpack file from here and install it via Add-ins...->Install from file...

It's been developed for the latest stable XS release (6.0) so I'd be particularly interested in whether it installs in beta/alpha releases, and if there's demand for it I could look at making it compatible with 5.x.

Thanks,
Ben.

Posts

  • decriptordecriptor USBeta, Developer Group Leader Xamurai

    The preferences page doesn't do very well when using the Dark theme

  • decriptordecriptor USBeta, Developer Group Leader Xamurai

    Here is a screenshot

  • ben.laceyben.lacey USMember ✭✭

    You're right, it looks a real mess! Should be easy to fix - thanks for the feedback.

  • I installed it but it doesn't show up in the context menu. It's available through the super menu (cmd+.) but not right-click. Anything special I'm supposed to do to enable it?

  • Ben, it seems that the "Attribute tolerance" parameter it's not being saved. Besides that, it would be awesome if we had a way to have an attribute besides the name of the element in the start tag when NOT using "Position first attribute on same line as start tag". This behavior already happens when checking this option.

    Other than that, great job! Thanks.

  • ben.laceyben.lacey USMember ✭✭

    @DavidHarris.7667 - that's strange, it should work without anything special. The only requirement is the filename has to have the extension .xaml (not case-sensitive) and it should appear in the context menu of the editor window. If you're still having issues I can send over a debug build that logs why it's not appearing to help track this down...

    @DouglasKazumiLopesUgochi - indeed it wasn't being saved, thanks for spotting it! I'll fix it asap. For your second point, do you mean that when the 'Position first attribute...' option is OFF, you can choose an attribute other than x:Name to be the first attribute on the new line? Like this, where it's Text rather than x:Name:

    <Label Text="Welcome to Xamarin Forms!" x:Name="MyLabel" HorizontalOptions="Center" VerticalOptions="Center" XAlign="Center" BackgroundColor="Lime" FontFamily="SourceSansPro-Bold" FontSize="15" Opacity="0.5" TextColor="Fuchsia" />

    A new release will be up on the Beta add-in repository soon with the fixes mentioned above, and a new key shortcut of Ctrl+Shift+I

  • ben.laceyben.lacey USMember ✭✭

    For anyone having issues with the 'Formal Xaml' option not appearing in the context menu of the Xaml source editor, I've uploaded a version of the add-in with a potential fix here - give it a try, and let me know if it works!

  • mike.hmike.h USMember ✭✭

    Great stuff!
    This is something which Xamarin Studio should have for some time already.

  • DamianSuessDamianSuess USMember ✭✭
    edited August 2016

    @ben.lacey, great job i love the addon!! Did find that the spaces are defaulting to 4 spaces even though i'm trying my best to set it to 2 spaces. Reason being, our code standards specifies tabbing to use 2 spaces.

    Any thoughts? I tried doing a quick search on GitHub so I could modify it & send out an optional patch but came up short.

    None the less, great job!

  • ben.laceyben.lacey USMember ✭✭

    @DamianSuess - strangely that is one of the only settings that's not configurable in the original VS plugin... I'm not sure why, it seems like a useful setting to be able to change.

    I've built a new version that should allow you to modify it to 2 spaces in the options, give 1.0.2 a try from the beta add-in repository and let me know how you get on!

    And thanks to everyone for the feedback, it seems stable enough that it can be added to the main add-in repository soon.

  • DamianSuessDamianSuess USMember ✭✭

    @ben.lacey, you're the man! Thank you for the feedback

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭

    Just installed this - great tool, I now have decently laid out XAML!

  • CliffCawleySkeduloCliffCawleySkedulo USMember ✭✭
    edited September 2016

    @BenLacey @ben.lacey Works great, really love it!

    I have about 50 xaml files though, any chance you can allow for batch formatting of all xaml files?

    Edit Hmm sorry to the other BenLaceys I tagged, seems the forums don't like a dot in your username when tagging :(

  • ben.laceyben.lacey USMember ✭✭

    @CliffCawleySkedulo - a great idea, I should have enough time coming up to get this implemented as a context-menu option on the entire solution or a specific project. Thanks!

  • Awesome, that'd be perfect! :smiley:

  • ben.laceyben.lacey USMember ✭✭

    Ok, there's a new release up on the beta add-in channel (1.0.3) that has support for solution and project-wide batch formatting - just right-click the project or solution and the 'Batch Format Xaml' option should appear near the bottom.

  • KrisAdamsKrisAdams GBMember ✭✭

    Great work.

    I had an issue with it not in the context menu, and noticed your second link wasn't working. I could have manually edited to find the 1_0_1 version, but I found it better to go into Xamarin Studio, go to Add Ins, and then click update (as there was a 1_0_3 version somehow magically linked to your repo).

    Perhaps adding it onto your Github would be useful. Thanks again.

  • OnurHazarOnurHazar USUniversity ✭✭

    @ben.lacey Thank you! installed immediately, very useful add-in.

  • CliffCawleySkeduloCliffCawleySkedulo USMember ✭✭
    edited December 2016

    @ben.lacey said:
    Ok, there's a new release up on the beta add-in channel (1.0.3) that has support for solution and project-wide batch formatting - just right-click the project or solution and the 'Batch Format Xaml' option should appear near the bottom.

    Awesome! I updated an attempted to run it on my PCL project which contains .xaml files in the Views sub directory, but nothing seemed to run and no files were updated. I also tried on the entire solution, but I got the same results. I'm assuming something is wrong?

  • voidvoid DKBeta ✭✭✭

    How about exporting and importing options?

  • @Ben Lacey, I am not sure why the xaml formatting is applying a line break between attribute properties.
    For instance:

    IsVisible="{Binding HasPicture, Converter={StaticResource InverseBooleanConverter}}"
    

    Is formatted to:

    IsVisible="{Binding HasPicture, 
                        Converter={StaticResource InverseBooleanConverter}}"
    

    The break line is added after the comma always.

    Maybe this could be handle via settings but I don't know which setting should I use.

    Furthermore, where we can fork this project to push issues or bug fixes?

  • anton.emelyancevanton.emelyancev USMember ✭✭

    Is there any chance this nice addon will be available for Visual Studio for MAC? MFractor provides some xaml formatting features but I don't realy like it comparing to XAML Styler.

  • Matthew-RobbinsMatthew-Robbins AUInsider ✭✭
    edited June 2017

    @AntonEmelyancev What can we improve in the XAML formatting for you? Tom and I are always open to feedback to improve MFractor so we can help you build better apps.

  • CodeGrueCodeGrue USMember ✭✭

    Visual Studio Mac version, please. I tried installing from the link at the top and it's not compatible.

  • voidvoid DKBeta ✭✭✭

    @anton.emelyancev said:
    Is there any chance this nice addon will be available for Visual Studio for MAC?

    I miss it as well.

  • anton.emelyancevanton.emelyancev USMember ✭✭

    @Matthew-Robbins said:
    @AntonEmelyancev What can we improve in the XAML formatting for you? Tom and I are always open to feedback to improve MFractor so we can help you build better apps.

    Sorry Matthew, missed your post.
    Main advantage of Xaml Styler - its simple and minimalistic. One key - formatting applied to all document (don't need to select particular code fragment or find closing brackets of ContentPage). Also it provides nice options for customization: for example you can choose space indentation with attribute on the same line as tag (just for my opinion it provides better xaml readabillity than with tabs). Even default options provide nice attribute order and formatting rules (and can be customized).

  • Matthew-RobbinsMatthew-Robbins AUInsider ✭✭

    @AntonEmelyancev We'll start looking into improve our formatting then, it looks like this is something the community is severely missing.

    For the options, are these specified in the Xamarin Studio / Visual Studio preferences menu?

    Would you be willing to give us further feedback as we improve our formatting support?

  • voidvoid DKBeta ✭✭✭
    edited July 2017

    @Matthew-Robbins said:
    @AntonEmelyancev We'll start looking into improve our formatting then, it looks like this is something the community is severely missing.

    For the options, are these specified in the Xamarin Studio / Visual Studio preferences menu?

    Would you be willing to give us further feedback as we improve our formatting support?

    It would be nice if the formatting options could follow the project/solution

  • anton.emelyancevanton.emelyancev USMember ✭✭

    @Matthew-Robbins
    Yes, these options specified in XS Preferences -> XamlStyler menu. As for feedback I think I can provide it when things will be done.

  • Matthew-RobbinsMatthew-Robbins AUInsider ✭✭

    @void @AntonEmelyancev Thanks for the feedback; I'll keep you both in the loop as we improve this tooling so I can get your feedback.

  • ben.laceyben.lacey USMember ✭✭

    Hi all - sorry for the delay, you know how deadlines are...!

    I've got a version compatible with VS for Mac available for download here which I've tested on the latest stable version of VS (v7.0.1) and it seems ok. Let me know if you get any issues.

    I'm working on getting it into the add-in repository but the build process is throwing more than a few problems my way, so it might be a while until it appears there.

  • anton.emelyancevanton.emelyancev USMember ✭✭

    Hi, @ben.lacey, nice to see you!
    Just checked provided addon on VS for Mac. Tried to format several xaml pages and seems it work okay.
    Thank you!

  • NicolasKrierNicolasKrier FRMember ✭✭✭

    Ohhhhh Yeaaaa baby ! I love you so much for providing a extension for VS on mac xD i don't understand how it s not integrated in visual studio yet... Such a shame :)

  • voidvoid DKBeta ✭✭✭

    @NicolasKrier said:
    Ohhhhh Yeaaaa baby ! I love you so much for providing a extension for VS on mac xD i don't understand how it s not integrated in visual studio yet... Such a shame :)

    Score! Thanks a bunch

  • This is an excellent extension @ben.lacey, is there a GitHub link, or a permalink of some sort that I can favorite for future reference?

  • PeterO_dkPeterO_dk DKMember ✭✭

    @ben.lacey there is a request from the Xavalon/XamlStyler people to get your help in getting the Mac Version official. We are using it in our team, and we have a combination of Windows and Mac users so we are very keen on feature parity.

    gitHub . com /Xavalon/XamlStyler/issues/135#issuecomment-393784969

  • alvynfashalvynfash FRMember

    @ben.lacey @ben.lacey @ben.lacey we need your help to port to vsmac 2019 please !!

Sign In or Register to comment.