Browse Source

Fix crash when creating a new solution.

pull/32/merge
Daniel Grunwald 12 years ago
parent
commit
8848eab4e0
  1. 3
      src/Main/Base/Project/Project/IProjectService.cs
  2. 4
      src/Main/Base/Project/Services/IUIService.cs
  3. 1
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
  4. 7
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  5. 29
      src/Main/Base/Project/Templates/ProjectTemplate.cs
  6. 3
      src/Main/Base/Project/Workbench/File/IFileService.cs
  7. 1
      src/Main/SharpDevelop/Project/SolutionFolder.cs
  8. 1
      src/Main/SharpDevelop/Templates/File/FileTemplateImpl.cs
  9. 1
      src/Main/SharpDevelop/Templates/Project/ProjectTemplateImpl.cs
  10. 1
      src/Main/SharpDevelop/Templates/TemplateService.cs

3
src/Main/Base/Project/Project/IProjectService.cs

@ -86,6 +86,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -86,6 +86,9 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// Opens a solution in the IDE that was created/loaded earlier.
/// </summary>
/// <remarks>
/// The solution must be saved to disk before it can be opened.
/// </remarks>
bool OpenSolution(ISolution solution);
/// <summary>

4
src/Main/Base/Project/Services/IUIService.cs

@ -16,6 +16,10 @@ namespace ICSharpCode.SharpDevelop @@ -16,6 +16,10 @@ namespace ICSharpCode.SharpDevelop
/// </summary>
public interface IUIService
{
// TODO: consider if we should move all the methods to other services, based on which SD components
// the dialogs belong to.
// Or, if we don't do that, consider moving UI-related methods from the services here (e.g. FileService.BrowseForFolder)
/// <summary>
/// Shows the 'Edit Solution Configurations' dialog.
/// </summary>

1
src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs

@ -36,7 +36,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -36,7 +36,6 @@ namespace ICSharpCode.SharpDevelop.Gui
public NewFileDialog(IProject project, DirectoryName basePath, IEnumerable<FileTemplate> fileTemplates)
{
StandardHeader.SetHeaders();
this.project = project;
this.basePath = basePath;
this.allowUntitledFiles = basePath == null;

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

@ -275,14 +275,14 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -275,14 +275,14 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
if (name.Length == 0 || !char.IsLetter(name[0]) && name[0] != '_') {
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.ProjectNameMustStartWithLetter}";
}
if (name.EndsWith(".", StringComparison.Ordinal)) {
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.ProjectNameMustNotEndWithDot}";
}
if (!FileUtility.IsValidDirectoryEntryName(solution)
|| !FileUtility.IsValidDirectoryEntryName(name))
{
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.IllegalProjectNameError}";
}
if (name.EndsWith(".")) {
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.ProjectNameMustNotEndWithDot}";
}
if (!FileUtility.IsValidPath(location) || !Path.IsPathRooted(location)) {
return "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.SpecifyValidLocation}";
}
@ -349,6 +349,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -349,6 +349,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
if (result != null)
item.Template.RunOpenActions(result);
ProjectBrowserPad.RefreshViewAsync();
DialogResult = DialogResult.OK;
}
}

29
src/Main/Base/Project/Templates/ProjectTemplate.cs

@ -32,17 +32,26 @@ namespace ICSharpCode.SharpDevelop.Templates @@ -32,17 +32,26 @@ namespace ICSharpCode.SharpDevelop.Templates
internal ProjectTemplateResult CreateAndOpenSolution(ProjectTemplateOptions options, string solutionDirectory, string solutionName)
{
FileName solutionFileName = FileName.Create(Path.Combine(solutionDirectory, solutionName + ".sln"));
bool solutionOpened = false;
ISolution createdSolution = SD.ProjectService.CreateEmptySolutionFile(solutionFileName);
options.Solution = createdSolution;
options.SolutionFolder = createdSolution;
var result = CreateProjects(options);
if (result == null || !SD.ProjectService.OpenSolution(createdSolution)) {
createdSolution.Dispose();
return null;
} else {
createdSolution.Save();
SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseSolutionCreated(new SolutionEventArgs(createdSolution));
return result;
try {
options.Solution = createdSolution;
options.SolutionFolder = createdSolution;
var result = CreateProjects(options);
if (result == null) {
return null;
}
createdSolution.Save(); // solution must be saved before it can be opened
if (SD.ProjectService.OpenSolution(createdSolution)) {
solutionOpened = true;
SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseSolutionCreated(new SolutionEventArgs(createdSolution));
return result;
} else {
return null;
}
} finally {
if (!solutionOpened)
createdSolution.Dispose();
}
}

3
src/Main/Base/Project/Workbench/File/IFileService.cs

@ -13,7 +13,8 @@ using ICSharpCode.SharpDevelop.Gui; @@ -13,7 +13,8 @@ using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// File service.
/// Manages the list files opened by view contents so that multiple view contents opening the same file can synchronize.
/// Also provides events that can be used to listen to file operations performed in the IDE.
/// </summary>
[SDService("SD.FileService")]
public interface IFileService

1
src/Main/SharpDevelop/Project/SolutionFolder.cs

@ -128,6 +128,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -128,6 +128,7 @@ namespace ICSharpCode.SharpDevelop.Project
Debug.Assert(project.IdGuid != Guid.Empty);
this.Items.Add(project);
project.ProjectLoaded();
ProjectBrowserPad.RefreshViewAsync();
return project;
}

1
src/Main/SharpDevelop/Templates/File/FileTemplateImpl.cs

@ -391,6 +391,7 @@ namespace ICSharpCode.SharpDevelop.Templates @@ -391,6 +391,7 @@ namespace ICSharpCode.SharpDevelop.Templates
{
FileTemplateResult result = new FileTemplateResult(options);
StandardHeader.SetHeaders();
StringParserPropertyContainer.FileCreation["StandardNamespace"] = options.Namespace;
StringParserPropertyContainer.FileCreation["FullName"] = options.FileName;
StringParserPropertyContainer.FileCreation["FileName"] = Path.GetFileName(options.FileName);

1
src/Main/SharpDevelop/Templates/Project/ProjectTemplateImpl.cs

@ -255,6 +255,7 @@ namespace ICSharpCode.SharpDevelop.Templates @@ -255,6 +255,7 @@ namespace ICSharpCode.SharpDevelop.Templates
public override ProjectTemplateResult CreateProjects(ProjectTemplateOptions options)
{
var result = new ProjectTemplateResult(options);
StandardHeader.SetHeaders();
if (solutionDescriptor != null) {
if (!solutionDescriptor.AddContents(options.SolutionFolder, result, languagename))
return null;

1
src/Main/SharpDevelop/Templates/TemplateService.cs

@ -21,6 +21,7 @@ namespace ICSharpCode.SharpDevelop.Templates @@ -21,6 +21,7 @@ namespace ICSharpCode.SharpDevelop.Templates
public TemplateService()
{
projectAndFileTemplates = new Lazy<IReadOnlyList<TemplateBase>>(LoadProjectAndFileTemplates);
textTemplates = new Lazy<IReadOnlyList<TextTemplateGroup>>(LoadTextTemplates);
}
public IEnumerable<FileTemplate> FileTemplates {

Loading…
Cancel
Save