Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for Net462 #2277

Closed
wants to merge 16 commits into from
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<TargetFrameworks>net452;net46;net461;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net452;net46;net461;net462;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand All @@ -28,8 +28,8 @@
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net46' Or '$(TargetFramework)' == 'net461' ">
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.30" />
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net46' Or '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.68" />

<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Cleanup()
Directory.Delete(this.tempPath, true);
}

#if NETCOREAPP2_1 || NETCOREAPP3_1
#if NETCOREAPP
[Ignore("Missing netstandard dependencies.")]
#endif
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net452;net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netcoreapp2.1;netcoreapp3.1</TargetFrameworks>

<AssemblyName>Microsoft.ApplicationInsights.TelemetryChannel.Tests</AssemblyName>
Expand Down Expand Up @@ -32,7 +32,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<Reference Include="System.Web" />
<Reference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ private static string GetBaseSdkTargetFramework()
return "net452";
#elif NET46
return "net46";
#elif NET462
return "net462";
#elif NETSTANDARD2_0
return "netstandard2.0";
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.ApplicationInsights</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights</AssemblyName>
<TargetFrameworks>net452;net46;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;net46;net462;netstandard2.0</TargetFrameworks>
TimothyMothra marked this conversation as resolved.
Show resolved Hide resolved
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netstandard2.0</TargetFrameworks>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public IPlatformFolder GetApplicationFolder()

internal static bool IsWindowsOperatingSystem()
{
#if NET452
#if NETFRAMEWORK
return true;
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Expand Down
6 changes: 3 additions & 3 deletions BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel</RootNamespace>
<AssemblyName>Microsoft.AI.ServerTelemetryChannel</AssemblyName>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netstandard2.0</TargetFrameworks>
</PropertyGroup>

Expand All @@ -19,7 +19,7 @@
<ProjectReference Include="..\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventRegister" Version="1.1.28">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
Expand All @@ -44,4 +44,4 @@
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Product.props" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>net452;net462;netstandard2.0</TargetFrameworks>
<RootNamespace>Microsoft.ApplicationInsights.DiagnosticSourceListener</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.DiagnosticSourceListener</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LOGGING/src/EtwCollector/EtwCollector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Product.props" />

<PropertyGroup>
<TargetFrameworks>net452</TargetFrameworks>
<TargetFrameworks>net452;net462</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding net462 might force us to support this project Microsoft.ApplicationInsights.EtwCollector for a long time. Should we reconsider adding net462 to this project?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, but I was reluctant to make that decision.

<RootNamespace>Microsoft.ApplicationInsights.EtwCollector</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.EtwCollector</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LOGGING/src/Log4NetAppender/Log4NetAppender.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Product.props" />

<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;net462;netstandard2.0</TargetFrameworks>
<RootNamespace>Microsoft.ApplicationInsights.Log4NetAppender</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.Log4NetAppender</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LOGGING/src/NLogTarget/NLogTarget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Product.props" />

<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;net462;netstandard2.0</TargetFrameworks>
<RootNamespace>Microsoft.ApplicationInsights.NLogTarget</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.NLogTarget</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LOGGING/src/TraceListener/TraceListener.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(PropsRoot)\Product.props" />

<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;net462;netstandard2.0</TargetFrameworks>
<RootNamespace>Microsoft.ApplicationInsights.TraceListener</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.TraceListener</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LOGGING/test/EtwCollector.Tests/EtwCollector.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.ApplicationInsights.EtwCollector.Tests</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.EtwCollector.Tests</AssemblyName>
<TargetFrameworks>net46</TargetFrameworks>
<TargetFrameworks>net46;net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.ApplicationInsights.Log4NetAppender.Tests</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.Log4NetAppender.Tests</AssemblyName>
<TargetFrameworks>net452;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net452;net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,7 +16,7 @@
<ProjectReference Include="..\..\src\Log4NetAppender\Log4NetAppender.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net462'">
<Reference Include="System.Net.Http" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions LOGGING/test/NLogTarget.Tests/NLogTarget.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.ApplicationInsights.NLogTarget.Tests</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.NLogTarget.Tests</AssemblyName>
<TargetFrameworks>net452;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net452;net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,7 +16,7 @@
<ProjectReference Include="..\..\src\NLogTarget\NLogTarget.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net462'">
<Reference Include="System.Net.Http" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void TraceListenerStoresDataItemsConvertedToStringInTraceMessage()
Assert.AreEqual(expectedEventId.ToString(InvariantCulture), telemetry.Properties["EventId"]);
}

#if NET452
#if NETFRAMEWORK
[TestMethod]
[TestCategory("TraceListener")]
public void TraceListenerSendsResumeAsVerbose()
Expand Down Expand Up @@ -357,7 +357,7 @@ public void TraceEventDoesNotThrowArgumentNullExceptionWhenArgsIsNull()
source.TraceInformation("TestMessage");
}

#if NET452
#if NETFRAMEWORK
[TestMethod]
public void TraceEventDoesNotStoreLogicalOperationStackInTelemetryPropertiesBecauseLongValuesAreRejected()
{
Expand Down Expand Up @@ -420,7 +420,7 @@ private void ValidateASingleMessageActionBased(
{
listener.TraceOutputOptions = options;
TraceEventCache traceEventCache = new TraceEventCache();
#if NET452
#if NETFRAMEWORK
PrivateObject privateObject = new PrivateObject(traceEventCache);
privateObject.SetField("timeStamp", DateTime.Now.Ticks);
privateObject.SetField("stackTrace", "Environment.StackTrace");
Expand Down
4 changes: 2 additions & 2 deletions LOGGING/test/TraceListener.Tests/TraceListener.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.ApplicationInsights.TraceListener.Tests</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.TraceListener.Tests</AssemblyName>
<TargetFrameworks>net452;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net452;net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,7 +16,7 @@
<ProjectReference Include="..\..\src\TraceListener\TraceListener.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'net462'">
<Reference Include="System.Net.Http" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<AssemblyName>Microsoft.ApplicationInsights.AspNetCore</AssemblyName>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>net461;net462;netstandard2.0</TargetFrameworks>

<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);AI_ASPNETCORE_WEB;</DefineConstants>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,10 @@ public static void ConfigureApplicationInsightsTelemetryModuleWorksWithoutOption
services.AddSingleton<ITelemetryModule, TestTelemetryModule>();

//ACT
#pragma warning disable CS0618 // Type or member is obsolete
services.ConfigureTelemetryModule<TestTelemetryModule>
(module => module.CustomProperty = "mycustomproperty");
#pragma warning restore CS0618 // Type or member is obsolete
services.AddApplicationInsightsTelemetry();
IServiceProvider serviceProvider = services.BuildServiceProvider();

Expand Down Expand Up @@ -1045,7 +1047,9 @@ public static void ConfigureRequestTrackingTelemetryCustomOptions(string configT
{
o.RequestCollectionOptions.InjectResponseHeaders = isEnable;
o.RequestCollectionOptions.TrackExceptions = isEnable;
#pragma warning disable CS0618 // Type or member is obsolete
o.RequestCollectionOptions.EnableW3CDistributedTracing = isEnable;
#pragma warning restore CS0618 // Type or member is obsolete
};
filePath = null;
}
Expand All @@ -1062,7 +1066,9 @@ public static void ConfigureRequestTrackingTelemetryCustomOptions(string configT

Assert.Equal(isEnable, requestTrackingModule.CollectionOptions.InjectResponseHeaders);
Assert.Equal(isEnable, requestTrackingModule.CollectionOptions.TrackExceptions);
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal(isEnable, requestTrackingModule.CollectionOptions.EnableW3CDistributedTracing);
#pragma warning restore CS0618 // Type or member is obsolete
}

[Fact]
Expand All @@ -1074,7 +1080,9 @@ public static void ConfigureApplicationInsightsTelemetryModuleThrowsIfConfigureI

//ACT and VALIDATE
Assert.Throws<ArgumentNullException>(() => services.ConfigureTelemetryModule<TestTelemetryModule>((Action<TestTelemetryModule, ApplicationInsightsServiceOptions>)null));
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Throws<ArgumentNullException>(() => services.ConfigureTelemetryModule<TestTelemetryModule>((Action<TestTelemetryModule>)null));
#pragma warning restore CS0618 // Type or member is obsolete
}

[Fact]
Expand Down Expand Up @@ -1455,7 +1463,9 @@ public static void W3CIsEnabledByDefault()
IServiceProvider serviceProvider = services.BuildServiceProvider();
var telemetryConfiguration = serviceProvider.GetTelemetryConfiguration();

#pragma warning disable CS0618 // Type or member is obsolete
Assert.DoesNotContain(telemetryConfiguration.TelemetryInitializers, t => t is W3COperationCorrelationTelemetryInitializer);
#pragma warning restore CS0618 // Type or member is obsolete

var modules = serviceProvider.GetServices<ITelemetryModule>().ToList();

Expand Down Expand Up @@ -1490,8 +1500,12 @@ public static void LoggerCallbackIsInvoked()
bool firstLoggerCallback = false;
bool secondLoggerCallback = false;

#pragma warning disable CS0618 // Type or member is obsolete
loggerProvider.AddApplicationInsights(serviceProvider, (s, level) => true, () => firstLoggerCallback = true);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
loggerProvider.AddApplicationInsights(serviceProvider, (s, level) => true, () => secondLoggerCallback = true);
#pragma warning restore CS0618 // Type or member is obsolete

Assert.True(firstLoggerCallback);
Assert.False(secondLoggerCallback);
Expand All @@ -1506,8 +1520,12 @@ public static void NullLoggerCallbackAlowed()

var loggerProvider = new MockLoggingFactory();

#pragma warning disable CS0618 // Type or member is obsolete
loggerProvider.AddApplicationInsights(serviceProvider, (s, level) => true, null);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
loggerProvider.AddApplicationInsights(serviceProvider, (s, level) => true, null);
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$(PropsRoot)\_Signing.props" />
<Import Project="$(PropsRoot)\Test.props" />

<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net461</TargetFrameworks>
<TargetFrameworks>net461;net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<DelaySign Condition=" '$(OS)' == 'Windows_NT' ">true</DelaySign>
<PreserveCompilationContext>true</PreserveCompilationContext>
Expand Down Expand Up @@ -34,10 +33,6 @@
</ItemGroup>

<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Generator>SettingsSingleFileGenerator</Generator>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ public void InitializeDoesNotOverrideExistingProperty()
{
var initializer = new AspNetCoreEnvironmentTelemetryInitializer(new HostingEnvironment() { EnvironmentName = "Production"});
var telemetry = new RequestTelemetry();
#pragma warning disable CS0618 // Type or member is obsolete
telemetry.Context.Properties.Add("AspNetCoreEnvironment", "Development");
#pragma warning restore CS0618 // Type or member is obsolete
initializer.Initialize(telemetry);

#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal("Development", telemetry.Context.Properties["AspNetCoreEnvironment"]);
#pragma warning restore CS0618 // Type or member is obsolete
}

[Fact]
Expand All @@ -32,7 +36,9 @@ public void InitializeSetsCurrentEnvironmentNameToProperty()
var telemetry = new RequestTelemetry();
initializer.Initialize(telemetry);

#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal("Production", telemetry.Context.Properties["AspNetCoreEnvironment"]);
#pragma warning restore CS0618 // Type or member is obsolete
}
}
}
Loading