diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d3a18812..d2b5b7d47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad ## [Unreleased] +### Added + +- `Render(RenderFragment)` is preferred via the `OverloadResolutionAttribute`. Reported by [@ScarletKuro](https://github.com/ScarletKuro) in #1800. Fixed by [@linkdotnet](https://github.com/linkdotnet). + ## [2.4.2] - 2025-12-21 ### Fixed diff --git a/src/bunit/BunitContext.cs b/src/bunit/BunitContext.cs index 948d44b15..cb3aea4d9 100644 --- a/src/bunit/BunitContext.cs +++ b/src/bunit/BunitContext.cs @@ -1,3 +1,6 @@ +#if NET9_0_OR_GREATER +using System.Runtime.CompilerServices; +#endif using Bunit.Extensions; using Bunit.Rendering; using Microsoft.Extensions.Logging; @@ -158,9 +161,12 @@ public virtual IRenderedComponent Render(ActionThe type of component to find in the render tree. /// The render fragment to render. /// The . +#if NET9_0_OR_GREATER + [OverloadResolutionPriority(1)] +#endif public virtual IRenderedComponent Render(RenderFragment renderFragment) where TComponent : IComponent - => this.RenderInsideRenderTree(renderFragment); + => RenderInsideRenderTree(renderFragment); /// /// Renders the and returns it as a .