c# - Is it possible to disallow or 'hide' methods to stop the development team using them? -


I work in a team of 20+ developers in which a new member of a recent flood includes our coding standards That the first () extension method for IEnumerable should never be used, and instead we should always use FirstOurfault () and check an empty return.

I appreciate it that some members discuss the training, apply coding standards, or to implement the unit tests to take such crimes, but in theory it is possible that a compilation Try to throw the error of time?

The best part is that you can compile time according to the help: < Ol>

  • Your ONW extension is the "first" method, which does nothing but throw an exception.

  • Mark that method as "obsolet" so you can get a compilation-time warning.

    I think you can do the best.

    (Some comments express concern about namespace ... you will use the same name space as Microsoft does [System.Linq] so that the compiler sees both. < / Div>

  • Comments

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -