diff --git a/src/Microsoft.ApplicationInsights/Extensibility/W3C/W3CActivityExtensions.cs b/src/Microsoft.ApplicationInsights/Extensibility/W3C/W3CActivityExtensions.cs index 0970ba1781..7f15d2bbe4 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/W3C/W3CActivityExtensions.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/W3C/W3CActivityExtensions.cs @@ -29,7 +29,11 @@ public static class W3CActivityExtensions /// Activity to generate W3C context on. /// The same Activity for chaining. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant +#pragma warning disable CS3002 // Return type is not CLS-compliant public static Activity GenerateW3CContext(this Activity activity) +#pragma warning restore CS3002 // Return type is not CLS-compliant +#pragma warning restore CS3001 // Argument type is not CLS-compliant { activity.SetVersion(W3CConstants.DefaultVersion); activity.SetSampled(W3CConstants.TraceFlagRecordedAndNotRequested); @@ -48,7 +52,9 @@ public static Activity GenerateW3CContext(this Activity activity) /// Activity to check. /// True if Activity has W3C properties, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static bool IsW3CActivity(this Activity activity) +#pragma warning restore CS3001 // Argument type is not CLS-compliant { return activity != null && activity.Tags.Any(t => t.Key == W3CConstants.TraceIdTag); } @@ -59,7 +65,11 @@ public static bool IsW3CActivity(this Activity activity) /// Activity to update W3C context on. /// The same Activity for chaining. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant +#pragma warning disable CS3002 // Return type is not CLS-compliant public static Activity UpdateContextOnActivity(this Activity activity) +#pragma warning restore CS3002 // Return type is not CLS-compliant +#pragma warning restore CS3001 // Argument type is not CLS-compliant { if (activity == null || activity.Tags.Any(t => t.Key == W3CConstants.TraceIdTag)) { @@ -79,7 +89,9 @@ public static Activity UpdateContextOnActivity(this Activity activity) /// Activity to read W3C context from. /// traceparent header value. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static string GetTraceparent(this Activity activity) +#pragma warning restore CS3001 // Argument type is not CLS-compliant { string version = null, traceId = null, spanId = null, sampled = null; foreach (var tag in activity.Tags) @@ -115,7 +127,9 @@ public static string GetTraceparent(this Activity activity) /// Activity to set W3C context on. /// Valid traceparent header like 00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static void SetTraceparent(this Activity activity, string value) +#pragma warning restore CS3001 // Argument type is not CLS-compliant { if (activity.IsW3CActivity()) { @@ -175,7 +189,9 @@ public static void SetTraceparent(this Activity activity, string value) /// Activity to get tracestate from. /// tracestate header value. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static string GetTracestate(this Activity activity) => +#pragma warning restore CS3001 // Argument type is not CLS-compliant activity.Tags.FirstOrDefault(t => t.Key == W3CConstants.TracestateTag).Value; /// @@ -184,7 +200,9 @@ public static string GetTracestate(this Activity activity) => /// Activity to set tracestate on. /// tracestate header value. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static void SetTracestate(this Activity activity, string value) => +#pragma warning restore CS3001 // Argument type is not CLS-compliant activity.AddTag(W3CConstants.TracestateTag, value); /// @@ -194,7 +212,9 @@ public static void SetTracestate(this Activity activity, string value) => /// Activity to get traceId from. /// TraceId value or null if it does not exist. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static string GetTraceId(this Activity activity) => activity.Tags.FirstOrDefault(t => t.Key == W3CConstants.TraceIdTag).Value; +#pragma warning restore CS3001 // Argument type is not CLS-compliant /// /// Gets SpanId from the Activity. @@ -203,7 +223,9 @@ public static void SetTracestate(this Activity activity, string value) => /// Activity to get spanId from. /// SpanId value or null if it does not exist. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static string GetSpanId(this Activity activity) => activity.Tags.FirstOrDefault(t => t.Key == W3CConstants.SpanIdTag).Value; +#pragma warning restore CS3001 // Argument type is not CLS-compliant /// /// Gets ParentSpanId from the Activity. @@ -212,7 +234,9 @@ public static void SetTracestate(this Activity activity, string value) => /// Activity to get ParentSpanId from. /// ParentSpanId value or null if it does not exist. [EditorBrowsable(EditorBrowsableState.Never)] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static string GetParentSpanId(this Activity activity) => activity.Tags.FirstOrDefault(t => t.Key == W3CConstants.ParentSpanIdTag).Value; +#pragma warning restore CS3001 // Argument type is not CLS-compliant /// /// Sets Activity W3C context on the telemetry. @@ -223,7 +247,9 @@ public static void SetTracestate(this Activity activity, string value) => [EditorBrowsable(EditorBrowsableState.Never)] [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "This method has different code for Net45/NetCore")] +#pragma warning disable CS3001 // Argument type is not CLS-compliant public static void UpdateTelemetry(this Activity activity, ITelemetry telemetry, bool forceUpdate) +#pragma warning restore CS3001 // Argument type is not CLS-compliant { if (activity == null) { diff --git a/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs b/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs index d51f2fe2ca..684124dde0 100644 --- a/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs +++ b/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs @@ -185,6 +185,7 @@ public static void StopOperation(this TelemetryClient telemetryClient, IOpera operation.Dispose(); } +#pragma warning disable CS3001 // Argument type is not CLS-compliant /// /// Creates an operation object with a respective telemetry item using instance that holds tracing context. /// @@ -218,6 +219,7 @@ public static void StopOperation(this TelemetryClient telemetryClient, IOpera /// Activity to get tracing context and telemetry properties from. /// Operation item object with a new telemetry item having current start time and timestamp. public static IOperationHolder StartOperation(this TelemetryClient telemetryClient, Activity activity) where T : OperationTelemetry, new() +#pragma warning restore CS3001 // Argument type is not CLS-compliant { if (telemetryClient == null) {