Your .NET Application Compiles. Does That Mean Your Architecture Is Correct? A developer argues that compiling .NET solutions and passing unit tests do not guarantee architectural integrity, illustrating how a Clean Architecture order-management application can silently violate the Dependency Rule when the Application layer injects a concrete SqlOrderRepository from Infrastructure. The proposed fix replaces the concrete dependency with an IOrderRepository abstraction defined in the Domain layer, so the Application layer depends inward rather than outward. When we start developing a new application, one of the first things we usually discuss is its architecture. Should we use Clean Architecture? A modular monolith? A traditional layered architecture? We define our projects, organize dependencies, establish some rules, and everything looks good. But what happens after six months? Or after several developers have worked on the same solution? More importantly, who makes sure that the architecture we initially designed is still respected? The compiler? Not really. Our unit tests? Not necessarily. Code reviews? Maybe, if someone notices the problem. This is something I've been thinking about for a while, especially with the increasing adoption of AI coding agents. Let's take a practical example to understand the problem, and then see how we can address it. Imagine we're developing an order management application using Clean Architecture. Our solution contains the following projects: Shop.slnx │ ├── Shop.Domain │ ├── Order.cs │ └── IOrderRepository.cs │ ├── Shop.Application │ └── OrderService.cs │ ├── Shop.Infrastructure │ └── SqlOrderRepository.cs │ └── Shop.Api └── Program.cs Nothing complicated here. The Domain layer contains our business model and abstractions. Application contains the use cases. Infrastructure contains the technical implementations. And API is our entry point and composition root. According to the Dependency Rule, dependencies should point inward. Domain should not know about Infrastructure, and Application should not directly depend on Infrastructure implementations. Now, imagine that we're implementing a use case to confirm an order. A developer writes the following code: using Shop.Domain; using Shop.Infrastructure; namespace Shop.Application; public sealed class OrderService SqlOrderRepository repository { public async Task ConfirmAsync Guid orderId, CancellationToken cancellationToken { var order = await repository.GetAsync orderId, cancellationToken ; order.Confirm ; await repository.SaveAsync order, cancellationToken ; } } Assuming the project reference exists and the repository exposes these methods, this code is perfectly valid from the compiler's perspective. It can compile successfully. The unit tests can pass. The feature can work exactly as expected. So, what's the problem? Well, our Application layer now directly depends on Infrastructure. We have introduced an outward dependency that violates the architecture we initially agreed on. And this is where things become interesting. The compiler checks whether our code is valid C . It doesn't know whether the dependencies respect our architectural decisions. Of course, we could catch this during code review. But should we really depend entirely on code reviews to detect something that can be checked automatically? I don't think so. The problem is not the functionality itself. The problem is the dependency. Instead of injecting SqlOrderRepository , our Application layer should depend on an abstraction. Let's start with our Domain project. namespace Shop.Domain; public interface IOrderRepository { Task