Browse Source

Fix null ref when building a solution containing non-MSBuild project.

The TypeScript addin did not handle building when one of the projects
was not an MSBuild project.

Fixes #740
pull/729/merge
devgopher 10 years ago committed by Matt Ward
parent
commit
9c3fd24cb1
  1. 8
      src/AddIns/BackendBindings/TypeScript/Project/Src/CompileTypeScriptFilesOnBuildAction.cs
  2. 19
      src/AddIns/BackendBindings/TypeScript/Project/Src/TypeScriptProject.cs

8
src/AddIns/BackendBindings/TypeScript/Project/Src/CompileTypeScriptFilesOnBuildAction.cs

@ -41,13 +41,19 @@ namespace ICSharpCode.TypeScriptBinding
public void CompileFiles(IEnumerable<IProject> projects) public void CompileFiles(IEnumerable<IProject> projects)
{ {
ClearOutputWindow(); ClearOutputWindow();
foreach (TypeScriptProject project in projects.Select(project => new TypeScriptProject(project))) { foreach (TypeScriptProject project in GetTypeScriptProjects(projects)) {
if (project.CompileOnBuild) { if (project.CompileOnBuild) {
CompileFiles(project); CompileFiles(project);
} }
} }
} }
static IEnumerable<TypeScriptProject> GetTypeScriptProjects(IEnumerable<IProject> projects)
{
return projects.OfType<MSBuildBasedProject>()
.Select(project => new TypeScriptProject(project));
}
void CompileFiles(TypeScriptProject project) void CompileFiles(TypeScriptProject project)
{ {
FileName[] fileNames = project.GetTypeScriptFileNames().ToArray(); FileName[] fileNames = project.GetTypeScriptFileNames().ToArray();

19
src/AddIns/BackendBindings/TypeScript/Project/Src/TypeScriptProject.cs

@ -88,8 +88,15 @@ namespace ICSharpCode.TypeScriptBinding
.Select(item => item.FileName); .Select(item => item.FileName);
} }
bool HasMSBuildProject {
get { return msbuildProject != null; }
}
string GetStringProperty(BuildConfiguration buildConfig, string name, string defaultValue) string GetStringProperty(BuildConfiguration buildConfig, string name, string defaultValue)
{ {
if (!HasMSBuildProject)
return defaultValue;
string propertyValue = msbuildProject.GetProperty(buildConfig.Configuration, buildConfig.Platform, name); string propertyValue = msbuildProject.GetProperty(buildConfig.Configuration, buildConfig.Platform, name);
if (!String.IsNullOrEmpty(propertyValue)) { if (!String.IsNullOrEmpty(propertyValue)) {
return propertyValue; return propertyValue;
@ -99,6 +106,9 @@ namespace ICSharpCode.TypeScriptBinding
bool GetBooleanProperty(BuildConfiguration buildConfig, string name, bool defaultValue) bool GetBooleanProperty(BuildConfiguration buildConfig, string name, bool defaultValue)
{ {
if (!HasMSBuildProject)
return defaultValue;
string propertyValue = msbuildProject.GetProperty(buildConfig.Configuration, buildConfig.Platform, name); string propertyValue = msbuildProject.GetProperty(buildConfig.Configuration, buildConfig.Platform, name);
return ConvertBooleanValue(propertyValue, defaultValue); return ConvertBooleanValue(propertyValue, defaultValue);
} }
@ -119,6 +129,9 @@ namespace ICSharpCode.TypeScriptBinding
void SetStringProperty(BuildConfiguration buildConfig, string name, string value) void SetStringProperty(BuildConfiguration buildConfig, string name, string value)
{ {
if (!HasMSBuildProject)
return;
msbuildProject.SetProperty( msbuildProject.SetProperty(
buildConfig.Configuration, buildConfig.Configuration,
buildConfig.Platform, buildConfig.Platform,
@ -130,12 +143,18 @@ namespace ICSharpCode.TypeScriptBinding
bool GetBooleanProperty(string name, bool defaultValue) bool GetBooleanProperty(string name, bool defaultValue)
{ {
if (!HasMSBuildProject)
return defaultValue;
string propertyValue = msbuildProject.GetEvaluatedProperty(name); string propertyValue = msbuildProject.GetEvaluatedProperty(name);
return ConvertBooleanValue(propertyValue, defaultValue); return ConvertBooleanValue(propertyValue, defaultValue);
} }
string GetStringProperty(string name, string defaultValue) string GetStringProperty(string name, string defaultValue)
{ {
if (!HasMSBuildProject)
return defaultValue;
string propertyValue = msbuildProject.GetEvaluatedProperty(name); string propertyValue = msbuildProject.GetEvaluatedProperty(name);
if (!String.IsNullOrEmpty(propertyValue)) { if (!String.IsNullOrEmpty(propertyValue)) {
return propertyValue; return propertyValue;

Loading…
Cancel
Save