reactiveui / reactiveui/ReactiveUI.Validation

[Bug]: Custom DI container with RxUI - Unable to resolve type IValidationTextFormatter

Open
#979 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
275
Forks
29
Avg merge
2d 12h
Merged PRs (30d)
9

Description

Prerequisites
  • I have searched open and closed issues for duplicates.
  • I am using the latest stable release.
Describe the bug 🐞

With ReactiveUI and Avalonia, I'm following the documentation to use my own DI container with a custom IDependencyResolver implementation and the AppBuilder extension .UseReactiveUIWithDIContainer().

I'm receiving the an InvalidOperationException when trying to resolve ReactiveUI.Validation.Formatters.Abstractions.IValidationTextFormatter`1[System.String]. The Validation classes are not registered into my container through my resolver. They are registered in the original Splat container before AppLocator.SetLocator(dependencyResolver) switches. What's the correct way to resolve this?

Steps to reproduce
using LightInject;

internal class Program
{
    private static ServiceContainer _container;

    [STAThread]
    public static void Main(string[] args)
    {
        _container = RegisterContainer();
        var builder = BuildAvaloniaApp();
        builder.StartWithClassicDesktopLifetime(args);
    }

    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure(static () => new App(_container))
            .UsePlatformDetect()
            .WithInterFont()
            .LogToTrace()
            .UseReactiveUIWithDIContainer(() => _container,
                                          x => { },
                                          c => new LightInjectResolver(c),
                                          x =>
                                          {
                                              x.WithExceptionHandler(new RootExceptionHandler());
                                          });
}
Reproduction repository

No response

Expected behavior

I would have expected an instance of ReactiveUI.Validation.Formatters.Abstractions.IValidationTextFormatter`1[System.String] to be automatically registered through my IDependencyResolver implementation. Or alternatively, a method to register RxUI.Validation types manually

Screenshots 🖼️

No response

IDE

No response

.NET version

.NET 10

Target framework(s)

No response

Operating system

No response

OS version

No response

Device

No response

ReactiveUI version

ReactiveUI.Validation=7.1.0, ReactiveUI.Avalonia=12.0.3

Additional information ℹ️

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the UseReactiveUIWithDIContainer entry point and the AppLocator.SetLocator transition, then inspect how ReactiveUI.Validation formatter types are registered and resolved through IDependencyResolver. Reproduce the LightInject setup and verify whether IValidationTextFormatter resolves through the custom container or requires a supported manual-registration path.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.