public static async Task GenerateCodeAsync(IReadOnlyCollection <GenerationItem> generationItems, bool withRegeneration, IUnitTestGeneratorPackage package, Dictionary <Project, Tuple <HashSet <TargetAsset>, HashSet <IReferencedAssembly> > > requiredAssetsByProject, IMessageLogger messageLogger) { var solution = package.Workspace.CurrentSolution; var options = package.Options; foreach (var generationItem in generationItems) { await GenerateItemAsync(withRegeneration, options, solution, generationItem).ConfigureAwait(true); } await package.JoinableTaskFactory.SwitchToMainThreadAsync(); Attempt.Action( () => { ThreadHelper.ThrowIfNotOnUIThread(); messageLogger.LogMessage("Adding required assets to target project..."); foreach (var pair in requiredAssetsByProject) { AddTargetAssets(options, pair); if (options.GenerationOptions.AddReferencesAutomatically) { ReferencesHelper.AddReferencesToProject(pair.Key, pair.Value.Item2.ToList(), messageLogger.LogMessage); } } if (generationItems.All(x => string.IsNullOrWhiteSpace(x.TargetContent))) { throw new InvalidOperationException("None of the selected targets contained a testable type. Tests can only be generated for classes and structs"); } messageLogger.LogMessage("Adding generated items to target project..."); foreach (var generationItem in generationItems.Where(x => !string.IsNullOrWhiteSpace(x.TargetContent))) { if (generationItem.TargetProjectItems != null) { AddTargetItem(generationItems, options, generationItem); } else { CreateUnsavedFile(package, generationItem); } } messageLogger.LogMessage("Generation complete."); }, package); }
public bool Announce(IMessage message, IMessageSettingsOut messageSettings) { _processor.Type = messageSettings.MessageSettings["produce.ontopic"]; var valueToSend = JsonHelperSerialiser.ToJson(message, JsonHelperSerialiserSettings.CamelCaseSerialiseSettings); var deliveryReport = producer.ProduceAsync(messageSettings.MessageSettings["produce.ontopic"], null, valueToSend); var result = deliveryReport.ConfigureAwait(false).GetAwaiter().GetResult(); // synchronously waits for message to be produced. if (result.IsSuccess()) { producer.Flush(TimeSpan.FromSeconds(10)); var messageToLog = new AllsaintsMessageLogger.LogMessage() { Id = message.Id, DateStampUtc = message.DateStampUtc, IsTest = message.IsTest, Message = message, }; _messageLogger.LogMessage(EventTypes.Sent, _processor, messageToLog); return(true); } else { OnError(result.Error.ToString()); return(false); } }
public static LogMessageRecord LogMessage(this IMessageLogger logger, LogLevel level, string message) { LogMessageRecord rec = new LogMessageRecord(level, message); logger?.LogMessage(rec); return(rec);; }
public static LogMessageRecord LogMessageDetail(this IMessageLogger logger, string category, LogLevel level, string message, string detail) { var rec = new LogMessageRecord { Category = category, Message = message, Detail = detail, Level = level }; logger?.LogMessage(rec); return(rec); }
public IConsumerResponse LogMessage(IConsumerRequest request, IConsumerResponse response) { if (MessageLogger != null) { MessageLogger.LogMessage(request, response); } return(response); }
public static LogMessageRecord LogMessage(this IMessageLogger logger, string category, LogLevel level, string format, params object[] args) { string msg = format; if (args.Length > 0) { msg = String.Format(format, args); } var rec = new LogMessageRecord { Category = category, Message = msg, Level = level }; logger?.LogMessage(rec); return(rec); }
private void Consumer_OnMessage(object sender, Message <string, string> msg) { var messageObject = JsonHelperSerialiser.FromJson <T>(msg.Value, JsonHelperSerialiserSettings.CamelCaseSerialiseSettings); OnMessage(messageObject); var committedOffsets = consumer.CommitAsync(msg).ConfigureAwait(false).GetAwaiter().GetResult(); // synchronously waits for message to be produced. var messageToLog = new AllsaintsMessageLogger.LogMessage() { Id = messageObject.Id, DateStampUtc = messageObject.DateStampUtc, IsTest = messageObject.IsTest, Message = messageObject, }; _messageLogger.LogMessage(EventTypes.Reveived, _processor, messageToLog); }
public static LogMessageRecord Error(this IMessageLogger logger, string message, params object[] args) { return(logger.LogMessage(LogLevel.Error, String.Format(message, args))); }
public static LogMessageRecord Error(this IMessageLogger logger, string message) { return(logger.LogMessage(LogLevel.Error, message)); }
public static LogMessageRecord Warning(this IMessageLogger logger, string message) { return(logger.LogMessage(LogLevel.Warning, message)); }
public static LogMessageRecord Info(this IMessageLogger logger, string message) { return(logger.LogMessage(LogLevel.Information, message)); }
public static LogMessageRecord Trace(this IMessageLogger logger, string message) { return(logger.LogMessage(LogLevel.Trace, message)); }
public static LogMessageRecord LogMessageEx(this IMessageLogger logger, LogMessageRecord rec) { logger.LogMessage(rec); return(rec); }