public string OperationName { get { throw null; } }
public System.Diagnostics.Activity Parent { get { throw null; } }
public string ParentId { get { throw null; } }
- public ref System.Diagnostics.ActivitySpanId ParentSpanId { get { throw null; } }
+ public ref readonly System.Diagnostics.ActivitySpanId ParentSpanId { get { throw null; } }
public string RootId { get { throw null; } }
- public ref System.Diagnostics.ActivitySpanId SpanId { get { throw null; } }
+ public ref readonly System.Diagnostics.ActivitySpanId SpanId { get { throw null; } }
public System.DateTime StartTimeUtc { get { throw null; } }
public System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string>> Tags { get { throw null; } }
- public ref System.Diagnostics.ActivityTraceId TraceId { get { throw null; } }
+ public ref readonly System.Diagnostics.ActivityTraceId TraceId { get { throw null; } }
public string TraceStateString { get { throw null; } set { } }
public System.Diagnostics.Activity AddBaggage(string key, string value) { throw null; }
public System.Diagnostics.Activity AddTag(string key, string value) { throw null; }
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[System.Security.SecuritySafeCriticalAttribute]
#endif
- public partial struct ActivitySpanId : System.IEquatable<System.Diagnostics.ActivitySpanId>
+ public readonly partial struct ActivitySpanId : System.IEquatable<System.Diagnostics.ActivitySpanId>
{
- private object _dummy;
- private int _dummyPrimitive;
+ private readonly object _dummy;
+ private readonly int _dummyPrimitive;
public void CopyTo(System.Span<byte> destination) { }
public static System.Diagnostics.ActivitySpanId CreateFromBytes(System.ReadOnlySpan<byte> idData) { throw null; }
public static System.Diagnostics.ActivitySpanId CreateFromString(System.ReadOnlySpan<char> idData) { throw null; }
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[System.Security.SecuritySafeCriticalAttribute]
#endif
- public partial struct ActivityTraceId : System.IEquatable<System.Diagnostics.ActivityTraceId>
+ public readonly partial struct ActivityTraceId : System.IEquatable<System.Diagnostics.ActivityTraceId>
{
- private object _dummy;
- private int _dummyPrimitive;
+ private readonly object _dummy;
+ private readonly int _dummyPrimitive;
public void CopyTo(System.Span<byte> destination) { }
public static System.Diagnostics.ActivityTraceId CreateFromBytes(System.ReadOnlySpan<byte> idData) { throw null; }
public static System.Diagnostics.ActivityTraceId CreateFromString(System.ReadOnlySpan<char> idData) { throw null; }
using System.Buffers.Binary;
using System.Buffers.Text;
using System.Collections.Generic;
+using System.Runtime.CompilerServices;
using System.Text;
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
using System.Security;
/// which will have the effect of updating Activity's instance so all subsequent uses
/// share the same converted string.
/// </summary>
- public ref ActivitySpanId SpanId
+ public ref readonly ActivitySpanId SpanId
{
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[System.Security.SecuritySafeCriticalAttribute]
/// which will have the effect of updating Activity's instance so all subsequent uses
/// share the same converted string.
/// </summary>
- public ref ActivityTraceId TraceId
+ public ref readonly ActivityTraceId TraceId
{
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[System.Security.SecuritySafeCriticalAttribute]
/// If the parent Activity ID has the W3C format, this returns the ID for the SpanId part of the ParentId.
/// Otherwise it returns a zero SpanId.
/// </summary>
- public ref ActivitySpanId ParentSpanId
+ public ref readonly ActivitySpanId ParentSpanId
{
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[System.Security.SecuritySafeCriticalAttribute]
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[SecuritySafeCritical]
#endif
- public unsafe struct ActivityTraceId : IEquatable<ActivityTraceId>
+ public unsafe readonly struct ActivityTraceId : IEquatable<ActivityTraceId>
{
/// <summary>
/// Create a new TraceId with at random number in it (very likely to be unique)
if (_asHexString == null)
{
fixed (ulong* idPtr = &_id1)
- _asHexString = SpanToHexString(new ReadOnlySpan<byte>(idPtr, sizeof(ulong) * 2));
+ {
+ // Cast away the read-only-ness of _asHexString, and assign the converted value to it.
+ // We are OK with this because conceptually the class is still read-only.
+ ref string strRef = ref Unsafe.AsRef(in _asHexString);
+ Interlocked.CompareExchange(ref strRef, SpanToHexString(new ReadOnlySpan<byte>(idPtr, sizeof(ulong) * 2)), null);
+ }
}
return _asHexString;
}
readonly ulong _id1;
readonly ulong _id2;
- string _asHexString; // Caches the Hex string
+ readonly string _asHexString; // Caches the Hex string
#endregion
}
#if ALLOW_PARTIALLY_TRUSTED_CALLERS
[SecuritySafeCritical]
#endif
- public unsafe struct ActivitySpanId : IEquatable<ActivitySpanId>
+ public unsafe readonly struct ActivitySpanId : IEquatable<ActivitySpanId>
{
/// <summary>
/// Create a new SpanId with at random number in it (very likely to be unique)
if (_asHexString == null)
{
fixed (ulong* idPtr = &_id1)
- _asHexString = ActivityTraceId.SpanToHexString(new ReadOnlySpan<byte>(idPtr, sizeof(ulong)));
+ {
+ // Cast away the read-only-ness of _asHexString, and assign the converted value to it.
+ // We are OK with this because conceptually the class is still read-only.
+ ref string strRef = ref Unsafe.AsRef(in _asHexString);
+ Interlocked.CompareExchange(ref strRef, ActivityTraceId.SpanToHexString(new ReadOnlySpan<byte>(idPtr, sizeof(ulong))), null);
+ }
}
return _asHexString;
}
}
readonly ulong _id1;
- string _asHexString; // Caches the Hex string
+ readonly string _asHexString; // Caches the Hex string
#endregion
}
}