public void GeneratedProjectBuildsSuccessfully(CodeGenLanguage codeGenLanguage) { var context = new ProjectTestContext(GetType().Name, $"{MethodBase.GetCurrentMethod().Name}{codeGenLanguage}"); try { //given context.TargetFramework = "netstandard2.0"; context.CreateEmptyProject(); var fullProjectFilePath = Path.Combine(context.TargetProjectFolder, context.ProjectName + CodeGenLanguageExt.ProjectFileExtensions[codeGenLanguage]); var generator = new NetStandardLibraryGenerator(fullProjectFilePath, codeGenLanguage) { NethereumWeb3Version = Constants.NethereumWeb3Version }; //when //code gen proj file var projectFile = generator.GenerateFileContent(context.TargetProjectFolder); GeneratedFileWriter.WriteFileToDisk(projectFile); //add in some code gen class files var contractMetaData = TestContracts.StandardContract; var contractABI = new GeneratorModelABIDeserialiser().DeserialiseABI(contractMetaData.ABI); var contractProjectGenerator = new ContractProjectGenerator( contractABI, "StandardContract", contractMetaData.ByteCode, context.ProjectName, "StandardContract.Service", "StandardContract.CQS", "StandardContract.DTO", context.TargetProjectFolder, Path.DirectorySeparatorChar.ToString(), codeGenLanguage) { AddRootNamespaceOnVbProjectsToImportStatements = false }; var generatedFiles = contractProjectGenerator.GenerateAll(); GeneratedFileWriter.WriteFilesToDisk(generatedFiles); context.BuildProject(); //then Assert.True(context.BuildHasSucceeded()); } finally { context.CleanUp(); } }
public void WriteClasses(GenerateClassesCommand command) { var contractAbi = new GeneratorModelABIDeserialiser().DeserialiseABI(command.Abi); var generator = new ContractProjectGenerator( contractAbi, command.ContractName, command.ContractByteCode, command.BaseNamespace, command.ServiceNamespace, command.CqsNamespace, command.DtoNamesapce, command.BasePath, command.PathDelimiter, command.CodeGenLanguage); var generatedClasses = generator.GenerateAll(); GeneratedFileWriter.WriteFilesToDisk(generatedClasses); }
public void With_Single_Messages_File_Generated_Code_Builds(CodeGenLanguage codeGenLanguage) { //given var context = new ProjectTestContext(BaseName, $"{MethodBase.GetCurrentMethod().Name}{codeGenLanguage}"); try { context.CreateProject(codeGenLanguage, new[] { new Tuple <string, string>("Nethereum.Web3", Constants.NethereumWeb3Version) }); var contractMetaData = TestContracts.StandardContract; var contractABI = new GeneratorModelABIDeserialiser().DeserialiseABI(contractMetaData.ABI); //when var contractProjectGenerator = new ContractProjectGenerator( contractABI, "StandardContract", contractMetaData.ByteCode, context.ProjectName, "StandardContract.Service", "StandardContract.CQS", "StandardContract.DTO", context.TargetProjectFolder, Path.DirectorySeparatorChar.ToString(), codeGenLanguage) { AddRootNamespaceOnVbProjectsToImportStatements = true, }; var generatedFiles = contractProjectGenerator.GenerateAllMessagesFileAndService(); GeneratedFileWriter.WriteFilesToDisk(generatedFiles); context.BuildProject(); //then Assert.True(context.BuildHasSucceeded()); } finally { context.CleanUp(); } }
private static void GenerateFilesForItem(ABIConfiguration item) { var generator = new ContractProjectGenerator( item.CreateContractABI(), item.ContractName, item.ByteCode, item.BaseNamespace, item.ServiceNamespace, item.CQSNamespace, item.DTONamespace, item.BaseOutputPath, Path.DirectorySeparatorChar.ToString(), item.CodeGenLanguage ); var generatedFiles = generator.GenerateAll(); GeneratedFileWriter.WriteFilesToDisk(generatedFiles); }