Skip to content

Gendarme.Rules.Interoperability.UseManagedAlternativesToPInvokeRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

UseManagedAlternativesToPInvokeRule

Assembly: Gendarme.Rules.Interoperability
Version: 2.10

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);
}
Clone this wiki locally