﻿<?xml version="1.0" encoding="utf-8"?><Type Name="DoNotUseThreadStaticWithInstanceFieldsRule" FullName="Gendarme.Rules.Concurrency.DoNotUseThreadStaticWithInstanceFieldsRule"><TypeSignature Language="C#" Value="public sealed class DoNotUseThreadStaticWithInstanceFieldsRule : Gendarme.Framework.Rule, Gendarme.Framework.ITypeRule" /><TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit DoNotUseThreadStaticWithInstanceFieldsRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IRule, class Gendarme.Framework.ITypeRule" /><AssemblyInfo><AssemblyName>Gendarme.Rules.Concurrency</AssemblyName><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Base><BaseTypeName>Gendarme.Framework.Rule</BaseTypeName></Base><Interfaces><Interface><InterfaceName>Gendarme.Framework.ITypeRule</InterfaceName></Interface></Interfaces><Attributes><Attribute><AttributeName>Gendarme.Framework.Problem("An instance field is decorated with System.ThreadStaticAttribute.")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Solution("ThreadStaticAttribute will only make static fields thread safe. To make an instance field thread safe you need to use techniques like locking or System.Threading.Thread.Thread::AllocateNamedDataSlot.")</AttributeName></Attribute></Attributes><Docs><summary>
             This rule will fire if an instance field is decorated with a <c>[ThreadStatic]</c> attribute. 
             This is an error because the attribute will only work with static fields.
             </summary><remarks>This rule is available since Gendarme 2.6</remarks><example>
             Bad example:
             <code>
             // the field isn't static so this will do nothing
             [ThreadStatic]
             private List&lt;object&gt; items;
             
             public void Add (object item)
             {
             	// If the field was thread safe this would ensure that each thread had 
             	// its own copy of the list.
             	if (items == null) {
             		items = new List&lt;object&gt; ();
            	 	}
             		
             	items.Add (item);
             } 
             </code></example><example>
             Good example:
             <code>
             private List&lt;object&gt; items = new List&lt;object&gt; ();
             private object mutex = new object ();
             
             // Typically some form of locking such as the code below is used to
             // serialize access to instance fields. However you can also use
             // Threading.Thread.Thread::AllocateNamedDataSlot or AllocateDataSlot.
             public void Add (object item)
             {
             	lock (mutex) {
             		items.Add (item);
             	}
             } 
             </code></example></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public DoNotUseThreadStaticWithInstanceFieldsRule ();" /><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="CheckType"><MemberSignature Language="C#" Value="public Gendarme.Framework.RuleResult CheckType (Mono.Cecil.TypeDefinition type);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance valuetype Gendarme.Framework.RuleResult CheckType(class Mono.Cecil.TypeDefinition type) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>Gendarme.Framework.RuleResult</ReturnType></ReturnValue><Parameters><Parameter Name="type" Type="Mono.Cecil.TypeDefinition" /></Parameters><Docs><param name="type">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks></Docs></Member></Members></Type>