Skip to content

[Fix] ReflectionExtensions Performance Improvments#3991

Merged
iancooper merged 8 commits into
BrighterCommand:masterfrom
SimonCropp:ReflectionExtensions-perf-improvments
Jan 28, 2026
Merged

[Fix] ReflectionExtensions Performance Improvments#3991
iancooper merged 8 commits into
BrighterCommand:masterfrom
SimonCropp:ReflectionExtensions-perf-improvments

Conversation

@SimonCropp

Copy link
Copy Markdown
Contributor

No description provided.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Comment thread tests/Paramore.Brighter.Core.Tests/Extensions/ReflectionExtensionsTests.cs Outdated

@iancooper iancooper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR Review: ReflectionExtensions Performance Improvements

Summary

This PR simplifies the ReflectionExtensions methods by leveraging built-in .NET reflection APIs more effectively, resulting in cleaner code and better performance.

Changes Overview

1. ReflectionExtensions.cs - Good simplifications:

  • GetOtherHandlersInPipeline(), GetOtherWrapsInPipeline(), GetOtherUnwrapsInPipeline() → Replaced verbose LINQ queries with direct GetCustomAttributes<T>(true) calls
  • HasNoInboxAttributesInPipeline(), HasExistingUseInboxAttributesInPipeline() → Replaced Any() with IsDefined() which is more efficient as it avoids attribute instantiation

2. Infrastructure changes for testing internal methods:

  • Added InternalsVisibleTo in the main project
  • Added strong-name signing to test assemblies

THIS IS NOT ALLOWED. We do not expose internal classes to tests; only public ones. We seek to build deep modules with narrow interfaces. Don't just make ReflectionExtensions public to fix this; it is an implementation detail and should not have its own tests

Verdict

The changes look good - the code is cleaner, more idiomatic, and the behavioral change to support deeper inheritance hierarchies is an improvement.

We MUST fix the test issues

@iancooper iancooper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Whilst the performance improvements to the ReflectionExtensions are welcome, other aspects of the PR cannot be accepted because they violate our guidelines on testing.

Comment thread src/Paramore.Brighter/Paramore.Brighter.csproj Outdated
Comment thread tests/Paramore.Brighter.Core.Tests/Extensions/ReflectionExtensionsTests.cs Outdated
@iancooper iancooper changed the title ReflectionExtensions perf improvments [Fix] ReflectionExtensions Performance Improvments Jan 27, 2026
Comment thread tests/Directory.Build.props Outdated
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@iancooper

Copy link
Copy Markdown
Member

Thanks @SimonCropp

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

@iancooper iancooper merged commit 263ccd2 into BrighterCommand:master Jan 28, 2026
25 of 27 checks passed
@SimonCropp SimonCropp deleted the ReflectionExtensions-perf-improvments branch January 28, 2026 21:04
DevJonny pushed a commit to DevJonny/Brighter that referenced this pull request Feb 28, 2026
)

* add ReflectionExtensions tests

and make Paramore.Brighter InternalsVisibleTo  to Paramore.Brighter.Core.Tests

* Update ReflectionExtensionsTests.cs

* Update ReflectionExtensions.cs

* Update ReflectionExtensions.cs

* more tests and simplify ReflectionExtensions

* .

---------

Co-authored-by: Ian Cooper <ian_hammond_cooper@yahoo.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants