/rocks/Mono.Cecil.Rocks/ModuleDefinitionRocks.cs

http://github.com/jbevain/cecil · C# · 32 lines · 17 code · 5 blank · 10 comment · 2 complexity · 8170caf31a0d575385b9a26630003ba7 MD5 · raw file

  1. //
  2. // Author:
  3. // Jb Evain (jbevain@gmail.com)
  4. //
  5. // Copyright (c) 2008 - 2015 Jb Evain
  6. // Copyright (c) 2008 - 2011 Novell, Inc.
  7. //
  8. // Licensed under the MIT/X11 license.
  9. //
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. namespace Mono.Cecil.Rocks {
  14. #if INSIDE_ROCKS
  15. public
  16. #endif
  17. static class ModuleDefinitionRocks {
  18. public static IEnumerable<TypeDefinition> GetAllTypes (this ModuleDefinition self)
  19. {
  20. if (self == null)
  21. throw new ArgumentNullException ("self");
  22. // it was fun to write, but we need a somewhat less convoluted implementation
  23. return self.Types.SelectMany (
  24. Functional.Y<TypeDefinition, IEnumerable<TypeDefinition>> (f => type => type.NestedTypes.SelectMany (f).Prepend (type)));
  25. }
  26. }
  27. }