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 @@ -263,9 +263,9 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
}
string solution = ((TextBox)ControlDictionary["solutionNameTextBox"]).Text;
string name = ((TextBox)ControlDictionary["nameTextBox"]).Text;
string location = ((TextBox)ControlDictionary["locationTextBox"]).Text;
string solution = ((TextBox)ControlDictionary["solutionNameTextBox"]).Text.Trim();
string name = ((TextBox)ControlDictionary["nameTextBox"]).Text.Trim();
string location = ((TextBox)ControlDictionary["locationTextBox"]).Text.Trim();
if (!FileUtility.IsValidFileName(solution)
|| solution.IndexOf(Path.DirectorySeparatorChar) >= 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 @@ -120,21 +120,24 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
// filter 'illegal' chars from standard namespace
if (newProjectName != null && newProjectName.Length > 0) {
char ch = newProjectName[0];
// can only begin with a letter or '_'
if (!Char.IsLetter(ch)) {
standardNamespace.Append('_');
} else {
standardNamespace.Append(ch);
}
for (int i = 1; i < newProjectName.Length; ++i) {
ch = newProjectName[i];
// can only contain letters, digits or '_'
if (!Char.IsLetterOrDigit(ch) && ch != '.') {
standardNamespace.Append('_');
char ch = '.';
for (int i = 0; i < newProjectName.Length; ++i) {
if (ch == '.') {
// at beginning or after '.', only a letter or '_' is allowed
ch = newProjectName[i];
if (!Char.IsLetter(ch)) {
standardNamespace.Append('_');
} else {
standardNamespace.Append(ch);
}
} 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