Author: brett
Date: Mon Jan 2 04:39:34 2012
New Revision: 1226344
URL: http://svn.apache.org/viewvc?rev=1226344&view=rev
Log:
simplify code that checks if a project is valid
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/SlnParser/ProjectSolutionParser.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/VisualStudioProjectTypes/VisualStudioProjectType.cs
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/SlnParser/ProjectSolutionParser.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/SlnParser/ProjectSolutionParser.cs?rev=1226344&r1=1226343&r2=1226344&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/SlnParser/ProjectSolutionParser.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/SlnParser/ProjectSolutionParser.cs
Mon Jan 2 04:39:34 2012
@@ -72,26 +72,13 @@ namespace NPanday.ProjectImporter.Parser
string fullpath = Path.Combine(solutionFile.DirectoryName,
project.ProjectPath);
- bool isValidProject = true;
+ VisualStudioProjectTypeEnum type;
try
{
-
VisualStudioProjectType.GetVisualStudioProjectType(project.ProjectTypeGUID);
- if
(!VisualStudioProjectType.VisualStudioProjectSupported(project.ProjectTypeGUID))
- {
- isValidProject = false;
- if (UnsupportedProjectsMessage == string.Empty)
- {
- UnsupportedProjectsMessage += project.ProjectName;
- }
- else
- {
- UnsupportedProjectsMessage += ", " +
project.ProjectName;
- }
- }
+ type =
VisualStudioProjectType.GetVisualStudioProjectType(project.ProjectTypeGUID);
}
catch (Exception)
{
- isValidProject = false;
if (string.Empty.Equals(UnsupportedProjectsMessage))
{
UnsupportedProjectsMessage += project.ProjectName;
@@ -100,67 +87,58 @@ namespace NPanday.ProjectImporter.Parser
{
UnsupportedProjectsMessage += ", " +
project.ProjectName;
}
-
+ continue;
}
- if (isValidProject)
- {
- dictionary.Add("ProjectType",
VisualStudioProjectType.GetVisualStudioProjectType(project.ProjectTypeGUID));
- dictionary.Add("ProjectTypeGuid", project.ProjectTypeGUID);
- dictionary.Add("ProjectName", project.ProjectName);
- dictionary.Add("ProjectPath", project.ProjectPath);
- dictionary.Add("ProjectGUID", project.ProjectGUID);
- dictionary.Add("ProjectFullPath", fullpath);
+ dictionary.Add("ProjectType", type);
+ dictionary.Add("ProjectTypeGuid", project.ProjectTypeGUID);
+ dictionary.Add("ProjectName", project.ProjectName);
+ dictionary.Add("ProjectPath", project.ProjectPath);
+ dictionary.Add("ProjectGUID", project.ProjectGUID);
+ dictionary.Add("ProjectFullPath", fullpath);
- // this is for web projects
- if ((VisualStudioProjectTypeEnum)dictionary["ProjectType"]
== VisualStudioProjectTypeEnum.Web_Site)
- {
+ // this is for web projects
+ if ((VisualStudioProjectTypeEnum)dictionary["ProjectType"] ==
VisualStudioProjectTypeEnum.Web_Site)
+ {
- string[] assemblies =
GetWebConfigAssemblies(Path.Combine(fullpath, "web.config"));
- dictionary.Add("WebConfigAssemblies", assemblies);
+ string[] assemblies =
GetWebConfigAssemblies(Path.Combine(fullpath, "web.config"));
+ dictionary.Add("WebConfigAssemblies", assemblies);
- //get project target framework if available
- if (project.ProjectSections.Count > 0)
+ //get project target framework if available
+ if (project.ProjectSections.Count > 0)
+ {
+ if
(project.ProjectSections[0].Map.ContainsKey("TargetFramework"))
{
- if
(project.ProjectSections[0].Map.ContainsKey("TargetFramework"))
- {
- dictionary.Add("TargetFramework",
project.ProjectSections[0].Map["TargetFramework"]);
- }
+ dictionary.Add("TargetFramework",
project.ProjectSections[0].Map["TargetFramework"]);
}
-
- //@001 SERNACIO START retrieving webreference
- Digest.Model.WebReferenceUrl[] webReferences =
getWebReferenceUrls(fullpath);
- dictionary.Add("WebReferencesUrl", webReferences);
- //@001 SERNACIO END retrieving webreference
-
- string[] binAssemblies =
GetBinAssemblies(Path.Combine(fullpath, @"bin"));
- dictionary.Add("BinAssemblies", binAssemblies);
- //ParseInnerData(dictionary,
match.Groups["projectInnerData"].ToString());
- ParseProjectReferences(dictionary, project, solution);
}
- // this is for normal projects
- else if (
- (VisualStudioProjectTypeEnum)dictionary["ProjectType"]
== VisualStudioProjectTypeEnum.Windows__CSharp
- ||
(VisualStudioProjectTypeEnum)dictionary["ProjectType"] ==
VisualStudioProjectTypeEnum.Windows__VbDotNet
- )
- {
- Microsoft.Build.BuildEngine.Project prj = new
Microsoft.Build.BuildEngine.Project(BUILD_ENGINE);
- prj.Load(fullpath);
+ //@001 SERNACIO START retrieving webreference
+ Digest.Model.WebReferenceUrl[] webReferences =
getWebReferenceUrls(fullpath);
+ dictionary.Add("WebReferencesUrl", webReferences);
+ //@001 SERNACIO END retrieving webreference
+
+ string[] binAssemblies =
GetBinAssemblies(Path.Combine(fullpath, @"bin"));
+ dictionary.Add("BinAssemblies", binAssemblies);
+ //ParseInnerData(dictionary,
match.Groups["projectInnerData"].ToString());
+ ParseProjectReferences(dictionary, project, solution);
+ }
+ // this is for normal projects
+ else if (
+ (VisualStudioProjectTypeEnum)dictionary["ProjectType"] ==
VisualStudioProjectTypeEnum.Windows__CSharp
+ || (VisualStudioProjectTypeEnum)dictionary["ProjectType"]
== VisualStudioProjectTypeEnum.Windows__VbDotNet
+ )
+ {
+ Microsoft.Build.BuildEngine.Project prj = new
Microsoft.Build.BuildEngine.Project(BUILD_ENGINE);
- //ParseInnerData(dictionary,
match.Groups["projectInnerData"].ToString());
- ParseProjectReferences(dictionary, project, solution);
- dictionary.Add("Project", prj);
- }
+ prj.Load(fullpath);
+ //ParseInnerData(dictionary,
match.Groups["projectInnerData"].ToString());
+ ParseProjectReferences(dictionary, project, solution);
+ dictionary.Add("Project", prj);
}
- // Skip projects that are not supported
- if (dictionary.Count > 0)
- {
- list.Add(dictionary);
- }
-
+ list.Add(dictionary);
}
if (!string.Empty.Equals(UnsupportedProjectsMessage))
{
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/VisualStudioProjectTypes/VisualStudioProjectType.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/VisualStudioProjectTypes/VisualStudioProjectType.cs?rev=1226344&r1=1226343&r2=1226344&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/VisualStudioProjectTypes/VisualStudioProjectType.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Parser/VisualStudioProjectTypes/VisualStudioProjectType.cs
Mon Jan 2 04:39:34 2012
@@ -225,11 +225,16 @@ namespace NPanday.ProjectImporter.Parser
{
try
{
- projectType |=
__visualStudioProjectTypes[guidItem.ToUpper()];
+ string upperGuid = guidItem.ToUpper();
+ projectType |= __visualStudioProjectTypes[upperGuid];
+ if (!__visualStudioProjectTypeSupported[upperGuid])
+ {
+ throw new NotSupportedException("NPanday does not
support projects with type GUID: " + guidItem);
+ }
}
catch
{
- throw new NotSupportedException("Unknown Project Type
GUID: " + guidItem);
+ throw new NotSupportedException("Unknown project type
GUID: " + guidItem);
}
}
@@ -249,37 +254,5 @@ namespace NPanday.ProjectImporter.Parser
return string.Join(";", list.ToArray());
}
-
- public static bool VisualStudioProjectSupported(string guid)
- {
- guid = guid.Replace("{", "");
- guid = guid.Replace("}", "");
-
- try
- {
- return __visualStudioProjectTypeSupported[guid.ToUpper()];
- }
- catch
- {
- MessageBox.Show("Unknown Project Type GUID: " +
guid.ToUpper(), "Project Import Warning", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
- return false;
- }
- }
-
- public static bool VisualStudioProjectSupportedGUID(string guid)
- {
- guid = guid.Replace("{", "");
- guid = guid.Replace("}", "");
-
- try
- {
- return __visualStudioProjectTypeSupported[guid.ToUpper()];
- }
- catch
- {
- //returns true since not all supported c# and vb project GUID
are listed
- return true;
- }
- }
}
}