Skip to content

Commit

Permalink
Updated version of System.Diagnostics.DiagnosticSource to 4.6.0-previ…
Browse files Browse the repository at this point in the history
…ew7 (#1183)

Updated version of System.Diagnostics.DiagnosticSource to 4.6.0-preview7
  • Loading branch information
cijothomas authored Jul 30, 2019
1 parent 215f4a5 commit 302ad90
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This changelog will be used to generate documentation on [release notes page](ht
- [Minor perf improvement by reading Actity.Tag only if required.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1170)
- [Fix: Channels not handling AggregateException, not logging full HttpRequestException.](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1173)
- [Metric Aggregator background thread safeguards added to never throw unhandled exception.](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1179)
- [Updated version of System.Diagnostics.DiagnosticSource to 4.6.0-preview7.19362.9. Also remove marking SDK as CLS-Compliant](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1183)

## Version 2.11.0-beta1
- [Performance fixes: Support Head Sampling; Remove NewGuid(); Sampling Flags; etc... ](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1158)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<PackageReference Include="Moq" Version="4.10.0" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<PackageReference Include="Moq" Version="4.10.0" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TelemetryConfigurationExtensionsTests
public void Metrics_DefaultPipeline()
{
TelemetryConfiguration defaultTelemetryPipeline = TelemetryConfiguration.Active;
//using (defaultTelemetryPipeline)
// using (defaultTelemetryPipeline)
{
Metrics_SpecifiedPipeline(defaultTelemetryPipeline);
TestUtil.CompleteDefaultAggregationCycle(defaultTelemetryPipeline.GetMetricManager());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.DataContracts;

[TestClass]
public class AppInsightsStandaloneTests
Expand All @@ -31,24 +33,32 @@ public void Cleanup()
[TestMethod]
public void AppInsightsDllCouldRunStandalone()
{
var dependencyId = RunTestApplication(false, "guid");
// This tests if ApplicationInsights.dll can work standalone without System.DiagnosticSource (for uses like in a powershell script)
// Its hard to mock this with plain unit tests, so we spin up a dummy application, copy just ApplicationInsights.dll
// and run it.
var dependencyId = RunTestApplication("guid");
Assert.IsFalse(dependencyId.Contains("guid"));
}

[TestMethod]
public void AppInsightsUsesActivityWhenDiagnosticSourceIsAvailable()
{
var dependencyId = RunTestApplication(true, "guid");
Assert.IsTrue(dependencyId.StartsWith("|guid."));
}

private string RunTestApplication(bool withDiagnosticSource, string operationId)
{
if (withDiagnosticSource)
// Regular use case - System.DiagnosticSource is available. Regular unit test can cover this scenario.
var config = new TelemetryConfiguration();
config.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
var tc = new TelemetryClient(config);
using (var requestOperation = tc.StartOperation<RequestTelemetry>("request", "guid"))
{
File.Copy("System.Diagnostics.DiagnosticSource.dll", $"{this.tempPath}\\System.Diagnostics.DiagnosticSource.dll");
using (var dependencyOperation = tc.StartOperation<DependencyTelemetry>("dependency", "guid"))
{
Assert.IsTrue(dependencyOperation.Telemetry.Id.StartsWith("|guid."));
tc.TrackTrace("Hello World!");
}
}
}

private string RunTestApplication(string operationId)
{
var fileName = $"{this.tempPath}\\ActivityTest.exe";

Assert.IsTrue(CreateTestApplication(fileName));
Expand All @@ -68,7 +78,10 @@ private string RunTestApplication(bool withDiagnosticSource, string operationId)
p.Start();

Assert.IsTrue(p.WaitForExit(10000));
Trace.WriteLine(p.StandardOutput.ReadToEnd());
Trace.WriteLine(p.StandardError.ReadToEnd());
Assert.AreEqual(0, p.ExitCode);


return p.StandardOutput.ReadToEnd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
<Reference Include="System.ComponentModel.Composition" />
<PackageReference Include="System.Console" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<PackageReference Include="System.Diagnostics.FileVersionInfo" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.StackTrace" Version="4.3.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<ProjectReference Include="..\..\..\src\ServerTelemetryChannel\TelemetryChannel.csproj">
<Project>{3273d899-d9b3-44fe-b3ab-578e18b2ef90}</Project>
<Name>TelemetryChannel</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="System.Security.AccessControl" Version="4.3.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<ProjectReference Include="..\..\..\src\ServerTelemetryChannel\TelemetryChannel.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<ProjectReference Include="..\..\..\src\ServerTelemetryChannel\TelemetryChannel.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<PackageReference Include="Castle.Core" Version="4.4.0" />
<ProjectReference Include="..\..\..\src\ServerTelemetryChannel\TelemetryChannel.csproj" />
<EmbeddedResource Include="..\..\..\src\ServerTelemetryChannel\ApplicationInsights.config.install.xdt">
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ApplicationInsights/ActivityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static bool Initialize()
{
try
{
Assembly.Load(new AssemblyName("System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"));
Assembly.Load(new AssemblyName("System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"));
return true;
}
catch (System.IO.FileNotFoundException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventRegister" Version="1.1.28" Condition="$(OS) == 'Windows_NT'">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0-preview7.19362.9" />
<Reference Include="System.Net.Http" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Runtime.InteropServices;

[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]

[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.Net45.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.Net46.Tests" + AssemblyInfo.PublicKey)]
Expand Down
1 change: 0 additions & 1 deletion src/ServerTelemetryChannel/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Runtime.InteropServices;

[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]

[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.Net45.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.Net46.Tests" + AssemblyInfo.PublicKey)]
Expand Down

0 comments on commit 302ad90

Please sign in to comment.