diff --git a/BASE/.vsts/linux-build.yml b/BASE/.vsts/linux-build.yml index 844f7d756b..636c1993e3 100644 --- a/BASE/.vsts/linux-build.yml +++ b/BASE/.vsts/linux-build.yml @@ -1,12 +1,12 @@ -variables: - DotNetVersion: "2.2.101" - pool: vmImage: 'ubuntu-16.04' steps: -- task: DotNetCoreInstaller@0 + + +- task: DotNetCoreInstaller@1 + displayName: install dotnet core 3.0 inputs: - version: $(DotNetVersion) + version: 3.0.x - task: DotNetCoreCLI@1 displayName: DotNetCoreCLI - Restore Solution @@ -21,6 +21,21 @@ steps: projects: "BASE/*.sln" arguments: "--configuration Release" +- task: DotNetCoreCLI@1 + displayName: DotNetCoreCLI - Test NetCore 3.0 + inputs: + command: "test" + projects: "BASE/Test/**/Microsoft.ApplicationInsights.Tests.csproj" + arguments: "--configuration Release --framework netcoreapp3.0 -l trx --filter TestCategory!=WindowsOnly" + + +## Install and test NetCore 2.2 + +- task: DotNetCoreInstaller@1 + displayName: install dotnet core 2.2 + inputs: + version: 2.2.x + - task: DotNetCoreCLI@1 displayName: DotNetCoreCLI - Test NetCore 2.0 inputs: @@ -28,9 +43,13 @@ steps: projects: "BASE/Test/**/Microsoft.ApplicationInsights.Tests.csproj" arguments: "--configuration Release --framework netcoreapp2.0 -l trx --filter TestCategory!=WindowsOnly" + + ## Install and test NetCore 1.1 + - task: DotNetCoreInstaller@0 + displayName: install dotnet core 1.1 inputs: - version: "1.1.5" + version: 1.1.5 - task: DotNetCoreCLI@1 displayName: DotNetCoreCLI - Test NetCore 1.1 @@ -39,6 +58,8 @@ steps: projects: "BASE/Test/**/Microsoft.ApplicationInsights.Tests.csproj" arguments: "--configuration Release --framework netcoreapp1.1 -l trx --filter TestCategory!=WindowsOnly" +## Publish test results + - task: PublishTestResults@2 condition: always() inputs: diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Channel/InMemoryChannelTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Channel/InMemoryChannelTest.cs index f767ab6ee3..1a79ff6e78 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Channel/InMemoryChannelTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Channel/InMemoryChannelTest.cs @@ -51,7 +51,7 @@ public void TelemetryWithNoInstrumentationKeyIsDropped() } } -#if (!NETCOREAPP1_1 && !NETCOREAPP2_0) +#if (!NETCOREAPP) // This constant is defined for all versions of NetCore https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget [Ignore("This test is failing intermittently and needs to be investigated. ~Timothy")] [TestMethod] diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/TelemetryConfigurationFactoryTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/TelemetryConfigurationFactoryTest.cs index 56242e9d47..61360f3346 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/TelemetryConfigurationFactoryTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/TelemetryConfigurationFactoryTest.cs @@ -504,7 +504,11 @@ public void LoadInstanceSetsInstancePropertiesOfTimeSpanTypeFromChildElementValu } [TestMethod] +#if NETCOREAPP3_0 + [ExpectedExceptionWithMessage(typeof(ArgumentException), "Failed to parse configuration value. Property: 'TimeSpanProperty' Reason: String 'TestValue' was not recognized as a valid TimeSpan.")] +#else [ExpectedExceptionWithMessage(typeof(ArgumentException), "Failed to parse configuration value. Property: 'TimeSpanProperty' Reason: String was not recognized as a valid TimeSpan.")] +#endif public void LoadInstanceSetsInstancePropertiesOfTimeSpanTypeFromChildElementValuesOfDefinitionWithInvalidFormatThrowsException() { var definition = new XElement( @@ -641,9 +645,9 @@ public void LoadInstanceCreatesNewInstanceOfExpectedTypeWhenPropertiesAreSpecifi Assert.AreEqual(42, loaded.Int32Property); } - #endregion +#endregion - #region TelemetryProcesors +#region TelemetryProcesors [TestMethod] public void InitializeTelemetryProcessorsFromConfigurationFile() @@ -873,9 +877,9 @@ public void UseAddsProcessorAfterProcessorsDefinedInConfiguration() AssertEx.IsType(configuration.TelemetryProcessors[1]); } - #endregion +#endregion - #region Modules +#region Modules [TestMethod] public void InitializeTelemetryModulesFromConfigurationFile() @@ -961,9 +965,9 @@ public void InitializeDoesNotThrowIsModuleInitializationFails() } } - #endregion +#endregion - #region TelemetryInitializers +#region TelemetryInitializers [TestMethod] public void InitializeAddTelemetryInitializersWithOneInvalid() { @@ -982,9 +986,9 @@ public void InitializeAddTelemetryInitializersWithOneInvalid() } - #endregion +#endregion - #region LoadInstances +#region LoadInstances [TestMethod] public void LoadInstancesPopulatesListWithInstancesOfSpecifiedType() @@ -1055,9 +1059,9 @@ public void LoadInstancesIgnoresElementsOtherThanAdd() AssertEx.AreEqual(new[] { 42 }, instances); } - #endregion +#endregion - #region LoadProperties +#region LoadProperties [TestMethod] public void LoadPropertiesConvertsPropertyValuesFromStringToPropertyType() @@ -1215,9 +1219,9 @@ public void DeveloperModePropertyCanLoadEmptyValue() Assert.IsFalse(instance.TelemetryChannel.DeveloperMode.HasValue); } - #endregion +#endregion - #region TelemetrySinks +#region TelemetrySinks [TestMethod] public void EmptyConfigurationCreatesDefaultSink() @@ -1783,7 +1787,7 @@ public void TelemetrySinkInitializesChannelAndAllProcessors() Assert.IsTrue(processor.Initialized); } - #endregion +#endregion [TestMethod] public void InitializeIsMarkesAsInternalSdkOperation() diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/TestUtility/TestUtil.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/TestUtility/TestUtil.cs index 98be324d43..2279e85539 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/TestUtility/TestUtil.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/TestUtility/TestUtil.cs @@ -236,7 +236,7 @@ public static void ValidateSdkVersionString(string versionMoniker) Assert.IsNotNull(versionMoniker); // Expected result example: "m-agg2:2.6.0-12552" -#if NETCOREAPP1_1 || NETCOREAPP2_0 +#if NETCOREAPP // This constant is defined for all versions of NetCore https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget const string expectedPrefix = "m-agg2c:"; #else const string expectedPrefix = "m-agg2:"; diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Microsoft.ApplicationInsights.Tests.csproj b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Microsoft.ApplicationInsights.Tests.csproj index 9e5dc36d3b..701988d683 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Microsoft.ApplicationInsights.Tests.csproj +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Microsoft.ApplicationInsights.Tests.csproj @@ -14,8 +14,8 @@ - net45;net46;netcoreapp1.1;netcoreapp2.0 - netcoreapp1.1;netcoreapp2.0 + net45;net46;netcoreapp1.1;netcoreapp2.0;netcoreapp3.0 + netcoreapp1.1;netcoreapp2.0;netcoreapp3.0 pdbonly true true diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryClientTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryClientTest.cs index af1f58a6d8..e3176a9249 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryClientTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryClientTest.cs @@ -1045,7 +1045,7 @@ public void TrackCopiesPropertiesFromClientToTelemetryBeforeInvokingInitializers Assert.AreEqual(client.Context.Properties[PropertyNameGlobal], globalValueInInitializer); } -#if (!NETCOREAPP1_1 && !NETCOREAPP2_0) +#if (!NETCOREAPP) // This constant is defined for all versions of NetCore https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget [TestMethod] public void TrackAddsSdkVerionByDefault() { diff --git a/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/TelemetryChannel.Tests.csproj b/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/TelemetryChannel.Tests.csproj index ea7ded8c0f..5d6a0cfbfd 100644 --- a/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/TelemetryChannel.Tests.csproj +++ b/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/TelemetryChannel.Tests.csproj @@ -15,8 +15,8 @@ - net45;netcoreapp1.1;netcoreapp2.0 - netcoreapp1.1;netcoreapp2.0 + net45;netcoreapp1.1;netcoreapp2.0;netcoreapp3.0 + netcoreapp1.1;netcoreapp2.0;netcoreapp3.0 Microsoft.ApplicationInsights.TelemetryChannel.Tests diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Tags.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Tags.cs index 3d7cdf64ef..00cb760002 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Tags.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Tags.cs @@ -68,10 +68,10 @@ internal static void UpdateTagValue(this IDictionary tags, strin { if (tagValue.HasValue) { -#if NET45 || NET46 || NETSTANDARD2_0 - string value = tagValue.Value.ToString(CultureInfo.InvariantCulture); -#else +#if NETSTANDARD1_3 string value = tagValue.Value.ToString(); +#else + string value = tagValue.Value.ToString(CultureInfo.InvariantCulture); #endif tags.Add(tagKey, value); } diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/HeartbeatProvider.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/HeartbeatProvider.cs index e717e65673..8000feb003 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/HeartbeatProvider.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/HeartbeatProvider.cs @@ -29,7 +29,7 @@ internal class HeartbeatProvider : IDisposable, IHeartbeatProvider /// /// Value for property indicating 'app insights version' related specifically to heartbeats. /// -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget private static string sdkVersionPropertyValue = SdkVersionUtils.GetSdkVersion("hbnetc:"); #else private static string sdkVersionPropertyValue = SdkVersionUtils.GetSdkVersion("hbnet:"); diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs index bd05a52f2d..6b75788ead 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs @@ -102,9 +102,9 @@ public TelemetryConfiguration(string instrumentationKey, ITelemetryChannel chann /// If the configuration file does not exist, the active configuration instance is initialized with minimum defaults /// needed to send telemetry to Application Insights. /// -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget [Obsolete("We do not recommend using TelemetryConfiguration.Active on .NET Core. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 for more details")] -#endif +#endif public static TelemetryConfiguration Active { get diff --git a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/Util.cs b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/Util.cs index 5a9db85e7f..411f36b1e9 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/Util.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/Util.cs @@ -16,7 +16,7 @@ internal static class Util private const string FallbackParameterName = "specified parameter"; -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget private static string sdkVersionMoniker = SdkVersionUtils.GetSdkVersion("m-agg2c:"); #else private static string sdkVersionMoniker = SdkVersionUtils.GetSdkVersion("m-agg2:"); diff --git a/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj b/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index cd70738fb1..708b3c2f9e 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj +++ b/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -8,6 +8,10 @@ Microsoft.ApplicationInsights net45;net46;netstandard1.3;netstandard2.0 netstandard1.3;netstandard2.0 + + + + $(DefineConstants);NETSTANDARD; diff --git a/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs b/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs index 5254db9067..8bb868c62c 100644 --- a/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs +++ b/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs @@ -19,7 +19,7 @@ /// public sealed class TelemetryClient { -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget private const string VersionPrefix = "dotnetc:"; #else private const string VersionPrefix = "dotnet:"; @@ -32,7 +32,7 @@ public sealed class TelemetryClient /// /// Initializes a new instance of the class. Send telemetry with the active configuration, usually loaded from ApplicationInsights.config. /// -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget [Obsolete("We do not recommend using TelemetryConfiguration.Active on .NET Core. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 for more details")] #endif public TelemetryClient() : this(TelemetryConfiguration.Active) diff --git a/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj b/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj index 30c16f9231..098b459b2e 100644 --- a/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj +++ b/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj @@ -8,6 +8,10 @@ Microsoft.AI.ServerTelemetryChannel net45;netstandard1.3;netstandard2.0 netstandard1.3;netstandard2.0 + + + + $(DefineConstants);NETSTANDARD;