protected IEnumerable <ProcessedMethod> PostProcessMethods(IEnumerable <MethodInfo> methods, IEnumerable <MethodInfo> equals)
        {
            HashSet <string>     duplicateNames   = FindDuplicateNames(methods);
            HashSet <MethodInfo> operatorToIgnore = new HashSet <MethodInfo> (OperatorOverloads.FindOperatorPairToIgnore(methods, equals));

            foreach (MethodInfo method in methods)
            {
                ProcessedMethod processedMethod = new ProcessedMethod(method);

                if (duplicateNames.Contains(CreateStringRep(method)) && method.Name != "CompareTo")                   // HACK
                {
                    processedMethod.FallBackToTypeName = true;
                }

                if (method.IsSpecialName && method.IsStatic && method.Name.StartsWith("op_", StringComparison.Ordinal))
                {
                    processedMethod.IsOperator = true;
                }

                if (method.IsSpecialName && method.IsStatic && method.Name == "op_Equality")
                {
                    processedMethod.NameOverride = "areEqual";
                }

                if (operatorToIgnore.Contains(method))
                {
                    delayed.Add(ErrorHelper.CreateWarning(1033, $"Method {processedMethod.Method.Name} is not generated because another method exposes the operator with a friendly name"));
                    continue;
                }

                yield return(processedMethod);
            }
        }
Exemple #2
0
        protected IEnumerable <ProcessedMethod> PostProcessMethods(IEnumerable <ProcessedMethod> methods)
        {
            HashSet <string> duplicateNames = FindDuplicateNames(methods);

            var equals = new HashSet <MethodInfo> ();

            foreach (var m in methods)
            {
                if (m.MethodType == MethodType.NSObjectProcotolIsEqual)
                {
                    equals.Add(m.Method);
                }
            }
            HashSet <MethodInfo> operatorToIgnore = new HashSet <MethodInfo> (OperatorOverloads.FindOperatorPairToIgnore(methods, equals));

            foreach (var processedMethod in methods)
            {
                var method = processedMethod.Method;
                if (operatorToIgnore.Contains(method))
                {
                    Delayed.Add(ErrorHelper.CreateWarning(1033, $"Method {method.Name} is not generated because another method exposes the operator with a friendly name"));
                    continue;
                }

                if (duplicateNames.Contains(CreateStringRep(method)) && method.Name != "CompareTo")                   // HACK
                {
                    processedMethod.FallBackToTypeName = true;
                }

                if (IsOperatorOrFriendlyVersion(method))
                {
                    processedMethod.IsOperator = true;
                }

                ProcessPotentialNameOverride(processedMethod);

                yield return(processedMethod);
            }
        }