Skip to content

Commit 453c814

Browse files
committed
Update vendoring
1 parent e3ce41d commit 453c814

1 file changed

Lines changed: 30 additions & 73 deletions

File tree

tracer/build/_build/UpdateVendors/VendoredDependency.cs

Lines changed: 30 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,35 @@ static VendoredDependency()
252252
},
253253
relativePathsToExclude: new[]
254254
{
255+
// .NET Core-only files
255256
"Internal/Utilities/EncodingHelper.netcoreapp.cs",
256257
"Internal/Utilities/StreamExtensions.netcoreapp.cs",
258+
259+
// Builder/writer code - the tracer only reads metadata, never writes it
260+
"Metadata/Ecma335/Encoding/",
261+
"Metadata/BlobBuilder.cs",
262+
"Metadata/BlobBuilder.Enumerators.cs",
263+
"Metadata/BlobWriter.cs",
264+
"Metadata/BlobWriterImpl.cs",
265+
"Metadata/PooledBlobBuilder.cs",
266+
"Metadata/ReservedBlob.cs",
267+
"Metadata/Ecma335/MetadataBuilder.cs",
268+
"Metadata/Ecma335/MetadataBuilder.Heaps.cs",
269+
"Metadata/Ecma335/MetadataBuilder.Tables.cs",
270+
"Metadata/Ecma335/MetadataRootBuilder.cs",
271+
"Metadata/Ecma335/PortablePdbBuilder.cs",
272+
"Metadata/Ecma335/MetadataSizes.cs",
273+
"Metadata/Ecma335/SerializedMetadataHeaps.cs",
274+
"Metadata/Ecma335/MetadataAggregator.cs",
275+
"Metadata/Internal/MetadataWriterUtilities.cs",
276+
"PortableExecutable/PEBuilder.cs",
277+
"PortableExecutable/ManagedPEBuilder.cs",
278+
"PortableExecutable/ManagedTextSection.cs",
279+
"PortableExecutable/PEDirectoriesBuilder.cs",
280+
"PortableExecutable/PEHeaderBuilder.cs",
281+
"PortableExecutable/ResourceSectionBuilder.cs",
282+
"PortableExecutable/DebugDirectory/DebugDirectoryBuilder.cs",
283+
"PortableExecutable/DebugDirectory/DebugDirectoryBuilder.EmbeddedPortablePdb.cs",
257284
});
258285

259286
Add(
@@ -472,14 +499,8 @@ private static string FixSystemReflectionMetadata(string filePath, string conten
472499
RewriteFileWithTransform(
473500
filePath,
474501
content => content.Replace(
475-
" private static ReadOnlySpan<byte> DosHeader => new byte[DosHeaderSize]",
476-
"""
477-
#if NETCOREAPP
478-
private static ReadOnlySpan<byte> DosHeader => new byte[DosHeaderSize]
479-
#else
480-
private static readonly byte[] DosHeader = new byte[DosHeaderSize]
481-
#endif
482-
"""
502+
"private static ReadOnlySpan<byte> DosHeader => new byte[DosHeaderSize]",
503+
"private static readonly byte[] DosHeader = new byte[DosHeaderSize]"
483504
));
484505
}
485506

@@ -511,85 +532,21 @@ private static string FixSystemReflectionMetadata(string filePath, string conten
511532

512533
contents = contents
513534
.Replace("using System.Collections.Immutable;", "using Datadog.Trace.VendoredMicrosoftCode.System.Collections.Immutable;")
514-
.Replace("namespace System.Reflection;", "namespace Datadog.Trace.VendoredMicrosoftCode.System.Reflection;")
535+
.Replace("namespace System.Reflection", "namespace Datadog.Trace.VendoredMicrosoftCode.System.Reflection")
515536
.Replace("Configuration.Assemblies.AssemblyHashAlgorithm", "global::System.Configuration.Assemblies.AssemblyHashAlgorithm");
516537

517-
// some somewhat hacky fixes for specific issues
518-
// if (string.Equals(Path.GetFileName(filePath), "Tables.cs")
519-
// || string.Equals(Path.GetFileName(filePath), "MetadataBuilder.Tables.cs")
520-
// || string.Equals(Path.GetFileName(filePath), "MetadataReader.netstandard.cs"))
521-
// {
522-
// // Add using System.Reflection
523-
// contents = contents.Replace(
524-
// "\n\nnamespace Datadog.Trace.VendoredMicrosoftCode.System.Reflection.",
525-
// "\nusing System.Reflection;\n\nnamespace Datadog.Trace.VendoredMicrosoftCode.System.Reflection.");
526-
// }
527-
// contents = contents
528-
// .Replace("Datadog.Trace.VendoredMicrosoftCode.System.Runtime.ConstrainedExecution", "System.Runtime.ConstrainedExecution")
529-
// .Replace("Datadog.Trace.VendoredMicrosoftCode.System.Runtime.ExceptionServices", "System.Runtime.ExceptionServices")
530-
// .Replace("Datadog.Trace.VendoredMicrosoftCode.System.Runtime.CompilerServices", "System.Runtime.CompilerServices")
531-
// .Replace("Datadog.Trace.VendoredMicrosoftCode.System.Runtime.Serialization", "System.Runtime.Serialization");
532-
// if (string.Equals(Path.GetFileName(filePath), "ImmutableList_1.Enumerator.cs"))
533-
// {
534-
// contents = contents.Replace("System.Collections.IEnumerator.Current", "global::System.Collections.IEnumerator.Current");
535-
// }
536-
//
537538
if (string.Equals(Path.GetFileName(filePath), "Throw.cs"))
538539
{
539540
contents = contents
540541
.Replace("throw new ObjectDisposedException(nameof(PortableExecutable.PEReader));", "throw new ObjectDisposedException(\"PEReader\");");
541542
}
542-
else if (string.Equals(Path.GetFileName(filePath), "BlobBuilder.cs"))
543-
{
544-
contents = contents
545-
.Replace("using System.Linq;\n", string.Empty)
546-
.Replace(
547-
"""GetChunks().Select<BlobBuilder, string>(chunk => $"[{Display(chunk._buffer, chunk.Length)}]"))""",
548-
"""GetChunks().Select<BlobBuilder, string>((Func<BlobBuilder, string>) (chunk => "[" + BlobBuilder.Display(chunk._buffer, chunk.Length) + "]")))""");
549-
}
550543
else if (string.Equals(Path.GetFileName(filePath), "MetadataReader.WinMD.cs"))
551544
{
552545
contents = contents
553546
.Replace(
554547
"""internal static readonly byte[] WinRTPrefix = "<WinRT>"u8.ToArray();""",
555548
"""internal static readonly byte[] WinRTPrefix = global::System.Text.Encoding.UTF8.GetBytes("<WinRT>");""");
556549
}
557-
else if (string.Equals(Path.GetFileName(filePath), "MethodDefinition.cs"))
558-
{
559-
// TODO: Maybe we should use duck typing for this instead, so we can exclude from .NET 6+?
560-
contents = contents
561-
.Replace(
562-
"""private MethodDefinitionHandle Handle\n""",
563-
"""internal MethodDefinitionHandle Handle\n""");
564-
}
565-
//
566-
// if (string.Equals(Path.GetFileName(filePath), "KeysOrValuesCollectionAccessor.cs"))
567-
// {
568-
// // Hacky, but it works
569-
// contents = contents.Replace("var sortedDictionary = this.Dictionary as ImmutableSortedDictionary<TKey, TValue>;", "var sortedDictionary = this.Dictionary as IImmutableDictionaryInternal<TKey, TValue>;");
570-
// }
571-
//
572-
// if (string.Equals(Path.GetFileName(filePath), "ImmutableList_1.Node.cs"))
573-
// {
574-
// contents = contents.Replace("root.AddRange(Linq.Enumerable.Select(this, converter));", "root.AddRange(global::System.Linq.Enumerable.Select(this, converter));");
575-
// }
576-
//
577-
// if (string.Equals(Path.GetFileName(filePath), "ImmutableList_1.Builder.cs"))
578-
// {
579-
// contents = contents.Replace("System.Threading.Interlocked.CompareExchange", "global::System.Threading.Interlocked.CompareExchange");
580-
// }
581-
//
582-
// if (string.Equals(Path.GetFileName(filePath), "ImmutableDictionary_2.Builder.cs"))
583-
// {
584-
// contents = contents.Replace("Threading.Interlocked.CompareExchange", "global::System.Threading.Interlocked.CompareExchange");
585-
// }
586-
//
587-
// // replace SR, hard to do generally
588-
// contents = contents
589-
// .Replace("""ArgumentException(SR.Format(SR.DuplicateKey, key))""", """ArgumentException("DuplicateKey" + key)""")
590-
// .Replace("""KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()))""", """KeyNotFoundException("Arg_KeyNotFoundWithKey" + key.ToString())""")
591-
// .Replace("""SR.Format(SR.Arg_KeyNotFoundWithKey, (object) key.ToString()));""", """key.ToString());""");
592-
// contents = Regex.Replace(contents, @"SR\.(\w+)(?=\W)", "@\"$1\"");
593550

594551
return contents;
595552
}

0 commit comments

Comments
 (0)