diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 1b2d03a..ee71980 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -17,7 +17,7 @@
https://github.com/benmccallum/fairybread/raw/master/logo-400x400.png
https://github.com/benmccallum/fairybread/blob/master/LICENSE
- 8.0.0-rc.2
+ 8.0.0-rc.3
12.0.1
diff --git a/src/FairyBread/ValidationMiddlewareInjector.cs b/src/FairyBread/ValidationMiddlewareInjector.cs
index f9af1ba..22142b6 100644
--- a/src/FairyBread/ValidationMiddlewareInjector.cs
+++ b/src/FairyBread/ValidationMiddlewareInjector.cs
@@ -52,7 +52,7 @@ public override void OnBeforeCompleteType(
// 3. the arg actually has a validator for it's runtime type
if (options.OptimizeMiddlewarePlacement)
{
- var (allowUnknown, argRuntimeType) = TryGetArgRuntimeType(argDef);
+ var (allowUnknown, argRuntimeType) = TryGetArgRuntimeType(objTypeDef, fieldDef, argDef);
if (argRuntimeType is null)
{
if (!allowUnknown &&
@@ -86,21 +86,36 @@ public override void OnBeforeCompleteType(
}
}
- private static (bool AllowUnknown, Type? Type) TryGetArgRuntimeType(ArgumentDefinition argDef)
+ private static (bool AllowUnknown, Type? Type) TryGetArgRuntimeType(
+ ObjectTypeDefinition objTypeDef,
+ ObjectFieldDefinition fieldDef,
+ ArgumentDefinition argDef)
{
if (argDef.Parameter?.ParameterType is { } argRuntimeType)
{
return (false, argRuntimeType);
}
- if (argDef.Type is SyntaxTypeReference synTypeRef)
+ if (argDef.Type is SyntaxTypeReference)
{
return (true, null);
}
if (argDef.Type is ExtendedTypeReference extTypeRef)
{
- return (false, TryGetRuntimeType(extTypeRef.Type));
+ try
+ {
+ return (false, TryGetRuntimeType(extTypeRef.Type));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(
+ $"Problem getting runtime type for argument '{argDef.Name}' " +
+ $"in field '{fieldDef.Name}' on object type '{objTypeDef.Name}'. " +
+ $"Disable {nameof(IFairyBreadOptions.OptimizeMiddlewarePlacement)} in " +
+ $"options and report the issue on GitHub.",
+ ex);
+ }
}
return (false, null);