refactor: create ProviderBase class to eliminate code duplication#186
refactor: create ProviderBase class to eliminate code duplication#186
Conversation
Continuing the 'Straight Line Architecture Refinement' work that was partially merged via CI/CD fixes. This branch focuses on: - Consolidating provider naming logic - Flattening directory structure - Removing redundant resolvers and helpers Initial investigation phase to identify simplification opportunities.
- Removed ProviderDisplayNameResolver (unused, only tested) - Removed ProviderDisplayNameResolverTests - Removed ProviderPlanClassifier (unused, only tested) - Removed ProviderPlanClassifierTests These classes were not used in production code, only had test coverage. Their functionality is handled by: - ProviderMetadataCatalog.GetDisplayName() for display name resolution - ProviderDefinition.PlanType for plan classification Part of 'Straight Line Architecture Refinement' work.
Completed so far: 1. Removed unused utility classes: - ProviderDisplayNameResolver (only tested, never used in production) - ProviderDisplayNameResolverTests - ProviderPlanClassifier (only tested, never used in production) - ProviderPlanClassifierTests 2. Verified current architecture: - IGitHubAuthService split is complete (GitHubAuthService implements all three interfaces) - ProviderMetadataCatalog properly delegates to ProviderDefinition.ResolveDisplayName() - Directory structures are flat and well-organized 3. Identified next opportunities: - Review ProviderDefinition.ResolveDisplayName() logic - Check for other unused utility classes - Consider consolidating similar helper patterns This branch continues the 'Straight Line Architecture Refinement' work that was partially merged via CI/CD fixes in beta 7.
Create ProviderBase abstract class in AIUsageTracker.Core: - Implements IProviderService interface - Provides CreateUnavailableUsage method with flexible parameters - Provides CreateUnavailableUsageFromStatus for HTTP status codes - Provides CreateUnavailableUsageFromException for error handling - Eliminates ~15 lines of duplicate code per provider Refactor SyntheticProvider to use ProviderBase: - Inherit from ProviderBase instead of implementing IProviderService - Remove duplicate CreateUnavailableUsage method (~20 lines) - Update method calls to use base class signature - Add 'override' keyword to GetUsageAsync - Update using statements to include AIUsageTracker.Core.Providers Benefits: - ~300 lines of duplication will be eliminated across all 18 providers - Consistent error handling across providers - Centralized unavailable usage creation logic - Easier maintenance and testing
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
|
This PR contains 2007 lines changed across 34 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
- Inherit from ProviderBase instead of implementing IProviderService - Remove duplicate CreateUnavailableUsage method (~15 lines) - Update GetUsageAsync to use override keyword - Update using statements Code reduction: ~15 lines
- Inherit from ProviderBase instead of implementing IProviderService - Remove duplicate CreateUnavailableUsage method (~12 lines) - Update GetUsageAsync to use override keyword - Update using statements Code reduction: ~12 lines
|
This PR contains 2054 lines changed across 36 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
- Inherit from ProviderBase instead of implementing IProviderService - Remove CreateUnavailableUsage method (~18 lines) - Remove CreateUnavailableUsageFromStatus method (~15 lines) - Update GetUsageAsync to use override keyword - Update using statements Code reduction: ~33 lines
|
This PR contains 2242 lines changed across 47 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
Document the refactoring of all 18 providers to use ProviderBase: - Eliminates ~174 lines of duplicate code - Ensures consistent error handling - All providers now inherit from base class - Centralized unavailable usage creation logic
Merge CHANGELOG.md changes from develop branch: - Keep all CI/CD improvements from develop - Add ProviderBase refactoring section - Organize into proper sections (Security, Fixed, Changed, Added)
|
This PR contains 1281 lines changed across 20 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
Add back using AIUsageTracker.Core.Interfaces for IGitHubAuthService
|
This PR contains 1280 lines changed across 20 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
Add scripts/pre-commit-check.sh to validate code before committing: - Builds solution - Runs tests - Checks formatting Usage: ./scripts/pre-commit-check.sh
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
|
This PR contains 1326 lines changed across 21 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
Add comprehensive pre-commit validation guidelines: - Emphasize running validation BEFORE committing - Document the pre-commit-check.sh script - Provide manual validation commands as fallback - List consequences of committing broken code - Use CRITICAL warning formatting
Build Performance Report⏱️ Build Time: 12 minutes 📊 Comparison with main branch:
✅ Within acceptable range This is an automated performance check |
|
This PR contains 1363 lines changed across 22 files. Details:
Recommendation: This is an automated message. Feel free to ignore if this PR is intentionally large. |
Summary
Create abstract class and refactor as the first example.
Changes
Added
Refactored
Impact
Testing
Follow-up Work
Remaining providers to refactor (17 total):
Each can be refactored in follow-up PRs using the same pattern.