Delete WebHeaderCollection's event source (#38871)
authorStephen Toub <stoub@microsoft.com>
Thu, 9 Jul 2020 13:08:39 +0000 (09:08 -0400)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2020 13:08:39 +0000 (09:08 -0400)
The logging is verbose, arbitrary, expensive, and duplicative of logging that happens when headers are actually read/written by the underlying networking stack.  Delete.

src/libraries/System.Net.WebHeaderCollection/src/System.Net.WebHeaderCollection.csproj
src/libraries/System.Net.WebHeaderCollection/src/System/Net/NetEventSource.WebHeaderCollection.cs [deleted file]
src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs
src/libraries/System.Net.WebHeaderCollection/tests/LoggingTest.cs [deleted file]
src/libraries/System.Net.WebHeaderCollection/tests/System.Net.WebHeaderCollection.Tests.csproj

index 5fd0e9a..d97d845 100644 (file)
@@ -11,7 +11,6 @@
     <Compile Include="System\Net\HttpRequestHeader.cs" />
     <Compile Include="System\Net\HeaderInfo.cs" />
     <Compile Include="System\Net\HeaderInfoTable.cs" />
-    <Compile Include="System\Net\NetEventSource.WebHeaderCollection.cs" />
     <Compile Include="$(CommonPath)System\Net\CaseInsensitiveAscii.cs"
              Link="Common\System\Net\CaseInsensitiveAscii.cs" />
     <Compile Include="$(CommonPath)System\StringExtensions.cs"
@@ -20,8 +19,6 @@
              Link="Common\System\Net\HttpKnownHeaderNames.cs" />
     <Compile Include="$(CommonPath)System\Net\HttpValidationHelpers.cs"
              Link="Common\System\Net\HttpValidationHelpers.cs" />
-    <Compile Include="$(CommonPath)System\Net\Logging\NetEventSource.Common.cs"
-             Link="Common\System\Net\Logging\NetEventSource.Common.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System.Collections" />
diff --git a/src/libraries/System.Net.WebHeaderCollection/src/System/Net/NetEventSource.WebHeaderCollection.cs b/src/libraries/System.Net.WebHeaderCollection/src/System/Net/NetEventSource.WebHeaderCollection.cs
deleted file mode 100644 (file)
index 772b474..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Diagnostics.Tracing;
-
-namespace System.Net
-{
-    [EventSource(Name = "Microsoft-System-Net-WebHeaderCollection")]
-    internal sealed partial class NetEventSource { }
-}
index 60f1733..8997629 100644 (file)
@@ -143,7 +143,6 @@ namespace System.Net
             name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
             ThrowOnRestrictedHeader(name);
             value = HttpValidationHelpers.CheckBadHeaderValueChars(value);
-            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Set() key:[{name}], value:[{value}]");
             if (_type == WebHeaderCollectionType.WebResponse)
             {
                 if (value != null && value.Length > ushort.MaxValue)
@@ -372,7 +371,6 @@ namespace System.Net
             name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
             ThrowOnRestrictedHeader(name);
             value = HttpValidationHelpers.CheckBadHeaderValueChars(value);
-            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Add({header}) calling InnerCollection.Add() key:[{name}], value:[{value}]");
             if (_type == WebHeaderCollectionType.WebResponse)
             {
                 if (value != null && value.Length > ushort.MaxValue)
@@ -400,7 +398,6 @@ namespace System.Net
             name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
             ThrowOnRestrictedHeader(name);
             value = HttpValidationHelpers.CheckBadHeaderValueChars(value);
-            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Add() key:[{name}], value:[{value}]");
             if (_type == WebHeaderCollectionType.WebResponse)
             {
                 if (value != null && value.Length > ushort.MaxValue)
@@ -416,7 +413,6 @@ namespace System.Net
         {
             headerName = HttpValidationHelpers.CheckBadHeaderNameChars(headerName);
             headerValue = HttpValidationHelpers.CheckBadHeaderValueChars(headerValue);
-            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Add() key:[{headerName}], value:[{headerValue}]");
             if (_type == WebHeaderCollectionType.WebResponse)
             {
                 if (headerValue != null && headerValue.Length > ushort.MaxValue)
@@ -469,7 +465,6 @@ namespace System.Net
             }
             ThrowOnRestrictedHeader(name);
             name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
-            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Remove() key:[{name}]");
             if (_innerCollection != null)
             {
                 InvalidateCachedArrays();
@@ -512,7 +507,6 @@ namespace System.Net
             }
 
             sb.Append("\r\n");
-            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"ToString: {sb}");
             return sb.ToString();
         }
 
diff --git a/src/libraries/System.Net.WebHeaderCollection/tests/LoggingTest.cs b/src/libraries/System.Net.WebHeaderCollection/tests/LoggingTest.cs
deleted file mode 100644 (file)
index 11442bc..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Diagnostics.Tracing;
-using Xunit;
-
-namespace System.Net.Tests
-{
-    public class WebHeaderCollectionLoggingTest
-    {
-        [Fact]
-        public void EventSource_ExistsWithCorrectId()
-        {
-            Type esType = typeof(WebHeaderCollection).Assembly.GetType("System.Net.NetEventSource", throwOnError: true, ignoreCase: false);
-            Assert.NotNull(esType);
-
-            Assert.Equal("Microsoft-System-Net-WebHeaderCollection", EventSource.GetName(esType));
-            Assert.Equal(Guid.Parse("fd36452f-9f2b-5850-d212-6c436231e3dc"), EventSource.GetGuid(esType));
-
-            Assert.NotEmpty(EventSource.GenerateManifest(esType, esType.Assembly.Location));
-        }
-    }
-}
index e75726b..9b2ed44 100644 (file)
@@ -4,6 +4,5 @@
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="WebHeaderCollectionTest.cs" />
-    <Compile Include="LoggingTest.cs" />
   </ItemGroup>
 </Project>
\ No newline at end of file