tags:

views:

108

answers:

4

the comments are not XML comments, just normal comments

+14  A: 

No. Comments are ignored by the compiler and have no representation in the assembly.

Mark Cidade
Do you mean an assembly actually does not carry any information related to the comments? Or it carries the information but it's not accessable?
Aperture
Source code is for humans. Assemblies are for machines. There are no comments in an assembly.
AMissico
@AMissico: Hi an assembly does not need comments, but it can still carry the comments as part of the program?
Aperture
@user370401 No it cannot. There is no IL instruction for "comment".
Josh Einstein
@user370401: The comments are NOT in the assembly. If you don't generate an XML-Comment file and deliver it with the assembly, the comments won't be accessible.
Christian
@user370401. No. Comments are ignored, are not parsed, by the compiler. Therefore, there are absolutely no comments, no comment information, nothing even remotely associated with comments, in an assembly. Comments are only in source code.
AMissico
@user370401 I'll give you ALL my reputation points if you ever happen to find any comment-derived information in any part of a standard .NET assembly. Bible code style statistical shenanigans are exempt.
Mark Cidade
+5  A: 

A disassembler can't get the original source code. It will only create source code that does the same thing as the original source code.

As comments doesn't result in any instructions in the program, they can't be recreated from the compiled code.

Guffa
+1 good point stressing the fact that the source is recreated from the assembly.
Brian Rasmussen
Simple example being the names of local variables - Reflector generally has to make them up.
Damien_The_Unbeliever
I cannot agree the disassembler cannot get to the source code, but only make up code to achieve the same function. The evidence is the order of certain statements. If the disassembler could not get to the source code, there is no way it can come up with exactly the same satements with the same order. Maybe it has some difficulty getting to the names of the variables but it surely can see each and every statement.
Aperture
@user370401: The disassembler only has access to the compiled code, which is the instructions to do what the source code describes. The disassembler can only create code that describes what the instructions do, not the original description. If you for example compile a statement like `int x = 1 + 2 + 3;` and disassemble that, you will get `int x = 6;` as that is what the compiled instructions do.
Guffa
+1  A: 

Just to add to Marks answer - the XML comments / docstrings found in the source code are also not written to the assembly, and so are also inaccessible using Reflector.

The XML comments are written to a separate xml file which the Visual Studio IDE needs access to in order to be able to supply these comments in intellisense.

Kragen
XML comments are called ***XML Documentation Comments***.
AMissico
+1  A: 

No it won't read the commented line from Source Code

programmer4programming