Enable FxCop - part 02 (#1009)

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
This commit is contained in:
Eddy Nakamura 2020-08-05 13:39:47 -03:00 committed by GitHub
parent 8077bab538
commit e79c3eee97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 41 additions and 15 deletions

View File

@ -38,7 +38,7 @@ namespace OpenTelemetry.Exporter.Console
WriteIndented = true,
};
this.displayAsJson = options.DisplayAsJson;
this.displayAsJson = options?.DisplayAsJson ?? false;
this.serializerOptions.Converters.Add(new JsonStringEnumConverter());
this.serializerOptions.Converters.Add(new ActivitySpanIdConverter());

View File

@ -22,7 +22,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
{
internal readonly struct Int128
{
public static Int128 Empty = default;
public static Int128 Empty;
private const int SpanIdBytes = 8;
private const int TraceIdBytes = 16;

View File

@ -26,7 +26,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
{
private readonly IJaegerClient client;
private readonly MemoryStream byteStream;
private bool isDisposed = false;
private bool isDisposed;
public JaegerThriftClientTransport(string host, int port)
: this(host, port, new MemoryStream(), new JaegerUdpClient())

View File

@ -25,10 +25,10 @@ using OpenTelemetry.Trace;
namespace OpenTelemetry.Exporter.Jaeger
{
public class JaegerExporter : ActivityExporter, IDisposable
public class JaegerExporter : ActivityExporter
{
private bool libraryResourceApplied = false;
private bool disposedValue = false; // To detect redundant dispose calls
private bool libraryResourceApplied;
private bool disposedValue; // To detect redundant dispose calls
public JaegerExporter(JaegerExporterOptions options)
{
@ -122,6 +122,8 @@ namespace OpenTelemetry.Exporter.Jaeger
this.disposedValue = true;
}
base.Dispose(disposing);
}
}
}

View File

@ -85,10 +85,18 @@ namespace OpenTelemetry.Exporter.Prometheus
}
}
/// <summary>
/// Disposes of managed resources.
/// </summary>
/// <inheritdoc/>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases the unmanaged resources used by this class and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (this.httpListener != null && this.httpListener.IsListening)
{

View File

@ -93,6 +93,16 @@ namespace OpenTelemetry.Exporter.ZPages
/// Disposes of managed resources.
/// </summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases the unmanaged resources used by this class and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (this.httpListener != null && this.httpListener.IsListening)
{

View File

@ -41,6 +41,6 @@ namespace OpenTelemetry.Exporter.Zipkin
/// <summary>
/// Gets or sets a value indicating whether short trace id should be used.
/// </summary>
public bool UseShortTraceIds { get; set; } = false;
public bool UseShortTraceIds { get; set; }
}
}

View File

@ -28,7 +28,7 @@ namespace OpenTelemetry.Instrumentation.Http
/// <summary>
/// Gets or sets a value indicating whether or not the HTTP version should be added as the <see cref="SemanticConventions.AttributeHttpFlavor"/> tag. Default value: False.
/// </summary>
public bool SetHttpFlavor { get; set; } = false;
public bool SetHttpFlavor { get; set; }
/// <summary>
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="TraceContextFormat"/>.

View File

@ -29,7 +29,7 @@ namespace OpenTelemetry.Instrumentation.Http
/// <summary>
/// Gets or sets a value indicating whether or not the HTTP version should be added as the <see cref="SemanticConventions.AttributeHttpFlavor"/> tag. Default value: False.
/// </summary>
public bool SetHttpFlavor { get; set; } = false;
public bool SetHttpFlavor { get; set; }
/// <summary>
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="TraceContextFormat"/>.

View File

@ -48,7 +48,7 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
private readonly PropertyFetcher stopResponseFetcher = new PropertyFetcher("Response");
private readonly PropertyFetcher stopExceptionFetcher = new PropertyFetcher("Exception");
private readonly PropertyFetcher stopRequestStatusFetcher = new PropertyFetcher("RequestTaskStatus");
private readonly bool httpClientSupportsW3C = false;
private readonly bool httpClientSupportsW3C;
private readonly HttpClientInstrumentationOptions options;
public HttpHandlerDiagnosticListener(HttpClientInstrumentationOptions options, ActivitySourceAdapter activitySource)

View File

@ -54,7 +54,7 @@ namespace OpenTelemetry.Instrumentation.SqlClient
/// <remarks>
/// The default behavior is to set the SqlConnection DataSource as the <see cref="SemanticConventions.AttributePeerService"/> tag. If enabled, SqlConnection DataSource will be parsed and the server name will be sent as the <see cref="SemanticConventions.AttributeNetPeerName"/> or <see cref="SemanticConventions.AttributeNetPeerIp"/> tag, the instance name will be sent as the <see cref="SemanticConventions.AttributeDbMsSqlInstanceName"/> tag, and the port will be sent as the <see cref="SemanticConventions.AttributeNetPeerPort"/> tag if it is not 1433 (the default port).
/// </remarks>
public bool EnableConnectionLevelAttributes { get; set; } = false;
public bool EnableConnectionLevelAttributes { get; set; }
internal static SqlConnectionDetails ParseDataSource(string dataSource)
{

View File

@ -83,6 +83,12 @@ namespace OpenTelemetry.Instrumentation
/// <inheritdoc/>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (Interlocked.CompareExchange(ref this.disposed, 1, 0) == 1)
{

View File

@ -39,7 +39,7 @@ namespace OpenTelemetry.Instrumentation
/// <summary>
/// Gets a value indicating whether the <see cref="ListenerHandler"/> supports NULL <see cref="Activity"/>.
/// </summary>
public virtual bool SupportsNullActivity { get; } = false;
public virtual bool SupportsNullActivity { get; }
/// <summary>
/// Method called for an event with the suffix 'Start'.