MethodDisplayInfo.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace Microsoft.Extensions.StackTrace.Sources
  7. {
  8. internal class MethodDisplayInfo
  9. {
  10. public string DeclaringTypeName { get; set; }
  11. public string Name { get; set; }
  12. public string GenericArguments { get; set; }
  13. public string SubMethod { get; set; }
  14. public IEnumerable<ParameterDisplayInfo> Parameters { get; set; }
  15. public override string ToString()
  16. {
  17. var builder = new StringBuilder();
  18. if (!string.IsNullOrEmpty(DeclaringTypeName))
  19. {
  20. builder
  21. .Append(DeclaringTypeName)
  22. .Append(".");
  23. }
  24. builder.Append(Name);
  25. builder.Append(GenericArguments);
  26. builder.Append("(");
  27. builder.Append(string.Join(", ", Parameters.Select(p => p.ToString())));
  28. builder.Append(")");
  29. if (!string.IsNullOrEmpty(SubMethod))
  30. {
  31. builder.Append("+");
  32. builder.Append(SubMethod);
  33. builder.Append("()");
  34. }
  35. return builder.ToString();
  36. }
  37. }
  38. }