Summary
The DURABLE0010 analyzer (LoggerOrchestrationAnalyzer) flags an ILogger parameter on a private helper method invoked from an orchestrator's RunAsync, even when the logger originates from context.CreateReplaySafeLogger(...) — which is the recommended replay-safe pattern.
The diagnostic should only fire when a non-replay-safe ILogger is actually used inside orchestration code. A logger created via CreateReplaySafeLogger and passed through to a helper is safe and idiomatic, so this is a false positive.
introduced in #553
Repro
using Microsoft.DurableTask;
using Microsoft.Extensions.Logging;
public record DemoInput(string Value);
public record DemoResult(string Value);
public class DemoOrchestrator : TaskOrchestrator<DemoInput, DemoResult>
{
public override async Task<DemoResult> RunAsync(TaskOrchestrationContext context, DemoInput input)
{
var logger = context.CreateReplaySafeLogger(nameof(DemoOrchestrator));
LogData(logger);
return new DemoResult($"Processed: {input.Value}");
}
private static void LogData(ILogger logger)
{
logger.LogInformation("Logging some data for demonstration purposes.");
}
}
Expected
No DURABLE0010 diagnostic. The logger was obtained via CreateReplaySafeLogger and passed to a helper — this is the documented, replay-safe pattern.
Actual
DURABLE0010 is reported on the ILogger logger parameter of LogData, with a message indicating that a non-contextual ILogger is used in orchestration code reachable from DemoOrchestrator.
Analysis
LoggerOrchestrationAnalyzer.LoggerOrchestrationVisitor.VisitMethod (in src/Analyzers/Orchestration/LoggerOrchestrationAnalyzer.cs) walks every method reachable from an orchestrator (via MethodProbeOrchestrationVisitor) and reports on any ILogger parameter, field, or property reference it encounters. It has no notion of whether the ILogger value flowing into that parameter came from TaskOrchestrationContext.CreateReplaySafeLogger.
This means any helper method that accepts ILogger as a parameter — even when callers always pass a replay-safe logger — produces a false positive.
Suggested fix
The analyzer should track the source of the ILogger value, not just its type. Some options:
- Suppress the diagnostic on parameters/locals/fields whose value can be traced back to a
TaskOrchestrationContext.CreateReplaySafeLogger(...) invocation (data-flow / call-site analysis).
- At minimum, do not flag
ILogger parameters of helper methods; instead only flag direct usages (field/property/local references and direct injection into the orchestrator entry point) where the source is known to be unsafe.
- Provide an opt-out attribute (e.g.
[ReplaySafeLogger]) for helper-method parameters to silence the warning when the developer has verified the call sites.
Environment
- Package:
Microsoft.DurableTask.Analyzers
- Diagnostic:
DURABLE0010 — Non-contextual ILogger usage in orchestration
Summary
The
DURABLE0010analyzer (LoggerOrchestrationAnalyzer) flags anILoggerparameter on a private helper method invoked from an orchestrator'sRunAsync, even when the logger originates fromcontext.CreateReplaySafeLogger(...)— which is the recommended replay-safe pattern.The diagnostic should only fire when a non-replay-safe
ILoggeris actually used inside orchestration code. A logger created viaCreateReplaySafeLoggerand passed through to a helper is safe and idiomatic, so this is a false positive.introduced in #553
Repro
Expected
No
DURABLE0010diagnostic. The logger was obtained viaCreateReplaySafeLoggerand passed to a helper — this is the documented, replay-safe pattern.Actual
DURABLE0010is reported on theILogger loggerparameter ofLogData, with a message indicating that a non-contextualILoggeris used in orchestration code reachable fromDemoOrchestrator.Analysis
LoggerOrchestrationAnalyzer.LoggerOrchestrationVisitor.VisitMethod(insrc/Analyzers/Orchestration/LoggerOrchestrationAnalyzer.cs) walks every method reachable from an orchestrator (viaMethodProbeOrchestrationVisitor) and reports on anyILoggerparameter, field, or property reference it encounters. It has no notion of whether theILoggervalue flowing into that parameter came fromTaskOrchestrationContext.CreateReplaySafeLogger.This means any helper method that accepts
ILoggeras a parameter — even when callers always pass a replay-safe logger — produces a false positive.Suggested fix
The analyzer should track the source of the
ILoggervalue, not just its type. Some options:TaskOrchestrationContext.CreateReplaySafeLogger(...)invocation (data-flow / call-site analysis).ILoggerparameters of helper methods; instead only flag direct usages (field/property/local references and direct injection into the orchestrator entry point) where the source is known to be unsafe.[ReplaySafeLogger]) for helper-method parameters to silence the warning when the developer has verified the call sites.Environment
Microsoft.DurableTask.AnalyzersDURABLE0010— Non-contextual ILogger usage in orchestration