Will the compiler only compile code that can get executed?

No, the compiler includes the “dead” code as well. A simple reason for this is that it’s not always possible to know exactly what code will and won’t be executed. For example, even a private method that is never referenced could be called via reflection, and public methods could be referenced by external assemblies.

You can use a tool to help you find and remove unused methods (including ones only called by other unused methods). Try What tools and techniques do you use to find dead code? and Find unused code to get you started.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)