Skip to content

Commit a232106

Browse files
author
Timothy Mothra
authored
fix analyzers (#2461)
* fix analyzer issues * fixes
1 parent 43afa8b commit a232106

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

BASE/src/Microsoft.ApplicationInsights/Channel/Transmission.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,11 @@ public class Transmission
2323
internal const string ContentEncodingHeader = "Content-Encoding";
2424

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

2929
private int isSending;
3030

31-
static Transmission()
32-
{
33-
client = new HttpClient(new RedirectHttpHandler())
34-
{
35-
Timeout = System.Threading.Timeout.InfiniteTimeSpan,
36-
};
37-
}
38-
3931
/// <summary>
4032
/// Initializes a new instance of the <see cref="Transmission"/> class.
4133
/// </summary>

BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/ReflectionCredentialEnvelope.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static Type GetTokenCredentialType()
123123

124124
if (typeTokenCredential == null)
125125
{
126-
if (AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(azureCoreAssemblyName)))
126+
if (AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(azureCoreAssemblyName, StringComparison.Ordinal)))
127127
{
128128
throw new Exception("An unknown error has occurred. Failed to get type Azure.Core.TokenCredential. Detected that Azure.Core is loaded in AppDomain.CurrentDomain.");
129129
}

BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/TransmissionPolicyCollection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ internal class TransmissionPolicyCollection : IDisposable
99
{
1010
private readonly IEnumerable<TransmissionPolicy> policies;
1111
private bool isDisposed;
12+
13+
[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "All policies are stored in the IEnumerable and are properly disposed.")]
1214
private AuthenticationTransmissionPolicy authenticationTransmissionPolicy;
1315

1416
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "applicationLifecycle is required only for NetFramework.")]

BASE/src/ServerTelemetryChannel/ServerTelemetryChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ public void Dispose()
283283
// Tested by FxCop rule CA2213
284284
this.TelemetryBuffer.Dispose();
285285
this.Transmitter.Dispose();
286+
this.policies.Dispose();
286287
}
287288

288289
/// <summary>

WEB/Src/DependencyCollector/DependencyCollector/DependencyTrackingTelemetryModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ protected virtual void Dispose(bool disposing)
282282
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
283283
private static void PrepareFirstActivity()
284284
{
285-
var activity = new Activity("Microsoft.ApplicationInsights.Init");
285+
using var activity = new Activity("Microsoft.ApplicationInsights.Init");
286286
activity.Start();
287287
activity.Stop();
288288
}

0 commit comments

Comments
 (0)