== Why is this an issue? Synchronization can be expensive in terms of time when multiple threads need to pass through the same bottleneck (method with ``++[MethodImpl(MethodImplOptions.Synchronized)]++``). If you have a piece of code calling a method with ``++[MethodImpl(MethodImplOptions.Synchronized)]++`` attribute once, then it only has to wait its turn to pass through the bottleneck once. But call it in a loop, and your code has to get back in line for the bottleneck over and over. Instead, it would be better to get into the bottleneck, and then do the looping. I.e. consider refactoring the code to perform the loop inside the method. This rule raises an issue when a method with ``++[MethodImpl(MethodImplOptions.Synchronized)]++`` is called in a loop. === Noncompliant code example [source,csharp] ---- public void doSomething(int max) { for (int i = 0; i < max; i++) { doSynchronized(i); // Noncompliant } } [MethodImpl(MethodImplOptions.Synchronized)] public void doSynchronized(int val) { // ... } ---- ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] ''' == Comments And Links (visible only on this page) === on 16 Jun 2015, 10:46:55 Tamas Vajk wrote: \[~ann.campbell.2] I've added this C# version. I think this attribute is used a lot less frequently than the ``++synchronized++`` language element in Java. It might not be worth implementing. === on 16 Jun 2015, 11:19:08 Ann Campbell wrote: Thanks for filling in the C# version [~tamas.vajk]. It's completely up to you whether or not to implement. Always feel free to de-target a rule written originally for Java. I add C# based on hunches and guesses. include::../comments-and-links.adoc[] endif::env-github,rspecator-view[]