Skip to content

Binding Discovery: Wrap calls to .GetCustomAttributes in try/catch #1006

Merged
gasparnagy merged 4 commits into
mainfrom
CaptureAttributeLoadingErrors_duringBindingDiscovery
Jan 27, 2026
Merged

Binding Discovery: Wrap calls to .GetCustomAttributes in try/catch #1006
gasparnagy merged 4 commits into
mainfrom
CaptureAttributeLoadingErrors_duringBindingDiscovery

Conversation

@clrudolphi
Copy link
Copy Markdown
Contributor

@clrudolphi clrudolphi commented Jan 18, 2026

🤔 What's changed?

In a small number of situations, binding discovery can fail if a test assembly uses an attribute (unrelated to Reqnroll) that can't be loaded. This can happen, for example, with the generic Connector when invoked against a .NET Framework test assembly and that assembly uses an attribute that belongs to another assembly that is loaded from the GAC. The generic connector (as a .net runtime app) can't load types from the GAC. Rather than have these situations fail the discovery completely, this PR catches those type load exceptions, logs them, and continues processing.

An example of this type of issue is logged in VS Issue #72.

⚡️ What's your motivation?

Allow the VS Extension to obtain (some) binding discovery results even in the face of unloadable types.
Partially address the errors mentioned in Discussion 977

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)

♻️ Anything particular you want feedback on?

  1. What do you think of the idea?
  2. How prominently should these type load errors be highlighted back to the user?
  3. From what I can see, the Reqnroll binding discovery will send a json payload back to the Connector that includes error and warning collections, but that the Connector itself does nothing with these. Do we need an enhancement to the Connector and the VS extension to display this information?

📋 Checklist:

  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "[vNext]" section of the CHANGELOG, linking to this pull request & included my GitHub handle to the release contributors list.

This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.

…ly handle loading errors while reflecting during binding discovery.
@clrudolphi clrudolphi changed the title Wrap calls to .GetCustomAttributes in try/catch Binding Discovery: Wrap calls to .GetCustomAttributes in try/catch Jan 18, 2026
Handle exceptions during type attribute loading and return false to prevent further error reporting.
Added improvement to binding discovery and updated contributors.
@gasparnagy gasparnagy marked this pull request as ready for review January 27, 2026 10:08
@gasparnagy gasparnagy modified the milestone: v3.4 Jan 27, 2026
Copy link
Copy Markdown
Contributor

@gasparnagy gasparnagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested and this works fine!

@gasparnagy gasparnagy merged commit d1a7aca into main Jan 27, 2026
8 checks passed
@gasparnagy gasparnagy deleted the CaptureAttributeLoadingErrors_duringBindingDiscovery branch January 27, 2026 18:50
@gasparnagy
Copy link
Copy Markdown
Contributor

Released in v3.3.3 today: https://github.com/reqnroll/Reqnroll/releases/tag/v3.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants