Skip to content

Gendarme.Rules.Interoperability.UseManagedAlternativesToPInvokeRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

UseManagedAlternativesToPInvokeRule

Assembly: Gendarme.Rules.Interoperability
Version: git

Description

This rule will fire if an external (P/Invoke) method is called but a managed alternative is provided by the .NET framework.

Examples

Bad example:

[DllImport ("kernel32.dll")]
static extern void Sleep (uint dwMilliseconds);
public void WaitTwoSeconds ()
{
    Sleep (2000);
}

Good example:

public void WaitTwoSeconds ()
{
    System.Threading.Thread.Sleep (2000);
}

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally