protected override void RunImpl() { var typeGenerator = new UnityTypeGenerator(); var enumGenerator = new UnityEnumGenerator(); var eventGenerator = new UnityEventGenerator(); var commandPayloadGenerator = new UnityCommandPayloadGenerator(); var blittableComponentGenerator = new UnityComponentDataGenerator(); var componentSenderGenerator = new UnityComponentSenderGenerator(); var ecsViewManagerGenerator = new UnityEcsViewManagerGenerator(); var referenceTypeProviderGenerator = new UnityReferenceTypeProviderGenerator(); var componentDiffStorageGenerator = new ComponentDiffStorageGenerator(); var componentDiffDeserializerGenerator = new ComponentDiffDeserializerGenerator(); var commandDiffDeserializerGenerator = new CommandDiffDeserializerGenerator(); var commandDiffStorageGenerator = new CommandDiffStorageGenerator(); var viewStorageGenerator = new ViewStorageGenerator(); var commandMetaDataStorageGenerator = new CommandMetaDataStorageGenerator(); var metaclassGenerator = new MetaclassGenerator(); foreach (var enumTarget in enumsToGenerate) { var fileName = Path.ChangeExtension(enumTarget.Content.TypeName, FileExtension); var enumCode = enumGenerator.Generate(enumTarget.Content, enumTarget.Package); Content.Add(Path.Combine(enumTarget.OutputPath, fileName), enumCode); } foreach (var typeTarget in typesToGenerate) { var fileName = Path.ChangeExtension(typeTarget.Content.CapitalisedName, FileExtension); var typeCode = typeGenerator.Generate(typeTarget.Content, typeTarget.Package); Content.Add(Path.Combine(typeTarget.OutputPath, fileName), typeCode); } foreach (var componentTarget in componentsToGenerate) { var relativeOutputPath = componentTarget.OutputPath; var componentName = componentTarget.Content.ComponentName; var package = componentTarget.Package; var componentFileName = Path.ChangeExtension(componentName, FileExtension); var componentCode = blittableComponentGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, componentFileName), componentCode); if (componentTarget.Content.CommandDetails.Count > 0) { var commandPayloadsFileName = Path.ChangeExtension($"{componentName}CommandPayloads", FileExtension); var commandPayloadCode = commandPayloadGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, commandPayloadsFileName), commandPayloadCode); var commandDiffDeserializerFileName = Path.ChangeExtension($"{componentName}CommandDiffDeserializer", FileExtension); var commandDiffDeserializerCode = commandDiffDeserializerGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, commandDiffDeserializerFileName), commandDiffDeserializerCode); var commandDiffStorageFileName = Path.ChangeExtension($"{componentName}CommandDiffStorage", FileExtension); var commandDiffStorageCode = commandDiffStorageGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, commandDiffStorageFileName), commandDiffStorageCode); var commandMetaDataStorageFileName = Path.ChangeExtension($"{componentName}CommandMetaDataStorage", FileExtension); var commandMetaDataStorageCode = commandMetaDataStorageGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, commandMetaDataStorageFileName), commandMetaDataStorageCode); } if (componentTarget.Content.EventDetails.Count > 0) { var eventsFileName = Path.ChangeExtension($"{componentName}Events", FileExtension); var eventsCode = eventGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, eventsFileName), eventsCode); } var updateSenderFileName = Path.ChangeExtension($"{componentName}UpdateSender", FileExtension); var updateSenderCode = componentSenderGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, updateSenderFileName), updateSenderCode); var ecsViewManagerFileName = Path.ChangeExtension($"{componentName}EcsViewManager", FileExtension); var ecsViewManagerCode = ecsViewManagerGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, ecsViewManagerFileName), ecsViewManagerCode); var componentDiffStorageFileName = Path.ChangeExtension($"{componentName}ComponentDiffStorage", FileExtension); var componentDiffStorageCode = componentDiffStorageGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, componentDiffStorageFileName), componentDiffStorageCode); var componentDiffDeserializerFileName = Path.ChangeExtension($"{componentName}ComponentDiffDeserializer", FileExtension); var componentDiffDeserializerCode = componentDiffDeserializerGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, componentDiffDeserializerFileName), componentDiffDeserializerCode); if (componentTarget.Content.FieldDetails.Any(field => !field.IsBlittable)) { var referenceProviderFileName = Path.ChangeExtension($"{componentName}Providers", FileExtension); var referenceProviderTranslationCode = referenceTypeProviderGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, referenceProviderFileName), referenceProviderTranslationCode); } var viewStorageFileName = Path.ChangeExtension($"{componentName}ViewStorage", FileExtension); var viewStorageCode = viewStorageGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, viewStorageFileName), viewStorageCode); var metaclassFileName = Path.ChangeExtension($"{componentName}Metaclass", FileExtension); var metaclassCode = metaclassGenerator.Generate(componentTarget.Content, package); Content.Add(Path.Combine(relativeOutputPath, metaclassFileName), metaclassCode); } }
protected override void RunImpl() { logger.Trace("Starting code generation for enums."); foreach (var enumTarget in enumsToGenerate) { logger.Trace($"Generating code for {enumTarget.Content.QualifiedName}."); var fileName = Path.ChangeExtension(enumTarget.Content.TypeName, FileExtension); var enumCode = UnityEnumGenerator.Generate(enumTarget.Content, enumTarget.Package); AddContent(Path.Combine(enumTarget.OutputPath, fileName), enumCode); } logger.Info($"Finished code generation for {enumsToGenerate.Count} enums."); logger.Trace("Starting code generation for types."); foreach (var typeTarget in typesToGenerate) { logger.Trace($"Generating code for {typeTarget.Content.QualifiedName}."); var fileName = Path.ChangeExtension(typeTarget.Content.CapitalisedName, FileExtension); var typeCode = UnityTypeGenerator.Generate(typeTarget.Content, typeTarget.Package); AddContent(Path.Combine(typeTarget.OutputPath, fileName), typeCode); } logger.Info($"Finished code generation for {typesToGenerate.Count} types."); logger.Trace("Starting code generation for components."); foreach (var componentTarget in componentsToGenerate) { logger.Trace($"Generating code for {componentTarget.Content.QualifiedName}."); var relativeOutputPath = componentTarget.OutputPath; var componentName = componentTarget.Content.ComponentName; var package = componentTarget.Package; var componentFileName = Path.ChangeExtension(componentName, FileExtension); var componentCode = UnityComponentDataGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, componentFileName), componentCode); if (componentTarget.Content.CommandDetails.Count > 0) { logger.Trace("Generating code for commands."); var commandPayloadsFileName = Path.ChangeExtension($"{componentName}CommandPayloads", FileExtension); var commandPayloadCode = UnityCommandPayloadGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, commandPayloadsFileName), commandPayloadCode); var commandDiffDeserializerFileName = Path.ChangeExtension($"{componentName}CommandDiffDeserializer", FileExtension); var commandDiffDeserializerCode = CommandDiffDeserializerGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, commandDiffDeserializerFileName), commandDiffDeserializerCode); var commandDiffStorageFileName = Path.ChangeExtension($"{componentName}CommandDiffStorage", FileExtension); var commandDiffStorageCode = CommandDiffStorageGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, commandDiffStorageFileName), commandDiffStorageCode); var commandMetaDataStorageFileName = Path.ChangeExtension($"{componentName}CommandMetaDataStorage", FileExtension); var commandMetaDataStorageCode = CommandMetaDataStorageGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, commandMetaDataStorageFileName), commandMetaDataStorageCode); } if (componentTarget.Content.EventDetails.Count > 0) { logger.Trace("Generating code for events."); var eventsFileName = Path.ChangeExtension($"{componentName}Events", FileExtension); var eventsCode = UnityEventGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, eventsFileName), eventsCode); } var updateSenderFileName = Path.ChangeExtension($"{componentName}UpdateSender", FileExtension); var updateSenderCode = UnityComponentSenderGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, updateSenderFileName), updateSenderCode); var ecsViewManagerFileName = Path.ChangeExtension($"{componentName}EcsViewManager", FileExtension); var ecsViewManagerCode = UnityEcsViewManagerGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, ecsViewManagerFileName), ecsViewManagerCode); var componentDiffStorageFileName = Path.ChangeExtension($"{componentName}ComponentDiffStorage", FileExtension); var componentDiffStorageCode = ComponentDiffStorageGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, componentDiffStorageFileName), componentDiffStorageCode); var componentDiffDeserializerFileName = Path.ChangeExtension($"{componentName}ComponentDiffDeserializer", FileExtension); var componentDiffDeserializerCode = ComponentDiffDeserializerGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, componentDiffDeserializerFileName), componentDiffDeserializerCode); if (componentTarget.Content.FieldDetails.Any(field => !field.IsBlittable)) { logger.Trace("Generating code for non-blittable fields."); var referenceProviderFileName = Path.ChangeExtension($"{componentName}Providers", FileExtension); var referenceProviderTranslationCode = UnityReferenceTypeProviderGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, referenceProviderFileName), referenceProviderTranslationCode); } var viewStorageFileName = Path.ChangeExtension($"{componentName}ViewStorage", FileExtension); var viewStorageCode = ViewStorageGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, viewStorageFileName), viewStorageCode); var metaclassFileName = Path.ChangeExtension($"{componentName}Metaclass", FileExtension); var metaclassCode = MetaclassGenerator.Generate(componentTarget.Content, package); AddContent(Path.Combine(relativeOutputPath, metaclassFileName), metaclassCode); } logger.Info($"Finished code generation for {componentsToGenerate.Count} components."); }