Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize feature sample #6942

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/feature/Core_9/Sample/CustomLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public IDisposable StartTimer(string name)
public void WriteSaga(IContainSagaData sagaData)
{
var serialized = JsonSerializer.Serialize(sagaData, options);
log.Warn($"Saga State: \r\n{serialized}");
log.WarnFormat("Saga State: \n{0}", serialized);
}

class Log :
Expand All @@ -35,7 +35,7 @@ public Log(string name)

public void Dispose()
{
log.Warn($"{name} took {stopwatch.ElapsedMilliseconds}ms to process");
log.WarnFormat("{0} took {1}ms to process", name, stopwatch.ElapsedMilliseconds);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/feature/Core_9/Sample/Handler/Handler1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Handler1 :
public Task Handle(HandlerMessage message, IMessageHandlerContext context)
{
var milliseconds = random.Next(100, 1000);
log.Info($"HandlerMessage received going to Task.Delay({milliseconds}ms)");
log.InfoFormat("HandlerMessage received going to Task.Delay({0}ms)", milliseconds);
return Task.Delay(milliseconds, context.CancellationToken);
}
}
2 changes: 1 addition & 1 deletion samples/feature/Core_9/Sample/Handler/Handler2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Handler2 :
public Task Handle(HandlerMessage message, IMessageHandlerContext context)
{
var milliseconds = random.Next(100, 1000);
log.Info($"HandlerMessage received going to Task.Delay({milliseconds}ms)");
log.InfoFormat("HandlerMessage received going to Task.Delay({0}ms)", milliseconds);
return Task.Delay(milliseconds, context.CancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
using NServiceBus.Pipeline;

#region HandlerTimerBehavior
class HandlerTimerBehavior :
class HandlerTimerBehavior(CustomLogger logger) :
Behavior<IInvokeHandlerContext>
{
CustomLogger logger;

public HandlerTimerBehavior(CustomLogger logger)
{
this.logger = logger;
}

public override async Task Invoke(IInvokeHandlerContext context, Func<Task> next)
{
var handlerName = context.MessageHandler.Instance.GetType().Name;
Expand Down
9 changes: 1 addition & 8 deletions samples/feature/Core_9/Sample/Saga/SagaStateAuditBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@
using NServiceBus.Sagas;

#region SagaStateAuditBehavior
class SagaStateAuditBehavior :
class SagaStateAuditBehavior(CustomLogger logger) :
Behavior<IInvokeHandlerContext>
{
CustomLogger logger;

public SagaStateAuditBehavior(CustomLogger logger)
{
this.logger = logger;
}

public override async Task Invoke(IInvokeHandlerContext context, Func<Task> next)
{
await next();
Expand Down
2 changes: 1 addition & 1 deletion samples/feature/sample.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Building a custom feature
summary: How to build a custom feature in NServiceBus
reviewed: 2022-06-01
reviewed: 2024-12-19
component: Core
related:
- nservicebus/pipeline
Expand Down