Effect of unused methods and properties on a library or executable file

I am playing with creating a source code generator for C # (.NET). Will generating properties or methods that are never called make my code run slower? How to insert “use” statements for libraries that are not used?

I assume that the compiler is smart enough not to create unused “used” statements, but there is no way to learn about properties and methods, since they can be inserted for use by external applications.

+5
source share
3 answers

The compiler is already smart enough to only list the referenced assemblies in the last executable that are actually used. No need to bother with assembly references or using directives.

The JIT compiler will only generate code for methods that are actually called. This way you will not have machine code or time compromise due to code that is never used.

CLR. , DLL CLR. , IL , , . , , JIT IL, . , , .

DLL , - .

+6

. .

, .

, .

"using" . .

, .EXE.

+5

, . , , .

+4

All Articles