Skip to content

Commit

Permalink
fix analyzers (#2461)
Browse files Browse the repository at this point in the history
* fix analyzer issues

* fixes
  • Loading branch information
TimothyMothra authored Oct 28, 2021
1 parent 43afa8b commit a232106
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
10 changes: 1 addition & 9 deletions BASE/src/Microsoft.ApplicationInsights/Channel/Transmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,11 @@ public class Transmission
internal const string ContentEncodingHeader = "Content-Encoding";

private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(100);
private static HttpClient client;
private static HttpClient client = new HttpClient(new RedirectHttpHandler()) { Timeout = System.Threading.Timeout.InfiniteTimeSpan };
private static long flushAsyncCounter = 0;

private int isSending;

static Transmission()
{
client = new HttpClient(new RedirectHttpHandler())
{
Timeout = System.Threading.Timeout.InfiniteTimeSpan,
};
}

/// <summary>
/// Initializes a new instance of the <see cref="Transmission"/> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private static Type GetTokenCredentialType()

if (typeTokenCredential == null)
{
if (AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(azureCoreAssemblyName)))
if (AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(azureCoreAssemblyName, StringComparison.Ordinal)))
{
throw new Exception("An unknown error has occurred. Failed to get type Azure.Core.TokenCredential. Detected that Azure.Core is loaded in AppDomain.CurrentDomain.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal class TransmissionPolicyCollection : IDisposable
{
private readonly IEnumerable<TransmissionPolicy> policies;
private bool isDisposed;

[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "All policies are stored in the IEnumerable and are properly disposed.")]
private AuthenticationTransmissionPolicy authenticationTransmissionPolicy;

[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "applicationLifecycle is required only for NetFramework.")]
Expand Down
1 change: 1 addition & 0 deletions BASE/src/ServerTelemetryChannel/ServerTelemetryChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ public void Dispose()
// Tested by FxCop rule CA2213
this.TelemetryBuffer.Dispose();
this.Transmitter.Dispose();
this.policies.Dispose();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected virtual void Dispose(bool disposing)
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
private static void PrepareFirstActivity()
{
var activity = new Activity("Microsoft.ApplicationInsights.Init");
using var activity = new Activity("Microsoft.ApplicationInsights.Init");
activity.Start();
activity.Stop();
}
Expand Down

0 comments on commit a232106

Please sign in to comment.