While refactoring some C# classes, I've run into classes that implement IDisposable.
Without thinking, I have created partial class files for each class that implements IDisposable interface.
E.g.) For Stamper.cs -> Stamper.cs + Stamper.Dispose.cs where Stamper.cs contains actual logic for stamping and Stamper.Dispose.cs that contains dispose logic
// Stamper.cs
public partial class Stamper
{
// actual logic
}
// Stamper.Dispose.cs
public partial class Stamper: IDisposable
{
// Implement IDisposable
}
When I looked at the code, Stamper.cs now looks a lot cleaner and readable (now about 52 lines instead of 100 lines where around 50 lines was simply a clean-up dispose code)
Am I going too far with this?
*EDIT: Thanks folks for your opinions - I have decided to put two files together into one. The Problem I had faced was that I was actually forgetting to update IDisposable implementation after updating actual logic.
Moreover there wasn't much problem navigating between method in the source code. The first reason seems more than a reason enough to stick with one file solution in my specific case.