Skip to content

Commit ad11bcf

Browse files
committed
Update vendored code
1 parent 1102b3b commit ad11bcf

89 files changed

Lines changed: 17635 additions & 10230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tracer/dependabot/Datadog.Dependabot.Vendors.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<!-- https://www.nuget.org/packages/Datadog.Sketches/main -->
3232
<PackageReference Include="Datadog.Sketches" Version="main" />
3333

34-
<!-- https://www.nuget.org/packages/System.Collections.Immutable/7.0.0 -->
35-
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
34+
<!-- https://www.nuget.org/packages/System.Collections.Immutable/7.0.20 -->
35+
<PackageReference Include="System.Collections.Immutable" Version="7.0.20" />
3636

3737
<!-- https://www.nuget.org/packages/System.Memory/4.5.5 -->
3838
<PackageReference Include="System.Memory" Version="4.5.5" />

tracer/src/Datadog.Trace/Vendors/System.Collections.Immutable/System.Collections.Immutable.csproj.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated />
3+
// This file was automatically generated by the UpdateVendoredCode tool.
4+
//------------------------------------------------------------------------------
5+
#pragma warning disable CS0105, CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
6+
#pragma warning disable CS8600, CS8601, CS8602, CS8603, CS8604, CS8618, CS8620, CS8714, CS8762, CS8765, CS8766, CS8767, CS8768, CS8769, CS8612, CS8629, CS8774
7+
// Licensed to the .NET Foundation under one or more agreements.
8+
// The .NET Foundation licenses this file to you under the MIT license.
9+
10+
#nullable enable
11+
using System;
12+
using System.Collections;
13+
using System.Collections.Generic;
14+
using System.IO;
15+
using System.Linq;
16+
using System.Threading;
17+
using System.Threading.Tasks;
18+
19+
namespace Datadog.Trace.VendoredMicrosoftCode.System.Collections.Generic
20+
{
21+
/// <summary>
22+
/// Defined on a generic collection that hashes its contents using an <see cref="IEqualityComparer{TKey}"/>.
23+
/// </summary>
24+
/// <typeparam name="TKey">The type of element hashed in the collection.</typeparam>
25+
internal interface IHashKeyCollection<in TKey>
26+
{
27+
/// <summary>
28+
/// Gets the comparer used to obtain hash codes for the keys and check equality.
29+
/// </summary>
30+
IEqualityComparer<TKey> KeyComparer { get; }
31+
}
32+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated />
3+
// This file was automatically generated by the UpdateVendoredCode tool.
4+
//------------------------------------------------------------------------------
5+
#pragma warning disable CS0105, CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
6+
#pragma warning disable CS8600, CS8601, CS8602, CS8603, CS8604, CS8618, CS8620, CS8714, CS8762, CS8765, CS8766, CS8767, CS8768, CS8769, CS8612, CS8629, CS8774
7+
// Licensed to the .NET Foundation under one or more agreements.
8+
// The .NET Foundation licenses this file to you under the MIT license.
9+
10+
using Datadog.Trace.VendoredMicrosoftCode.System.Collections.Generic;
11+
using System.Diagnostics.CodeAnalysis;
12+
13+
#nullable enable
14+
using System;
15+
using System.Collections;
16+
using System.Collections.Generic;
17+
using System.IO;
18+
using System.Linq;
19+
using System.Threading;
20+
using System.Threading.Tasks;
21+
22+
namespace Datadog.Trace.VendoredMicrosoftCode.System.Collections.Immutable
23+
{
24+
internal static class AllocFreeConcurrentStack<T>
25+
{
26+
private const int MaxSize = 35;
27+
28+
#if NETCOREAPP
29+
[ThreadStatic]
30+
private static Stack<RefAsValueType<T>>? t_stack;
31+
#else
32+
private static readonly Type s_typeOfT = typeof(T);
33+
#endif
34+
35+
public static void TryAdd(T item)
36+
{
37+
Stack<RefAsValueType<T>> localStack =
38+
#if NETCOREAPP
39+
t_stack ??= new Stack<RefAsValueType<T>>(MaxSize);
40+
#else
41+
ThreadLocalStack;
42+
#endif
43+
44+
// Just in case we're in a scenario where an object is continually requested on one thread
45+
// and returned on another, avoid unbounded growth of the stack.
46+
if (localStack.Count < MaxSize)
47+
{
48+
localStack.Push(new RefAsValueType<T>(item));
49+
}
50+
}
51+
52+
public static bool TryTake([MaybeNullWhen(false)] out T item)
53+
{
54+
#if NETCOREAPP
55+
Stack<RefAsValueType<T>>? localStack = t_stack; // cache in a local to avoid unnecessary TLS hits on repeated accesses
56+
#else
57+
Stack<RefAsValueType<T>> localStack = ThreadLocalStack;
58+
#endif
59+
if (localStack != null && localStack.Count > 0)
60+
{
61+
item = localStack.Pop().Value;
62+
return true;
63+
}
64+
65+
item = default;
66+
return false;
67+
}
68+
69+
#if !NETCOREAPP
70+
private static Stack<RefAsValueType<T>> ThreadLocalStack
71+
{
72+
get
73+
{
74+
// Ensure the [ThreadStatic] is initialized to a dictionary
75+
Dictionary<Type, object>? typesToStacks = AllocFreeConcurrentStack.t_stacks ??= new Dictionary<Type, object>();
76+
77+
// Get the stack that corresponds to the T
78+
if (!typesToStacks.TryGetValue(s_typeOfT, out object? stackObj))
79+
{
80+
stackObj = new Stack<RefAsValueType<T>>(MaxSize);
81+
typesToStacks.Add(s_typeOfT, stackObj);
82+
}
83+
84+
// Return it as the correct type.
85+
return (Stack<RefAsValueType<T>>)stackObj;
86+
}
87+
}
88+
#endif
89+
}
90+
91+
#if !NETCOREAPP
92+
internal static class AllocFreeConcurrentStack
93+
{
94+
// Workaround for https://github.com/dotnet/runtime/issues/4731.
95+
[ThreadStatic]
96+
internal static Dictionary<Type, object>? t_stacks;
97+
}
98+
#endif
99+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated />
3+
// This file was automatically generated by the UpdateVendoredCode tool.
4+
//------------------------------------------------------------------------------
5+
#pragma warning disable CS0105, CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
6+
#pragma warning disable CS8600, CS8601, CS8602, CS8603, CS8604, CS8618, CS8620, CS8714, CS8762, CS8765, CS8766, CS8767, CS8768, CS8769, CS8612, CS8629, CS8774
7+
// Licensed to the .NET Foundation under one or more agreements.
8+
// The .NET Foundation licenses this file to you under the MIT license.
9+
10+
using Datadog.Trace.VendoredMicrosoftCode.System.Collections.Generic;
11+
12+
#nullable enable
13+
using System;
14+
using System.Collections;
15+
using System.Collections.Generic;
16+
using System.IO;
17+
using System.Linq;
18+
using System.Threading;
19+
using System.Threading.Tasks;
20+
21+
namespace Datadog.Trace.VendoredMicrosoftCode.System.Collections.Immutable
22+
{
23+
internal sealed class DictionaryEnumerator<TKey, TValue> : IDictionaryEnumerator where TKey : notnull
24+
{
25+
private readonly IEnumerator<KeyValuePair<TKey, TValue>> _inner;
26+
27+
internal DictionaryEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> inner)
28+
{
29+
Requires.NotNull(inner, nameof(inner));
30+
31+
_inner = inner;
32+
}
33+
34+
public DictionaryEntry Entry
35+
{
36+
get { return new DictionaryEntry(_inner.Current.Key, _inner.Current.Value); }
37+
}
38+
39+
public object Key
40+
{
41+
get { return _inner.Current.Key; }
42+
}
43+
44+
public object? Value
45+
{
46+
get { return _inner.Current.Value; }
47+
}
48+
49+
public object Current
50+
{
51+
get { return this.Entry; }
52+
}
53+
54+
public bool MoveNext()
55+
{
56+
return _inner.MoveNext();
57+
}
58+
59+
public void Reset()
60+
{
61+
_inner.Reset();
62+
}
63+
}
64+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated />
3+
// This file was automatically generated by the UpdateVendoredCode tool.
4+
//------------------------------------------------------------------------------
5+
#pragma warning disable CS0105, CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
6+
#pragma warning disable CS8600, CS8601, CS8602, CS8603, CS8604, CS8618, CS8620, CS8714, CS8762, CS8765, CS8766, CS8767, CS8768, CS8769, CS8612, CS8629, CS8774
7+
// Licensed to the .NET Foundation under one or more agreements.
8+
// The .NET Foundation licenses this file to you under the MIT license.
9+
10+
using Datadog.Trace.VendoredMicrosoftCode.System.Collections.Generic;
11+
12+
#nullable enable
13+
using System;
14+
using System.Collections;
15+
using System.Collections.Generic;
16+
using System.IO;
17+
using System.Linq;
18+
using System.Threading;
19+
using System.Threading.Tasks;
20+
21+
namespace Datadog.Trace.VendoredMicrosoftCode.System.Collections.Immutable
22+
{
23+
/// <summary>
24+
/// An adapter that allows a single foreach loop in C# to avoid
25+
/// boxing an enumerator when possible, but fall back to boxing when necessary.
26+
/// </summary>
27+
/// <typeparam name="T">The type of value to be enumerated.</typeparam>
28+
/// <typeparam name="TEnumerator">The type of the enumerator struct.</typeparam>
29+
internal struct DisposableEnumeratorAdapter<T, TEnumerator> : IDisposable
30+
where TEnumerator : struct, IEnumerator<T>
31+
{
32+
/// <summary>
33+
/// The enumerator object to use if not null.
34+
/// </summary>
35+
private readonly IEnumerator<T>? _enumeratorObject;
36+
37+
/// <summary>
38+
/// The enumerator struct to use if <see cref="_enumeratorObject"/> is <c>null</c>.
39+
/// </summary>
40+
/// <remarks>
41+
/// This field must NOT be readonly because the field's value is a struct and must be able to mutate
42+
/// in-place. A readonly keyword would cause any mutation to take place in a copy rather than the field.
43+
/// </remarks>
44+
private TEnumerator _enumeratorStruct;
45+
46+
/// <summary>
47+
/// Initializes a new instance of the <see cref="DisposableEnumeratorAdapter{T, TEnumerator}"/> struct
48+
/// for enumerating over a strongly typed struct enumerator.
49+
/// </summary>
50+
/// <param name="enumerator">The initialized enumerator struct.</param>
51+
internal DisposableEnumeratorAdapter(TEnumerator enumerator)
52+
{
53+
_enumeratorStruct = enumerator;
54+
_enumeratorObject = null;
55+
}
56+
57+
/// <summary>
58+
/// Initializes a new instance of the <see cref="DisposableEnumeratorAdapter{T, TEnumerator}"/> struct
59+
/// for enumerating over a (boxed) <see cref="IEnumerable{T}"/> enumerator.
60+
/// </summary>
61+
/// <param name="enumerator">The initialized enumerator object.</param>
62+
internal DisposableEnumeratorAdapter(IEnumerator<T> enumerator)
63+
{
64+
_enumeratorStruct = default(TEnumerator);
65+
_enumeratorObject = enumerator;
66+
}
67+
68+
/// <summary>
69+
/// Gets the current enumerated value.
70+
/// </summary>
71+
public T Current
72+
{
73+
get { return _enumeratorObject != null ? _enumeratorObject.Current : _enumeratorStruct.Current; }
74+
}
75+
76+
/// <summary>
77+
/// Moves to the next value.
78+
/// </summary>
79+
public bool MoveNext()
80+
{
81+
return _enumeratorObject != null ? _enumeratorObject.MoveNext() : _enumeratorStruct.MoveNext();
82+
}
83+
84+
/// <summary>
85+
/// Disposes the underlying enumerator.
86+
/// </summary>
87+
public void Dispose()
88+
{
89+
if (_enumeratorObject != null)
90+
{
91+
_enumeratorObject.Dispose();
92+
}
93+
else
94+
{
95+
_enumeratorStruct.Dispose();
96+
}
97+
}
98+
99+
/// <summary>
100+
/// Returns a copy of this struct.
101+
/// </summary>
102+
/// <remarks>
103+
/// This member is here so that it can be used in C# foreach loops.
104+
/// </remarks>
105+
public DisposableEnumeratorAdapter<T, TEnumerator> GetEnumerator()
106+
{
107+
return this;
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)