Repository navigation
Description
Product
Hot Chocolate
Version
14.1.0
Link to minimal reproduction
.
Steps to reproduce
[ObjectType<LineItem>]
public static partial class LineItemType
{
[BindField("product")]
public static Product GetProduct([Parent] LineItem lineItem)
=> new(lineItem.ProductId);
}
generates:
public static partial class LineItemType
{
internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor<global::quick_start.Ordering.Types.LineItem> descriptor)
{
const global::System.Reflection.BindingFlags bindingFlags =
global::System.Reflection.BindingFlags.Public
| global::System.Reflection.BindingFlags.NonPublic
| global::System.Reflection.BindingFlags.Static;
var thisType = typeof(global::quick_start.Ordering.Types.LineItemType);
var bindingResolver = descriptor.Extend().Context.ParameterBindingResolver;
global::quick_start.Ordering.Types.LineItemTypeResolvers.InitializeBindings(bindingResolver);
descriptor
.Field(thisType.GetMember("GetProduct", bindingFlags)[0])
.ExtendWith(c =>
{
c.Definition.SetSourceGeneratorFlags();
c.Definition.Resolvers = global::quick_start.Ordering.Types.LineItemTypeResolvers.LineItemType_GetProduct();
});
descriptor // <---- HERE IS THE ISSUE
Configure(descriptor);
}
static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor<global::quick_start.Ordering.Types.LineItem> descriptor);
}
}
Workaround:
public static partial class LineItemType
{
static partial void Configure(IObjectTypeDescriptor<LineItem> descriptor)
{
descriptor.Ignore(x => x.ProductId);
}
public static Product GetProduct([Parent] LineItem lineItem)
=> new(lineItem.ProductId);
}
What is expected?
The code is generated correctly
What is actually happening?
There is a compilation errros
Relevant log output
Additional context
No response
Reacted by Ben Ayles
Activity
[-]Source Generator cannot deal with [BindMember][/-][+]Source Generator cannot deal with [BindFIeld][/+][-]Source Generator cannot deal with [BindFIeld][/-][+]Source Generator cannot deal with [BindField][/+]michaelstaib commentedon Feb 27, 2026
Hey,
I have tested this on main.
I retested at commit d7dafeb.
What I tested:
Result on net8/net9/net10: passed.
I could not reproduce the source-generator compile failure with
[BindField]on currentmain.michaelstaib commentedon Feb 27, 2026
Closing this since I couldn't reproduce it on current main after the retest above.