private IEnumerable <MethodDefinition> SelectMethods(ModuleDefinition moduleDefinition, string excludeAttributeName) { var noLogAssembly = moduleDefinition.ContainsAttribute(excludeAttributeName); if (noLogAssembly) { LogInfo(string.Format("Skipping '{0}' assembly due to {1} attribute", moduleDefinition.Name, excludeAttributeName)); return(Enumerable.Empty <MethodDefinition>()); } LogInfo(string.Format("Searching for Methods in assembly ({0}).", moduleDefinition.Name)); var definitions = new HashSet <MethodDefinition>( moduleDefinition .Types .Where(x => x.IsClass && !x.ContainsAttribute(excludeAttributeName)) .SelectMany(x => x.Methods) .Where(x => ValidMethod(moduleDefinition, excludeAttributeName, x)) ); // Remove NoLogAttribute moduleDefinition.Types.SelectMany(x => x.Methods).ToList().ForEach(x => x.RemoveAttribute(excludeAttributeName)); moduleDefinition.Types.ToList().ForEach(x => x.RemoveAttribute(excludeAttributeName)); moduleDefinition.Assembly.RemoveAttribute(excludeAttributeName); return(definitions); }