/Mono.Cecil/IMethodSignature.cs

http://github.com/jbevain/cecil · C# · 57 lines · 35 code · 13 blank · 9 comment · 5 complexity · 06f3369b0da288e74160a91b57af91d0 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.Text;
  11. using Mono.Collections.Generic;
  12. namespace Mono.Cecil {
  13. public interface IMethodSignature : IMetadataTokenProvider {
  14. bool HasThis { get; set; }
  15. bool ExplicitThis { get; set; }
  16. MethodCallingConvention CallingConvention { get; set; }
  17. bool HasParameters { get; }
  18. Collection<ParameterDefinition> Parameters { get; }
  19. TypeReference ReturnType { get; set; }
  20. MethodReturnType MethodReturnType { get; }
  21. }
  22. static partial class Mixin {
  23. public static bool HasImplicitThis (this IMethodSignature self)
  24. {
  25. return self.HasThis && !self.ExplicitThis;
  26. }
  27. public static void MethodSignatureFullName (this IMethodSignature self, StringBuilder builder)
  28. {
  29. builder.Append ("(");
  30. if (self.HasParameters) {
  31. var parameters = self.Parameters;
  32. for (int i = 0; i < parameters.Count; i++) {
  33. var parameter = parameters [i];
  34. if (i > 0)
  35. builder.Append (",");
  36. if (parameter.ParameterType.IsSentinel)
  37. builder.Append ("...,");
  38. builder.Append (parameter.ParameterType.FullName);
  39. }
  40. }
  41. builder.Append (")");
  42. }
  43. }
  44. }