public System.Diagnostics.ActivityTraceFlags TraceFlags { get { throw null; } }
public string? TraceState { get { throw null; } }
public bool IsRemote { get { throw null; } }
- public static bool TryParse(string traceParent, string? traceState, out System.Diagnostics.ActivityContext context) { throw null; }
+ public static bool TryParse(string? traceParent, string? traceState, out System.Diagnostics.ActivityContext context) { throw null; }
public static System.Diagnostics.ActivityContext Parse(string traceParent, string? traceState) { throw null; }
public static bool operator ==(System.Diagnostics.ActivityContext left, System.Diagnostics.ActivityContext right) { throw null; }
public static bool operator !=(System.Diagnostics.ActivityContext left, System.Diagnostics.ActivityContext right) { throw null; }
/// <param name="traceParent">W3C trace parent header.</param>
/// <param name="traceState">W3C trace state.</param>
/// <param name="context">The ActivityContext object created from the parsing operation.</param>
- public static bool TryParse(string traceParent, string? traceState, out ActivityContext context)
+ public static bool TryParse(string? traceParent, string? traceState, out ActivityContext context)
{
- if (traceParent == null)
+ if (traceParent is null)
{
- throw new ArgumentNullException(nameof(traceParent));
+ context = default;
+ return false;
}
return Activity.TryConvertIdToContext(traceParent, traceState, out context);
/// </returns>
public static ActivityContext Parse(string traceParent, string? traceState)
{
- if (!TryParse(traceParent, traceState, out ActivityContext context))
+ if (traceParent is null)
+ {
+ throw new ArgumentNullException(nameof(traceParent));
+ }
+
+ if (!Activity.TryConvertIdToContext(traceParent, traceState, out ActivityContext context))
{
throw new ArgumentException(SR.InvalidTraceParent);
}
context = ActivityContext.Parse(w3cId, null);
Assert.Null(context.TraceState);
- Assert.Throws<ArgumentNullException>(() => ActivityContext.TryParse(null, "k=v", out context));
+ Assert.False(ActivityContext.TryParse(null, "k=v", out context));
Assert.Throws<ArgumentNullException>(() => ActivityContext.Parse(null, null));
Assert.Throws<ArgumentException>(() => ActivityContext.Parse("BadW3C", null));