﻿<?xml version="1.0" encoding="utf-8"?><Type Name="AvoidCodeWithSideEffectsInConditionalCodeRule" FullName="Gendarme.Rules.Correctness.AvoidCodeWithSideEffectsInConditionalCodeRule"><TypeSignature Language="C#" Value="public class AvoidCodeWithSideEffectsInConditionalCodeRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" /><TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit AvoidCodeWithSideEffectsInConditionalCodeRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" /><AssemblyInfo><AssemblyName>Gendarme.Rules.Correctness</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.Problem("A conditionally compiled method is being called, but one of the actual arguments mutates state.")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Solution("If the state must be changed then do it outside the method call.")</AttributeName></Attribute></Attributes><Docs><summary>
            A number of System methods are conditionally compiled on #defines.
            For example, System.Diagnostics.Trace::Assert is a no-op if TRACE
            is not defined and System.Diagnostics.Debug::Write is a no-op if DEBUG
            is not defined.
            When calling a conditionally compiled method care should be taken to
            avoid executing code which has visible side effects. The reason is that
            the state of the program should generally not depend on the value of
            a define. If it does it is all too easy to create code which, for example,
            works in DEBUG but fails or behaves differently in release.
            This rule flags expressions used to construct the arguments to a
            conditional call if those expressions write to a local variable, method
            argument, or field. This includes pre/postfix increment and decrement
            expressions and assignment expressions.
            </summary><remarks>To be added.</remarks><example>
            Bad example:
            <code>
            internal sealed class Helpers {
            	public string StripHex (string text)
            	{
            		int i = 0;
            		// This code will work in debug, but not in release.
            		Debug.Assert (text [i++] == '0');
            		Debug.Assert (text [i++] == 'x');
            		return text.Substring (i);
            	}
            }
            </code></example><example>
            Good example:
            <code>
            internal sealed class Helpers {
            	public string StripHex (string text)
            	{
            		Debug.Assert (text [0] == '0');
            		Debug.Assert (text [1] == 'x');
            		return text.Substring (2);
            	}
            }
            </code></example></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public AvoidCodeWithSideEffectsInConditionalCodeRule ();" /><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></Members></Type>