diff options
3 files changed, 27 insertions, 3 deletions
diff --git a/main/src/core/MonoDevelop.Ide/ChangeLog b/main/src/core/MonoDevelop.Ide/ChangeLog index 91466ce423..2555824014 100644 --- a/main/src/core/MonoDevelop.Ide/ChangeLog +++ b/main/src/core/MonoDevelop.Ide/ChangeLog @@ -1,5 +1,12 @@ 2009-08-28 Mike Krüger <mkrueger@novell.com> + * MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs: + * MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs: + Fixed 'Bug 502880 - Cannot create file with hypen in the + name'. + +2009-08-28 Mike Krüger <mkrueger@novell.com> + * MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs: Fixed "Bug 479196 - "add test fixture" adds refs to nunit.core and nunit.framework from "Package". diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs index 7e36c2540a..059467137b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs @@ -81,7 +81,8 @@ namespace MonoDevelop.Ide.Templates public virtual bool IsValidName (string name, string language) { - if (name.Length > 0) { + return name.IndexOfAny (Path.GetInvalidFileNameChars ()) == -1; +/* if (name.Length > 0) { if (language != null && language.Length > 0) { IDotNetLanguageBinding binding = LanguageBindingService.GetBindingPerLanguageName (language) as IDotNetLanguageBinding; if (binding != null) { @@ -93,7 +94,7 @@ namespace MonoDevelop.Ide.Templates return name.IndexOfAny (Path.GetInvalidFileNameChars ()) == -1; } else - return false; + return false;*/ } public virtual bool SupportsProject (Project project, string projectPath) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs index 965433eed0..310f2b5df6 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs @@ -38,6 +38,7 @@ using MonoDevelop.Projects; using MonoDevelop.Projects.Text; using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.StandardHeader; +using System.Text; namespace MonoDevelop.Ide.Templates { @@ -294,7 +295,7 @@ namespace MonoDevelop.Ide.Templates while (Path.GetExtension (identifier).Length > 0) identifier = Path.GetFileNameWithoutExtension (identifier); - tags ["Name"] = identifier; + tags ["Name"] = CreateIdentifierName (identifier); tags ["FullName"] = ns.Length > 0 ? ns + "." + identifier : identifier; //some .NET languages may be able to use keywords as identifiers if they're escaped @@ -330,6 +331,21 @@ namespace MonoDevelop.Ide.Templates } } + static string CreateIdentifierName (string identifier) + { + StringBuilder result = new StringBuilder (); + for (int i = 0; i < identifier.Length; i++) { + char ch = identifier[i]; + if (i != 0 && Char.IsLetterOrDigit (ch) || i == 0 && Char.IsLetter (ch) || ch == '_') { + result.Append (ch); + } else { + result.Append ('_'); + } + } + return result.ToString (); + } + + protected ILanguageBinding GetLanguageBinding (string language) { ILanguageBinding binding = LanguageBindingService.GetBindingPerLanguageName (language); |