Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-romano-DD committed Nov 15, 2024
1 parent 449cbd4 commit 80ecfb1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
2 changes: 0 additions & 2 deletions tracer/build/_build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tracer/build/_build/Build.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 21 additions & 30 deletions tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static bool IsTargetAttribute(Mono.Cecil.CustomAttribute attribute)
static List<CallTargetDefinitionSource> GetCallTargetDefinition(TypeDefinition type, CustomAttribute attribute)
{
var res = new List<CallTargetDefinitionSource>();
var hasMisconfiguredInput = false;
string assemblyName = null;
string[] assemblyNames = null;
string integrationName = null;
Expand Down Expand Up @@ -122,20 +121,21 @@ static List<CallTargetDefinitionSource> 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 })
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}'");
}
}

Expand All @@ -253,8 +245,6 @@ static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute a
static List<AssemblyCallTargetDefinitionSource> GetAdoNetClientInstruments(CustomAttribute attribute)
{
var res = new List<AssemblyCallTargetDefinitionSource>();
var hasMisconfiguredInput = false;

string assemblyName = null;
string integrationName = null;
string typeName = null;
Expand Down Expand Up @@ -293,20 +283,21 @@ static List<AssemblyCallTargetDefinitionSource> 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!)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80ecfb1

Please sign in to comment.