Performance code quality
ProprietaryPerformance optimization recipes for C# code.
OpenRewrite. Recipes. CSharp. CodeQuality. Performance. PerformanceCodeQualitymod run . --recipe= OpenRewrite. Recipes. CSharp. CodeQuality. Performance. PerformanceCodeQualityInstall 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.
- Avoid boxing of value type
- Use StringComparison
- Avoid locking on publicly accessible instance
- Use StringBuilder.AppendLine
- Use Array.Empty<T>() instead of new T[0]
- Return completed task instead of null
- Use Count/Length property instead of Count()
- Use Regex.IsMatch
- Use string.Concat instead of string.Join
- Bitwise operation on enum without Flags attribute
- Make parameter ref read-only
- Avoid NullReferenceException
- Remove unnecessary explicit enumerator
- Throwing of new NotImplementedException
- Optimize method call
- Do not pass non-read-only struct by read-only reference
- Replace Enum.ToString() with nameof
- Optimize StringBuilder.Append usage
- Find blocking calls in async methods
- Find methods not forwarding CancellationToken
- Find implicit culture-sensitive string methods
- Find implicit culture-sensitive ToString calls
- Find LINQ methods replaceable with direct methods
- Find missing WithCancellation on async enumerables
- Do not use async void
- Do not use NaN in comparisons
- Add timeout to Regex
- Do not use blocking calls on tasks
- Use ContainsKey instead of TryGetValue with discard
- String.Format format string should be constant
- Avoid closure when using ConcurrentDictionary
- Use RegexOptions.ExplicitCapture
- Do not use ToString on GetType result
- Find EqualityComparer<string>.Default usage
- Find string.GetHashCode() without StringComparer
- Use char overload for single-character string methods
- Find Regex that could use source generator
- Find FormattableString that could use string.Create
- Find GetCustomAttributes that could use Attribute.IsDefined
- Find Span<char> equality that should use SequenceEqual
- Find structs without StructLayout attribute
- Find methods that could be static
- Find Guid.Parse with constant string
- Find calls that could use TimeProvider
- Find simplifiable string.Create calls
- Find closure in GetOrAdd that could use factory argument
- Find GetType() called on System.Type
- Find LINQ Count() on materialized collection
- Find unused Stream.Read return value
- Find Dictionary/HashSet with struct key type
- Find LINQ methods replaceable with indexer
- Use ContainsKey instead of Keys.Contains
- Find Values.Contains() instead of ContainsValue()
- Find closure in GetOrAdd/AddOrUpdate factory