Refactoring a C# library can keep your solution green while consumers of the old API break in ways tests never see. The article separates source, binary and behavioral compatibility and shows what evidence each dimension actually needs.
Key points
- Source compatibility asks whether consumer code recompiles; binary compatibility asks whether an already-built consumer still binds.
- Renaming a public parameter breaks named-argument callers even though positional calls compile and tests pass.
- Changing an optional parameter's default is not a binary break, but recompiled callers omitting the argument behave differently.
- Swapping params T[] for params ReadOnlySpan<T> changes the IL signature and breaks already-compiled callers.
- Binary evidence requires a consumer artifact built against the old library, validated separately against the candidate.
- API diff tools catch removed members but cannot show exception type, ordering or mutation changes in behavior.
Real-world use
- An internal NuGet library that your solution updates but other teams consume as compiled binaries
- Consumers that load types through reflection or a plugin loader and depend on member and parameter names
- A calculation service where exception type, ordering and input mutation are part of the observable contract
- Library maintainers pairing a public API diff with behavior tests across a version upgrade
This summary was generated by the agent from the original post on Nick Cosentino (Dev Leader). The full text and all rights belong to its author and publisher. Go to original