I created a private validation method for a certain validation that happens multiple times in my class (I can't store the validated data for various reasons). Now, ReSharper suggests that the function could be made static. I'm a little reluctant to do so due known problems with static methods. It would be a private static method. My question is, can private static methods cause similar coupling and testing problems like public static methods? Is it a bad practice? I would guess not, but I'm not sure if there is a pitfall here.
Do Private Static Methods in C# Have Any Downsides?
cstatic methods
Related Topic
- C# Static Methods – Using Multiple Static Classes with One Public Method
- C# – How to Store Data Accessible to Other Classes
- C# – How does breaking up a big method into smaller methods improve unit testability when the methods are all private
- WPF – Dialog Service as Injectable Service or Static Class
- C# – How to implement an opaque handle in C#
Best Answer
I would think: "Do I need to test this?"
If your method is private anyway, meaning you don't want to unit test the logic in the method itself, then as far as testability and maintainability are concerned your class is a black box either way, the inner workings of your class are its business and its alone. Refactoring will not be affected either, which is also something to consider.
So, in my opinion: No, making a "private" method "private static" will have no long term ramifications whatsoever.