public void GenerateCode(FileProjectItem item, CustomToolContext context) { context.RunAsync( () => { string fileName = item.FileName; var projectNode = item.Project; SpecFlowProject specFlowProject = CreateSpecFlowProjectFrom(projectNode); var specFlowGenerator = new SpecFlowGenerator(specFlowProject); string outputFile = context.GetOutputFileName(item, ".feature"); var specFlowFeatureFile = specFlowProject.GetOrCreateFeatureFile(fileName); var fileContents = File.ReadAllText(fileName); string outputFileContents; using (var reader = new StringReader(fileContents)) { using (var writer = new StringWriter(new StringBuilder())) { specFlowGenerator.GenerateTestFile(specFlowFeatureFile, projectNode.LanguageProperties.CodeDomProvider, reader, writer); outputFileContents = writer.ToString(); } } File.WriteAllText(outputFile, outputFileContents); WorkbenchSingleton.SafeThreadCall( () => context.EnsureOutputFileIsInProject(item, outputFile)); }); }
public void GenerateCode(FileProjectItem item, CustomToolContext context) { LanguageOption languageToGenerateCode = LanguageOption.GenerateCSharpCode; if (item.Project.Language != "C#") { languageToGenerateCode = LanguageOption.GenerateVBCode; } XDocument edmxDocument = XDocument.Load(item.FileName); XElement conceptualModelsElement = EDMXIO.ReadSection(edmxDocument, EDMXIO.EDMXSection.CSDL); if (conceptualModelsElement == null) { throw new ArgumentException("Input file is not a valid EDMX file."); } XDocument csdlDocument = new XDocument(new XDeclaration("1.0", "utf-8", null), conceptualModelsElement.Element(XName.Get("Schema", csdlNamespace.NamespaceName))); string tempFileName = IO.GetTempFilenameWithExtension("csdl"); csdlDocument.Save(tempFileName); string outputFileName = context.GetOutputFileName(item, "Designer"); EntityCodeGenerator entityCodeGenerator = new EntityCodeGenerator(languageToGenerateCode); IList <EdmSchemaError> edmSchemaErrors = entityCodeGenerator.GenerateCode(tempFileName, outputFileName); File.Delete(tempFileName); context.EnsureOutputFileIsInProject(item, outputFileName); }
public void GenerateCode(FileProjectItem item, CustomToolContext context) { context.RunAsync(() => { var ideSingleFileGenerator = new IdeSingleFileGenerator(); string outputFilePath = context.GetOutputFileName(item, ".feature"); ideSingleFileGenerator.GenerateFile(item.FileName, outputFilePath, () => new SharpDevelop4GeneratorServices(item.Project)); WorkbenchSingleton.SafeThreadCall( () => context.EnsureOutputFileIsInProject(item, outputFilePath)); }); }
public void GenerateCode(FileProjectItem item, CustomToolContext context) { XElement schema = GetModelSchema(item); XDocument csdlDocument = CreateCsdlDocument(schema); string tempFileName = IO.GetTempFilenameWithExtension("csdl"); csdlDocument.Save(tempFileName); LanguageOption languageToGenerateCode = GetLanguageOption(item); string outputFileName = context.GetOutputFileName(item, "Designer"); EntityCodeGenerator entityCodeGenerator = new EntityCodeGenerator(languageToGenerateCode); AddNamespaceMapping(entityCodeGenerator, schema, context.OutputNamespace); IList <EdmSchemaError> edmSchemaErrors = entityCodeGenerator.GenerateCode(tempFileName, outputFileName); File.Delete(tempFileName); context.EnsureOutputFileIsInProject(item, outputFileName); }
public FileProjectItem EnsureOutputFileIsInProject(FileProjectItem baseItem, string outputFileName) { return(context.EnsureOutputFileIsInProject(baseItem, outputFileName)); }