---
phase: 10-branding-data-foundation
plan: 03
type: execute
wave: 2
depends_on:
  - 10-01
  - 10-02
files_modified:
  - SharepointToolbox/App.xaml.cs
autonomous: true
requirements:
  - BRAND-01
  - BRAND-03
  - BRAND-06

must_haves:
  truths:
    - "BrandingRepository, BrandingService, and GraphUserDirectoryService are resolved by DI without runtime errors"
    - "The full test suite passes including all new and existing tests"
  artifacts:
    - path: "SharepointToolbox/App.xaml.cs"
      provides: "DI registration for Phase 10 services"
      contains: "BrandingRepository"
  key_links:
    - from: "SharepointToolbox/App.xaml.cs"
      to: "SharepointToolbox/Infrastructure/Persistence/BrandingRepository.cs"
      via: "AddSingleton registration"
      pattern: "BrandingRepository.*branding\\.json"
    - from: "SharepointToolbox/App.xaml.cs"
      to: "SharepointToolbox/Services/BrandingService.cs"
      via: "AddSingleton registration"
      pattern: "AddSingleton<BrandingService>"
    - from: "SharepointToolbox/App.xaml.cs"
      to: "SharepointToolbox/Services/GraphUserDirectoryService.cs"
      via: "AddTransient registration"
      pattern: "IGraphUserDirectoryService.*GraphUserDirectoryService"
---

<objective>
Register all Phase 10 services in the DI container and run the full test suite to confirm no regressions.

Purpose: Without DI registration, none of the new services are available at runtime. This plan wires BrandingRepository, BrandingService, and GraphUserDirectoryService into App.xaml.cs following established patterns.

Output: Updated App.xaml.cs with Phase 10 DI registrations. Full test suite green.
</objective>

<execution_context>
@C:/Users/dev/.claude/get-shit-done/workflows/execute-plan.md
@C:/Users/dev/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/10-branding-data-foundation/10-01-SUMMARY.md
@.planning/phases/10-branding-data-foundation/10-02-SUMMARY.md

<interfaces>
<!-- DI registration pattern from App.xaml.cs (lines 73-163). -->

From SharepointToolbox/App.xaml.cs:
```csharp
private static void RegisterServices(HostBuilderContext ctx, IServiceCollection services)
{
    var appData = Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
        "SharepointToolbox");
    services.AddSingleton(_ => new ProfileRepository(Path.Combine(appData, "profiles.json")));
    services.AddSingleton(_ => new SettingsRepository(Path.Combine(appData, "settings.json")));
    services.AddSingleton<MsalClientFactory>();
    services.AddSingleton<SessionManager>();
    // ... more registrations ...
    services.AddSingleton<GraphClientFactory>();
    // ... more registrations ...
}
```

From 10-RESEARCH.md Pattern 7:
```csharp
// Phase 10: Branding Data Foundation
services.AddSingleton(_ => new BrandingRepository(Path.Combine(appData, "branding.json")));
services.AddSingleton<IBrandingService, BrandingService>();
services.AddTransient<IGraphUserDirectoryService, GraphUserDirectoryService>();
```
</interfaces>
</context>

<tasks>

<task type="auto">
  <name>Task 1: Register Phase 10 services in DI and run full test suite</name>
  <files>SharepointToolbox/App.xaml.cs</files>
  <action>
    1. Open `SharepointToolbox/App.xaml.cs` and locate the `RegisterServices` method.

    2. Add a new section comment and three registrations AFTER the existing `SettingsRepository` registration (around line 79) and BEFORE the `MsalClientFactory` line. Place them logically with the other repository/service registrations:
       ```csharp
       // Phase 10: Branding Data Foundation
       services.AddSingleton(_ => new BrandingRepository(Path.Combine(appData, "branding.json")));
       services.AddSingleton<IBrandingService, BrandingService>();
       services.AddTransient<IGraphUserDirectoryService, GraphUserDirectoryService>();
       ```

    3. Add the necessary `using` statements at the top of the file if not already present:
       - `using SharepointToolbox.Infrastructure.Persistence;` (likely already present for ProfileRepository/SettingsRepository)
       - `using SharepointToolbox.Services;` (likely already present for other service registrations)

    4. Rationale for lifetimes per RESEARCH:
       - `BrandingRepository`: Singleton — single file, shared SemaphoreSlim lock (same as ProfileRepository and SettingsRepository).
       - `BrandingService` (as `IBrandingService`): Singleton — stateless after construction, depends on singleton repository.
       - `GraphUserDirectoryService` (as `IGraphUserDirectoryService`): Transient — stateless, per-call usage, different tenants.

    5. Build and run the full test suite to confirm zero regressions:
       ```bash
       dotnet build --no-restore -warnaserror
       dotnet test
       ```
  </action>
  <verify>
    <automated>dotnet build --no-restore -warnaserror && dotnet test</automated>
  </verify>
  <done>App.xaml.cs has Phase 10 DI registrations. Full build succeeds with zero warnings. Full test suite passes with zero failures.</done>
</task>

</tasks>

<verification>
```bash
dotnet build --no-restore -warnaserror
dotnet test
```
Both must succeed. Zero warnings, zero test failures. This is the phase gate.
</verification>

<success_criteria>
- App.xaml.cs registers BrandingRepository (Singleton, branding.json), IBrandingService/BrandingService (Singleton), IGraphUserDirectoryService/GraphUserDirectoryService (Transient)
- Full build passes with -warnaserror
- Full test suite passes (all existing + all new tests)
</success_criteria>

<output>
After completion, create `.planning/phases/10-branding-data-foundation/10-03-SUMMARY.md`
</output>
