Skip to content

Commit e8dbf66

Browse files
bieluclaude
andcommitted
refactor: resolve binding type name only when reporting the error
Move the typeof(TBinding) lookup into the unregistered-binding branch so it is not evaluated for every bindings object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bd679d9 commit e8dbf66

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/ByteBard.AsyncAPI.Readers/BindingDeserializer.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ internal static AsyncApiBindings<TBinding> LoadBindings<TBinding>(
2929
where TBinding : IBinding
3030
{
3131
var context = mapNode.Context;
32-
33-
// TBinding is the binding interface (e.g. IChannelBinding), so drop the leading "I" for the diagnostic.
34-
var bindingType = typeof(TBinding).Name.Substring(1);
3532
var bindings = new AsyncApiBindings<TBinding>();
3633
foreach (var property in mapNode)
3734
{
@@ -42,6 +39,9 @@ internal static AsyncApiBindings<TBinding> LoadBindings<TBinding>(
4239

4340
if (!parsers.TryGetValue(property.Name, out var parser))
4441
{
42+
// TBinding is the binding interface (e.g. IChannelBinding), so drop the leading "I" for the diagnostic.
43+
var bindingType = typeof(TBinding).Name.Substring(1);
44+
4545
// Reported as an error because the binding is dropped from the model and cannot be written back.
4646
context.Diagnostic.Errors.Add(
4747
new AsyncApiError(context.GetLocation(), $"{bindingType} {property.Name} is not found"));

0 commit comments

Comments
 (0)