| name | managing-global-usings |
| description | Centralize external namespace imports (BCL, FCL, NuGet) in a GlobalUsings.cs file per project, keeping individual files clean. |
GlobalUsings.cs๋ก ์ธ๋ถ ๋ค์์คํ์ด์ค ์ค์ ๊ด๋ฆฌ
์ค๋ช
ํ๋ก์ ํธ ๋ด์์ ๋ฐ๋ณต์ ์ผ๋ก ์ฌ์ฉ๋๋ ์ธ๋ถ ๋ค์์คํ์ด์ค(System.*, NuGet ํจํค์ง ๋ฑ)๋ฅผ GlobalUsings.cs ํ์ผ์ global using์ผ๋ก ์ ์ธํ์ฌ ๊ฐ๋ณ ํ์ผ์ using ๋ฌธ์ ์ต์ํํฉ๋๋ค.
๊ท์น
- ๊ฐ ํ๋ก์ ํธ ๋ฃจํธ์
GlobalUsings.cs ํ์ผ์ ์์ฑํฉ๋๋ค
- .NET BCL/FCL ๋ค์์คํ์ด์ค(
System.*, Microsoft.* ๋ฑ)๋ global using์ผ๋ก ๋ฑ๋กํฉ๋๋ค
- NuGet ํจํค์ง ๋ค์์คํ์ด์ค(
Bogus, Moq, Scalar.AspNetCore ๋ฑ)๋ global using์ผ๋ก ๋ฑ๋กํฉ๋๋ค
- ์๋ฃจ์
๋ด๋ถ ํ๋ก์ ํธ์ ๋ค์์คํ์ด์ค(์:
CompanyC.Api)๋ global using์ ๋ฑ๋กํ์ง ์์ต๋๋ค
- ๊ฐ๋ณ ํ์ผ์์๋
GlobalUsings.cs์ ๋ฑ๋ก๋ ๋ค์์คํ์ด์ค์ using ๋ฌธ์ ์ ๊ฑฐํฉ๋๋ค
- ์ํ๋ฒณ ์์ผ๋ก ์ ๋ ฌํฉ๋๋ค
Worst Case (๋์ ์)
using System.Net;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc.Testing;
namespace CompanyC.Api.IntegrationTests;
public class EmployeeApiTests { ... }
using System.Net;
using System.Text;
using System.Text.Json;
using CompanyC.Api;
using Microsoft.AspNetCore.Mvc.Testing;
namespace CompanyC.Api.IntegrationTests;
public class EmployeeBogusTests { ... }
Best Case (์ข์ ์)
global using System.Net;
global using System.Net.Http.Headers;
global using System.Text;
global using System.Text.Json;
global using Bogus;
global using Microsoft.AspNetCore.Mvc.Testing;
global using Microsoft.Extensions.DependencyInjection;
global using Moq;
namespace CompanyC.Api.IntegrationTests;
public class EmployeeApiTests { ... }
using CompanyC.Api;
namespace CompanyC.Api.IntegrationTests;
public class EmployeeBogusTests { ... }
์ ์ฉ ๋์
- ์๋ฃจ์
๋ด ๋ชจ๋ ํ๋ก์ ํธ (API, ํ
์คํธ, ๋๊ตฌ)
- .NET BCL/FCL ๋ค์์คํ์ด์ค (
System.*, Microsoft.*)
- NuGet ํจํค์ง ๋ค์์คํ์ด์ค
- 2๊ฐ ์ด์์ ํ์ผ์์ ์ฌ์ฉ๋๋ ์ธ๋ถ ๋ค์์คํ์ด์ค
์ ์ธ ๋์
- ์๋ฃจ์
๋ด๋ถ ํ๋ก์ ํธ ๋ค์์คํ์ด์ค (์:
using CompanyC.Api;)
- ๋จ์ผ ํ์ผ์์๋ง ์ฌ์ฉ๋๋ ํน์ ๋ค์์คํ์ด์ค