Skip to content

Commit

Permalink
allign indendation to .editorconfig setttings for Elastic.Apm.Profile…
Browse files Browse the repository at this point in the history
…r.* (#2015)
  • Loading branch information
Mpdreamz authored Feb 23, 2023
1 parent 3ce184b commit 70691bd
Show file tree
Hide file tree
Showing 176 changed files with 12,129 additions and 11,787 deletions.
157 changes: 155 additions & 2 deletions ElasticApmAgent.sln.DotSettings

Large diffs are not rendered by default.

508 changes: 262 additions & 246 deletions src/Elastic.Apm.Profiler.Managed/CallTarget/CallTargetInvoker.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

namespace Elastic.Apm.Profiler.Managed.CallTarget
{
internal class CallTargetInvokerException : Exception
{
public CallTargetInvokerException(Exception innerException)
: base(innerException.Message, innerException)
{
}
}
internal class CallTargetInvokerException : Exception
{
public CallTargetInvokerException(Exception innerException)
: base(innerException.Message, innerException) { }
}
}
76 changes: 38 additions & 38 deletions src/Elastic.Apm.Profiler.Managed/CallTarget/CallTargetReturn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@

namespace Elastic.Apm.Profiler.Managed.CallTarget
{
/// <summary>
/// Call target return value
/// </summary>
/// <typeparam name="T">Type of the return value</typeparam>
public readonly struct CallTargetReturn<T>
{
private readonly T _returnValue;
/// <summary>
/// Call target return value
/// </summary>
/// <typeparam name="T">Type of the return value</typeparam>
public readonly struct CallTargetReturn<T>
{
private readonly T _returnValue;

/// <summary>
/// Initializes a new instance of the <see cref="CallTargetReturn{T}"/> struct.
/// </summary>
/// <param name="returnValue">Return value</param>
public CallTargetReturn(T returnValue) => _returnValue = returnValue;
/// <summary>
/// Initializes a new instance of the <see cref="CallTargetReturn{T}"/> struct.
/// </summary>
/// <param name="returnValue">Return value</param>
public CallTargetReturn(T returnValue) => _returnValue = returnValue;

/// <summary>
/// Gets the default call target return value (used by the native side to initialize the locals)
/// </summary>
/// <returns>Default call target return value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static CallTargetReturn<T> GetDefault() => default;
/// Gets the default call target return value (used by the native side to initialize the locals)
/// </summary>
/// <returns>Default call target return value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static CallTargetReturn<T> GetDefault() => default;

/// <summary>
/// Gets the return value
/// </summary>
/// <returns>Return value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T GetReturnValue() => _returnValue;
/// Gets the return value
/// </summary>
/// <returns>Return value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T GetReturnValue() => _returnValue;

/// <summary>
/// ToString override
/// </summary>
/// <returns>String value</returns>
public override string ToString() => $"{typeof(CallTargetReturn<T>).FullName}({_returnValue})";
/// <summary>
/// ToString override
/// </summary>
/// <returns>String value</returns>
public override string ToString() => $"{typeof(CallTargetReturn<T>).FullName}({_returnValue})";
}

/// <summary>
/// Call target return value
/// </summary>
public readonly struct CallTargetReturn
{
/// <summary>
/// Gets the default call target return value (used by the native side to initialize the locals)
/// </summary>
/// <returns>Default call target return value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static CallTargetReturn GetDefault() => default;
/// <summary>
/// Call target return value
/// </summary>
public readonly struct CallTargetReturn
{
/// <summary>
/// Gets the default call target return value (used by the native side to initialize the locals)
/// </summary>
/// <returns>Default call target return value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static CallTargetReturn GetDefault() => default;
}
}
150 changes: 75 additions & 75 deletions src/Elastic.Apm.Profiler.Managed/CallTarget/CallTargetState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,91 +13,91 @@

namespace Elastic.Apm.Profiler.Managed.CallTarget
{
/// <summary>
/// Call target execution state
/// </summary>
public readonly struct CallTargetState
{
private readonly IExecutionSegment _previousSegment;
private readonly IExecutionSegment _segment;
private readonly object _state;
private readonly DateTimeOffset? _startTime;
/// <summary>
/// Call target execution state
/// </summary>
public readonly struct CallTargetState
{
private readonly IExecutionSegment _previousSegment;
private readonly IExecutionSegment _segment;
private readonly object _state;
private readonly DateTimeOffset? _startTime;

/// <summary>
/// Initializes a new instance of the <see cref="CallTargetState"/> struct.
/// </summary>
/// <param name="segment">Scope instance</param>
public CallTargetState(IExecutionSegment segment)
{
_previousSegment = null;
_segment = segment;
_state = null;
_startTime = null;
}
/// <summary>
/// Initializes a new instance of the <see cref="CallTargetState"/> struct.
/// </summary>
/// <param name="segment">Scope instance</param>
public CallTargetState(IExecutionSegment segment)
{
_previousSegment = null;
_segment = segment;
_state = null;
_startTime = null;
}

/// <summary>
/// Initializes a new instance of the <see cref="CallTargetState"/> struct.
/// </summary>
/// <param name="segment">Scope instance</param>
/// <param name="state">Object state instance</param>
public CallTargetState(IExecutionSegment segment, object state)
{
_previousSegment = null;
_segment = segment;
_state = state;
_startTime = null;
}
/// <summary>
/// Initializes a new instance of the <see cref="CallTargetState"/> struct.
/// </summary>
/// <param name="segment">Scope instance</param>
/// <param name="state">Object state instance</param>
public CallTargetState(IExecutionSegment segment, object state)
{
_previousSegment = null;
_segment = segment;
_state = state;
_startTime = null;
}

/// <summary>
/// Initializes a new instance of the <see cref="CallTargetState"/> struct.
/// </summary>
/// <param name="segment">Scope instance</param>
/// <param name="state">Object state instance</param>
/// <param name="startTime">The intended start time of the scope, intended for scopes created in the OnMethodEnd handler</param>
public CallTargetState(IExecutionSegment segment, object state, DateTimeOffset? startTime)
{
_previousSegment = null;
_segment = segment;
_state = state;
_startTime = startTime;
}
/// <summary>
/// Initializes a new instance of the <see cref="CallTargetState"/> struct.
/// </summary>
/// <param name="segment">Scope instance</param>
/// <param name="state">Object state instance</param>
/// <param name="startTime">The intended start time of the scope, intended for scopes created in the OnMethodEnd handler</param>
public CallTargetState(IExecutionSegment segment, object state, DateTimeOffset? startTime)
{
_previousSegment = null;
_segment = segment;
_state = state;
_startTime = startTime;
}

internal CallTargetState(IExecutionSegment previousSegment, CallTargetState state)
{
_previousSegment = previousSegment;
_segment = state._segment;
_state = state._state;
_startTime = state._startTime;
}
internal CallTargetState(IExecutionSegment previousSegment, CallTargetState state)
{
_previousSegment = previousSegment;
_segment = state._segment;
_state = state._state;
_startTime = state._startTime;
}

/// <summary>
/// Gets the CallTarget BeginMethod segment
/// </summary>
public IExecutionSegment Segment => _segment;
/// <summary>
/// Gets the CallTarget BeginMethod segment
/// </summary>
public IExecutionSegment Segment => _segment;

/// <summary>
/// Gets the CallTarget BeginMethod state
/// </summary>
public object State => _state;
/// <summary>
/// Gets the CallTarget BeginMethod state
/// </summary>
public object State => _state;

/// <summary>
/// Gets the CallTarget state StartTime
/// </summary>
public DateTimeOffset? StartTime => _startTime;
/// <summary>
/// Gets the CallTarget state StartTime
/// </summary>
public DateTimeOffset? StartTime => _startTime;

internal IExecutionSegment PreviousSegment => _previousSegment;
internal IExecutionSegment PreviousSegment => _previousSegment;

/// <summary>
/// Gets the default call target state (used by the native side to initialize the locals)
/// </summary>
/// <returns>Default call target state</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static CallTargetState GetDefault() => default;
/// <summary>
/// Gets the default call target state (used by the native side to initialize the locals)
/// </summary>
/// <returns>Default call target state</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static CallTargetState GetDefault() => default;

/// <summary>
/// ToString override
/// </summary>
/// <returns>String value</returns>
public override string ToString() => $"{typeof(CallTargetState).FullName}({_previousSegment}, {_segment}, {_state})";
/// ToString override
/// </summary>
/// <returns>String value</returns>
public override string ToString() => $"{typeof(CallTargetState).FullName}({_previousSegment}, {_segment}, {_state})";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@

namespace Elastic.Apm.Profiler.Managed.CallTarget.Handlers
{
internal static class BeginMethodHandler<TIntegration, TTarget>
{
private static readonly InvokeDelegate _invokeDelegate;
internal static class BeginMethodHandler<TIntegration, TTarget>
{
private static readonly InvokeDelegate _invokeDelegate;

static BeginMethodHandler()
{
try
{
var dynMethod = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), Array.Empty<Type>());
if (dynMethod != null)
static BeginMethodHandler()
{
try
{
var dynMethod = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), Array.Empty<Type>());
if (dynMethod != null)
_invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
}
catch (Exception ex)
{
throw new CallTargetInvokerException(ex);
}
finally
{
if (_invokeDelegate is null)
catch (Exception ex)
{
throw new CallTargetInvokerException(ex);
}
finally
{
if (_invokeDelegate is null)
_invokeDelegate = instance => CallTargetState.GetDefault();
}
}
}

internal delegate CallTargetState InvokeDelegate(TTarget instance);
internal delegate CallTargetState InvokeDelegate(TTarget instance);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static CallTargetState Invoke(TTarget instance) =>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static CallTargetState Invoke(TTarget instance) =>
new CallTargetState(Agent.IsConfigured ? Agent.Tracer.CurrentExecutionSegment() : null, _invokeDelegate(instance));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@

namespace Elastic.Apm.Profiler.Managed.CallTarget.Handlers
{
internal static class BeginMethodHandler<TIntegration, TTarget, TArg1>
{
private static readonly InvokeDelegate _invokeDelegate;
internal static class BeginMethodHandler<TIntegration, TTarget, TArg1>
{
private static readonly InvokeDelegate _invokeDelegate;

static BeginMethodHandler()
{
try
{
var dynMethod = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), new[] { typeof(TArg1) });
if (dynMethod != null)
{
_invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
}
}
catch (Exception ex)
{
throw new CallTargetInvokerException(ex);
}
finally
{
if (_invokeDelegate is null)
{
_invokeDelegate = (instance, arg1) => CallTargetState.GetDefault();
}
}
}
static BeginMethodHandler()
{
try
{
var dynMethod = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), new[] { typeof(TArg1) });
if (dynMethod != null)
{
_invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
}
}
catch (Exception ex)
{
throw new CallTargetInvokerException(ex);
}
finally
{
if (_invokeDelegate is null)
{
_invokeDelegate = (instance, arg1) => CallTargetState.GetDefault();
}
}
}

internal delegate CallTargetState InvokeDelegate(TTarget instance, TArg1 arg1);
internal delegate CallTargetState InvokeDelegate(TTarget instance, TArg1 arg1);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static CallTargetState Invoke(TTarget instance, TArg1 arg1) =>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static CallTargetState Invoke(TTarget instance, TArg1 arg1) =>
new CallTargetState(Agent.IsConfigured ? Agent.Tracer.CurrentExecutionSegment() : null, _invokeDelegate(instance, arg1));
}
}
Loading

0 comments on commit 70691bd

Please sign in to comment.