Browse Source

Fixed SD2-1018: Nameing projects with especial characters makes them unable to run.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1728 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
fcc3c17310
  1. 6
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  2. 31
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

6
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -263,9 +263,9 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
} }
string solution = ((TextBox)ControlDictionary["solutionNameTextBox"]).Text; string solution = ((TextBox)ControlDictionary["solutionNameTextBox"]).Text.Trim();
string name = ((TextBox)ControlDictionary["nameTextBox"]).Text; string name = ((TextBox)ControlDictionary["nameTextBox"]).Text.Trim();
string location = ((TextBox)ControlDictionary["locationTextBox"]).Text; string location = ((TextBox)ControlDictionary["locationTextBox"]).Text.Trim();
if (!FileUtility.IsValidFileName(solution) if (!FileUtility.IsValidFileName(solution)
|| solution.IndexOf(Path.DirectorySeparatorChar) >= 0 || solution.IndexOf(Path.DirectorySeparatorChar) >= 0
|| solution.IndexOf(Path.AltDirectorySeparatorChar) >= 0 || solution.IndexOf(Path.AltDirectorySeparatorChar) >= 0

31
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

@ -120,21 +120,24 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
// filter 'illegal' chars from standard namespace // filter 'illegal' chars from standard namespace
if (newProjectName != null && newProjectName.Length > 0) { if (newProjectName != null && newProjectName.Length > 0) {
char ch = newProjectName[0]; char ch = '.';
// can only begin with a letter or '_' for (int i = 0; i < newProjectName.Length; ++i) {
if (!Char.IsLetter(ch)) { if (ch == '.') {
standardNamespace.Append('_'); // at beginning or after '.', only a letter or '_' is allowed
} else { ch = newProjectName[i];
standardNamespace.Append(ch); if (!Char.IsLetter(ch)) {
} standardNamespace.Append('_');
for (int i = 1; i < newProjectName.Length; ++i) { } else {
ch = newProjectName[i]; standardNamespace.Append(ch);
// can only contain letters, digits or '_' }
if (!Char.IsLetterOrDigit(ch) && ch != '.') {
standardNamespace.Append('_');
} else { } else {
standardNamespace.Append(ch); ch = newProjectName[i];
// can only contain letters, digits or '_'
if (!Char.IsLetterOrDigit(ch) && ch != '.') {
standardNamespace.Append('_');
} else {
standardNamespace.Append(ch);
}
} }
} }
} }

Loading…
Cancel
Save