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