Skip to content

Commit

Permalink
update analyzers and fix issues (#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMothra authored May 21, 2019
1 parent dcd64ac commit f181abb
Show file tree
Hide file tree
Showing 103 changed files with 680 additions and 683 deletions.
6 changes: 5 additions & 1 deletion ApplicationInsightsSDKRules.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<!-- Suppressing Message "Modify 'method' to catch a more specific exception type, or rethrow the exception" because we already catch Exceptions we care about and either log/ignore others. -->
<Rule Id="CA1031" Action="None" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
Expand Down Expand Up @@ -81,7 +83,9 @@
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2210" Action="None" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<!-- Disabling this check "CA2213:DisposableFieldsShouldBeDisposed".
This analyzer has a bug which fails the build, https://github.com/dotnet/roslyn-analyzers/issues/1815 -->
<Rule Id="CA2213" Action="None" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2219" Action="Warning" />
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface ITelemetry
ITelemetry DeepClone();

/// <summary>
/// Writes serialization info about the data class of the implementing type using the given <see cref="ISerializationWriter"/>
/// Writes serialization info about the data class of the implementing type using the given <see cref="ISerializationWriter"/>.
/// </summary>
void SerializeData(ISerializationWriter serializationWriter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ namespace Microsoft.ApplicationInsights.Channel
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Extensibility;
using Extensibility.Implementation;
using Extensibility.Implementation.Tracing;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;

/// <summary>
/// A transmitter that will immediately send telemetry over HTTP.
Expand All @@ -32,7 +33,6 @@ internal class InMemoryTransmitter : IDisposable
/// The number of times this object was disposed.
/// </summary>
private int disposeCount = 0;

private TimeSpan sendingInterval = TimeSpan.FromSeconds(30);
private Uri endpointAddress = new Uri(Constants.TelemetryServiceEndpoint);

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ApplicationInsights/Channel/Transmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public virtual async Task<HttpWebResponseWrapper> SendAsync()
wrapper = new HttpWebResponseWrapper
{
StatusCode = (int)response.StatusCode,
StatusDescription = response.ReasonPhrase // maybe not required?
StatusDescription = response.ReasonPhrase, // maybe not required?
};
wrapper.RetryAfterHeader = response.Headers?.RetryAfter?.ToString();

Expand Down Expand Up @@ -204,7 +204,7 @@ public virtual async Task<HttpWebResponseWrapper> SendAsync()
{
wrapper = new HttpWebResponseWrapper
{
StatusCode = (int)HttpStatusCode.RequestTimeout
StatusCode = (int)HttpStatusCode.RequestTimeout,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ExceptionDetailsInfo(int id, int outerId, string typeName, string message
message = message,
hasFullStack = hasFullStack,
stack = stack,
parsedStack = parsedStack.Select(ps => ps.Data).ToList()
parsedStack = parsedStack.Select(ps => ps.Data).ToList(),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public enum ExceptionHandledAt
/// <summary>
/// Exception was handled by some platform handlers.
/// </summary>
Platform
Platform,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Extensibility.Implementation;
using Extensibility.Implementation.External;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.Implementation.External;

/// <summary>
/// Wrapper class for <see cref="ExceptionData"/> that lets user provide exception data without having the actual Exception object.
Expand All @@ -14,7 +14,7 @@ internal sealed class ExceptionInfo
private readonly ExceptionData data;

/// <summary>
/// Constructs the instance of <see cref="ExceptionInfo"/>
/// Constructs the instance of <see cref="ExceptionInfo"/>.
/// </summary>
public ExceptionInfo(IEnumerable<ExceptionDetailsInfo> exceptionDetailsInfoList, SeverityLevel? severityLevel, string problemId,
IDictionary<string, string> properties, IDictionary<string, double> measurements)
Expand All @@ -25,7 +25,7 @@ public ExceptionInfo(IEnumerable<ExceptionDetailsInfo> exceptionDetailsInfoList,
severityLevel = severityLevel.TranslateSeverityLevel(),
problemId = problemId,
properties = new ConcurrentDictionary<string, string>(properties),
measurements = new ConcurrentDictionary<string, double>(measurements)
measurements = new ConcurrentDictionary<string, double>(measurements),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;

using Channel;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum SessionState
/// <summary>
/// Indicates that a user session ended.
/// </summary>
End
End,
}
#pragma warning restore CA1724
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public StackFrame(string assembly, string fileName, int level, int line, string
fileName = fileName,
level = level,
line = line,
method = method
method = method,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
public interface IApplicationIdProvider
{
/// <summary>
/// Retrieves the Application Id to be used for Request.Source or Dependency.Target
/// Retrieves the Application Id to be used for Request.Source or Dependency.Target.
/// </summary>
/// <remarks>
/// Application Insights data model defines two fields: request.source and dependency.target.
/// The first field identifies the component that initiated the dependency request,
/// and the second identifies which component returned the response of the dependency call.
/// For more information see: https://docs.microsoft.com/azure/application-insights/application-insights-correlation
/// For more information see: https://docs.microsoft.com/azure/application-insights/application-insights-correlation .
/// </remarks>
/// <param name="instrumentationKey">Instrumentation Key string used to lookup associated Application Id.</param>
/// <param name="applicationId">Application Id corresponding to the Instrumentation Key. Returns NULL if a match was not found.</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace Microsoft.ApplicationInsights.Extensibility
{
/// <summary>
/// Interface for defining objects which can be serialized with a given <see cref="ISerializationWriter"/>
/// Interface for defining objects which can be serialized with a given <see cref="ISerializationWriter"/>.
/// </summary>
public interface ISerializableWithWriter
{
/// <summary>
/// Writes serialization info about the class using the given <see cref="ISerializationWriter"/>
/// Writes serialization info about the class using the given <see cref="ISerializationWriter"/>.
/// </summary>
void Serialize(ISerializationWriter serializationWriter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,62 @@
public interface ISerializationWriter
{
/// <summary>
/// Writes name and value for a string field
/// Writes name and value for a string field.
/// </summary>
void WriteProperty(string name, string value);

/// <summary>
/// Writes name and value for a double field
/// Writes name and value for a double field.
/// </summary>
void WriteProperty(string name, double? value);

/// <summary>
/// Writes name and value for a int field
/// Writes name and value for a int field.
/// </summary>
void WriteProperty(string name, int? value);

/// <summary>
/// Writes name and value for a boolean field
/// Writes name and value for a boolean field.
/// </summary>
void WriteProperty(string name, bool? value);

/// <summary>
/// Writes name and value for a TimeSpan field
/// Writes name and value for a TimeSpan field.
/// </summary>
void WriteProperty(string name, TimeSpan? value);

/// <summary>
/// Writes name and value for a DateTimeOffset field
/// Writes name and value for a DateTimeOffset field.
/// </summary>
void WriteProperty(string name, DateTimeOffset? value);

/// <summary>
/// Writes name and value for a ISerializableWithWriter field
/// Writes name and value for a ISerializableWithWriter field.
/// </summary>
void WriteProperty(string name, ISerializableWithWriter value);

/// <summary>
/// Writes value ISerializableWithWriter field
/// Writes value ISerializableWithWriter field.
/// </summary>
void WriteProperty(ISerializableWithWriter value);

/// <summary>
/// Writes name and values for a IList field of strings
/// Writes name and values for a IList field of strings.
/// </summary>
void WriteProperty(string name, IList<string> items);

/// <summary>
/// Writes name and values for a IList field of objects implementing ISerializableWithWriter
/// Writes name and values for a IList field of objects implementing ISerializableWithWriter.
/// </summary>
void WriteProperty(string name, IList<ISerializableWithWriter> items);

/// <summary>
/// Writes name and value for a IDictionary field with string,string as key,value
/// Writes name and value for a IDictionary field with string,string as key,value.
/// </summary>
void WriteProperty(string name, IDictionary<string, string> items);

/// <summary>
/// Writes name and value for a IDictionary field with string,string as key,value
/// Writes name and value for a IDictionary field with string,string as key,value.
/// </summary>
void WriteProperty(string name, IDictionary<string, double> items);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
internal static class ApplicationIdHelper
{
/// <summary>
/// special string which describes that ID was taken from Breeze
/// special string which describes that ID was taken from Breeze.
/// </summary>
private const string Format = "cid-v1:{0}";

Expand Down Expand Up @@ -83,7 +83,7 @@ private static string EnforceMaxLength(string input, int maxLength)
/// ASCII Extended characters (hex: 0x80 - 0xFF) (decimal: 128-255) (NOT ALLOWED)
/// Non-Printable ASCII characters are (hex: 0x00 - 0x1F) (decimal: 0-31) (NOT ALLOWED)
/// Printable ASCII characters are (hex: 0x20 - 0xFF) (decimal: 32-255) (PARTIALLY ALLOWED)
/// ALLOWED characters are (hex: 0x20 - 0x7F) (decimal: 32-127)
/// ALLOWED characters are (hex: 0x20 - 0x7F) (decimal: 32-127).
/// </summary>
private static bool IsCharHeaderSafe(char ch) => (uint)(ch - 0x20) <= (0x7F - 0x20);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using Extensibility;

using Microsoft.ApplicationInsights.Extensibility;

/// <summary>
/// This <see cref="ApplicationInsightsApplicationIdProvider"/> will query the Application Insights' Breeze endpoint to lookup an Application Id based on Instrumentation Key.
Expand Down Expand Up @@ -42,7 +42,7 @@ internal ApplicationInsightsApplicationIdProvider(ProfileServiceWrapper profileS

/// <summary>
/// Gets or sets the endpoint that is to be used to get the Application Insights resource's profile (Application Id etc.).
/// Default value is "https://dc.services.visualstudio.com/api/profiles/{0}/appId". If this is overwritten, MUST include the '{0}' for string replacement!
/// Default value is "https://dc.services.visualstudio.com/api/profiles/{0}/appId". If this is overwritten, MUST include the '{0}' for string replacement!.
/// </summary>
public string ProfileQueryEndpoint
{
Expand All @@ -51,7 +51,7 @@ public string ProfileQueryEndpoint
}

/// <summary>
/// Disposes resources
/// Disposes resources.
/// </summary>
public void Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class DictionaryApplicationIdProvider : IApplicationIdProvider
{
/// <summary>
/// Gets or sets a dictionary of Instrumentation Keys to Application Ids
/// Gets or sets a dictionary of Instrumentation Keys to Application Ids.
/// </summary>
public IReadOnlyDictionary<string, string> Defined { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.Collections.Concurrent;
using System.Net;
using Extensibility.Implementation.Tracing;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;

internal class FailedRequestsManager
{
Expand Down Expand Up @@ -104,7 +104,7 @@ private class FailedResult
/// <summary>
/// Initializes a new instance of the <see cref="FailedResult" /> class.
/// </summary>
/// <param name="retryAfter">Time to wait before a retry</param>
/// <param name="retryAfter">Time to wait before a retry.</param>
/// <param name="httpStatusCode">Failure response code. Used to determine if we should retry requests.</param>
public FailedResult(TimeSpan retryAfter, HttpStatusCode httpStatusCode = HttpStatusCode.OK)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using Extensibility;
using Microsoft.ApplicationInsights.Extensibility;

internal class ProfileServiceWrapper : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public TelemetryDispatcher(TelemetrySink sink, bool cloneBeforeDispatch)
}

/// <summary>
/// Sends the item to sink. If cloning of item is required, clones the item before sending it to <see cref="TelemetrySink"/>
/// Sends the item to sink. If cloning of item is required, clones the item before sending it to <see cref="TelemetrySink"/>.
/// </summary>
/// <param name="telemetry">The telemetry item to send to sink.</param>
public void SendItemToSink(ITelemetry telemetry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static External.StackFrame GetStackFrame(StackFrame stackFrame, int fra
{
var convertedStackFrame = new External.StackFrame()
{
level = frameId
level = frameId,
};

var methodInfo = stackFrame.GetMethod();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.ApplicationInsights.DataContracts;

/// <summary>
/// Partial class to implement ISerializableWithWriter
/// Partial class to implement ISerializableWithWriter.
/// </summary>
internal partial class AvailabilityData : ISerializableWithWriter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.ApplicationInsights.DataContracts;

/// <summary>
/// Partial class to implement ISerializableWithWriter
/// Partial class to implement ISerializableWithWriter.
/// </summary>
internal partial class DataPoint : ISerializableWithWriter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.ApplicationInsights.DataContracts;

/// <summary>
/// Partial class to implement ISerializableWithWriter
/// Partial class to implement ISerializableWithWriter.
/// </summary>
internal partial class EventData : ISerializableWithWriter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.ApplicationInsights.DataContracts;

/// <summary>
/// Partial class to implement ISerializableWithWriter
/// Partial class to implement ISerializableWithWriter.
/// </summary>
internal partial class ExceptionData : ISerializableWithWriter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, Exc
{
id = exception.GetHashCode(),
typeName = exception.GetType().FullName,
message = exception.Message
message = exception.Message,
};

if (parentExceptionDetails != null)
Expand Down
Loading

0 comments on commit f181abb

Please sign in to comment.