Beispiel #1
0
        private static bool ParametersMatch(
            ComparisonOptions options,
            Compilation compilation,
            ImmutableArray <IParameterSymbol> parameters,
            RefKind[] refKinds,
            SymbolKey[] typeKeys,
            CancellationToken cancellationToken)
        {
            if (parameters.Length != refKinds.Length)
            {
                return(false);
            }

            for (int i = 0; i < refKinds.Length; i++)
            {
                // The ref-out distinction is not interesting for SymbolKey because you can't overload
                // based on the difference.
                var parameter = parameters[i];
                if (!SymbolEquivalenceComparer.AreRefKindsEquivalent(refKinds[i], parameter.RefKind, distinguishRefFromOut: false))
                {
                    return(false);
                }

                // We are checking parameters for equality, if they refer to method type parameters,
                // then we don't want to recurse through the method (which would then recurse right
                // back into the parameters).  So we ask that type parameters only be checked by
                // metadataName to prevent that.
                var newOptions = new ComparisonOptions(
                    options.IgnoreCase,
                    options.IgnoreAssemblyKey,
                    compareMethodTypeParametersByName: true);

                if (!typeKeys[i].Equals(SymbolKey.Create(parameter.Type, compilation, cancellationToken), newOptions))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
        private static bool ParameterRefKindsMatch(
            ImmutableArray <IParameterSymbol> parameters,
            ImmutableArray <RefKind> refKinds)
        {
            if (parameters.Length != refKinds.Length)
            {
                return(false);
            }

            for (int i = 0; i < refKinds.Length; i++)
            {
                // The ref-out distinction is not interesting for SymbolKey because you can't overload
                // based on the difference.
                if (!SymbolEquivalenceComparer.AreRefKindsEquivalent(
                        refKinds[i], parameters[i].RefKind, distinguishRefFromOut: false))
                {
                    return(false);
                }
            }

            return(true);
        }