Skip to content

Commit

Permalink
Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-romano-DD committed Nov 22, 2024
1 parent 3288cc5 commit 7effd69
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ static List<CallTargetDefinitionSource> GetCallTargetDefinition(TypeDefinition t
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for maximum: '{maximumVersion}'");
}

if (assemblyNames is null or { Length: 0 } && assemblyName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for assemblyNames: '{assemblyNames}'");
}

if (typeNames is null or { Length: 0 } && typeName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for typeNames: '{typeNames}'");
}

if (integrationName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for integrationName: '{integrationName}'");
}

if (methodName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for methodName: '{methodName}'");
}

if (returnTypeName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for returnTypeName: '{returnTypeName}'");
}

foreach (var assembly in assemblyNames ?? new[] { assemblyName })
{
foreach (var t in typeNames ?? new[] { typeName })
Expand Down Expand Up @@ -234,6 +259,21 @@ static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute a
}
}

if (methodName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for methodName: '{methodName}'");
}

if (callTargetType is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for callTargetType: '{callTargetType}'");
}

if (returnType is 0 && returnTypeName is null)
{
throw new InvalidOperationException($"Error: Integration type '{type}' has invalid value for returnType: '{returnType}'");
}

return new AdoNetSignature(
className: type.FullName,
targetMethodName: methodName!,
Expand Down Expand Up @@ -301,6 +341,36 @@ static List<AssemblyCallTargetDefinitionSource> GetAdoNetClientInstruments(Custo
throw new InvalidOperationException($"Error: Assembly ADO Attribute Integration '{attribute}' has invalid value for maximum: '{maximumVersion}'");
}

if (string.IsNullOrEmpty(assemblyName))
{
throw new InvalidOperationException($"Error: Integration type '{attribute}' has invalid value for assemblyName: '{assemblyName}'");
}

if (string.IsNullOrEmpty(typeName))
{
throw new InvalidOperationException($"Error: Integration type '{attribute}' has invalid value for typeName: '{typeName}'");
}

if (integrationName is null)
{
throw new InvalidOperationException($"Error: Integration type '{attribute}' has invalid value for integrationName: '{integrationName}'");
}

if (dataReaderTypeName is null)
{
throw new InvalidOperationException($"Error: Integration type '{attribute}' has invalid value for dataReaderTypeName: '{dataReaderTypeName}'");
}

if (dataReaderTaskTypeName is null)
{
throw new InvalidOperationException($"Error: Integration type '{attribute}' has invalid value for dataReaderTaskTypeName: '{dataReaderTaskTypeName}'");
}

if (signatureAttributeTypes is null or { Length: 0 })
{
throw new InvalidOperationException($"Error: Integration type '{attribute}' has invalid value for signatureAttributeTypes: '{signatureAttributeTypes}'");
}

foreach (var signatureAttributeName in signatureAttributeTypes!)
{
res.Add(
Expand Down Expand Up @@ -542,7 +612,7 @@ static string GetCallTargetKind(int kind)
0 => "CallTargetKind::Default",
1 => "CallTargetKind::Derived",
2 => "CallTargetKind::Interface",
_ => throw new InvalidOperationException($"Invalid call target kind: {kind}" );
_ => throw new InvalidOperationException($"Invalid call target kind: {kind}" ),
};
}
}
Expand Down

0 comments on commit 7effd69

Please sign in to comment.