/// <summary>
            /// Returns a collection of attributes that are defined on the <paramref name="methodInfo"/> as well as any
            /// underlying interface definitions.
            /// </summary>
            /// <param name="methodInfo">The <see cref="MethodInfo"/> to return attributes for.</param>
            /// <returns>A collection of attributes.</returns>
            private static AttributeCollection GetAttributeCollection(MethodInfo methodInfo)
            {
                // Get all of the attributes defined on the MethodInfo
                List <Attribute> attributes = new List <Attribute>(methodInfo.GetCustomAttributes(true).Cast <Attribute>());

                // Filter out AsyncStateMachineAttribute for "async" methods
                attributes.RemoveAll(a => a.GetType().FullName == "System.Runtime.CompilerServices.AsyncStateMachineAttribute");

                // Examine interfaces on the type and try to find matching method implmentations.
                foreach (Type interfaceType in methodInfo.DeclaringType.GetInterfaces())
                {
                    InterfaceMapping interfaceMapping = methodInfo.DeclaringType.GetInterfaceMap(interfaceType);
                    for (int i = 0; i < interfaceMapping.TargetMethods.Length; ++i)
                    {
                        if (interfaceMapping.TargetMethods[i].MethodHandle == methodInfo.MethodHandle)
                        {
                            // Merge method attributes with those found on the interface method definition
                            ReflectionDomainOperationEntry.MergeAttributes(
                                attributes,
                                interfaceMapping.InterfaceMethods[i].GetCustomAttributes(true).Cast <Attribute>());
                            break;
                        }
                    }
                }

                return(new AttributeCollection(attributes.ToArray()));
            }