Loading...
Loading...
C# code refactoring skill. Applies SOLID principles, extracts methods/classes, introduces design patterns, and modernizes syntax. Use when improving code maintainability, addressing code smells, or modernizing legacy C# code.
npx skill4agent add jeongheonk/c-sharp-custom-marketplace csharp-refactor$ARGUMENTS[0]$ARGUMENTS[1]solidpatternmodernextractall$ARGUMENTS[0].cs.csproj<TargetFramework>$ARGUMENTS[1]solid| 위반 | 리팩토링 |
|---|---|
| SRP | Extract class, 책임 분리 |
| OCP | Strategy/Template Method 패턴 도입 |
| LSP | 상속 계층 수정, Composition 사용 |
| ISP | 인터페이스를 작은 단위로 분리 |
| DIP | 인터페이스 추출, 의존성 주입 |
pattern| Code Smell | 권장 패턴 |
|---|---|
| 복잡한 객체 생성 | Builder, Factory Method |
| 타입별 다중 조건문 | Strategy, State |
| 전역 상태 접근 | Singleton (신중하게), DI |
| 복잡한 하위 시스템 | Facade |
| 트리/복합 구조 | Composite |
| 동적 기능 추가 | Decorator |
| 요청 처리 체인 | Chain of Responsibility |
modern| 기존 문법 | Modern 대안 | 최소 버전 |
|---|---|---|
| 생성자 + 필드 할당 | Primary constructor | C# 12 |
| Collection expressions | C# 12 |
| 다중 null 체크 | Pattern matching, | C# 8 |
| 장황한 switch 문 | Switch expressions | C# 8 |
| 수동 INPC 구현 | | - |
| 변경 가능한 프로퍼티 (non-MVVM) | | C# 11 |
| 단순 데이터용 class | Record types | C# 9 |
| 전통적 foreach | LINQ (적절한 경우) | - |
extract# 리팩토링 결과
## 대상
- 파일: {파일 경로}
- 리팩토링 유형: {유형}
- TargetFramework: {버전}
## 적용된 변경
### {리팩토링 이름}
- 위치: `file.cs:line`
- 변경 전:
```csharp
// 기존 코드// 리팩토링된 코드
## 에러 처리
| 상황 | 처리 |
|------|------|
| `.cs` 파일 없음 | "리팩토링 대상 .cs 파일이 없습니다" 메시지 출력 후 종료 |
| 대상 파일 미발견 | 사용자에게 파일 경로 재확인 요청 |
| TargetFramework < net8.0 | C# 12 전용 기능 제안 제외, 경고 노트 출력 |
## 가이드라인
- 기존 기능을 유지합니다 (동작 변경 없음)
- 대규모 재작성이 아닌 점진적 변경을 합니다
- 영리함보다 가독성을 우선합니다
- 팀의 패턴 친숙도를 고려합니다
- 로직이 명확하지 않은 경우에만 주석을 추가합니다
- 테스트 프로젝트가 존재하면 `dotnet test` 실행 후 회귀 없음을 확인합니다