From a7d5d69ba471070d3f26cf69ad10467143de88c5 Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Tue, 4 Sep 2018 12:26:54 -0700 Subject: [PATCH] Clean up fxcop warnings (#41) --- .../ActivityExtensionsTest.cs | 29 +-- .../ActivityHelperTest.cs | 204 +++++++----------- .../HttpContextHelper.cs | 16 +- .../Properties/AssemblyInfo.cs | 9 +- .../PropertyExtensions.cs | 15 ++ .../TestDiagnosticListener.cs | 15 +- ... WebConfigWithLocationTagTransformTest.cs} | 10 +- 7 files changed, 135 insertions(+), 163 deletions(-) create mode 100644 test/Microsoft.AspNet.TelemetryCorrelation.Tests/PropertyExtensions.cs rename test/Microsoft.AspNet.TelemetryCorrelation.Tests/{WebConfigWithLocaltionTagTransformTest.cs => WebConfigWithLocationTagTransformTest.cs} (99%) diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityExtensionsTest.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityExtensionsTest.cs index 7f0a1f8..8960450 100644 --- a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityExtensionsTest.cs +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityExtensionsTest.cs @@ -1,14 +1,14 @@ // 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.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Linq; -using Xunit; - namespace Microsoft.AspNet.TelemetryCorrelation.Tests { + using System.Collections.Generic; + using System.Collections.Specialized; + using System.Diagnostics; + using System.Linq; + using Xunit; + public class ActivityExtensionsTest { private const string TestActivityName = "Activity.Test"; @@ -46,7 +46,7 @@ public void Restore_Empty_RequestId_Should_Not_Throw_Exception() var activity = new Activity(TestActivityName); var requestHeaders = new NameValueCollection { - { ActivityExtensions.RequestIDHeaderName, "" } + { ActivityExtensions.RequestIDHeaderName, string.Empty } }; Assert.False(activity.Extract(requestHeaders)); @@ -132,30 +132,33 @@ public void Can_Restore_Baggages_When_Some_MalFormat_CorrelationContext_In_Heade } [Theory] - [InlineData("key0=value0,key1=value1,key2=value2,key3=value3,key4=value4,key5=value5,key6=value6,key7=value7,key8=value8,key9=value9," + + [InlineData( + "key0=value0,key1=value1,key2=value2,key3=value3,key4=value4,key5=value5,key6=value6,key7=value7,key8=value8,key9=value9," + "key10=value10,key11=value11,key12=value12,key13=value13,key14=value14,key15=value15,key16=value16,key17=value17,key18=value18,key19=value19," + "key20=value20,key21=value21,key22=value22,key23=value23,key24=value24,key25=value25,key26=value26,key27=value27,key28=value28,key29=value29," + "key30=value30,key31=value31,key32=value32,key33=value33,key34=value34,key35=value35,key36=value36,key37=value37,key38=value38,key39=value39," + "key40=value40,key41=value41,key42=value42,key43=value43,key44=value44,key45=value45,key46=value46,key47=value47,key48=value48,key49=value49," + "key50=value50,key51=value51,key52=value52,key53=value53,key54=value54,key55=value55,key56=value56,key57=value57,key58=value58,key59=value59," + "key60=value60,key61=value61,key62=value62,key63=value63,key64=value64,key65=value65,key66=value66,key67=value67,key68=value68,key69=value69," + - "key70=value70,key71=value71,key72=value72,key73=value73,k100=vx", 1023)] //1023 chars - [InlineData("key0=value0,key1=value1,key2=value2,key3=value3,key4=value4,key5=value5,key6=value6,key7=value7,key8=value8,key9=value9," + + "key70=value70,key71=value71,key72=value72,key73=value73,k100=vx", 1023)] // 1023 chars + [InlineData( + "key0=value0,key1=value1,key2=value2,key3=value3,key4=value4,key5=value5,key6=value6,key7=value7,key8=value8,key9=value9," + "key10=value10,key11=value11,key12=value12,key13=value13,key14=value14,key15=value15,key16=value16,key17=value17,key18=value18,key19=value19," + "key20=value20,key21=value21,key22=value22,key23=value23,key24=value24,key25=value25,key26=value26,key27=value27,key28=value28,key29=value29," + "key30=value30,key31=value31,key32=value32,key33=value33,key34=value34,key35=value35,key36=value36,key37=value37,key38=value38,key39=value39," + "key40=value40,key41=value41,key42=value42,key43=value43,key44=value44,key45=value45,key46=value46,key47=value47,key48=value48,key49=value49," + "key50=value50,key51=value51,key52=value52,key53=value53,key54=value54,key55=value55,key56=value56,key57=value57,key58=value58,key59=value59," + "key60=value60,key61=value61,key62=value62,key63=value63,key64=value64,key65=value65,key66=value66,key67=value67,key68=value68,key69=value69," + - "key70=value70,key71=value71,key72=value72,key73=value73,k100=vx1", 1024)] //1024 chars - [InlineData("key0=value0,key1=value1,key2=value2,key3=value3,key4=value4,key5=value5,key6=value6,key7=value7,key8=value8,key9=value9," + + "key70=value70,key71=value71,key72=value72,key73=value73,k100=vx1", 1024)] // 1024 chars + [InlineData( + "key0=value0,key1=value1,key2=value2,key3=value3,key4=value4,key5=value5,key6=value6,key7=value7,key8=value8,key9=value9," + "key10=value10,key11=value11,key12=value12,key13=value13,key14=value14,key15=value15,key16=value16,key17=value17,key18=value18,key19=value19," + "key20=value20,key21=value21,key22=value22,key23=value23,key24=value24,key25=value25,key26=value26,key27=value27,key28=value28,key29=value29," + "key30=value30,key31=value31,key32=value32,key33=value33,key34=value34,key35=value35,key36=value36,key37=value37,key38=value38,key39=value39," + "key40=value40,key41=value41,key42=value42,key43=value43,key44=value44,key45=value45,key46=value46,key47=value47,key48=value48,key49=value49," + "key50=value50,key51=value51,key52=value52,key53=value53,key54=value54,key55=value55,key56=value56,key57=value57,key58=value58,key59=value59," + "key60=value60,key61=value61,key62=value62,key63=value63,key64=value64,key65=value65,key66=value66,key67=value67,key68=value68,key69=value69," + - "key70=value70,key71=value71,key72=value72,key73=value73,key74=value74", 1029)] //more than 1024 chars + "key70=value70,key71=value71,key72=value72,key73=value73,key74=value74", 1029)] // more than 1024 chars public void Validates_Correlation_Context_Length(string correlationContext, int expectedLength) { var activity = new Activity(TestActivityName); diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityHelperTest.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityHelperTest.cs index 468a0ec..9e23636 100644 --- a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityHelperTest.cs +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/ActivityHelperTest.cs @@ -1,39 +1,40 @@ // 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; -using System.Collections; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using System.Web; -using Xunit; - namespace Microsoft.AspNet.TelemetryCorrelation.Tests { + using System; + using System.Collections; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Collections.Specialized; + using System.Diagnostics; + using System.Linq; + using System.Reflection; + using System.Threading; + using System.Threading.Tasks; + using System.Web; + using Xunit; + public class ActivityHelperTest : IDisposable { private const string TestActivityName = "Activity.Test"; - private readonly List> _baggageItems; - private readonly string _baggageInHeader; + private readonly List> baggageItems; + private readonly string baggageInHeader; private IDisposable subscriptionAllListeners; private IDisposable subscriptionAspNetListener; public ActivityHelperTest() { - _baggageItems = new List> + this.baggageItems = new List> { new KeyValuePair("TestKey1", "123"), new KeyValuePair("TestKey2", "456"), new KeyValuePair("TestKey1", "789") }; - _baggageInHeader = "TestKey1=123,TestKey2=456,TestKey1=789"; + this.baggageInHeader = "TestKey1=123,TestKey2=456,TestKey1=789"; + // reset static fields var allListenerField = typeof(DiagnosticListener). GetField("s_allListenerObservable", BindingFlags.Static | BindingFlags.NonPublic); @@ -45,15 +46,14 @@ public ActivityHelperTest() public void Dispose() { - subscriptionAspNetListener?.Dispose(); - subscriptionAllListeners?.Dispose(); + this.subscriptionAspNetListener?.Dispose(); + this.subscriptionAllListeners?.Dispose(); } - #region RestoreActivity tests [Fact] public async Task Can_Restore_Activity() { - var rootActivity = CreateActivity(); + var rootActivity = this.CreateActivity(); rootActivity.AddTag("k1", "v1"); rootActivity.AddTag("k2", "v2"); @@ -67,10 +67,9 @@ await Task.Run(() => ActivityHelper.RestoreActivityIfNeeded(context.Items); - AssertIsRestoredActivity(rootActivity, Activity.Current); + this.AssertIsRestoredActivity(rootActivity, Activity.Current); } - [Fact] public void Do_Not_Restore_Activity_When_There_Is_No_Activity_In_Context() { @@ -131,7 +130,7 @@ await Task.Run(() => Activity restored = Activity.Current; var events = new ConcurrentQueue>(); - EnableAll((kvp) => events.Enqueue(kvp)); + this.EnableAll((kvp) => events.Enqueue(kvp)); ActivityHelper.StopRestoredActivity(restored, context); @@ -143,14 +142,11 @@ await Task.Run(() => Assert.Same(restored, eventPayload.GetProperty("Activity")); } - #endregion - - #region StopAspNetActivity tests [Fact] public void Can_Stop_Activity_Without_AspNetListener_Enabled() { var context = HttpContextHelper.GetFakeHttpContext(); - var rootActivity = CreateActivity(); + var rootActivity = this.CreateActivity(); rootActivity.Start(); Thread.Sleep(100); ActivityHelper.StopAspNetActivity(rootActivity, context.Items); @@ -164,10 +160,10 @@ public void Can_Stop_Activity_Without_AspNetListener_Enabled() public void Can_Stop_Activity_With_AspNetListener_Enabled() { var context = HttpContextHelper.GetFakeHttpContext(); - var rootActivity = CreateActivity(); + var rootActivity = this.CreateActivity(); rootActivity.Start(); Thread.Sleep(100); - EnableAspNetListenerOnly(); + this.EnableAspNetListenerOnly(); ActivityHelper.StopAspNetActivity(rootActivity, context.Items); Assert.True(rootActivity.Duration != TimeSpan.Zero); @@ -175,12 +171,11 @@ public void Can_Stop_Activity_With_AspNetListener_Enabled() Assert.Null(context.Items[ActivityHelper.ActivityKey]); } - [Fact] public void Can_Stop_Root_Activity_With_All_Children() { var context = HttpContextHelper.GetFakeHttpContext(); - var rootActivity = CreateActivity(); + var rootActivity = this.CreateActivity(); rootActivity.Start(); new Activity("child").Start(); new Activity("grandchild").Start(); @@ -196,7 +191,7 @@ public void Can_Stop_Root_Activity_With_All_Children() public void Can_Stop_Child_Activity_With_All_Children() { var context = HttpContextHelper.GetFakeHttpContext(); - var rootActivity = CreateActivity(); + var rootActivity = this.CreateActivity(); rootActivity.Start(); var child = new Activity("child").Start(); new Activity("grandchild").Start(); @@ -222,6 +217,7 @@ await Task.Run(() => { // when we enter this method, Current is 'child' activity Activity.Current.Stop(); + // here Current is 'parent', but only in this execution context }); } @@ -248,16 +244,14 @@ public void Stop_Root_Activity_With_129_Nesting_Depth() new Activity("child" + i).Start(); } - // we do not allow more than 128 nested activities here + // we do not allow more than 128 nested activities here // only to protect from hypothetical cycles in Activity stack Assert.False(ActivityHelper.StopAspNetActivity(root, context.Items)); Assert.NotNull(context.Items[ActivityHelper.ActivityKey]); Assert.Null(Activity.Current); } - #endregion - #region CreateRootActivity tests [Fact] public void Should_Not_Create_RootActivity_If_AspNetListener_Not_Enabled() { @@ -271,7 +265,7 @@ public void Should_Not_Create_RootActivity_If_AspNetListener_Not_Enabled() public void Should_Not_Create_RootActivity_If_AspNetActivity_Not_Enabled() { var context = HttpContextHelper.GetFakeHttpContext(); - EnableAspNetListenerOnly(); + this.EnableAspNetListenerOnly(); var rootActivity = ActivityHelper.CreateRootActivity(context); Assert.Null(rootActivity); @@ -281,7 +275,7 @@ public void Should_Not_Create_RootActivity_If_AspNetActivity_Not_Enabled() public void Should_Not_Create_RootActivity_If_AspNetActivity_Not_Enabled_With_Arguments() { var context = HttpContextHelper.GetFakeHttpContext(); - EnableAspNetListenerAndDisableActivity(); + this.EnableAspNetListenerAndDisableActivity(); var rootActivity = ActivityHelper.CreateRootActivity(context); Assert.Null(rootActivity); @@ -292,17 +286,17 @@ public void Can_Create_RootActivity_And_Restore_Info_From_Request_Header() { var requestHeaders = new Dictionary { - {ActivityExtensions.RequestIDHeaderName, "|aba2f1e978b2cab6.1"}, - {ActivityExtensions.CorrelationContextHeaderName, _baggageInHeader} + { ActivityExtensions.RequestIDHeaderName, "|aba2f1e978b2cab6.1" }, + { ActivityExtensions.CorrelationContextHeaderName, this.baggageInHeader } }; var context = HttpContextHelper.GetFakeHttpContext(headers: requestHeaders); - EnableAspNetListenerAndActivity(); + this.EnableAspNetListenerAndActivity(); var rootActivity = ActivityHelper.CreateRootActivity(context); Assert.NotNull(rootActivity); Assert.True(rootActivity.ParentId == "|aba2f1e978b2cab6.1"); - var expectedBaggage = _baggageItems.OrderBy(item => item.Value); + var expectedBaggage = this.baggageItems.OrderBy(item => item.Value); var actualBaggage = rootActivity.Baggage.OrderBy(item => item.Value); Assert.Equal(expectedBaggage, actualBaggage); } @@ -311,7 +305,7 @@ public void Can_Create_RootActivity_And_Restore_Info_From_Request_Header() public void Can_Create_RootActivity_And_Start_Activity() { var context = HttpContextHelper.GetFakeHttpContext(); - EnableAspNetListenerAndActivity(); + this.EnableAspNetListenerAndActivity(); var rootActivity = ActivityHelper.CreateRootActivity(context); Assert.NotNull(rootActivity); @@ -322,15 +316,12 @@ public void Can_Create_RootActivity_And_Start_Activity() public void Can_Create_RootActivity_And_Saved_In_HttContext() { var context = HttpContextHelper.GetFakeHttpContext(); - EnableAspNetListenerAndActivity(); + this.EnableAspNetListenerAndActivity(); var rootActivity = ActivityHelper.CreateRootActivity(context); Assert.NotNull(rootActivity); Assert.Same(rootActivity, context.Items[ActivityHelper.ActivityKey]); } - #endregion - - #region Helper methods private void AssertIsRestoredActivity(Activity original, Activity restored) { @@ -351,91 +342,86 @@ private void AssertIsRestoredActivity(Activity original, Activity restored) private Activity CreateActivity() { var activity = new Activity(TestActivityName); - _baggageItems.ForEach(kv => activity.AddBaggage(kv.Key, kv.Value)); + this.baggageItems.ForEach(kv => activity.AddBaggage(kv.Key, kv.Value)); return activity; } private void EnableAll(Action> onNext = null) { - subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => + this.subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => { // if AspNetListener has subscription, then it is enabled if (listener.Name == ActivityHelper.AspNetListenerName) { - subscriptionAspNetListener = listener.Subscribe(new TestDiagnosticListener(onNext), (name) => true); + this.subscriptionAspNetListener = listener.Subscribe(new TestDiagnosticListener(onNext), (name) => true); } }); } - private void EnableAspNetListenerAndDisableActivity(Action> onNext = null, - string ActivityName = ActivityHelper.AspNetActivityName) + private void EnableAspNetListenerAndDisableActivity( + Action> onNext = null, + string activityName = ActivityHelper.AspNetActivityName) { - subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => + this.subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => { // if AspNetListener has subscription, then it is enabled if (listener.Name == ActivityHelper.AspNetListenerName) { - subscriptionAspNetListener = listener.Subscribe(new TestDiagnosticListener(onNext), - (name, arg1, arg2) => name == ActivityName && arg1 == null); + this.subscriptionAspNetListener = listener.Subscribe( + new TestDiagnosticListener(onNext), + (name, arg1, arg2) => name == activityName && arg1 == null); } }); } - private void EnableAspNetListenerAndActivity(Action> onNext = null, - string ActivityName = ActivityHelper.AspNetActivityName) + private void EnableAspNetListenerAndActivity( + Action> onNext = null, + string activityName = ActivityHelper.AspNetActivityName) { - subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => + this.subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => { // if AspNetListener has subscription, then it is enabled if (listener.Name == ActivityHelper.AspNetListenerName) { - subscriptionAspNetListener = listener.Subscribe(new TestDiagnosticListener(onNext), - (name, arg1, arg2) => name == ActivityName); + this.subscriptionAspNetListener = listener.Subscribe( + new TestDiagnosticListener(onNext), + (name, arg1, arg2) => name == activityName); } }); } private void EnableAspNetListenerOnly(Action> onNext = null) { - subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => + this.subscriptionAllListeners = DiagnosticListener.AllListeners.Subscribe(listener => { // if AspNetListener has subscription, then it is enabled if (listener.Name == ActivityHelper.AspNetListenerName) { - subscriptionAspNetListener = listener.Subscribe(new TestDiagnosticListener(onNext), + this.subscriptionAspNetListener = listener.Subscribe( + new TestDiagnosticListener(onNext), activityName => false); } }); } - #endregion - - #region Helper Class private class TestHttpRequest : HttpRequestBase { - NameValueCollection _headers = new NameValueCollection(); - public override NameValueCollection Headers - { - get - { - return _headers; - } - } + private readonly NameValueCollection headers = new NameValueCollection(); + + public override NameValueCollection Headers => this.headers; - public override UnvalidatedRequestValuesBase Unvalidated => new TestUnvalidatedRequestValues(_headers); + public override UnvalidatedRequestValuesBase Unvalidated => new TestUnvalidatedRequestValues(this.headers); } private class TestUnvalidatedRequestValues : UnvalidatedRequestValuesBase { - NameValueCollection _headers = new NameValueCollection(); - public TestUnvalidatedRequestValues(NameValueCollection headers) { - this._headers = headers; + this.Headers = headers; } - public override NameValueCollection Headers => _headers; + public override NameValueCollection Headers { get; } } private class TestHttpResponse : HttpResponseBase @@ -444,76 +430,38 @@ private class TestHttpResponse : HttpResponseBase private class TestHttpServerUtility : HttpServerUtilityBase { - HttpContextBase _context; + private readonly HttpContextBase context; public TestHttpServerUtility(HttpContextBase context) { - _context = context; + this.context = context; } public override Exception GetLastError() { - return _context.Error; + return this.context.Error; } } private class TestHttpContext : HttpContextBase { - HttpRequestBase _request; - HttpResponseBase _response; - HttpServerUtilityBase _server; - Hashtable _items; - Exception _error; + private readonly Hashtable items; public TestHttpContext(Exception error = null) { - _request = new TestHttpRequest(); - _response = new TestHttpResponse(); - _server = new TestHttpServerUtility(this); - _items = new Hashtable(); - _error = error; - } - - public override HttpRequestBase Request - { - get - { - return _request; - } + this.Server = new TestHttpServerUtility(this); + this.items = new Hashtable(); + this.Error = error; } - public override IDictionary Items - { - get - { - return _items; - } - } + public override HttpRequestBase Request { get; } = new TestHttpRequest(); - public override Exception Error - { - get - { - return _error; - } - } + /// + public override IDictionary Items => this.items; - public override HttpServerUtilityBase Server - { - get - { - return _server; - } - } - } - #endregion - } + public override Exception Error { get; } - static class PropertyExtensions - { - public static object GetProperty(this object _this, string propertyName) - { - return _this.GetType().GetTypeInfo().GetDeclaredProperty(propertyName)?.GetValue(_this); + public override HttpServerUtilityBase Server { get; } } } } diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/HttpContextHelper.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/HttpContextHelper.cs index 3024d14..79e2b77 100644 --- a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/HttpContextHelper.cs +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/HttpContextHelper.cs @@ -1,16 +1,16 @@ // 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.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Threading; -using System.Web; -using System.Web.Hosting; - namespace Microsoft.AspNet.TelemetryCorrelation.Tests { - class HttpContextHelper + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Threading; + using System.Web; + using System.Web.Hosting; + + internal class HttpContextHelper { public static HttpContext GetFakeHttpContext(string page = "/page", string query = "", IDictionary headers = null) { diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/Properties/AssemblyInfo.cs index 652de0f..a5711b7 100644 --- a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/Properties/AssemblyInfo.cs @@ -1,8 +1,11 @@ -using System.Runtime.InteropServices; +// 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.Runtime.InteropServices; using Xunit; -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/PropertyExtensions.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/PropertyExtensions.cs new file mode 100644 index 0000000..98d17dd --- /dev/null +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/PropertyExtensions.cs @@ -0,0 +1,15 @@ +// 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.AspNet.TelemetryCorrelation.Tests +{ + using System.Reflection; + + internal static class PropertyExtensions + { + public static object GetProperty(this object obj, string propertyName) + { + return obj.GetType().GetTypeInfo().GetDeclaredProperty(propertyName)?.GetValue(obj); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/TestDiagnosticListener.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/TestDiagnosticListener.cs index 6388789..a6ede43 100644 --- a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/TestDiagnosticListener.cs +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/TestDiagnosticListener.cs @@ -1,15 +1,18 @@ -using System; -using System.Collections.Generic; +// 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.AspNet.TelemetryCorrelation.Tests { - class TestDiagnosticListener : IObserver> + using System; + using System.Collections.Generic; + + internal class TestDiagnosticListener : IObserver> { - Action> _onNextCallBack; + private readonly Action> onNextCallBack; public TestDiagnosticListener(Action> onNext) { - _onNextCallBack = onNext; + this.onNextCallBack = onNext; } public void OnCompleted() @@ -22,7 +25,7 @@ public void OnError(Exception error) public void OnNext(KeyValuePair value) { - _onNextCallBack?.Invoke(value); + this.onNextCallBack?.Invoke(value); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/WebConfigWithLocaltionTagTransformTest.cs b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/WebConfigWithLocationTagTransformTest.cs similarity index 99% rename from test/Microsoft.AspNet.TelemetryCorrelation.Tests/WebConfigWithLocaltionTagTransformTest.cs rename to test/Microsoft.AspNet.TelemetryCorrelation.Tests/WebConfigWithLocationTagTransformTest.cs index f13b2ee..39595a4 100644 --- a/test/Microsoft.AspNet.TelemetryCorrelation.Tests/WebConfigWithLocaltionTagTransformTest.cs +++ b/test/Microsoft.AspNet.TelemetryCorrelation.Tests/WebConfigWithLocationTagTransformTest.cs @@ -1,13 +1,13 @@ // 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.IO; -using System.Xml.Linq; -using Microsoft.Web.XmlTransform; -using Xunit; - namespace Microsoft.AspNet.TelemetryCorrelation.Tests { + using System.IO; + using System.Xml.Linq; + using Microsoft.Web.XmlTransform; + using Xunit; + public class WebConfigWithLocationTagTransformTest { private const string InstallConfigTransformationResourceName = "Microsoft.AspNet.TelemetryCorrelation.Tests.Resources.web.config.install.xdt";