Skip to content

Commit 4fab7ca

Browse files
committed
Add attribute-based routing support and docs
Introduces attribute-based routing with 8 new route attributes, automatic route discovery, and extension methods for mixing declarative and programmatic routes. Adds comprehensive documentation (ATTRIBUTE_ROUTING.md), updates sample apps to demonstrate attribute routing and transitions, enhances error handling, expands built-in transitions to 14 types, and improves layout and guard systems. Documentation and sample projects are updated to reflect new features and usage.
1 parent d383f16 commit 4fab7ca

121 files changed

Lines changed: 8993 additions & 256 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ATTRIBUTE_ROUTING.md

Lines changed: 477 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,77 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.0.10] - 2025-11-19
11+
12+
### Added
13+
- **Enhanced Route Transitions**: Expanded from 4 to 14 built-in transition types
14+
- Added: `None`, `Pop`, `Blur`, `Reveal`, `Rotate`, `Curtain`, `SlideFade`, `Spotlight`, `Swipe`, `Lift`
15+
- All transitions are GPU-accelerated for smooth performance
16+
- Respects `prefers-reduced-motion` accessibility preference
17+
- Comprehensive XML documentation for each transition type with use cases and best practices
18+
- **Attribute-Based Routing System**: Complete declarative routing configuration
19+
- 8 attribute types: `[Route]`, `[RouteGuard]`, `[RouteTransition]`, `[RouteLayout]`, `[RouteTitle]`, `[RouteData]`, `[RouteRedirect]`, `[RouteExact]`
20+
- `RouteAttributeDiscoveryService` for automatic route discovery via assembly scanning
21+
- `AddAttributeRoutes()` extension method for mixing programmatic and attribute-based routes
22+
- `FromAttributes()` static method for pure attribute-based configuration
23+
- Full support for nested routes and complex configurations via attributes
24+
- Detailed documentation in ATTRIBUTE_ROUTING.md
25+
- **Comprehensive Error Handling System**
26+
- `IRouterErrorHandler` interface for custom error handling implementations
27+
- `DefaultRouterErrorHandler` with built-in console logging
28+
- `RouterErrorContext` providing detailed error information and context
29+
- `RouterErrorType` enum with error categories: `ComponentLoadFailed`, `GuardRejected`, `NavigationFailed`, `InvalidRoute`
30+
- `ErrorContent` RenderFragment parameter in Router component for custom error UI
31+
- Retry mechanism support for failed operations
32+
- Error event notifications throughout routing lifecycle
33+
- `AddBlazouterErrorHandler<T>()` extension method for registering custom error handlers
34+
- **Enhanced Layout System**
35+
- `DefaultLayout` parameter on Router component for application-wide layouts
36+
- Per-route layout override via `RouteConfig.Layout` property
37+
- Support for no-layout routes by explicitly setting `Layout = null`
38+
- Layout priority system: Route.Layout > Router.DefaultLayout > No Layout
39+
- `HasExplicitLayout` internal flag for proper layout resolution
40+
- Seamless layout switching during navigation with state preservation
41+
- **Additional Components and Services**
42+
- `BlankLayout` component for routes requiring no layout structure
43+
- Enhanced `RouteMatcherService` with improved pattern matching
44+
- `RouterStateService` with parameter change notifications
45+
- Loading state support with `<Loading>` RenderFragment parameter in Router
46+
- Component caching for lazy-loaded routes after first load
47+
48+
### Changed
49+
- **Documentation Overhaul**
50+
- README.md: Updated to reflect all 14 transitions, added error handling section, enhanced project structure
51+
- FEATURES.md: Expanded from 8 to 10 features with detailed implementation descriptions
52+
- All sample applications updated to showcase 14 transitions instead of 4
53+
- Added comprehensive comparison table showing Blazouter advantages over traditional Blazor routing
54+
- Project Structure section now includes all folders: Attributes/, Extensions/, Resources/, Components/Layouts/
55+
- **Enhanced RouteConfig Model**
56+
- Added `HasExplicitLayout` property for proper layout handling
57+
- Improved XML documentation for all properties
58+
- Better support for complex nested route scenarios
59+
- **Sample Applications**
60+
- All 4 sample apps (WebAssembly, Server, Hybrid, Web) updated with transition demos
61+
- Added demo pages for all 14 transition types with descriptions and code examples
62+
- Enhanced Home.razor with accurate feature showcase
63+
- Added Transitions.razor pages demonstrating all transition types
64+
65+
### Fixed
66+
- Layout handling when explicitly set to null vs. not set
67+
- Documentation inconsistencies between README.md and FEATURES.md
68+
- Sample applications showing outdated feature counts
69+
70+
## [1.0.9] - 2025-11-18
71+
72+
### Changed
73+
- Documentation links updated to reflect new repository location
74+
75+
## [1.0.6-1.0.8] - 2025-11-16 to 2025-11-17
76+
77+
### Note
78+
- Internal version increments for package stability and distribution
79+
- Minor bug fixes and improvements
80+
1081
### Deprecated
1182
- **Blazouter.Web package**: The `Blazouter.Web` package has been deprecated in favor of using `Blazouter.Server` and `Blazouter.WebAssembly` for Blazor Web Applications. This provides a clearer, more consistent package structure where:
1283
- Server project uses: `Blazouter.Server`
@@ -80,6 +151,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
80151
- FEATURES.md detailing all capabilities
81152
- Sample application demonstrating key features
82153

154+
[1.0.10]: https://github.com/Taiizor/Blazouter/compare/v1.0.9...v1.0.10
155+
[1.0.9]: https://github.com/Taiizor/Blazouter/compare/v1.0.5...v1.0.9
156+
[1.0.6-1.0.8]: https://github.com/Taiizor/Blazouter/compare/v1.0.5...v1.0.9
83157
[1.0.5]: https://github.com/Taiizor/Blazouter/compare/v1.0.2...v1.0.5
84158
[1.0.2]: https://github.com/Taiizor/Blazouter/compare/v1.0.1...v1.0.2
85159
[1.0.1]: https://github.com/Taiizor/Blazouter/releases/tag/v1.0.1

FEATURES.md

Lines changed: 105 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,50 @@ Blazouter is a comprehensive routing library for Blazor applications, available
1919
- Tested and verified working
2020
- Full hierarchical route structure support
2121
- Example: `/users` (parent) → `/users/:id` (child)
22+
- Unlimited nesting depth for complex route hierarchies
2223
- Parent routes with child routes using `RouterOutlet` component
2324

2425
### ✅ 2. Route Guards (Protected Routes)
2526
- Tested and verified working
2627
- `CanActivateAsync` method to control route access
2728
- Example: `SampleAuthGuard` in the sample application
2829
- `GetRedirectPathAsync` for redirect on denied access
30+
- Support for multiple guards per route (executed in order)
2931
- `IRouteGuard` interface for custom authentication/authorization logic
32+
- Guards can be registered via dependency injection or created via Activator
3033

3134
### ✅ 3. Lazy Loading
3235
- Reduces initial bundle size
3336
- Tested and verified working
3437
- Async component loading with `Task<Type>`
3538
- Example: Lazy page with simulated 1-second delay
3639
- `ComponentLoader` function property on `RouteConfig`
40+
- Loading state support with `<Loading>` parameter in Router
41+
- Component caching after first load for performance
3742

3843
### ✅ 4. Route Transitions/Animations
3944
- Tested and verified working
45+
- 14 built-in transition types
4046
- Custom animations can be added via CSS
4147
- Configurable per-route via `Transition` property
4248
- Automatic animation application on route change
49+
- GPU-accelerated animations for smooth performance
50+
- Respects prefers-reduced-motion accessibility preference
4351
- Built-in transitions: `None`, `Pop`, `Blur`, `Fade`, `Flip`, `Lift`, `Scale`, `Slide`, `Swipe`, `Reveal`, `Rotate`, `Curtain`, `SlideUp`, `SlideFade`, `Spotlight`
4452

4553
### ✅ 5. Programmatic Navigation
4654
- Query parameter support
55+
- Browser history integration
4756
- Tested and verified working
4857
- `NavigateTo(path)` method
58+
- Support for relative and absolute navigation
4959
- Integration with Blazor's `NavigationManager`
5060
- `RouterNavigationService` for imperative navigation
5161

5262
### ✅ 6. Dynamic Route Parameters
5363
- Tested and verified working
64+
- Parameter change notifications
65+
- Type-safe parameter extraction
5466
- Query string parameter support
5567
- Support for nested route parameters
5668
- Path parameters using `:paramName` syntax
@@ -60,18 +72,42 @@ Blazouter is a comprehensive routing library for Blazor applications, available
6072
- `Exact` matching option
6173
- Tested and verified working
6274
- Visual feedback for current route
75+
- Supports nested route active states
76+
- Automatic update on route changes
6377
- `ActiveClass` property for custom styling
6478
- `RouterLink` component with automatic active class
6579

6680
### ✅ 8. Layout System
6781
- Tested and verified working
82+
- Layout state preservation during navigation
6883
- Seamless layout switching during navigation
6984
- Support for no-layout routes by setting Layout to null
7085
- `RouteConfig.Layout` property for route-specific layouts
7186
- `Router.DefaultLayout` parameter for application-wide layout
7287
- Layout priority: Route.Layout > Router.DefaultLayout > No Layout
7388
- Automatic layout wrapping using @Body from LayoutComponentBase
7489

90+
### ✅ 9. Attribute-Based Routing
91+
- Tested and verified working
92+
- Mix programmatic and attribute-based routes
93+
- Declarative route configuration using attributes
94+
- Full documentation in [ATTRIBUTE_ROUTING.md](https://github.com/Taiizor/Blazouter/blob/develop/ATTRIBUTE_ROUTING.md)
95+
- Automatic route discovery via assembly scanning
96+
- `AddAttributeRoutes()` extension for easy integration
97+
- `FromAttributes()` for pure attribute-based configuration
98+
- 8 attribute types: `[Route]`, `[RouteGuard]`, `[RouteTransition]`, `[RouteLayout]`, `[RouteTitle]`, `[RouteData]`, `[RouteRedirect]`, `[RouteExact]`
99+
100+
### ✅ 10. Error Handling
101+
- Error event notifications
102+
- Comprehensive error handling system
103+
- Retry mechanism for failed operations
104+
- `DefaultRouterErrorHandler` with built-in logging
105+
- `RouterErrorContext` with detailed error information
106+
- `ErrorContent` parameter in Router for custom error UI
107+
- `IRouterErrorHandler` interface for custom error handlers
108+
- Custom error handler registration via `AddBlazouterErrorHandler<T>()`
109+
- Error types: `ComponentLoadFailed`, `GuardRejected`, `NavigationFailed`, `InvalidRoute`
110+
75111
## Components
76112

77113
### Router
@@ -98,47 +134,78 @@ Nested route renderer that:
98134

99135
## Services
100136

101-
### RouteMatcherService
102-
- Query string parsing
103-
- Nested route matching
104-
- Pattern matching for routes
105-
- Dynamic parameter extraction
137+
### RouteMatcherService (IRouteMatcherService)
138+
- Registered as scoped service
139+
- Route priority and exact match handling
140+
- Dynamic parameter extraction from URL paths
141+
- Query string parsing and parameter extraction
142+
- Pattern matching for routes with wildcard support
143+
- Nested route matching with parent-child relationships
106144

107145
### RouterStateService
108-
- Parameter access
109-
- Event notifications
110-
- Current route tracking
111-
- Central state management
146+
- Query parameter retrieval
147+
- Registered as scoped service
148+
- Component lifecycle integration
149+
- Event notifications for route changes
150+
- Current route tracking with RouteMatch
151+
- Parameter access via GetParam(key) method
152+
- Central state management for routing context
112153

113154
### RouterNavigationService
114-
- Query parameter handling
115-
- Programmatic navigation API
116-
- Wrapper around NavigationManager
155+
- Browser history integration
156+
- Registered as scoped service
157+
- Support for relative and absolute navigation
158+
- Query parameter handling and URL building
159+
- Programmatic navigation API with NavigateTo(path)
160+
- Wrapper around NavigationManager for enhanced functionality
161+
162+
### RouteAttributeDiscoveryService
163+
- Supports all 8 route attributes
164+
- Reflection-based with trimming warnings
165+
- Converts attributes to RouteConfig objects
166+
- Static service for route discovery at startup
167+
- Discovers components with [Route] attribute
168+
- Assembly scanning for attribute-based routes
169+
170+
### IRouterErrorHandler / DefaultRouterErrorHandler
171+
- Error type categorization
172+
- Retry mechanism support
173+
- Default handler with console logging
174+
- Error context with detailed information
175+
- Error handling interface for custom implementations
176+
- Registered as scoped service via AddBlazouterErrorHandler<T>()
117177

118178
## Configuration
119179

120180
### RouteConfig Properties
121-
- `RedirectTo`: Redirect path
122-
- `Data`: Custom data dictionary
123-
- `Transition`: Animation name
124-
- `Title`: Route title for metadata
125-
- `Exact`: Exact path matching flag
126-
- `Guards`: List of route guard types
127-
- `Path`: Route pattern (e.g., "/users/:id")
128-
- `Children`: Nested route configurations
129-
- `Component`: Component type to render
130-
- `Layout`: Layout component type (overrides DefaultLayout)
131-
- `ComponentLoader`: Async component loader for lazy loading
181+
- `Exact`: Exact path matching flag - When true, requires exact URL match
182+
- `Data`: Custom data dictionary - Arbitrary metadata passed to components
183+
- `Transition`: Animation type - One of 14 built-in RouteTransition enum values
184+
- `HasExplicitLayout`: Internal flag - Tracks if Layout was explicitly set (even if null)
185+
- `Layout`: Layout component type - Overrides DefaultLayout, set to null for no layout
186+
- `Path`: Route pattern (e.g., "/users/:id") - Supports dynamic parameters with `:` prefix
187+
- `Title`: Route title for metadata - Used for page title, breadcrumbs, or navigation labels
188+
- `Children`: Nested route configurations - List of child RouteConfig for hierarchical routing
189+
- `RedirectTo`: Redirect path - Automatically redirects to specified path when route matches
190+
- `Guards`: List of route guard types - Array of IRouteGuard implementations for access control
191+
- `Component`: Component type to render - Direct component reference for immediate loading
192+
- `ComponentLoader`: Async component loader for lazy loading - Returns `Task<Type>` for on-demand loading
132193

133194
## Package-Specific Features
134195

135196
### Blazouter (Core)
136-
- Navigation services
137-
- Lazy loading support
138-
- Route guards interface
139-
- Route configuration and matching
140-
- Multi-framework support (net6.0-net10.0)
197+
- Lazy loading support with ComponentLoader
198+
- 14 transition types with RouteTransition enum
199+
- Comprehensive XML documentation for IntelliSense
200+
- Layout system support (DefaultLayout, per-route Layout)
201+
- CSS animations included (blazouter.css, blazouter.min.css)
141202
- All routing components (Router, RouterLink, RouterOutlet)
203+
- Multi-framework support (net6.0, net7.0, net8.0, net9.0, net10.0)
204+
- Navigation services (RouterNavigationService, RouterStateService)
205+
- Route guards interface (IRouteGuard, AuthGuard base implementation)
206+
- Route configuration and matching (RouteConfig, RouteMatcherService)
207+
- Attribute-based routing (RouteAttributeDiscoveryService, 8 route attributes)
208+
- Error handling (IRouterErrorHandler, DefaultRouterErrorHandler, RouterErrorContext)
142209

143210
### Blazouter.Server
144211
- Server-side route optimization
@@ -174,11 +241,13 @@ All features are interactive and can be tested by navigating through the applica
174241

175242
| Feature | Traditional Blazor | Blazouter |
176243
|---------|-------------------|-----------|
177-
| Transitions | ❌ None | ✅ Built-in |
178-
| Active Links | ⚠️ Manual | ✅ Automatic |
179-
| Lazy Loading | ⚠️ Limited | ✅ Full support |
180-
| Route Guards | ❌ Manual | ✅ Built-in |
181-
| Nested Routes | ❌ Limited | ✅ Full support |
182-
| Parameter Access | ✅ Basic | ✅ Enhanced |
183-
| Programmatic Nav | ✅ Basic | ✅ Enhanced |
184-
| Layout System | ⚠️ Static @layout | ✅ Dynamic per-route |
244+
| Transitions | ❌ None | ✅ 14 built-in transitions |
245+
| Active Links | ⚠️ Manual | ✅ Automatic with RouterLink |
246+
| Lazy Loading | ⚠️ Limited | ✅ Full support with ComponentLoader |
247+
| Route Guards | ❌ Manual | ✅ Built-in IRouteGuard interface |
248+
| Layout System | ⚠️ Static @layout | ✅ Dynamic per-route with priority |
249+
| Error Handling | ❌ Manual | ✅ Built-in with IRouterErrorHandler |
250+
| Nested Routes | ❌ Limited | ✅ Unlimited nesting depth |
251+
| Attribute Routes |@page only | ✅ 8 attribute types with full config |
252+
| Parameter Access | ✅ Basic | ✅ Enhanced with RouterStateService |
253+
| Programmatic Nav | ✅ Basic | ✅ Enhanced with RouterNavigationService |

0 commit comments

Comments
 (0)