Merge branch 'develop' into rajrang/flushasync-exp
This commit is contained in:
Коммит
51a6b34895
|
@ -0,0 +1,11 @@
|
|||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "nuget"
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "daily"
|
|
@ -18,12 +18,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CompareNETObjects" Version="4.64.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net452' ">
|
||||
|
|
|
@ -17,16 +17,14 @@
|
|||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.0.0" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
<Reference Include="System" />
|
||||
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<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.Console" Version="4.3.1" />
|
||||
<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" />
|
||||
|
@ -37,13 +35,12 @@
|
|||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<PackageReference Include="System.Reflection.Metadata" Version="1.4.2" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
|
||||
<PackageReference Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
|
||||
<PackageReference Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
|
||||
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.3.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
|
||||
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
|
||||
<PackageReference Include="System.Xml.ReaderWriter" Version="4.3.0" />
|
||||
|
|
|
@ -17,12 +17,10 @@
|
|||
<ProjectReference Include="..\..\..\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
<ProjectReference Include="..\..\..\Test\Microsoft.ApplicationInsights.Test\ApplicationInsightsTypes\ApplicationInsightsTypes.csproj" />
|
||||
<PackageReference Include="Microsoft.Web.Xdt" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
<PackageReference Include="Castle.Core" Version="4.4.0" />
|
||||
<ProjectReference Include="..\..\..\src\ServerTelemetryChannel\TelemetryChannel.csproj" />
|
||||
<EmbeddedResource Include="..\..\..\src\ServerTelemetryChannel\ApplicationInsights.config.install.xdt">
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
<ProjectReference Include="..\..\..\Test\Microsoft.ApplicationInsights.Test\ApplicationInsightsTypes\ApplicationInsightsTypes.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\ServerTelemetryChannel\TelemetryChannel.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
|
||||
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
## VNext
|
||||
|
||||
- [Fix PropertyFetcher error when used with multiple types](https://github.com/microsoft/ApplicationInsights-dotnet/issues/2194)
|
||||
|
||||
## Version 2.17.0
|
||||
- [Fix: telemetry parent id when using W3C activity format in TelemetryDiagnosticSourceListener](https://github.com/microsoft/ApplicationInsights-dotnet/issues/2142)
|
||||
- [Add ingestion response duration for transmission to data delivery status - TransmissionStatusEventArgs](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2157)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<ProjectReference Include="..\..\..\BASE\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
<PackageReference Include="log4net" Version="2.0.10" />
|
||||
<PackageReference Include="log4net" Version="2.0.12" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.42" />
|
||||
<ProjectReference Include="..\..\..\BASE\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="log4net" Version="2.0.10" />
|
||||
<PackageReference Include="log4net" Version="2.0.12" />
|
||||
<ProjectReference Include="..\..\..\BASE\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
<ProjectReference Include="..\..\src\Log4NetAppender\Log4NetAppender.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="NLog" Version="4.6.8" />
|
||||
<ProjectReference Include="..\..\..\BASE\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="log4net" Version="2.0.8" />
|
||||
<PackageReference Include="log4net" Version="2.0.12" />
|
||||
<ProjectReference Include="..\..\..\BASE\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
<ProjectReference Include="..\..\src\TraceListener\TraceListener.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.Web.Xdt" Version="3.0.0" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
internal class PropertyFetcher
|
||||
{
|
||||
private readonly string propertyName;
|
||||
private PropertyFetch innerFetcher;
|
||||
private volatile PropertyFetch innerFetcher;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PropertyFetcher"/> class.
|
||||
|
@ -29,32 +29,46 @@
|
|||
/// <returns>Returns the value of the property if it exists in the provided object. Otherwise returns null.</returns>
|
||||
public object Fetch(object obj)
|
||||
{
|
||||
if (this.innerFetcher == null)
|
||||
PropertyFetch fetch = this.innerFetcher;
|
||||
Type objType = obj?.GetType();
|
||||
|
||||
if (fetch == null || fetch.Type != objType)
|
||||
{
|
||||
this.innerFetcher = PropertyFetch.FetcherForProperty(obj.GetType().GetTypeInfo().GetDeclaredProperty(this.propertyName));
|
||||
this.innerFetcher = fetch = PropertyFetch.FetcherForProperty(objType, objType?.GetTypeInfo()?.GetDeclaredProperty(this.propertyName));
|
||||
}
|
||||
|
||||
return this.innerFetcher?.Fetch(obj);
|
||||
return fetch?.Fetch(obj);
|
||||
}
|
||||
|
||||
private class PropertyFetch
|
||||
{
|
||||
public PropertyFetch(Type type)
|
||||
{
|
||||
this.Type = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the object that the property is fetched from. For well-known static methods that
|
||||
/// aren't actually property getters this will return null.
|
||||
/// </summary>
|
||||
internal Type Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a property fetcher from a .NET Reflection PropertyInfo class that
|
||||
/// represents a property of a particular type.
|
||||
/// </summary>
|
||||
public static PropertyFetch FetcherForProperty(PropertyInfo propertyInfo)
|
||||
public static PropertyFetch FetcherForProperty(Type type, PropertyInfo propertyInfo)
|
||||
{
|
||||
if (propertyInfo == null)
|
||||
{
|
||||
// returns null on any fetch.
|
||||
return new PropertyFetch();
|
||||
return new PropertyFetch(type);
|
||||
}
|
||||
|
||||
var typedPropertyFetcher = typeof(TypedFetchProperty<,>);
|
||||
var instantiatedTypedPropertyFetcher = typedPropertyFetcher.GetTypeInfo().MakeGenericType(
|
||||
propertyInfo.DeclaringType, propertyInfo.PropertyType);
|
||||
return (PropertyFetch)Activator.CreateInstance(instantiatedTypedPropertyFetcher, propertyInfo);
|
||||
return (PropertyFetch)Activator.CreateInstance(instantiatedTypedPropertyFetcher, type, propertyInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -69,7 +83,7 @@
|
|||
{
|
||||
private readonly Func<TObject, TProperty> propertyFetch;
|
||||
|
||||
public TypedFetchProperty(PropertyInfo property)
|
||||
public TypedFetchProperty(Type type, PropertyInfo property) : base(type)
|
||||
{
|
||||
this.propertyFetch = (Func<TObject, TProperty>)property.GetMethod.CreateDelegate(typeof(Func<TObject, TProperty>));
|
||||
}
|
||||
|
|
|
@ -39,15 +39,15 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.1" />
|
||||
<PackageReference Include="System.Reactive.Linq" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
|
||||
<ProjectReference Include="..\IntegrationTests.WebApp\IntegrationTests.WebApp.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
internal class PropertyFetcher
|
||||
{
|
||||
private readonly string propertyName;
|
||||
private PropertyFetch innerFetcher;
|
||||
private volatile PropertyFetch innerFetcher;
|
||||
|
||||
public PropertyFetcher(string propertyName)
|
||||
{
|
||||
|
@ -20,33 +20,47 @@
|
|||
|
||||
public object Fetch(object obj)
|
||||
{
|
||||
if (this.innerFetcher == null)
|
||||
PropertyFetch fetch = this.innerFetcher;
|
||||
Type objType = obj?.GetType();
|
||||
|
||||
if (fetch == null || fetch.Type != objType)
|
||||
{
|
||||
this.innerFetcher = PropertyFetch.FetcherForProperty(obj?.GetType()?.GetTypeInfo()?.GetDeclaredProperty(this.propertyName));
|
||||
this.innerFetcher = fetch = PropertyFetch.FetcherForProperty(objType, objType?.GetTypeInfo()?.GetDeclaredProperty(this.propertyName));
|
||||
}
|
||||
|
||||
return this.innerFetcher?.Fetch(obj);
|
||||
return fetch?.Fetch(obj);
|
||||
}
|
||||
|
||||
// see https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs
|
||||
private class PropertyFetch
|
||||
{
|
||||
public PropertyFetch(Type type)
|
||||
{
|
||||
this.Type = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the object that the property is fetched from. For well-known static methods that
|
||||
/// aren't actually property getters this will return null.
|
||||
/// </summary>
|
||||
internal Type Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a property fetcher from a .NET Reflection PropertyInfo class that
|
||||
/// represents a property of a particular type.
|
||||
/// </summary>
|
||||
public static PropertyFetch FetcherForProperty(PropertyInfo propertyInfo)
|
||||
public static PropertyFetch FetcherForProperty(Type type, PropertyInfo propertyInfo)
|
||||
{
|
||||
if (propertyInfo == null)
|
||||
{
|
||||
// returns null on any fetch.
|
||||
return new PropertyFetch();
|
||||
return new PropertyFetch(type);
|
||||
}
|
||||
|
||||
var typedPropertyFetcher = typeof(TypedFetchProperty<,>);
|
||||
var instantiatedTypedPropertyFetcher = typedPropertyFetcher.GetTypeInfo().MakeGenericType(
|
||||
propertyInfo.DeclaringType, propertyInfo.PropertyType);
|
||||
return (PropertyFetch)Activator.CreateInstance(instantiatedTypedPropertyFetcher, propertyInfo);
|
||||
return (PropertyFetch)Activator.CreateInstance(instantiatedTypedPropertyFetcher, type, propertyInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -61,7 +75,7 @@
|
|||
{
|
||||
private readonly Func<TObject, TProperty> propertyFetch;
|
||||
|
||||
public TypedFetchProperty(PropertyInfo property)
|
||||
public TypedFetchProperty(Type type, PropertyInfo property) : base(type)
|
||||
{
|
||||
this.propertyFetch = (Func<TObject, TProperty>)property.GetMethod.CreateDelegate(typeof(Func<TObject, TProperty>));
|
||||
}
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
namespace Microsoft.ApplicationInsights.Tests
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using Microsoft.ApplicationInsights.Common;
|
||||
using Microsoft.ApplicationInsights.DependencyCollector.Implementation;
|
||||
using VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
[TestClass]
|
||||
public class PropertyFetcherTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void FetchWithMultipleObjectTypes()
|
||||
{
|
||||
PropertyFetcher fetcher = new PropertyFetcher("Name");
|
||||
|
||||
string value1 = (string)fetcher.Fetch(new TestClass1 { Name = "Value1" });
|
||||
string value2 = (string)fetcher.Fetch(new TestClass2 { Name = "Value2" });
|
||||
|
||||
Assert.AreEqual("Value1", value1);
|
||||
Assert.AreEqual("Value2", value2);
|
||||
}
|
||||
|
||||
private class TestClass1
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
private class TestClass2
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="System.Buffers" Version="4.5.1" />
|
||||
<ProjectReference Include="..\..\..\..\BASE\src\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.csproj" />
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -38,6 +38,10 @@
|
|||
<PackageReference Include="Moq" Version="4.8.2" />
|
||||
<PackageReference Include="OpenCover" Version="4.7.922" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="Shared" />
|
||||
</Project>
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer
|
|||
public void AzureIMSGetFieldByNameFailsWithException()
|
||||
{
|
||||
AzureInstanceComputeMetadata md = new AzureInstanceComputeMetadata();
|
||||
Assert.Throws(typeof(ArgumentOutOfRangeException), () => md.GetValueForField("not-a-field"));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => md.GetValueForField("not-a-field"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
@ -117,17 +117,17 @@ namespace Microsoft.ApplicationInsights.WindowsServer
|
|||
}
|
||||
}
|
||||
|
||||
Assert.Equal(1, metrics.Count);
|
||||
Assert.Single(metrics);
|
||||
Assert.Equal("Exceptions thrown", metrics[0].Key.Name);
|
||||
|
||||
var dims = metrics[0].Key.Dimensions;
|
||||
Assert.Equal(1, dims.Count);
|
||||
|
||||
Assert.True(dims["problemId"].StartsWith(typeof(Exception).FullName, StringComparison.Ordinal));
|
||||
Assert.StartsWith(typeof(Exception).FullName, dims["problemId"], StringComparison.Ordinal);
|
||||
|
||||
int nameStart = dims["problemId"].IndexOf(" at ", StringComparison.OrdinalIgnoreCase) + 4;
|
||||
|
||||
Assert.True(dims["problemId"].Substring(nameStart).StartsWith(typeof(FirstChanceExceptionStatisticsTelemetryModuleTest).FullName + "." + nameof(this.FirstChanceExceptionStatisticsTelemetryModuleTracksMetricWithTypeAndMethodOnException), StringComparison.Ordinal));
|
||||
Assert.StartsWith(typeof(FirstChanceExceptionStatisticsTelemetryModuleTest).FullName + "." + nameof(this.FirstChanceExceptionStatisticsTelemetryModuleTracksMetricWithTypeAndMethodOnException), dims["problemId"].Substring(nameStart), StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -175,7 +175,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer
|
|||
}
|
||||
}
|
||||
|
||||
Assert.Equal(1, metrics.Count);
|
||||
Assert.Single(metrics);
|
||||
Assert.Equal("Exceptions thrown", metrics[0].Key.Name);
|
||||
|
||||
var dims = metrics[0].Key.Dimensions;
|
||||
|
@ -221,7 +221,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer
|
|||
}
|
||||
}
|
||||
|
||||
Assert.Equal(1, metrics.Count);
|
||||
Assert.Single(metrics);
|
||||
Assert.Equal("Exceptions thrown", metrics[0].Key.Name);
|
||||
|
||||
var dims = metrics[0].Key.Dimensions;
|
||||
|
@ -265,7 +265,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer
|
|||
}
|
||||
}
|
||||
|
||||
Assert.Equal(1, metrics.Count);
|
||||
Assert.Single(metrics);
|
||||
Assert.Equal("Exceptions thrown", metrics[0].Key.Name);
|
||||
|
||||
var dims = metrics[0].Key.Dimensions;
|
||||
|
@ -520,7 +520,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer
|
|||
}
|
||||
}
|
||||
|
||||
Assert.Equal(1, metrics.Count);
|
||||
Assert.Single(metrics);
|
||||
Assert.Equal("Exceptions thrown", metrics[0].Key.Name);
|
||||
|
||||
Assert.Equal(1, metrics[0].Value, 15);
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.1" />
|
||||
<PackageReference Include="xunit.assert" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.core" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.extensibility.core" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.extensibility.execution" Version="2.3.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
|
||||
|
@ -42,7 +42,7 @@
|
|||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
|
||||
<PackageReference Include="NETStandard.HttpListener" Version="1.0.2" />
|
||||
<PackageReference Include="NETStandard.HttpListener" Version="1.0.3.5" />
|
||||
<PackageReference Include="System.Diagnostics.StackTrace" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче