Skip to content

Commit

Permalink
Fix build (#2226)
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang authored Aug 4, 2021
1 parent f954e64 commit 4b90945
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Microsoft.AspNet.TelemetryCorrelation
{
/// <summary>
/// Extensions of Activity class
/// Extensions of Activity class.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ActivityExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Microsoft.AspNet.TelemetryCorrelation
{
/// <summary>
/// Activity helper class
/// Activity helper class.
/// </summary>
internal static class ActivityHelper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,76 +34,76 @@ internal sealed class AspNetTelemetryCorrelationEventSource : EventSource
[NonEvent]
public void ActivityException(string id, string eventName, Exception ex)
{
if (IsEnabled(EventLevel.Error, (EventKeywords)(-1)))
if (this.IsEnabled(EventLevel.Error, EventKeywords.All))
{
ActivityException(id, eventName, ex.ToString());
this.ActivityException(id, eventName, ex.ToString());
}
}

[Event(1, Message = "Callback='{0}'", Level = EventLevel.Verbose)]
public void TraceCallback(string callback)
{
WriteEvent(1, callback);
this.WriteEvent(1, callback);
}

[Event(2, Message = "Activity started, Id='{0}'", Level = EventLevel.Verbose)]
public void ActivityStarted(string id)
{
WriteEvent(2, id);
this.WriteEvent(2, id);
}

[Event(3, Message = "Activity stopped, Id='{0}', Name='{1}'", Level = EventLevel.Verbose)]
public void ActivityStopped(string id, string eventName)
{
WriteEvent(3, id, eventName);
this.WriteEvent(3, id, eventName);
}

[Event(4, Message = "Failed to parse header '{0}', value: '{1}'", Level = EventLevel.Informational)]
public void HeaderParsingError(string headerName, string headerValue)
{
WriteEvent(4, headerName, headerValue);
this.WriteEvent(4, headerName, headerValue);
}

[Event(5, Message = "Failed to extract activity, reason '{0}'", Level = EventLevel.Error)]
public void ActvityExtractionError(string reason)
{
WriteEvent(5, reason);
this.WriteEvent(5, reason);
}

[Event(6, Message = "Finished Activity is detected on the stack, Id: '{0}', Name: '{1}'", Level = EventLevel.Error)]
public void FinishedActivityIsDetected(string id, string name)
{
WriteEvent(6, id, name);
this.WriteEvent(6, id, name);
}

[Event(7, Message = "System.Diagnostics.Activity stack is too deep. This is a code authoring error, Activity will not be stopped.", Level = EventLevel.Error)]
public void ActivityStackIsTooDeepError()
{
WriteEvent(7);
this.WriteEvent(7);
}

[Event(8, Message = "Activity restored, Id='{0}'", Level = EventLevel.Informational)]
public void ActivityRestored(string id)
{
WriteEvent(8, id);
this.WriteEvent(8, id);
}

[Event(9, Message = "Failed to invoke OnExecuteRequestStep, Error='{0}'", Level = EventLevel.Error)]
public void OnExecuteRequestStepInvokationError(string error)
{
WriteEvent(9, error);
this.WriteEvent(9, error);
}

[Event(10, Message = "System.Diagnostics.Activity stack is too deep. Current Id: '{0}', Name: '{1}'", Level = EventLevel.Warning)]
public void ActivityStackIsTooDeepDetails(string id, string name)
{
WriteEvent(10, id, name);
this.WriteEvent(10, id, name);
}

[Event(11, Message = "Activity exception, Id='{0}', Name='{1}': {2}", Level = EventLevel.Error)]
public void ActivityException(string id, string eventName, string ex)
{
WriteEvent(11, id, eventName, ex);
this.WriteEvent(11, id, eventName, ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,40 @@ public sealed override bool TryParseValue(string value, ref int index, out T par
// Accept: text/plain; q=0.2
if (string.IsNullOrEmpty(value) || (index == value.Length))
{
return SupportsMultipleValues;
return this.SupportsMultipleValues;
}

var separatorFound = false;
var current = HeaderUtilities.GetNextNonEmptyOrWhitespaceIndex(value, index, SupportsMultipleValues, out separatorFound);
var current = HeaderUtilities.GetNextNonEmptyOrWhitespaceIndex(value, index, this.SupportsMultipleValues, out separatorFound);

if (separatorFound && !SupportsMultipleValues)
if (separatorFound && !this.SupportsMultipleValues)
{
return false; // leading separators not allowed if we don't support multiple values.
}

if (current == value.Length)
{
if (SupportsMultipleValues)
if (this.SupportsMultipleValues)
{
index = current;
}

return SupportsMultipleValues;
return this.SupportsMultipleValues;
}

T result;
var length = GetParsedValueLength(value, current, out result);
var length = this.GetParsedValueLength(value, current, out result);

if (length == 0)
{
return false;
}

current = current + length;
current = HeaderUtilities.GetNextNonEmptyOrWhitespaceIndex(value, current, SupportsMultipleValues, out separatorFound);
current = HeaderUtilities.GetNextNonEmptyOrWhitespaceIndex(value, current, this.SupportsMultipleValues, out separatorFound);

// If we support multiple values and we've not reached the end of the string, then we must have a separator.
if ((separatorFound && !SupportsMultipleValues) || (!separatorFound && (current < value.Length)))
if ((separatorFound && !this.SupportsMultipleValues) || (!separatorFound && (current < value.Length)))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal GenericHeaderParser(bool supportsMultipleValues, GetParsedValueLengthDe

protected override int GetParsedValueLength(string value, int startIndex, out T parsedValue)
{
return getParsedValueLength(value, startIndex, out parsedValue);
return this.getParsedValueLength(value, startIndex, out parsedValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected HttpHeaderParser(bool supportsMultipleValues)

public bool SupportsMultipleValues
{
get { return supportsMultipleValues; }
get { return this.supportsMultipleValues; }
}

// If a parser supports multiple values, a call to ParseValue/TryParseValue should return a value for 'index'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.AspNet.TelemetryCorrelation
internal enum HttpParseResult
{
/// <summary>
/// Parsed succesfully.
/// Parsed successfully.
/// </summary>
Parsed,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal static HttpParseResult GetQuotedPairLength(string input, int startIndex
return HttpParseResult.NotParsed;
}

// Quoted-char has 2 characters. Check wheter there are 2 chars left ('\' + char)
// Quoted-char has 2 characters. Check whether there are 2 chars left ('\' + char)
// If so, check whether the character is in the range 0-127. If not, it's an invalid value.
if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="NamValueHeaderValue.cs" company="OpenTelemetry Authors">
// <copyright file="NameValueHeaderValue.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -38,12 +38,12 @@ private NameValueHeaderValue()

public string Name
{
get { return name; }
get { return this.name; }
}

public string Value
{
get { return value; }
get { return this.value; }
}

public static bool TryParse(string input, out NameValueHeaderValue parsedValue)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,85 +1,19 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Microsoft.AspNet.TelemetryCorrelation.sln))\tools\Common.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{4C8E592C-C532-4CF2-80EF-3BDD0D788D12}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.AspNet.TelemetryCorrelation</RootNamespace>
<AssemblyName>Microsoft.AspNet.TelemetryCorrelation</AssemblyName>
<TargetFrameworks>net45</TargetFrameworks>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<CodeAnalysisRuleSet>Microsoft.AspNet.TelemetryCorrelation.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>$(OutputPath)/$(TargetFramework)/$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(PublicRelease)' == 'True' ">
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>$(RepositoryRoot)tools\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<DefineConstants>$(DefineConstants);PUBLIC_RELEASE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(PublicRelease)' != 'True' ">
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>$(RepositoryRoot)tools\Debug.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<Company>Microsoft Corporation</Company>
<!--https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets-->
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!--PackageOutputPath>Defined in Directory.Build.props</PackageOutputPath-->
<PackageId>Microsoft.AspNet.TelemetryCorrelation</PackageId>
<!--PackageVersion is defined in from VersionPrefix and VersionSuffix -->
<!--PackageVersion></PackageVersion-->
<Authors>Microsoft</Authors>
<Title>Microsoft Asp.Net telemetry correlation</Title>
<TargetFrameworks>net461</TargetFrameworks>
<Description>A module that instruments incoming request with System.Diagnostics.Activity and notifies listeners with DiagnosticsSource.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>http://www.asp.net/</PackageProjectUrl>
<PackageIconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</PackageIconUrl>
<PackageTags>Diagnostics DiagnosticSource Correlation Activity ASP.NET</PackageTags>
<RepositoryUrl>https://github.com/aspnet/Microsoft.AspNet.TelemetryCorrelation/</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageType>Dependency</PackageType>
<ContentTargetFolders>content</ContentTargetFolders>
<!--
TODO: Disable this exception, and actually do document all public API.
-->
<NoWarn>$(NoWarn),1591,CS0618</NoWarn>
<MinVerTagPrefix>core-</MinVerTagPrefix>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Web" />
<PackageReference Include="Desktop.Analyzers" Version="1.1.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventRegister" Version="1.1.28">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<None Include="Microsoft.AspNet.TelemetryCorrelation.ruleset" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticSourcePkgVer)" />
</ItemGroup>

<ItemGroup>
<Content Include="web.config.install.xdt" />
<Content Include="web.config.uninstall.xdt" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public void Dispose()
/// <inheritdoc />
public void Init(HttpApplication context)
{
context.BeginRequest += Application_BeginRequest;
context.EndRequest += Application_EndRequest;
context.Error += Application_Error;
context.BeginRequest += this.Application_BeginRequest;
context.EndRequest += this.Application_EndRequest;
context.Error += this.Application_Error;

// OnExecuteRequestStep is availabile starting with 4.7.1
// If this is executed in 4.7.1 runtime (regardless of targeted .NET version),
Expand All @@ -67,7 +67,7 @@ public void Init(HttpApplication context)
{
try
{
onStepMethodInfo.Invoke(context, new object[] { (Action<HttpContextBase, Action>)OnExecuteRequestStep });
onStepMethodInfo.Invoke(context, new object[] { (Action<HttpContextBase, Action>)this.OnExecuteRequestStep });
}
catch (Exception e)
{
Expand All @@ -76,7 +76,7 @@ public void Init(HttpApplication context)
}
else
{
context.PreRequestHandlerExecute += Application_PreRequestHandlerExecute;
context.PreRequestHandlerExecute += this.Application_PreRequestHandlerExecute;
}
}

Expand Down Expand Up @@ -106,7 +106,7 @@ private void Application_BeginRequest(object sender, EventArgs e)
{
var context = ((HttpApplication)sender).Context;
AspNetTelemetryCorrelationEventSource.Log.TraceCallback("Application_BeginRequest");
ActivityHelper.CreateRootActivity(context, ParseHeaders);
ActivityHelper.CreateRootActivity(context, this.ParseHeaders);
context.Items[BeginCalledFlag] = true;
}

Expand Down Expand Up @@ -141,7 +141,7 @@ private void Application_EndRequest(object sender, EventArgs e)
else
{
// Activity has never been started
ActivityHelper.CreateRootActivity(context, ParseHeaders);
ActivityHelper.CreateRootActivity(context, this.ParseHeaders);
}
}

Expand All @@ -162,7 +162,7 @@ private void Application_Error(object sender, EventArgs e)
{
if (!context.Items.Contains(BeginCalledFlag))
{
ActivityHelper.CreateRootActivity(context, ParseHeaders);
ActivityHelper.CreateRootActivity(context, this.ParseHeaders);
}

ActivityHelper.WriteActivityException(context.Items, exception);
Expand Down

0 comments on commit 4b90945

Please sign in to comment.