private void OnMessagesCollected(MessageCollection <GenerateFilesRequested, ModelVersionCreated> set)
        {
            set.MarkAsConsumed(set.Message1);
            List <Message> messages = new();
            List <string>  errors   = new();

            foreach (AgentModel agentModel in set.Message2.Model.Agents)
            {
                List <MessageModel> consuming = new();
                List <MessageModel> producing = new();
                FindMessageModels(agentModel.ConsumingMessages, agentModel, "consuming", consuming,
                                  set.Message2.Model.Messages, errors);
                FindMessageModels(agentModel.ProducedMessages, agentModel, "producing", producing,
                                  set.Message2.Model.Messages, errors);
                Message message = AgentModelSelectedForGeneration.Decorate(new ModelSelectedForGeneration(
                                                                               set.Message1.Path, set), agentModel,
                                                                           consuming.ToArray(), producing.ToArray());
                if (agentModel is InterceptorAgentModel interceptorAgent)
                {
                    List <MessageModel> intercepting = new();
                    FindMessageModels(interceptorAgent.InterceptingMessages, agentModel, "intercepting", intercepting,
                                      set.Message2.Model.Messages, errors);
                    message = InterceptorAgentModelSelectedForGeneration.Decorate((AgentModelSelectedForGeneration)message, intercepting.ToArray());
                }
                messages.Add(message);
            }

            foreach (MessageModel modelMessage in set.Message2.Model.Messages)
            {
                if (modelMessage.BuildIn || modelMessage.IsGenericInstance)
                {
                    continue;
                }

                Message message =
                    MessageModelSelectedForGeneration.Decorate(new ModelSelectedForGeneration(set.Message1.Path, set),
                                                               modelMessage);
                if (modelMessage is MessageDecoratorModel decoratorModel &&
                    decoratorModel.DecoratedMessage != default)
                {
                    MessageModel decoratedMessage = GetMessageModel(decoratorModel.DecoratedMessage,
                                                                    set.Message2.Model.Messages,
                                                                    () => errors.Add($"No message definition found for message decorator definition {modelMessage.FullName()} with " +
                                                                                     $"defined message decorator {decoratorModel.DecoratedMessage}"));
                    message = MessageDecoratorSelectedForGeneration.Decorate((MessageModelSelectedForGeneration)message, decoratedMessage);
                }
                messages.Add(message);
            }

            if (errors.Any())
            {
                OnMessage(new ModelInvalid(errors.ToArray(), set));
            }
            else
            {
                OnMessage(new GeneratorSettingsDefined(set.Message2.Model.GeneratorSettings ?? new GeneratorSettings(), set.Message1.Path, set));
                OnMessages(messages);
            }
        }
        protected override void ExecuteCore(Message messageData)
        {
            AgentModelSelectedForGeneration agentModel = messageData.Get <AgentModelSelectedForGeneration>();
            string           name                 = agentModel.Agent.Name;
            string           agentNamespace       = agentModel.Agent.FullNamespace();
            string           path                 = agentModel.Get <ModelSelectedForGeneration>().GenerationPath;
            List <string>    consumingMessages    = new();
            List <string>    producingMessages    = new();
            List <string>    interceptingMessages = new();
            HashSet <string> dependencies         = new();

            AddMessages(agentModel.ProducingMessages, producingMessages);
            AddMessages(agentModel.ConsumingMessages, consumingMessages);
            if (agentModel.TryGet(out InterceptorAgentModelSelectedForGeneration interceptorAgent))
            {
                AddMessages(interceptorAgent.InterceptingMessages, interceptingMessages);
            }

            Message message = GeneratingAgent.Decorate(new GeneratingFile(name, agentNamespace, path,
                                                                          agentModel),
                                                       consumingMessages.ToArray(),
                                                       producingMessages.ToArray(),
                                                       dependencies.ToArray());

            if (agentModel.Is <InterceptorAgentModelSelectedForGeneration>())
            {
                message = GeneratingInterceptorAgent.Decorate((GeneratingAgent)message, interceptingMessages.ToArray());
            }
            OnMessage(message);

            void AddMessages(IEnumerable <MessageModel> messageModels, List <string> messageNames)
            {
                foreach (MessageModel messageModel in messageModels)
                {
                    messageNames.Add(messageModel.Name);
                    string messageNamespace = messageModel.FullNamespace();
                    if (messageNamespace != agentNamespace && messageNamespace != "Agents.Net")
                    {
                        dependencies.Add(messageNamespace);
                    }
                }
            }
        }