From 80ecfb1146a9b8f632ce2a11474d9077829116cc Mon Sep 17 00:00:00 2001 From: Daniel Romano <108014683+daniel-romano-DD@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:13:53 +0100 Subject: [PATCH] Addressed comments --- tracer/build/_build/Build.Steps.cs | 2 - tracer/build/_build/Build.Utilities.cs | 2 +- .../CodeGenerators/CallTargetsGenerator.cs | 51 ++++++++----------- .../GenerateIntegrationDefinitions.cs | 3 -- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/tracer/build/_build/Build.Steps.cs b/tracer/build/_build/Build.Steps.cs index be1a545875b2..bbbc03cf158d 100644 --- a/tracer/build/_build/Build.Steps.cs +++ b/tracer/build/_build/Build.Steps.cs @@ -82,8 +82,6 @@ partial class Build AbsolutePath TempDirectory => (AbsolutePath)(IsWin ? Path.GetTempPath() : "/tmp/"); - AbsolutePath DependabotPath => TracerDirectory / "dependabot"; - readonly string[] WafWindowsArchitectureFolders = { "win-x86", "win-x64" }; Project NativeTracerProject => Solution.GetProject(Projects.ClrProfilerNative); Project NativeTracerTestsProject => Solution.GetProject(Projects.NativeTracerNativeTests); diff --git a/tracer/build/_build/Build.Utilities.cs b/tracer/build/_build/Build.Utilities.cs index b81a6de36fbb..d39ad75444a3 100644 --- a/tracer/build/_build/Build.Utilities.cs +++ b/tracer/build/_build/Build.Utilities.cs @@ -223,7 +223,7 @@ partial class Build } var testDir = Solution.GetProject(Projects.ClrProfilerIntegrationTests).Directory; - var dependabotProj = DependabotPath / "Datadog.Dependabot.Integrations.csproj"; + var dependabotProj = TracerDirectory / "dependabot" / "Datadog.Dependabot.Integrations.csproj"; var definitionsFile = BuildDirectory / FileNames.DefinitionsJson; var currentDependencies = DependabotFileManager.GetCurrentlyTestedVersions(dependabotProj); var excludedFromUpdates = ((IncludePackages, ExcludePackages) switch diff --git a/tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs b/tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs index 250c3cee0884..34a9ad7a6aa7 100644 --- a/tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs +++ b/tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs @@ -63,7 +63,6 @@ static bool IsTargetAttribute(Mono.Cecil.CustomAttribute attribute) static List GetCallTargetDefinition(TypeDefinition type, CustomAttribute attribute) { var res = new List(); - var hasMisconfiguredInput = false; string assemblyName = null; string[] assemblyNames = null; string integrationName = null; @@ -122,20 +121,21 @@ static List GetCallTargetDefinition(TypeDefinition t instrumentationCategory = (InstrumentationCategory)(namedArgument.Argument.Value as uint?).GetValueOrDefault(); break; default: - hasMisconfiguredInput = true; - break; - } - - if (hasMisconfiguredInput) - { - break; + throw new InvalidOperationException($"Error: Integration type '{type}' has invalid property: '{namedArgument.Name}'"); } } (ushort Major, ushort Minor, ushort Patch) minVersion = default; + if (!TryGetVersion(minimumVersion, ushort.MinValue, out minVersion)) + { + throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for minimum: '{minimumVersion}'"); + } + (ushort Major, ushort Minor, ushort Patch) maxVersion = default; - TryGetVersion(minimumVersion, ushort.MinValue, out minVersion); - TryGetVersion(maximumVersion, ushort.MaxValue, out maxVersion); + if (!TryGetVersion(maximumVersion, ushort.MaxValue, out maxVersion)) + { + throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for maximum: '{maximumVersion}'"); + } foreach (var assembly in assemblyNames ?? new[] { assemblyName }) { @@ -198,8 +198,6 @@ static bool IsTargetSignatureAttribute(Mono.Cecil.CustomAttribute attribute) static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute attribute) { - var hasMisconfiguredInput = false; - string methodName = null; string returnTypeName = null; string[] parameterTypeNames = null; @@ -230,13 +228,7 @@ static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute a returnType = namedArgument.Argument.Value as int?; break; default: - hasMisconfiguredInput = true; - break; - } - - if (hasMisconfiguredInput) - { - break; + throw new InvalidOperationException($"Error: Integration type '{type}' has invalid property: '{namedArgument.Name}'"); } } @@ -253,8 +245,6 @@ static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute a static List GetAdoNetClientInstruments(CustomAttribute attribute) { var res = new List(); - var hasMisconfiguredInput = false; - string assemblyName = null; string integrationName = null; string typeName = null; @@ -293,20 +283,21 @@ static List GetAdoNetClientInstruments(Custo signatureAttributeTypes = GetStringArray(namedArgument.Argument.Value); break; default: - hasMisconfiguredInput = true; - break; - } - - if (hasMisconfiguredInput) - { - break; + throw new InvalidOperationException($"Error: Assembly ADO Attribute Integration '{attribute}' has invalid property: '{namedArgument.Name}'"); } } (ushort Major, ushort Minor, ushort Patch) minVersion = default; + if (!TryGetVersion(minimumVersion, ushort.MinValue, out minVersion)) + { + throw new InvalidOperationException($"Error: Assembly ADO Attribute Integration '{attribute}' has invalid value for minimum: '{minimumVersion}'"); + } + (ushort Major, ushort Minor, ushort Patch) maxVersion = default; - TryGetVersion(minimumVersion, ushort.MinValue, out minVersion); - TryGetVersion(maximumVersion, ushort.MaxValue, out maxVersion); + if (!TryGetVersion(maximumVersion, ushort.MaxValue, out maxVersion)) + { + throw new InvalidOperationException($"Error: Assembly ADO Attribute Integration '{attribute}' has invalid value for maximum: '{maximumVersion}'"); + } foreach (var signatureAttributeName in signatureAttributeTypes!) { diff --git a/tracer/build/_build/PrepareRelease/GenerateIntegrationDefinitions.cs b/tracer/build/_build/PrepareRelease/GenerateIntegrationDefinitions.cs index dcf1a91da30c..ee6bd7996f3a 100644 --- a/tracer/build/_build/PrepareRelease/GenerateIntegrationDefinitions.cs +++ b/tracer/build/_build/PrepareRelease/GenerateIntegrationDefinitions.cs @@ -8,10 +8,7 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Runtime.InteropServices; using System.Runtime.Loader; -using Microsoft.VisualStudio.Services.WebApi; -using Newtonsoft; using Newtonsoft.Json; using Nuke.Common.IO; using static CodeGenerators.CallTargetsGenerator;