﻿<?xml version="1.0" encoding="utf-8"?><Type Name="DoNotThrowInUnexpectedLocationRule" FullName="Gendarme.Rules.Exceptions.DoNotThrowInUnexpectedLocationRule"><TypeSignature Language="C#" Value="public sealed class DoNotThrowInUnexpectedLocationRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" /><TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit DoNotThrowInUnexpectedLocationRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" /><AssemblyInfo><AssemblyName>Gendarme.Rules.Exceptions</AssemblyName><AssemblyVersion>3.10.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.FxCopCompatibility("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Problem("A method throws an exception it should not.")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Solution("Change the code so that it does not throw, throws a legal exception, or traps exceptions.")</AttributeName></Attribute></Attributes><Docs><summary>
            There are a number of methods which have constraints on the exceptions
            which they may throw. This rule checks the following methods:
            <list type="bullet"><item><description>Property getters - properties should work very much
            like fields: they should execute very quickly and, in general, should
            not throw exceptions. However they may throw System.InvalidOperationException,
            System.NotSupportedException, or an exception derived from these.
            Indexed getters may also throw System.ArgumentException or
            System.Collections.Generic.KeyNotFoundException.</description></item><item><description>Event accessors - in general events should not throw
            when adding or removing a handler. However they may throw
            System.InvalidOperationException, System.NotSupportedException,
            System.ArgumentException, or an exception derived from these.</description></item><item><description>Object.Equals and IEqualityComparer&lt;T&gt;.Equals - should
            not throw. In particular they should do something sensible when passed
            null arguments or unexpected types.</description></item><item><description>Object.GetHashCode - should not throw or the object
            will not work properly with dictionaries and hash sets.</description></item><item><description>IEqualityComparer&lt;T&gt;.GetHashCode - may throw
            System.ArgumentException.</description></item><item><description>Object.ToString - these are called by the debugger to display
            objects and are also often used with printf style debugging so they should
            not change the object's state and should not throw.</description></item><item><description>static constructors - should very rarely throw. If they
            do throw then the type will not be useable within that application
            domain.</description></item><item><description>finalizers - should not throw. If they do (as of .NET 2.0)
            the process will be torn down.</description></item><item><description>IDisposable.Dispose - should not throw. If they do
            it's much harder to guarantee that objects clean up properly.</description></item><item><description>Dispose (bool) - should not throw because that makes
            it very difficult to clean up objects and because they are often
            called from a finalizer.</description></item><item><description>operator== and operator!= - should not throw. In particular
            they should do something sensible when passed null arguments or
            unexpected types.</description></item><item><description>implicit cast operators - should not throw. These methods
            are called implicitly so it tends to be quite surprising if they throw
            exceptions.</description></item><item><description><c>TryParse</c> methods - should not throw. These methods
            are designed to be executed without having to catch multiple exceptions
            (unlike the <c>Parse</c> methods).</description></item></list>
            Note that the rule does not complain if a method throws
            System.NotImplementedException because
            DoNotForgetNotImplementedMethodsRule will flag them. Also the rule
            may fire with anonymous types with gmcs versions prior to 2.2, see
            [https://bugzilla.novell.com/show_bug.cgi?id=462622] for more details.
            </summary><remarks>This rule is available since Gendarme 2.4</remarks><example>
            Bad example:
            <code>
            public override bool Equals (object obj)
            {
            	if (obj == null) {
            		return false;
            	}
            	Customer rhs = (Customer) obj;	// throws if obj is not a Customer
            	return name == rhs.name;
            }
            </code></example><example>
            Good example:
            <code>
            public override bool Equals (object obj)
            {
            	Customer rhs = obj as Customer;
            	if (rhs == null) {
            		return false;
            	}
            	return name == rhs.name;
            }
            </code></example></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public DoNotThrowInUnexpectedLocationRule ();" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>3.10.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>3.10.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><Member MemberName="Initialize"><MemberSignature Language="C#" Value="public override void Initialize (Gendarme.Framework.IRunner runner);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Initialize(class Gendarme.Framework.IRunner runner) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>3.10.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Void</ReturnType></ReturnValue><Parameters><Parameter Name="runner" Type="Gendarme.Framework.IRunner" /></Parameters><Docs><param name="runner">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks></Docs></Member></Members></Type>