-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathUnmanagedCodeCheck.qhelp
More file actions
29 lines (24 loc) · 1.26 KB
/
UnmanagedCodeCheck.qhelp
File metadata and controls
29 lines (24 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Microsoft defines two broad categories for source code. Managed code compiles into bytecode and is then executed by a virtual
machine. Unmanaged code is compiled directly into machine code. All C# code is managed but it is possible to call external unmanaged
code. This rule finds <code>extern</code> methods that are implemented by unmanaged code. Managed code has many advantages over
unmanaged code such as built in memory management performed by the virtual machine and the ability to run compiled programs
on a wider variety of architectures.</p>
</overview>
<recommendation>
<p>Consider whether the unmanaged <code>extern</code> methods could be implemented in C# instead.</p>
</recommendation>
<example>
<p>This example shows a function that displays a message box when clicked. The unmanaged code is shown first and then the
same function being performed by managed code is shown after.</p>
<sample src="UnmanagedCodeCheck.cs" />
</example>
<references>
<li>MSDN, C# Reference <a href="http://msdn.microsoft.com/en-us/library/e59b22c5(v=vs.80).aspx">extern</a>.</li>
<li>Wikipedia, <a href="http://en.wikipedia.org/wiki/Managed_code">Managed code</a>.</li>
</references>
</qhelp>