-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished hooking up the custom tool to call into the SpecFlow Generat…
…or. When a feature file is created or saved, it creates the feature code file. The MonoDevelop add-in is complete. The only difference between it and the Visual Studio one is VB support.
- Loading branch information
Showing
3 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
IdeIntegration/MonoDevelopIntegration/MonoDevelopProjectReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using MonoDevelop.Projects; | ||
|
||
using TechTalk.SpecFlow.Generator.Configuration; | ||
|
||
namespace MonoDevelop.TechTalk.SpecFlow | ||
{ | ||
internal static class MonoDevelopProjectReader | ||
{ | ||
public static SpecFlowProject CreateSpecFlowProjectFrom(Project project) | ||
{ | ||
var specFlowProject = new SpecFlowProject(); | ||
specFlowProject.ProjectFolder = project.BaseDirectory; | ||
specFlowProject.ProjectName = project.Name; | ||
|
||
string defaultNamespace = "Namespace"; | ||
if (project is DotNetProject) | ||
{ | ||
defaultNamespace = ((DotNetProject)project).GetDefaultNamespace(project.Name); | ||
} | ||
|
||
// No way to get AssemblyName right now, therefore we'll just use DefaultNamespace | ||
specFlowProject.AssemblyName = defaultNamespace; | ||
specFlowProject.DefaultNamespace = defaultNamespace; | ||
|
||
foreach (SolutionItemConfiguration configuration in project.Configurations) | ||
{ | ||
MonoDevelop.Core.LoggingService.LogInfo(configuration.Name); | ||
} | ||
|
||
// TODO: Find out if we really need to add all the feature files everytime we generate | ||
foreach (ProjectFile projectFile in project.Files.Where(IsFeatureOrAppConfigFile)) | ||
{ | ||
string extension = Path.GetExtension(projectFile.Name); | ||
|
||
if (extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
string fileName = projectFile.FilePath.ToRelative(project.BaseDirectory); | ||
var featureFile = new SpecFlowFeatureFile(fileName); | ||
var customToolNamespace = projectFile.CustomToolNamespace; | ||
|
||
if (!String.IsNullOrEmpty(customToolNamespace)) | ||
featureFile.CustomNamespace = customToolNamespace; | ||
|
||
specFlowProject.FeatureFiles.Add(featureFile); | ||
} | ||
|
||
if (extension.Equals(".config", StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
string configContent = File.ReadAllText(projectFile.FilePath); | ||
GeneratorConfigurationReader.UpdateConfigFromFileContent(specFlowProject.GeneratorConfiguration, configContent); | ||
} | ||
} | ||
|
||
return specFlowProject; | ||
} | ||
|
||
private static bool IsFeatureOrAppConfigFile(ProjectFile projectFile) | ||
{ | ||
string extension = Path.GetExtension(projectFile.Name); | ||
return extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase) | ||
|| projectFile.Name.Equals("app.config", StringComparison.InvariantCultureIgnoreCase); | ||
} | ||
} | ||
} |
72 changes: 68 additions & 4 deletions
72
IdeIntegration/MonoDevelopIntegration/SingleFeatureFileGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters