{"record":{"id":"35575921d612d4fd","repo":"PrismLibrary/Prism","slug":"the-builder-does-not-implement-iregistryaware-355759","errorCode":null,"errorMessage":"The builder does not implement IRegistryAware","messagePattern":"The builder does not implement IRegistryAware","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Builder/TabbedSegmentBuilder.cs","lineNumber":17,"sourceCode":"using Prism.Common;\nusing Prism.Mvvm;\n\nnamespace Prism.Navigation.Builder;\n\ninternal class TabbedSegmentBuilder : ITabbedSegmentBuilder, IConfigurableSegmentName, IUriSegment, IRegistryAware\n{\n    private INavigationParameters _parameters { get; }\n    private INavigationBuilder _builder { get; }\n\n    public TabbedSegmentBuilder(INavigationBuilder builder)\n    {\n        _builder = builder;\n        _parameters = new NavigationParameters();\n\n        if (builder is not IRegistryAware registryAware)\n            throw new Exception(\"The builder does not implement IRegistryAware\");\n\n        var registrations = registryAware.Registry.ViewsOfType(typeof(TabbedPage));\n        if (!registrations.Any())\n            throw new NavigationException(NavigationException.NoPageIsRegistered, nameof(TabbedPage));\n\n        var registration = registrations.Last();\n        SegmentName = registration.Name;\n    }\n\n    public TabbedSegmentBuilder(INavigationBuilder builder, string segmentName)\n    {\n        _builder = builder;\n        _parameters = new NavigationParameters();\n\n        if (builder is not IRegistryAware registryAware)\n            throw new Exception(\"The builder does not implement IRegistryAware\");\n\n        var registration = registryAware.Registry.ViewsOfType(typeof(TabbedPage)).FirstOrDefault(x => x.Name == segmentName);","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Builder/TabbedSegmentBuilder.cs#L1-L35","documentation":"The TabbedSegmentBuilder constructor requires the supplied INavigationBuilder to implement IRegistryAware so it can look up TabbedPage registrations. If it does not, a plain Exception is thrown at construction time. Prism's own builders implement this interface; third-party or test-double builders typically do not.","triggerScenarios":"Constructing `new TabbedSegmentBuilder(builder)` where `builder` is an INavigationBuilder implementation lacking IRegistryAware - e.g. a mock or custom INavigationBuilder used in tests or a derived builder.","commonSituations":"Testing Prism navigation with hand-rolled INavigationBuilder fakes; subclassing Prism's NavigationBuilder in a version where IRegistryAware did not exist; replacing navigation services via DI with a simplified implementation.","solutions":["Ensure the builder passed to TabbedSegmentBuilder is Prism's own INavigationBuilder (which implements IRegistryAware).","Implement IRegistryAware on custom builders and delegate Registry to the wrapped builder.","Register TabbedPage in the view registry so the subsequent registration lookup succeeds."],"exampleFix":"// before\npublic class FakeNavBuilder : INavigationBuilder { ... }\nvar tabBuilder = new TabbedSegmentBuilder(fakeNavBuilder); // throws\n// after\npublic class FakeNavBuilder : INavigationBuilder, IRegistryAware\n{\n    public IViewRegistry Registry { get; set; }\n}","handlingStrategy":"type-guard","validationCode":"if (navBuilder is not IRegistryAware)\n    throw new InvalidOperationException(\"INavigationBuilder must implement IRegistryAware to build TabbedSegments\");","typeGuard":"bool SupportsTabbedSegment(INavigationBuilder b) => b is IRegistryAware;","tryCatchPattern":"try { var tab = new TabbedSegmentBuilder(navBuilder); }\ncatch (Exception ex) when (ex.Message.Contains(\"IRegistryAware\"))\n{\n    // swap in Prism's stock INavigationBuilder implementation\n}","preventionTips":["Test doubles for INavigationBuilder should implement IRegistryAware","Check the Prism version API surface when upgrading custom builders","Avoid wrapping INavigationBuilder in classes that drop implemented interfaces"],"tags":["prism","maui","navigation","builder","tabbedpage"],"backgroundTag":"invalid-argument-value","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}