Incorporate new Telemetry package
This commit is contained in:
Родитель
f4f7c2fd99
Коммит
f0c8b08d72
|
@ -1,15 +1,15 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.22808.1
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8B66E199-1AFE-4B68-AC71-4521C46EC4CD}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D75011A4-DEEE-48DE-BB83-CE042F2AC05B}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Notification", "src\Microsoft.Framework.Notification\Microsoft.Framework.Notification.xproj", "{4C660D0B-32C5-43D0-899D-73FF60352172}"
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TelemetryAdapter", "src\Microsoft.Framework.TelemetryAdapter\Microsoft.Framework.TelemetryAdapter.xproj", "{87808F3C-362E-4261-AA4A-EE40BA39D64E}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Notification.Test", "test\Microsoft.Framework.Notification.Test\Microsoft.Framework.Notification.Test.xproj", "{51E95E1C-FE88-4DAF-8E03-3FC3153A03AF}"
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TelemetryAdapter.Test", "test\Microsoft.Framework.TelemetryAdapter.Test\Microsoft.Framework.TelemetryAdapter.Test.xproj", "{FB993EEE-FF13-4454-BF49-F60DD0A531F7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -17,20 +17,20 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4C660D0B-32C5-43D0-899D-73FF60352172}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4C660D0B-32C5-43D0-899D-73FF60352172}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C660D0B-32C5-43D0-899D-73FF60352172}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C660D0B-32C5-43D0-899D-73FF60352172}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{51E95E1C-FE88-4DAF-8E03-3FC3153A03AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{51E95E1C-FE88-4DAF-8E03-3FC3153A03AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{51E95E1C-FE88-4DAF-8E03-3FC3153A03AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{51E95E1C-FE88-4DAF-8E03-3FC3153A03AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{87808F3C-362E-4261-AA4A-EE40BA39D64E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{87808F3C-362E-4261-AA4A-EE40BA39D64E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{87808F3C-362E-4261-AA4A-EE40BA39D64E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{87808F3C-362E-4261-AA4A-EE40BA39D64E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FB993EEE-FF13-4454-BF49-F60DD0A531F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FB993EEE-FF13-4454-BF49-F60DD0A531F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FB993EEE-FF13-4454-BF49-F60DD0A531F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB993EEE-FF13-4454-BF49-F60DD0A531F7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{4C660D0B-32C5-43D0-899D-73FF60352172} = {8B66E199-1AFE-4B68-AC71-4521C46EC4CD}
|
||||
{51E95E1C-FE88-4DAF-8E03-3FC3153A03AF} = {D75011A4-DEEE-48DE-BB83-CE042F2AC05B}
|
||||
{87808F3C-362E-4261-AA4A-EE40BA39D64E} = {8B66E199-1AFE-4B68-AC71-4521C46EC4CD}
|
||||
{FB993EEE-FF13-4454-BF49-F60DD0A531F7} = {D75011A4-DEEE-48DE-BB83-CE042F2AC05B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetlitedev/api/v2" />
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
EventNotification
|
||||
===
|
||||
|
||||
Notice
|
||||
-------
|
||||
|
||||
The infrastructure for publishing notifications has moved to the .Net framework. See the new `TelemetrySource` and `TelemetryListerner` APIs in the `System.Diagnostics.Tracing.Telemetry` package. The infrastructure provided here is for subscribing to events using runtime-generated proxies.
|
||||
|
||||
AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/t1bk7hrnqqvlx0fa/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/EventNotification/branch/dev)
|
||||
|
||||
Travis: [![Travis](https://travis-ci.org/aspnet/EventNotification.svg?branch=dev)](https://travis-ci.org/aspnet/EventNotification)
|
||||
|
||||
Event notification system for broadcasting application state and configuration.
|
||||
|
||||
This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo.
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
{
|
||||
public interface INotifier
|
||||
{
|
||||
void EnlistTarget(object target);
|
||||
|
||||
bool ShouldNotify(string notificationName);
|
||||
|
||||
void Notify(string notificationName, object parameters);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>4c660d0b-32c5-43d0-899d-73ff60352172</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AssemblyName>Microsoft.Framework.Notification</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<RootNamespace>Microsoft.Framework.Notification</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Framework.DependencyInjection.Extensions;
|
||||
using Microsoft.Framework.Notification;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddNotifier(this IServiceCollection services)
|
||||
{
|
||||
#if PROXY_SUPPORT
|
||||
services.TryAddSingleton<INotifierMethodAdapter, ProxyNotifierMethodAdapter>();
|
||||
#else
|
||||
services.TryAddSingleton<INotifierMethodAdapter, ReflectionNotifierMethodAdapter>();
|
||||
#endif
|
||||
services.TryAddSingleton<INotifier, Notifier>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "An event notification system.",
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*",
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
"compilationOptions": {
|
||||
"define": [
|
||||
"TRACE"
|
||||
]
|
||||
},
|
||||
"frameworks": {
|
||||
"net45": {
|
||||
"compilationOptions": { "define": [ "PROXY_SUPPORT" ] },
|
||||
"frameworkAssemblies": {
|
||||
"System.Linq": "",
|
||||
"System.Collections.Concurrent": ""
|
||||
}
|
||||
},
|
||||
"dotnet": {
|
||||
"compilationOptions": { "define": [ "PROXY_SUPPORT" ] },
|
||||
"dependencies": {
|
||||
"System.ComponentModel": "4.0.1-beta-*",
|
||||
"System.Collections.Concurrent": "4.0.11-beta-*",
|
||||
"System.Collections": "4.0.11-beta-*",
|
||||
"System.Diagnostics.Debug": "4.0.11-beta-*",
|
||||
"System.Globalization": "4.0.11-beta-*",
|
||||
"System.Linq": "4.0.1-beta-*",
|
||||
"System.Linq.Expressions": "4.0.11-beta-*",
|
||||
"System.Threading": "4.0.11-beta-*",
|
||||
"System.Reflection": "4.0.11-beta-*",
|
||||
"System.Reflection.Emit": "4.0.1-beta-*",
|
||||
"System.Reflection.Emit.Lightweight": "4.0.1-beta-*",
|
||||
"System.Reflection.Extensions": "4.0.1-beta-*",
|
||||
"System.Reflection.TypeExtensions": "4.0.1-beta-*",
|
||||
"System.Resources.ResourceManager": "4.0.1-beta-*",
|
||||
"System.Runtime": "4.0.21-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.11-beta-*"
|
||||
}
|
||||
},
|
||||
"netcore50": {
|
||||
"dependencies": {
|
||||
"System.ComponentModel": "4.0.1-beta-*",
|
||||
"System.Collections.Concurrent": "4.0.11-beta-*",
|
||||
"System.Collections": "4.0.11-beta-*",
|
||||
"System.Diagnostics.Debug": "4.0.11-beta-*",
|
||||
"System.Globalization": "4.0.11-beta-*",
|
||||
"System.Linq": "4.0.1-beta-*",
|
||||
"System.Linq.Expressions": "4.0.11-beta-*",
|
||||
"System.Threading": "4.0.11-beta-*",
|
||||
"System.Reflection": "4.0.11-beta-*",
|
||||
"System.Reflection.Extensions": "4.0.1-beta-*",
|
||||
"System.Reflection.TypeExtensions": "4.0.1-beta-*",
|
||||
"System.Resources.ResourceManager": "4.0.1-beta-*",
|
||||
"System.Runtime": "4.0.21-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.11-beta-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,20 +6,20 @@ using System.Collections.Concurrent;
|
|||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class Notifier : INotifier
|
||||
public class DefaultTelemetrySourceAdapter : TelemetrySourceAdapter
|
||||
{
|
||||
private readonly NotificationListenerCache _listeners = new NotificationListenerCache();
|
||||
private readonly ListenerCache _listeners = new ListenerCache();
|
||||
|
||||
private readonly INotifierMethodAdapter _methodAdapter;
|
||||
private readonly ITelemetrySourceMethodAdapter _methodAdapter;
|
||||
|
||||
public Notifier(INotifierMethodAdapter methodAdapter)
|
||||
public DefaultTelemetrySourceAdapter(ITelemetrySourceMethodAdapter methodAdapter)
|
||||
{
|
||||
_methodAdapter = methodAdapter;
|
||||
}
|
||||
|
||||
public void EnlistTarget(object target)
|
||||
public override void EnlistTarget(object target)
|
||||
{
|
||||
var typeInfo = target.GetType().GetTypeInfo();
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace Microsoft.Framework.Notification
|
|||
|
||||
foreach (var methodInfo in methodInfos)
|
||||
{
|
||||
var notificationNameAttribute = methodInfo.GetCustomAttribute<NotificationNameAttribute>();
|
||||
var notificationNameAttribute = methodInfo.GetCustomAttribute<TelemetryNameAttribute>();
|
||||
if (notificationNameAttribute != null)
|
||||
{
|
||||
Enlist(notificationNameAttribute.Name, target, methodInfo);
|
||||
|
@ -44,12 +44,17 @@ namespace Microsoft.Framework.Notification
|
|||
entries.Add(new ListenerEntry(target, methodInfo));
|
||||
}
|
||||
|
||||
public bool ShouldNotify(string notificationName)
|
||||
public override bool IsEnabled(string telemetryName)
|
||||
{
|
||||
return _listeners.ContainsKey(notificationName);
|
||||
if (_listeners.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _listeners.ContainsKey(telemetryName);
|
||||
}
|
||||
|
||||
public void Notify(string notificationName, object parameters)
|
||||
public override void WriteTelemetry(string telemetryName, object parameters)
|
||||
{
|
||||
if (parameters == null)
|
||||
{
|
||||
|
@ -57,7 +62,7 @@ namespace Microsoft.Framework.Notification
|
|||
}
|
||||
|
||||
ConcurrentBag<ListenerEntry> entries;
|
||||
if (_listeners.TryGetValue(notificationName, out entries))
|
||||
if (_listeners.TryGetValue(telemetryName, out entries))
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
|
@ -83,9 +88,9 @@ namespace Microsoft.Framework.Notification
|
|||
}
|
||||
}
|
||||
|
||||
private class NotificationListenerCache : ConcurrentDictionary<string, ConcurrentBag<ListenerEntry>>
|
||||
private class ListenerCache : ConcurrentDictionary<string, ConcurrentBag<ListenerEntry>>
|
||||
{
|
||||
public NotificationListenerCache()
|
||||
public ListenerCache()
|
||||
: base(StringComparer.Ordinal)
|
||||
{
|
||||
}
|
|
@ -4,9 +4,9 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public interface INotifierMethodAdapter
|
||||
public interface ITelemetrySourceMethodAdapter
|
||||
{
|
||||
Func<object, object, bool> Adapt(MethodInfo method, Type inputType);
|
||||
}
|
|
@ -7,7 +7,7 @@ using System;
|
|||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public static class ProxyAssembly
|
||||
{
|
||||
|
@ -18,11 +18,11 @@ namespace Microsoft.Framework.Notification.Internal
|
|||
|
||||
static ProxyAssembly()
|
||||
{
|
||||
var assemblyName = new AssemblyName("Microsoft.Framework.Notification.ProxyAssembly");
|
||||
var assemblyName = new AssemblyName("Microsoft.Framework.TelemetryAdapter.ProxyAssembly");
|
||||
var access = AssemblyBuilderAccess.Run;
|
||||
|
||||
AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, access);
|
||||
ModuleBuilder = AssemblyBuilder.DefineDynamicModule("Microsoft.Framework.Notification.ProxyAssembly.dll");
|
||||
ModuleBuilder = AssemblyBuilder.DefineDynamicModule("Microsoft.Framework.TelemetryAdapter.ProxyAssembly.dll");
|
||||
}
|
||||
|
||||
public static TypeBuilder DefineType(
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public abstract class ProxyBase
|
||||
{
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public class ProxyBase<T> : ProxyBase where T : class
|
||||
{
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public class ProxyEnumerable<TSourceElement, TTargetElement> : IEnumerable<TTargetElement>
|
||||
{
|
|
@ -6,7 +6,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public class ProxyList<TSourceElement, TTargetElement> : IReadOnlyList<TTargetElement>
|
||||
{
|
|
@ -7,7 +7,7 @@ using System;
|
|||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public static class ProxyMethodEmitter
|
||||
{
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public class ProxyTypeCache : ConcurrentDictionary<Tuple<Type, Type>, ProxyTypeCacheResult>
|
||||
{
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public class ProxyTypeCacheResult
|
||||
{
|
|
@ -10,7 +10,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public static class ProxyTypeEmitter
|
||||
{
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>87808f3c-362e-4261-aa4a-ee40ba39d64e</ProjectGuid>
|
||||
<RootNamespace>Microsoft.Framework.TelemetryAdapter</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -1,5 +1,5 @@
|
|||
// <auto-generated />
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
@ -8,7 +8,7 @@ namespace Microsoft.Framework.Notification
|
|||
internal static class Resources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("Microsoft.Framework.Notification.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
= new ResourceManager("Microsoft.Framework.TelemetryAdapter.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// The property '{0}' on type '{1}' must define a getter to support proxy generation.
|
|
@ -6,9 +6,9 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class ProxyNotifierMethodAdapter : INotifierMethodAdapter
|
||||
public class ProxyTelemetrySourceMethodAdapter : ITelemetrySourceMethodAdapter
|
||||
{
|
||||
public Func<object, object, bool> Adapt(MethodInfo method, Type inputType)
|
||||
{
|
|
@ -10,9 +10,9 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class ReflectionNotifierMethodAdapter : INotifierMethodAdapter
|
||||
public class ReflectionTelemetrySourceMethodAdapter : ITelemetrySourceMethodAdapter
|
||||
{
|
||||
public Func<object, object, bool> Adapt(MethodInfo method, Type inputType)
|
||||
{
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Framework.DependencyInjection.Extensions;
|
||||
using Microsoft.Framework.TelemetryAdapter;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddTelemetrySourceAdapter(this IServiceCollection services)
|
||||
{
|
||||
#if PROXY_SUPPORT
|
||||
services.TryAddSingleton<ITelemetrySourceMethodAdapter, ProxyTelemetrySourceMethodAdapter>();
|
||||
#else
|
||||
services.TryAddSingleton<ITelemetrySourceMethodAdapter, ReflectionTelemetrySourceMethodAdapter>();
|
||||
#endif
|
||||
services.TryAddSingleton<TelemetrySourceAdapter, DefaultTelemetrySourceAdapter>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class NotificationNameAttribute : Attribute
|
||||
public class TelemetryNameAttribute : Attribute
|
||||
{
|
||||
public NotificationNameAttribute(string name)
|
||||
public TelemetryNameAttribute(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public abstract class TelemetrySourceAdapter : TelemetrySource
|
||||
{
|
||||
public abstract void EnlistTarget(object listener);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "An TelemetryListener implementation which provides duck-typing through generated proxy types.",
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*",
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"System.Diagnostics.Tracing.Telemetry": "4.0.0-beta-*"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"define": [
|
||||
"TRACE"
|
||||
]
|
||||
},
|
||||
"frameworks": {
|
||||
"net45": {
|
||||
"compilationOptions": { "define": [ "PROXY_SUPPORT" ] },
|
||||
"frameworkAssemblies": {
|
||||
"System.Collections.Concurrent": "",
|
||||
"System.Linq": "",
|
||||
"System.Runtime": ""
|
||||
}
|
||||
},
|
||||
"dotnet": {
|
||||
"compilationOptions": { "define": [ "PROXY_SUPPORT" ] },
|
||||
"dependencies": {
|
||||
"System.ComponentModel": "4.0.1-beta-*",
|
||||
"System.Collections.Concurrent": "4.0.11-beta-*",
|
||||
"System.Collections": "4.0.11-beta-*",
|
||||
"System.Diagnostics.Debug": "4.0.11-beta-*",
|
||||
"System.Globalization": "4.0.11-beta-*",
|
||||
"System.Linq": "4.0.1-beta-*",
|
||||
"System.Linq.Expressions": "4.0.11-beta-*",
|
||||
"System.Threading": "4.0.11-beta-*",
|
||||
"System.Reflection": "4.0.11-beta-*",
|
||||
"System.Reflection.Emit": "4.0.1-beta-*",
|
||||
"System.Reflection.Emit.Lightweight": "4.0.1-beta-*",
|
||||
"System.Reflection.Extensions": "4.0.1-beta-*",
|
||||
"System.Reflection.TypeExtensions": "4.0.1-beta-*",
|
||||
"System.Resources.ResourceManager": "4.0.1-beta-*",
|
||||
"System.Runtime": "4.0.21-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.11-beta-*"
|
||||
}
|
||||
},
|
||||
"netcore50": {
|
||||
"dependencies": {
|
||||
"System.ComponentModel": "4.0.1-beta-*",
|
||||
"System.Collections.Concurrent": "4.0.11-beta-*",
|
||||
"System.Collections": "4.0.11-beta-*",
|
||||
"System.Diagnostics.Debug": "4.0.11-beta-*",
|
||||
"System.Globalization": "4.0.11-beta-*",
|
||||
"System.Linq": "4.0.1-beta-*",
|
||||
"System.Linq.Expressions": "4.0.11-beta-*",
|
||||
"System.Threading": "4.0.11-beta-*",
|
||||
"System.Reflection": "4.0.11-beta-*",
|
||||
"System.Reflection.Extensions": "4.0.1-beta-*",
|
||||
"System.Reflection.TypeExtensions": "4.0.1-beta-*",
|
||||
"System.Resources.ResourceManager": "4.0.1-beta-*",
|
||||
"System.Runtime": "4.0.21-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.11-beta-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class NotifierTest
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Microsoft.Framework.Notification
|
|||
{
|
||||
public int OneCallCount { get; private set; }
|
||||
|
||||
[NotificationName("One")]
|
||||
[TelemetryName("One")]
|
||||
public void One()
|
||||
{
|
||||
++OneCallCount;
|
||||
|
@ -23,13 +23,13 @@ namespace Microsoft.Framework.Notification
|
|||
{
|
||||
var notifier = CreateNotifier();
|
||||
|
||||
Assert.False(notifier.ShouldNotify("One"));
|
||||
Assert.False(notifier.ShouldNotify("Two"));
|
||||
Assert.False(notifier.IsEnabled("One"));
|
||||
Assert.False(notifier.IsEnabled("Two"));
|
||||
|
||||
notifier.EnlistTarget(new OneTarget());
|
||||
|
||||
Assert.True(notifier.ShouldNotify("One"));
|
||||
Assert.False(notifier.ShouldNotify("Two"));
|
||||
Assert.True(notifier.IsEnabled("One"));
|
||||
Assert.False(notifier.IsEnabled("Two"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -41,7 +41,7 @@ namespace Microsoft.Framework.Notification
|
|||
notifier.EnlistTarget(target);
|
||||
|
||||
Assert.Equal(0, target.OneCallCount);
|
||||
notifier.Notify("One", new { });
|
||||
notifier.WriteTelemetry("One", new { });
|
||||
Assert.Equal(1, target.OneCallCount);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace Microsoft.Framework.Notification
|
|||
notifier.EnlistTarget(target);
|
||||
|
||||
Assert.Equal(0, target.OneCallCount);
|
||||
notifier.Notify("Two", new { });
|
||||
notifier.WriteTelemetry("Two", new { });
|
||||
Assert.Equal(0, target.OneCallCount);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace Microsoft.Framework.Notification
|
|||
public string Beta { get; private set; }
|
||||
public int Delta { get; private set; }
|
||||
|
||||
[NotificationName("Two")]
|
||||
[TelemetryName("Two")]
|
||||
public void Two(string alpha, string beta, int delta)
|
||||
{
|
||||
Alpha = alpha;
|
||||
|
@ -81,7 +81,7 @@ namespace Microsoft.Framework.Notification
|
|||
|
||||
notifier.EnlistTarget(target);
|
||||
|
||||
notifier.Notify("Two", new { alpha = "ALPHA", beta = "BETA", delta = -1 });
|
||||
notifier.WriteTelemetry("Two", new { alpha = "ALPHA", beta = "BETA", delta = -1 });
|
||||
|
||||
Assert.Equal("ALPHA", target.Alpha);
|
||||
Assert.Equal("BETA", target.Beta);
|
||||
|
@ -96,7 +96,7 @@ namespace Microsoft.Framework.Notification
|
|||
|
||||
notifier.EnlistTarget(target);
|
||||
|
||||
notifier.Notify("Two", new { alpha = "ALPHA", beta = "BETA", delta = -1, extra = this });
|
||||
notifier.WriteTelemetry("Two", new { alpha = "ALPHA", beta = "BETA", delta = -1, extra = this });
|
||||
|
||||
Assert.Equal("ALPHA", target.Alpha);
|
||||
Assert.Equal("BETA", target.Beta);
|
||||
|
@ -110,7 +110,7 @@ namespace Microsoft.Framework.Notification
|
|||
var target = new TwoTarget();
|
||||
|
||||
notifier.EnlistTarget(target);
|
||||
notifier.Notify("Two", new { alpha = "ALPHA", delta = -1 });
|
||||
notifier.WriteTelemetry("Two", new { alpha = "ALPHA", delta = -1 });
|
||||
|
||||
Assert.Equal("ALPHA", target.Alpha);
|
||||
Assert.Null(target.Beta);
|
||||
|
@ -124,7 +124,7 @@ namespace Microsoft.Framework.Notification
|
|||
var target = new ThreeTarget();
|
||||
|
||||
notifier.EnlistTarget(target);
|
||||
notifier.Notify("Three", new
|
||||
notifier.WriteTelemetry("Three", new
|
||||
{
|
||||
person = new Person
|
||||
{
|
||||
|
@ -148,7 +148,7 @@ namespace Microsoft.Framework.Notification
|
|||
{
|
||||
public IPerson Person { get; private set; }
|
||||
|
||||
[NotificationName("Three")]
|
||||
[TelemetryName("Three")]
|
||||
public void Three(IPerson person)
|
||||
{
|
||||
Person = person;
|
||||
|
@ -198,9 +198,9 @@ namespace Microsoft.Framework.Notification
|
|||
public int Value { get; private set; }
|
||||
}
|
||||
|
||||
private static INotifier CreateNotifier()
|
||||
private static TelemetrySourceAdapter CreateNotifier()
|
||||
{
|
||||
return new Notifier(new ProxyNotifierMethodAdapter());
|
||||
return new DefaultTelemetrySourceAdapter(new ProxyTelemetrySourceMethodAdapter());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Framework.Notification.Internal
|
||||
namespace Microsoft.Framework.TelemetryAdapter.Internal
|
||||
{
|
||||
public class ProxyTypeEmitterTest
|
||||
{
|
|
@ -4,21 +4,18 @@
|
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>51e95e1c-fe88-4daf-8e03-3fc3153a03af</ProjectGuid>
|
||||
<RootNamespace>Microsoft.Framework.Notification.Test</RootNamespace>
|
||||
<ProjectGuid>fb993eee-ff13-4454-bf49-f60dd0a531f7</ProjectGuid>
|
||||
<RootNamespace>Microsoft.Framework.TelemetryAdapter.Test</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AssemblyName>Microsoft.Framework.Notification.Test</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -6,15 +6,15 @@ using System.Linq.Expressions;
|
|||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class ProxyNotifierMethodAdapterTest
|
||||
public class ProxyTelemetrySourceMethodAdapterTest
|
||||
{
|
||||
[Fact]
|
||||
public void Adapt_ReturnsTrueForTypeMatch()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ProxyNotifierMethodAdapter();
|
||||
var adapter = new ProxyTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener1();
|
||||
var method = GetMethodInfo<Listener1>(l => l.Listen());
|
||||
|
@ -30,7 +30,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_ReturnsFalseForTypeNotMatching()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ProxyNotifierMethodAdapter();
|
||||
var adapter = new ProxyTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener1();
|
||||
var method = GetMethodInfo<Listener1>(l => l.Listen());
|
||||
|
@ -46,7 +46,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ProxyNotifierMethodAdapter();
|
||||
var adapter = new ProxyTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener2();
|
||||
var value = new { id = 17, name = "Bill" };
|
||||
|
@ -65,7 +65,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters_ExtraEventDataIgnored()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ProxyNotifierMethodAdapter();
|
||||
var adapter = new ProxyTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener2();
|
||||
var value = new { id = 17, name = "Bill", ignored = "hi" };
|
||||
|
@ -84,7 +84,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters_ExtraParametersGetDefaultValues()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ProxyNotifierMethodAdapter();
|
||||
var adapter = new ProxyTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener2();
|
||||
var value = new { };
|
||||
|
@ -103,7 +103,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters_WithProxy()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ProxyNotifierMethodAdapter();
|
||||
var adapter = new ProxyTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener3();
|
||||
var value = new { id = 17, person = new Person() { Name = "Bill" } };
|
|
@ -6,15 +6,15 @@ using System.Linq.Expressions;
|
|||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Framework.Notification
|
||||
namespace Microsoft.Framework.TelemetryAdapter
|
||||
{
|
||||
public class ReflectionNotifierMethodAdapterTest
|
||||
public class ReflectionTelemetrySourceMethodAdapterTest
|
||||
{
|
||||
[Fact]
|
||||
public void Adapt_ReturnsTrueForTypeMatch()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ReflectionNotifierMethodAdapter();
|
||||
var adapter = new ReflectionTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener1();
|
||||
var method = GetMethodInfo<Listener1>(l => l.Listen());
|
||||
|
@ -30,7 +30,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_ReturnsFalseForTypeNotMatching()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ReflectionNotifierMethodAdapter();
|
||||
var adapter = new ReflectionTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener1();
|
||||
var method = GetMethodInfo<Listener1>(l => l.Listen());
|
||||
|
@ -46,7 +46,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ReflectionNotifierMethodAdapter();
|
||||
var adapter = new ReflectionTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener2();
|
||||
var value = new { id = 17, name = "Bill" };
|
||||
|
@ -65,7 +65,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters_ExtraEventDataIgnored()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ReflectionNotifierMethodAdapter();
|
||||
var adapter = new ReflectionTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener2();
|
||||
var value = new { id = 17, name = "Bill", ignored = "hi" };
|
||||
|
@ -84,7 +84,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters_ExtraParametersGetDefaultValues()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ReflectionNotifierMethodAdapter();
|
||||
var adapter = new ReflectionTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener2();
|
||||
var value = new { };
|
||||
|
@ -103,7 +103,7 @@ namespace Microsoft.Framework.Notification
|
|||
public void Adapt_SplatsParameters_CannotCreateProxy()
|
||||
{
|
||||
// Arrange
|
||||
var adapter = new ReflectionNotifierMethodAdapter();
|
||||
var adapter = new ReflectionTelemetrySourceMethodAdapter();
|
||||
|
||||
var listener = new Listener3();
|
||||
var value = new { id = 17, person = new Person() { Name = "Bill" } };
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.Notification": "1.0.0-*",
|
||||
"Microsoft.Framework.TelemetryAdapter": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"compile": "..\\..\\src\\Microsoft.Framework.Notification\\ReflectionNotifierMethodAdapter.cs",
|
||||
"compile": "..\\..\\src\\Microsoft.Framework.TelemetryAdapter\\ReflectionTelemetrySourceMethodAdapter.cs",
|
||||
"compilationOptions": {"define": ["TEST"]},
|
||||
"commands": {
|
||||
"run": "xunit.runner.aspnet",
|
Загрузка…
Ссылка в новой задаче