Matt Ward: File Nesting in Xamarin Studio

With recent versions of Xamarin Studio it is not currently possible to nest files without directly editing the project file. In the past it was possible to drag and drop a file so it was then nested inside another file.

Solution window with nested files in Xamarin Studio

Visual Studio also does not support nesting files by using drag and drop however
Mads Kristensen created a File Nesting extension that adds support for manual and automatic nesting of files within Visual Studio. There is a demo video of the File Nesting extension that shows the extension being used with Visual Studio.
This extension has now been ported to Xamarin Studio and is available from the MonoDevelop Add-in Repository.

Let us take a walkthrough of the features of the File Nesting addin for Xamarin Studio.

Features

  • Manual file nesting
  • Manual file un-nesting
  • Automatic file nesting of selected files based on rules
  • Automatic file nesting when files are added to a project
  • Options to specify which file nesting rules are applied

Supports

  • Xamarin Studio 6.0 or MonoDevelop 6.0.

Manual File Nesting

To manually nest a file select it in the Solution window then right click and select File Nesting – Nest Item…

Manual file nesting - nest item context menu

This will open a file nesting dialog where the parent file can be selected.

File nesting dialog

Select the parent file and click OK to nest the file under that parent file.

Manual file nesting result in solution window

You can also nest multiple files under a parent by selecting multiple files in the Solution window and selecting the Nest Item menu.

Manual File Un-nesting

To un-nest a file select it in the Solution window then right click and select File Nesting – Un-nest Item.

Manual file nesting - un-nest item context menu

The file will then be un-nested from its parent.

Manual file un-nesting result in solution window

Automatic Nesting Rules

The file nesting rules are available from the Preferences dialog.

File nesting rules in preferences

Each rule has a tooltip which will show more detailed information about what the rule does.

Enable auto-nesting

The Enable auto-nesting option will enable or disable automatic file nesting when a file is added to a project.

Enable extension rule

This rule will nest files added with an extra extension under their corresponding parent file. For example MyView.xaml.cs nests under MyView.xaml.

Nested file using extension rule

Enable interface implementation rule

This nests C# interface implementations under the corresponding interface based on the filename. For example, if there is an interface file IMyInterface.cs then a new file called CustomMyInterface.cs will be nested under the IMyInterface file.

Nested file using interface implementation rule

Enable known file type rule

This nests certain known files types. For example, MyPage.ts will be nested under MyPage.html.

Nested file using known file type rule

Enable path segment rule

This nests files with an added path segment under its parent. For example, MyFile.Designer.cs nests under MyFile.cs.

Nested file using path segment rule

Automatic Nesting of Selected Files

To automatically nest files, based on the enabled file nesting rules, select the files, or folder, or project, then right click and select File Nesting – Auto-nest selected items.

Auto-nest selected items context menu

This will then apply the enabled file nesting rules to the selected files.

Automatic File Nesting on Adding Files

To enable automatic file nesting when files are added right click the project and select File Nesting – Enable automatic nesting.

Enable automatic nesting context menu

A check box will be displayed next to this menu item if this feature is enabled. Now when a file is added the enabled nesting rules will be applied and the file will be automatically nested.

Installation

The File Nesting addin is available from the MonoDevelop Add-in Repository on the beta channel. To install the addin open the Add-in Manager, search for the File Nesting addin, then click the Install button.

File Nesting addin in addin manager window

After installing the addin Xamarin Studio will need to be restarted for the addin to work correctly.

Source Code

Xamarin: New Xamarin Dev Days Cities Announced!

Last year, hundreds of developers joined us at Xamarin Dev Days in dozens of cities around the US to learn cross-platform mobile development. The events were such a success that we’re bringing it back this year and taking it global! The first Xamarin Dev Days of 2016 in Milan and Mexico City were great, with […]

The post New Xamarin Dev Days Cities Announced! appeared first on Xamarin Blog.

Xamarin: Introducing Stack Overflow Documentation

Xamarin and Microsoft are excited to be a part of the launch of Stack Overflow Documentation. This new feature brings the same collaborative approach from Stack Overflow’s question-and-answer system to developer documentation. Stack Overflow Documentation provides a set of edit and review tools that lets the community write example-focused documentation to complement our existing developer […]

The post Introducing Stack Overflow Documentation appeared first on Xamarin Blog.

Marcos Cobeña Morián: Introducing Xamarin.iOS to Objective-C/Swift developers

A few months ago I had the chance to showcase Xamarin.iOS to pure Objective-C/Swift developers, within a local group called NSCoder Sevilla. Instead of making slides I thought it’d be more interesting to build a small app which’d do the same, as well as serving as a playground to showcase some topics: managed vs. native… Continue reading Introducing Xamarin.iOS to Objective-C/Swift developers

Xamarin: Build C# and F# Apps on Your iPad with Continuous Mobile Development Environment

It doesn’t matter if you’re on a Windows or a macOS machine, you have access to amazing IDEs to build iOS, Android, Mac, and Windows apps and libraries with Visual Studio and Xamarin Studio. But, what if you could take all of your code on the go and with you everywhere you go? What if […]

The post Build C# and F# Apps on Your iPad with Continuous Mobile Development Environment appeared first on Xamarin Blog.

Xamarin: Explore iOS 10, tvOS 10, watchOS 3, and macOS Sierra Previews Today

Apple announced major updates to all of their operating systems and a smattering of new APIs for developers to explore at this year’s WWDC conference. We are excited for Xamarin developers to get their hands on these new APIs to start building beautiful native apps in C#, so today, we’re releasing our first set of […]

The post Explore iOS 10, tvOS 10, watchOS 3, and macOS Sierra Previews Today appeared first on Xamarin Blog.

Xamarin: Podcast: Tools for Creating & Designing Five Star Apps

This week on the Xamarin Podcast, Mike James and I share the tools and processes we use to create and design beautiful, five-star cross-platform apps, including Sketch, Zeplin, Paintcode, and Bitrise. Subscribe or Download Today Knowing the latest in .NET, C#, and Xamarin is easier than ever with the Xamarin Podcast! The Xamarin Podcast is available […]

The post Podcast: Tools for Creating & Designing Five Star Apps appeared first on Xamarin Blog.