src/CSharpIsNullAnalyzer/IOperationExtensions.cs
/// <summary>
/// Gets the first ancestor of this operation with:
///  1. Any OperationKind from the specified <paramref name="ancestorKinds"/>.
///  2. If <paramref name="predicate"/> is non-null, it succeeds for the ancestor.
/// Returns null if there is no such ancestor.
/// </summary>
/// <param name="root">The operation to start the search.</param>
/// <param name="ancestorKinds">The kinds of ancestors to look for.</param>
/// <param name="predicate">An optional test to apply before matching.</param>
/// <returns>The matching ancestor operation, if found.</returns>
Gets the first ancestor of this operation with:
1. Any OperationKind from the specified .
2. If  is non-null, it succeeds for the ancestor.
Returns null if there is no such ancestor.
Gets the first ancestor of this operation with : 1 . Any OperationKind from the specified . 2 . If is non - null it succeeds for the ancestor . Returns null if there is no such ancestor .
internal static IOperation? GetAncestor(this IOperation root, ImmutableArray<OperationKind> ancestorKinds, Func<IOperation, bool>? predicate = null)
        {
            IOperation? ancestor = root;
            do
            {
                ancestor = ancestor.Parent;
            }
            while (ancestor is object && !ancestorKinds.Contains(ancestor.Kind));
            if (ancestor is object)
            {
                if (predicate is object && !predicate(ancestor))
                {
                    return GetAncestor(ancestor, ancestorKinds, predicate);
                }
                return ancestor;
            }
            else
            {
                return default;
            }
        }
internal static IOperation ? GetAncestor ( this IOperation root , ImmutableArray < OperationKind > ancestorKinds , Func < IOperation , bool > ? predicate = null ) { IOperation ? ancestor = root ; do { ancestor = ancestor . Parent ; } while ( ancestor is object && ! ancestorKinds . Contains ( ancestor . Kind ) ) ; if ( ancestor is object ) { if ( predicate is object && ! predicate ( ancestor ) ) { return GetAncestor ( ancestor , ancestorKinds , predicate ) ; } return ancestor ; } else { return default ; } }
Gets the first ancestor of this operation with:
1.
Gets the first ancestor of this operation with : 1 .
The matching ancestor operation, if found.
The matching ancestor operation if found .
IOperation
this
ancestorKinds
ImmutableArray<OperationKind>
The kinds of ancestors to look for.
The kinds of ancestors to look for .
predicate
Func<IOperation, bool>?
An optional test to apply before matching.
An optional test to apply before matching .
root
The operation to start the search.
The operation to start the search .