Skip to content

Commit

Permalink
show message when loading projects fail
Browse files Browse the repository at this point in the history
when loading the projects for the module editor, if a failure occurs a
message is shown to the user instead of crashing the editor.
  • Loading branch information
brianlagunas committed Feb 4, 2016
1 parent e7416fa commit 80c9b8e
Showing 1 changed file with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,52 @@ private void LoadModules(string filePath)

void LoadProjectModules()
{
var projects = GetProjects();
try
{
var projects = GetProjects();

List<ProjectModuleInfo> projectModules = new List<ProjectModuleInfo>();
List<ProjectModuleInfo> projectModules = new List<ProjectModuleInfo>();

foreach (var project in projects)
{
foreach (ProjectItem item in project.ProjectItems)
foreach (var project in projects)
{
FileCodeModel2 codeModel = (FileCodeModel2)item.FileCodeModel;
if (codeModel != null)
foreach (ProjectItem item in project.ProjectItems)
{
CodeClass2 codeClass = GetCodeClass(codeModel.CodeElements);
if (codeClass != null)
FileCodeModel2 codeModel = (FileCodeModel2)item.FileCodeModel;
if (codeModel != null)
{
if (IsIModule(codeClass.ImplementedInterfaces))
CodeClass2 codeClass = GetCodeClass(codeModel.CodeElements);
if (codeClass != null)
{
var moduleInfo = new ProjectModuleInfo();
moduleInfo.ModuleName = codeClass.Name;
moduleInfo.AssemblyFile = String.Format("{0}.dll", project.Properties.Item("AssemblyName").Value);
moduleInfo.ModuleType = GetModuleType(project, codeClass);
projectModules.Add(moduleInfo);
break;
if (IsIModule(codeClass.ImplementedInterfaces))
{
var moduleInfo = new ProjectModuleInfo();
moduleInfo.ModuleName = codeClass.Name;
moduleInfo.AssemblyFile = String.Format("{0}.dll", project.Properties.Item("AssemblyName").Value);
moduleInfo.ModuleType = GetModuleType(project, codeClass);
projectModules.Add(moduleInfo);
break;
}
}
}
}
}
}

_designer.ProjectModules = new System.Collections.ObjectModel.ObservableCollection<ProjectModuleInfo>(projectModules);
_designer.ProjectModules = new System.Collections.ObjectModel.ObservableCollection<ProjectModuleInfo>(projectModules);
}
catch(Exception ex)
{
string message = "The was a problem reading the projects in this solution. Build the solution and try again.";
string title = "Error Loading Projects";

// Show a message box to prove we were here
VsShellUtilities.ShowMessageBox(
this,
message,
title,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
}

CodeClass2 GetCodeClass(CodeElements codeElements)
Expand Down

0 comments on commit 80c9b8e

Please sign in to comment.