Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public async Task SendAsyncReturnsCorrectHttpResponseWrapperWithRetryHeaderWhenN

}

#if NETCOREAPP2_1 || NETCOREAPP3_1
#if NETCOREAPP
[TestMethod]
public async Task SendAsyncLogsIngestionReponseTimeEventCounter()
{
Expand Down Expand Up @@ -425,9 +425,7 @@ public async Task SendAsyncLogsIngestionReponseTimeEventCounter()
// Max should be more than 30 ms, as we introduced a delay of 30ms in SendAsync.
#if NETCOREAPP2_1
Assert.IsTrue((float)payload["Max"] >= 30);
#endif

#if NETCOREAPP3_1
#elif NETCOREAPP3_1
Assert.IsTrue((double)payload["Max"] >= 30);
#endif
}
Expand Down Expand Up @@ -474,9 +472,7 @@ public async Task SendAsyncLogsIngestionReponseTimeOnFailureEventCounter()
// Mean should be more than 30 ms, as we introduced a delay of 30ms in SendAsync.
#if NETCOREAPP2_1
Assert.IsTrue((float)payload["Mean"] >= 30);
#endif

#if NETCOREAPP3_1
#elif NETCOREAPP3_1
Assert.IsTrue((double)payload["Mean"] >= 30);
#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Platform
{
#if !NETCOREAPP
#if NETFRAMEWORK
using System;
using System.IO;
using System.Security;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Platform
{
#if !NETCOREAPP
#if NETFRAMEWORK
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.ApplicationInsights.Extensibility.Implementation
{
#if !NETCOREAPP
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Microsoft.ApplicationInsights
{
#if !NETCOREAPP
#if NETFRAMEWORK
using System;
using System.Diagnostics;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void FirstErrorDelayIsSameAsSlotDelay()
[TestMethod]
public void UpperBoundOfDelayIsMaxDelay()
{
#if !NETCOREAPP
#if NETFRAMEWORK
var manager = new BackoffLogicManager(TimeSpan.Zero, TimeSpan.Zero);

PrivateObject wrapper = new PrivateObject(manager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void ConstructorThrowsArgumentNullExceptionWhenSerializerIsNull()
AssertEx.Throws<ArgumentNullException>(() => new TelemetryBuffer(null, new StubApplicationLifecycle()));
}

#if !NETCOREAPP
#if NETFRAMEWORK
[TestMethod]
public void ConstructorThrowsArgumentNullExceptionWhenApplicationLifecycleIsNull()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation
{
#if !NETCOREAPP
#if NETFRAMEWORK
using System;
using System.Threading.Tasks;
using System.Web.Hosting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private static void LoadInstanceFromValue(XElement definition, Type expectedType
{
instance = TimeSpan.Parse(valueString, CultureInfo.InvariantCulture);
}
#if NET452 || NET46
#if NETFRAMEWORK
else if (expectedType.IsEnum)
#else
else if (expectedType.GetTypeInfo().IsEnum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public Task<bool> SetDefaultPayload(IEnumerable<string> disabledFields, IHeartbe
/// <returns>a string representing the version of the current .NET framework.</returns>
private static string GetRuntimeFrameworkVer()
{
#if NET452 || NET46
#if NETFRAMEWORK
Assembly assembly = typeof(Object).GetTypeInfo().Assembly;
AssemblyFileVersionAttribute objectAssemblyFileVer =
assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute))
.Cast<AssemblyFileVersionAttribute>()
.FirstOrDefault();
return objectAssemblyFileVer != null ? objectAssemblyFileVer.Version : "undefined";
#elif NETSTANDARD2_0
#elif NETSTANDARD
return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
#else
#error Unrecognized framework
Expand Down Expand Up @@ -127,11 +127,11 @@ private static string GetBaseSdkTargetFramework()
private static string GetRuntimeOsType()
{
string osValue = "unknown";
#if NET452 || NET46
#if NETFRAMEWORK

osValue = Environment.OSVersion.Platform.ToString();

#elif NETSTANDARD2_0
#elif NETSTANDARD

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public WeakConcurrentRandom()

public static WeakConcurrentRandom Instance
{
#if NET452 || NET46
#if NETFRAMEWORK
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
get
Expand Down
8 changes: 4 additions & 4 deletions BASE/src/Microsoft.ApplicationInsights/PreciseTimestamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using System;
using System.Diagnostics;
#if NET452 || NET46
#if NETFRAMEWORK
using System.Diagnostics.CodeAnalysis;
using System.Threading;
#endif
Expand All @@ -14,7 +14,7 @@ internal class PreciseTimestamp
/// </summary>
internal static readonly double StopwatchTicksToTimeSpanTicks = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;

#if NET452 || NET46
#if NETFRAMEWORK
private static readonly Timer SyncTimeUpdater;
private static TimeSync timeSync = new TimeSync();

Expand All @@ -30,7 +30,7 @@ static PreciseTimestamp()
/// </summary>
public static DateTimeOffset GetUtcNow()
{
#if NET452 || NET46
#if NETFRAMEWORK
// DateTime.UtcNow accuracy on .NET Framework is ~16ms, this method
// uses combination of Stopwatch and DateTime to calculate accurate UtcNow.

Expand All @@ -46,7 +46,7 @@ public static DateTimeOffset GetUtcNow()
#endif
}

#if NET452 || NET46
#if NETFRAMEWORK
private static void Sync()
{
// wait for DateTime.UtcNow update to the next granular value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private DirectoryInfo CreateTelemetrySubdirectory(DirectoryInfo root)
{
string baseDirectory = string.Empty;

#if !NETSTANDARD
#if NETFRAMEWORK
baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
#else
baseDirectory = AppContext.BaseDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public TelemetryBuffer(TelemetrySerializer serializer, IApplicationLifecycle app
throw new ArgumentNullException(nameof(serializer));
}

#if !NETSTANDARD
#if NETFRAMEWORK
// We don't have implementation for IApplicationLifecycle for .NET Core
if (applicationLifecycle == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public WeakConcurrentRandom()

public static WeakConcurrentRandom Instance
{
#if NET452 || NET46
#if NETFRAMEWORK
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
get
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NETSTANDARD
#if NETFRAMEWORK
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation
{
using System;
Expand Down
4 changes: 2 additions & 2 deletions BASE/src/ServerTelemetryChannel/ServerTelemetryChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed class ServerTelemetryChannel : ITelemetryChannel, IAsyncFlushable,
/// <summary>
/// Initializes a new instance of the <see cref="ServerTelemetryChannel"/> class.
/// </summary>
#if !NETSTANDARD
#if NETFRAMEWORK
[SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification = "WebApplicationLifecycle is needed for the life of the application.")]
public ServerTelemetryChannel() : this(new Network(), new WebApplicationLifecycle())
#else
Expand All @@ -45,7 +45,7 @@ internal ServerTelemetryChannel(INetwork network, IApplicationLifecycle applicat
{
var policies = new TransmissionPolicy[]
{
#if !NETSTANDARD
#if NETFRAMEWORK
// We don't have implementation for IApplicationLifecycle for .NET Core
new ApplicationLifecycleTransmissionPolicy(applicationLifecycle),
#endif
Expand Down