Best practices: C# Extension methods namespace and promoting extension methods

后端 未结 10 1020
南方客
南方客 2021-02-02 06:43

I know there exists already a post, describing nearly the same, but I think mine is a bit different.

What I would like to know is how you organize your extension methods

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 07:18

    This is not a namespace problem it is a communication problem.

    If these methods are useful you need to communicate this to the developers and, conversely, act on the feedback from them (with appropriate levels of judgement).

    Placing anything into the System namespace is a recipe for disaster and confusion later. The only times you ever want to do this is to 'back port' functionality into older frameworks and then you probably shouldn't do it yourself but should use something like LinqBridge to do it.

    Be wary of the desire to throw all extensions into one namespace unless they really are widely useful together. Some developers may find the wood lost for the trees if they are bombarded with everything and the kitchen sink via intellisense.

    Keeping the namespace the company name is sensible in general to avoid confusion.

提交回复
热议问题