Performance code quality

Proprietary

Performance optimization recipes for C# code.

OpenRewrite.Recipes.CSharp.CodeQuality.Performance.PerformanceCodeQuality
mod run . --recipe=OpenRewrite.Recipes.CSharp.CodeQuality.Performance.PerformanceCodeQuality

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Avoid boxing of value type
  2. Use StringComparison
  3. Avoid locking on publicly accessible instance
  4. Use StringBuilder.AppendLine
  5. Use Array.Empty<T>() instead of new T[0]
  6. Return completed task instead of null
  7. Use Count/Length property instead of Count()
  8. Use Regex.IsMatch
  9. Use string.Concat instead of string.Join
  10. Bitwise operation on enum without Flags attribute
  11. Make parameter ref read-only
  12. Avoid NullReferenceException
  13. Remove unnecessary explicit enumerator
  14. Throwing of new NotImplementedException
  15. Optimize method call
  16. Do not pass non-read-only struct by read-only reference
  17. Replace Enum.ToString() with nameof
  18. Optimize StringBuilder.Append usage
  19. Find blocking calls in async methods
  20. Find methods not forwarding CancellationToken
  21. Find implicit culture-sensitive string methods
  22. Find implicit culture-sensitive ToString calls
  23. Find LINQ methods replaceable with direct methods
  24. Find missing WithCancellation on async enumerables
  25. Do not use async void
  26. Do not use NaN in comparisons
  27. Add timeout to Regex
  28. Do not use blocking calls on tasks
  29. Use ContainsKey instead of TryGetValue with discard
  30. String.Format format string should be constant
  31. Avoid closure when using ConcurrentDictionary
  32. Use RegexOptions.ExplicitCapture
  33. Do not use ToString on GetType result
  34. Find EqualityComparer<string>.Default usage
  35. Find string.GetHashCode() without StringComparer
  36. Use char overload for single-character string methods
  37. Find Regex that could use source generator
  38. Find FormattableString that could use string.Create
  39. Find GetCustomAttributes that could use Attribute.IsDefined
  40. Find Span<char> equality that should use SequenceEqual
  41. Find structs without StructLayout attribute
  42. Find methods that could be static
  43. Find Guid.Parse with constant string
  44. Find calls that could use TimeProvider
  45. Find simplifiable string.Create calls
  46. Find closure in GetOrAdd that could use factory argument
  47. Find GetType() called on System.Type
  48. Find LINQ Count() on materialized collection
  49. Find unused Stream.Read return value
  50. Find Dictionary/HashSet with struct key type
  51. Find LINQ methods replaceable with indexer
  52. Use ContainsKey instead of Keys.Contains
  53. Find Values.Contains() instead of ContainsValue()
  54. Find closure in GetOrAdd/AddOrUpdate factory