Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor in Microsoft.OpenApi #6461

Merged
merged 10 commits into from
Jan 14, 2025
Merged
16 changes: 11 additions & 5 deletions tracer/build/_build/UpdateVendors/UpdateVendors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ private static async Task UpdateVendor(VendoredDependency dependency, AbsolutePa
File.Delete(projFile);
Console.WriteLine($"Renamed {libraryName} project file.");

// Delete the assembly properties
var assemblyPropertiesFolder = Path.Combine(sourceLocation, @"Properties");
SafeDeleteDirectory(assemblyPropertiesFolder);
Console.WriteLine($"Deleted {libraryName} assembly properties file.");
// Delete the assembly info file
var assemblyInfo = Path.Combine(sourceLocation, @"Properties", "AssemblyInfo.cs");
if (File.Exists(assemblyInfo))
{
File.Delete(assemblyInfo);
}

Console.WriteLine($"Deleted {libraryName} assembly info file.");

Console.WriteLine($"Running transforms on files for {libraryName}.");

Expand Down Expand Up @@ -111,7 +115,9 @@ private static bool ShouldDropFile(VendoredDependency dependency, string basePat
foreach (var relativeFileToDrop in dependency.RelativePathsToExclude)
{
var absolutePath = Path.Combine(basePath, relativeFileToDrop).Replace('/', '\\');
if (normalizedFilePath.Equals(absolutePath, StringComparison.OrdinalIgnoreCase))
if (normalizedFilePath.Equals(absolutePath, StringComparison.OrdinalIgnoreCase)
|| (absolutePath.EndsWith('\\') &&
normalizedFilePath.StartsWith(absolutePath, StringComparison.OrdinalIgnoreCase)))
{
return true;
}
Expand Down
24 changes: 23 additions & 1 deletion tracer/build/_build/UpdateVendors/VendoredDependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,34 @@ public class VendoredDependency
{
private const string AutoGeneratedMessage = @"//------------------------------------------------------------------------------
// <auto-generated />
// This file was automatically generated by the UpdateVendors tool.
// This file was automatically generated by the UpdateVendoredCode tool.
//------------------------------------------------------------------------------
";

static VendoredDependency()
{
Add(
libraryName: "Microsoft.OpenApi",
"1.6.23",
"https://github.com/microsoft/OpenAPI.NET/archive/1.6.23.zip",
new[] { "OpenAPI.NET-1.6.23", "src", "Microsoft.OpenApi" },
filePath => RewriteCsFileWithStandardTransform(filePath, "Microsoft.OpenApi"),
new[]
{
"Extensions/OpenApiElementExtensions.cs",
"Extensions/OpenApiSerializableExtensions.cs",
"Extensions/OpenApiTypeMapper.cs",
"MicrosoftExtensions/", // whole folder
"Services/CopyReferences.cs",
"Services/OpenApiFilterService.cs",
"Services/OpenApiUrlTreeNode.cs",
"Services/OperationSearch.cs",
"Services/SearchResult.cs",
"Validations/", // whole folder
"Writers/FormattingStreamWriter.cs",
"Writers/OpenApiYamlWriter.cs"
});

Add(
libraryName: "Serilog",
version: "2.10.0",
Expand Down
17 changes: 13 additions & 4 deletions tracer/dependabot/Datadog.Dependabot.Vendors.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<RootNamespace>Datadog.Dependabot.Honeypot</RootNamespace>
</PropertyGroup>

<ItemGroup>
<!-- https://www.nuget.org/packages/Microsoft.OpenApi/1.6.23 -->
<PackageReference Include="Microsoft.OpenApi" Version="1.6.23" />

<!-- https://www.nuget.org/packages/Serilog/2.10.0 -->
<PackageReference Include="Serilog" Version="2.10.0" />

Expand All @@ -30,18 +33,24 @@
<!-- https://www.nuget.org/packages/IndieSystem.Text.RegularExpressions/0.6 -->
<PackageReference Include="IndieSystem.Text.RegularExpressions" Version="0.6" />

<!-- https://www.nuget.org/packages/System.Collections.Immutable/1.0.0 -->
<!-- https://www.nuget.org/packages/System.Collections.Immutable/7.0.0 -->
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />

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

<!-- https://www.nuget.org/packages/System.Reflection.Metadata/1.0.0 -->
<!-- https://www.nuget.org/packages/System.Private.CoreLib/1.0.0 -->
<PackageReference Include="System.Private.CoreLib" Version="1.0.0" />

<!-- https://www.nuget.org/packages/System.Reflection.Metadata/7.0.2 -->
<PackageReference Include="System.Reflection.Metadata" Version="7.0.2" />

<!-- https://www.nuget.org/packages/ICSharpCode.SharpZipLib/1.3.3 -->
<PackageReference Include="ICSharpCode.SharpZipLib" Version="1.3.3" />

<!-- https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/1.0.0 -->
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="1.0.0" />

</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
<type fullname="System.Diagnostics.DebuggerBrowsableState" />
<type fullname="System.Diagnostics.DebuggerDisplayAttribute" />
<type fullname="System.Diagnostics.DebuggerHiddenAttribute" />
<type fullname="System.Diagnostics.DebuggerNonUserCodeAttribute" />
<type fullname="System.Diagnostics.DebuggerStepThroughAttribute" />
<type fullname="System.Diagnostics.DebuggerTypeProxyAttribute" />
</assembly>
Expand All @@ -246,6 +247,7 @@
<type fullname="System.Diagnostics.SymbolStore.SymDocumentType" />
</assembly>
<assembly fullname="System.Diagnostics.Tools">
<type fullname="System.CodeDom.Compiler.GeneratedCodeAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
</assembly>
<assembly fullname="System.Diagnostics.TraceSource">
Expand Down Expand Up @@ -494,6 +496,7 @@
<type fullname="System.Buffers.SpanAction`2" />
<type fullname="System.Byte" />
<type fullname="System.Char" />
<type fullname="System.CodeDom.Compiler.GeneratedCodeAttribute" />
<type fullname="System.Collections.ArrayList" />
<type fullname="System.Collections.DictionaryEntry" />
<type fullname="System.Collections.Generic.ICollection`1" />
Expand Down Expand Up @@ -538,6 +541,8 @@
<type fullname="System.Diagnostics.CodeAnalysis.AllowNullAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes" />
<type fullname="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.MaybeNullAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute" />
Expand All @@ -546,6 +551,8 @@
<type fullname="System.Diagnostics.CodeAnalysis.NotNullAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.NotNullWhenAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute" />
<type fullname="System.Diagnostics.ConditionalAttribute" />
<type fullname="System.Diagnostics.DebuggableAttribute" />
<type fullname="System.Diagnostics.DebuggableAttribute/DebuggingModes" />
Expand All @@ -554,6 +561,7 @@
<type fullname="System.Diagnostics.DebuggerBrowsableState" />
<type fullname="System.Diagnostics.DebuggerDisplayAttribute" />
<type fullname="System.Diagnostics.DebuggerHiddenAttribute" />
<type fullname="System.Diagnostics.DebuggerNonUserCodeAttribute" />
<type fullname="System.Diagnostics.DebuggerStepThroughAttribute" />
<type fullname="System.Diagnostics.DebuggerTypeProxyAttribute" />
<type fullname="System.Diagnostics.StackTraceHiddenAttribute" />
Expand Down Expand Up @@ -719,6 +727,7 @@
<type fullname="System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1" />
<type fullname="System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder" />
<type fullname="System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1" />
<type fullname="System.Runtime.CompilerServices.CallerArgumentExpressionAttribute" />
<type fullname="System.Runtime.CompilerServices.CallerFilePathAttribute" />
<type fullname="System.Runtime.CompilerServices.CallerLineNumberAttribute" />
<type fullname="System.Runtime.CompilerServices.CompilationRelaxationsAttribute" />
Expand Down Expand Up @@ -970,7 +979,10 @@
</assembly>
<assembly fullname="System.Security.Cryptography.Primitives">
<type fullname="System.Security.Cryptography.AsymmetricAlgorithm" />
<type fullname="System.Security.Cryptography.CryptoStream" />
<type fullname="System.Security.Cryptography.CryptoStreamMode" />
<type fullname="System.Security.Cryptography.HashAlgorithm" />
<type fullname="System.Security.Cryptography.ICryptoTransform" />
</assembly>
<assembly fullname="System.Text.Encoding.Extensions">
<type fullname="System.Text.UnicodeEncoding" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <auto-generated />
// This file was automatically generated by the UpdateVendoredCode tool.
//------------------------------------------------------------------------------
#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
{
/// <summary>
/// Type of an <see cref="IOpenApiAny"/>
/// </summary>
internal enum AnyType
{
/// <summary>
/// Primitive.
/// </summary>
Primitive,

/// <summary>
/// Null.
/// </summary>
Null,

/// <summary>
/// Array.
/// </summary>
Array,

/// <summary>
/// Object.
/// </summary>
Object
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated />
// This file was automatically generated by the UpdateVendoredCode tool.
//------------------------------------------------------------------------------
#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;

namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
{
/// <summary>
/// Base interface for all the types that represent Open API Any.
/// </summary>
internal interface IOpenApiAny : IOpenApiElement, IOpenApiExtension
{
/// <summary>
/// Type of an <see cref="IOpenApiAny"/>.
/// </summary>
AnyType AnyType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//------------------------------------------------------------------------------
// <auto-generated />
// This file was automatically generated by the UpdateVendoredCode tool.
//------------------------------------------------------------------------------
#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
{
/// <summary>
/// Primitive type.
/// </summary>
internal enum PrimitiveType
{
/// <summary>
/// Integer
/// </summary>
Integer,

/// <summary>
/// Long
/// </summary>
Long,

/// <summary>
/// Float
/// </summary>
Float,

/// <summary>
/// Double
/// </summary>
Double,

/// <summary>
/// String
/// </summary>
String,

/// <summary>
/// Byte
/// </summary>
Byte,

/// <summary>
/// Binary
/// </summary>
Binary,

/// <summary>
/// Boolean
/// </summary>
Boolean,

/// <summary>
/// Date
/// </summary>
Date,

/// <summary>
/// DateTime
/// </summary>
DateTime,

/// <summary>
/// Password
/// </summary>
Password
}

/// <summary>
/// Base interface for the Primitive type.
/// </summary>
internal interface IOpenApiPrimitive : IOpenApiAny
{
/// <summary>
/// Primitive type.
/// </summary>
PrimitiveType PrimitiveType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//------------------------------------------------------------------------------
// <auto-generated />
// This file was automatically generated by the UpdateVendoredCode tool.
//------------------------------------------------------------------------------
#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;

namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
{
/// <summary>
/// Contains logic for cloning objects through copy constructors.
/// </summary>
internal class OpenApiAnyCloneHelper
{
/// <summary>
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>A clone copy or the object itself.</returns>
[Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")]
[RequiresUnreferencedCode("CloneFromCopyConstructor is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of CloneFromCopyConstructor instead.")]
public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj)
{
if (obj != null)
{
var t = obj.GetType();
foreach (var ci in t.GetConstructors())
{
var pi = ci.GetParameters();
if (pi.Length == 1 && pi[0].ParameterType == t)
{
return (IOpenApiAny)ci.Invoke(new object[] { obj });
}
}
}

return obj;
}

/// <summary>
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>A clone copy or the object itself.</returns>
public static T CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny
{
if (obj != null)
{
foreach (var ci in typeof(T).GetConstructors())
{
var pi = ci.GetParameters();
if (pi.Length == 1 && pi[0].ParameterType == typeof(T))
{
return (T)ci.Invoke([obj]);
}
}
}

return obj;
}
}
}
Loading
Loading