﻿<?xml version="1.0" encoding="utf-8"?><Type Name="DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule" FullName="Gendarme.Rules.Interoperability.DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule"><TypeSignature Language="C#" Value="public sealed class DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" /><TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" /><AssemblyInfo><AssemblyName>Gendarme.Rules.Interoperability</AssemblyName><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Base><BaseTypeName>Gendarme.Framework.Rule</BaseTypeName></Base><Interfaces><Interface><InterfaceName>Gendarme.Framework.IMethodRule</InterfaceName></Interface></Interfaces><Attributes><Attribute><AttributeName>Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine))</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Problem("Every delegate passed to native code must include an exception block which spans the entire method and has a catch all block.")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Solution("Surround the entire method body with a try/catch block.")</AttributeName></Attribute></Attributes><Docs><summary>
             This rule checks for delegates which are created for methods which don't
             have exception handling and then passed to native code.
             Every delegate which is passed to native code must include an exception
             block which spans the entire method and has a catch all block.
             </summary><remarks>This rule is available since Gendarme 2.6</remarks><example>
             Bad example:
             <code>
             delegate void Callback ();
             [DllImport ("mylibrary.dll")]
             static extern void RegisterCallback (Callback callback);
             public void RegisterManagedCallback ()
             {
             	RegisterCallback (ManagedCallback);
             }
             public void ManagedCallback ()
             {
             	// This will cause the process to crash if native code calls this method.
             	throw new NotImplementedException ();
             }
             </code></example><example>
             Good example:
             <code>
             delegate void Callback ();
             [DllImport ("mylibrary.dll")]
             static extern void RegisterCallback (Callback callback);
             public void RegisterManagedCallback ()
             {
             	RegisterCallback (ManagedCallback);
             }
             public void ManagedCallback ()
             {
            	try {
            		throw new NotImplementedException ();
            	}
            	catch {
            		// This way the exception won't "leak" to native code
            	}
            	try {
            		throw new NotImplementedException ();
            	}
            	catch (System.Exception ex) {
            		// This is also safe - the runtime will process this catch clause,
            		// even if it is technically possible (by writing assemblies in managed
            		// C++ or IL) to throw an exception that doesn't inherit from
            		// System.Exception.
            	}
             }
             </code></example></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule ();" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Parameters /><Docs><summary>To be added.</summary><remarks>To be added.</remarks></Docs></Member><Member MemberName="CheckMethod"><MemberSignature Language="C#" Value="public Gendarme.Framework.RuleResult CheckMethod (Mono.Cecil.MethodDefinition method);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance valuetype Gendarme.Framework.RuleResult CheckMethod(class Mono.Cecil.MethodDefinition method) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>Gendarme.Framework.RuleResult</ReturnType></ReturnValue><Parameters><Parameter Name="method" Type="Mono.Cecil.MethodDefinition" /></Parameters><Docs><param name="method">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks></Docs></Member></Members></Type>