Azure / Azure/azure-functions-core-tools

Decompose SetupRunner.cs (1,100 lines, multiple responsibilities)

Open
#5,451 0 comments 0 reactions 1 assignee Claimed by @ahmedmuhsin View on GitHub
GA v5
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
4d 20h
Merged PRs (30d)
14

Description

## Summary

`src/Func/Commands/Setup/SetupRunner.cs` is 1,100 lines and violates the Single Responsibility Principle by handling at least 6 distinct concerns in one class. This makes it difficult to test individual behaviours, understand control flow, and safely modify one concern without risking regressions in others.

## Current Responsibilities (mixed in one class)

1. Feature resolution
2. Profile/scope resolution
3. Dependency plan building
4. Setup orchestration
5. Hardcoded stack package discovery (see TODO on line 933)
6. Interaction with the user for confirmations/progress

## Proposed Fix

Split into focused, testable components:

- `FeatureResolver` — determines which features to install/configure
- `ProfileScopeResolver` — resolves profile and scope for the setup
- `DependencyPlanBuilder` — builds the dependency installation plan
- `SetupOrchestrator` — coordinates the above, drives the flow
- Move hardcoded stack package logic into workload metadata (addresses the TODO)

Each component should be independently testable with clear inputs/outputs.

## Acceptance Criteria

- [ ] `SetupRunner.cs` is decomposed into ≤4 focused classes
- [ ] Each component is independently unit-testable
- [ ] Hardcoded stack package (line 933 TODO) is resolved via workload metadata
- [ ] All existing tests continue to pass
- [ ] No regression in `func setup` behaviour

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.