Bug 12115 - New file dialog ignores secondary extensions in creating files
Summary: New file dialog ignores secondary extensions in creating files
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Mac OS
: Low enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Matt Ward
: 32973 ()
Depends on:
Reported: 2013-05-06 09:41 UTC by Chris Hamons
Modified: 2016-10-18 15:03 UTC (History)
5 users (show)

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

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 12115 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:

Description Chris Hamons 2013-05-06 09:41:09 UTC
If in a project I add -> new files and create say a Xamarin.Mac View with controler and attempt to name it Foo.MonoMac.cs, the files created with be Foo.cs, Foo.Designer.cs, Foo.xib, and FooController.cs.

This is a problem if I'm porting code and already have a Foo.cs on disk. I have to create the file, then rename them all, then possibly revert changes to the Foo.cs.
Comment 1 Matt Ward 2015-06-18 13:05:00 UTC
Had a quick look at this.

Currently some templates (e.g. ASP.NET and Xamarin.Mac) use the ${Name} property in the template as part of the filename.

    <File name="${Name}.master">

The Name is generated from the text entered in the New File dialog but the templating system deliberating removes all the file extensions. Looking at how the Name is used this seems to be because it is used as a Class name in some templates. Visual Studio has the same behaviour here - creating a new C# class called Foo.Bar.cs creates a Foo class.

With a file template that uses the Name property for its filename any file extension you enter in the New File dialog will be ignored.

Other file templates allow any filename to be used but specify a default file extension.

    <File DefaultExtension=".html">

This allows you to specify the file extension in the New File dialog or not and a file extension will be added if it is missing.

Neither of these features as implemented can fix the bug. It seems as though we would need to extend the file templates to allow the file extension to be changed or forced so something like:

    <File ChangeExtension=".xib">
    <File Extension=".xib">

How would we want this to work?

User entered name => Files generated.

1) Foo => Foo.cs, Foo.designer.cs, Foo.xib
2) Foo.cs => Foo.cs, Foo.designer.cs, Foo.xib
3) Foo.Bar.cs => Foo.Bar.cs, Foo.Bar.designer.cs, Foo.Bar.xib
4) Foo.Bar => Foo.Bar.cs, Foo.Bar.designer.cs, Foo.Bar.xib
5) Foo.Bar.txt => Foo.Bar.txt.cs, Foo.Bar.txt.designer.cs, Foo.Bar.txt.xib

There is a question about whether 4) and 5) is correct. For 5) above possibly XS could check known file extensions instead and handle this better. If this was done we could just use the DefaultExtension attribute and if there was no known file extension used then the default would be used. However this would prevent a user creating a particular filename extension, which might be OK for some file templates.

For 4) and 5) Visual Studio has different behaviour and would do something like:

VS 4) Foo.Bar => Foo.Bar, Foo.designer.cs, Foo.xib
VS 5) Foo.Bar.txt => Foo.Bar.txt, Foo.Bar.designer.cs, Foo.Bar.xib
Comment 2 Matt Ward 2015-08-13 06:00:32 UTC
*** Bug 32973 has been marked as a duplicate of this bug. ***
Comment 3 iain 2016-10-18 15:03:58 UTC
I can confirm this still happens with V6.2

Not sure why it was marked as Needs Info.