DiagnosticRules.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Microsoft.CodeAnalysis;
  2. namespace ET.Analyzer
  3. {
  4. public static class ETTaskInSyncMethodAnalyzerRule
  5. {
  6. private const string Title = "ETTask方法调用在非异步方法体内使用错误";
  7. private const string MessageFormat = "方法: {0} 在非异步方法体内使用时需要添加.Coroutine()后缀";
  8. private const string Description = "ETTask方法调用在非异步方法体内使用错误.";
  9. public static readonly DiagnosticDescriptor Rule =
  10. new DiagnosticDescriptor(DiagnosticIds.ETTaskInSyncMethodAnalyzerRuleId,
  11. Title,
  12. MessageFormat,
  13. DiagnosticCategories.Hotfix,
  14. DiagnosticSeverity.Error,
  15. true,
  16. Description);
  17. }
  18. public static class ETTaskInAsyncMethodAnalyzerRule
  19. {
  20. private const string Title = "ETTask方法调用在异步方法体内使用错误";
  21. private const string MessageFormat = "方法: {0} 在异步方法体内使用时需要添加await前缀 或 .Coroutine()后缀";
  22. private const string Description = "ETTask方法调用在异步方法体内使用错误.";
  23. public static readonly DiagnosticDescriptor Rule =
  24. new DiagnosticDescriptor(DiagnosticIds.ETTaskInAsyncMethodAnalyzerRuleId,
  25. Title,
  26. MessageFormat,
  27. DiagnosticCategories.Hotfix,
  28. DiagnosticSeverity.Error,
  29. true,
  30. Description);
  31. }
  32. public static class UniqueIdRangeAnaluzerRule
  33. {
  34. private const string Title = "唯一Id字段数值区间约束";
  35. private const string MessageFormat = "类: {0} Id字段: {1}的值: {2} 不在约束的区间内, 请修改";
  36. private const string Description = "唯一Id字段数值区间约束.";
  37. public static readonly DiagnosticDescriptor Rule =
  38. new DiagnosticDescriptor(DiagnosticIds.UniqueIdRangeAnalyzerRuleId,
  39. Title,
  40. MessageFormat,
  41. DiagnosticCategories.Model,
  42. DiagnosticSeverity.Error,
  43. true,
  44. Description);
  45. }
  46. public static class UniqueIdDuplicateAnalyzerRule
  47. {
  48. private const string Title = "唯一Id字段禁止重复";
  49. private const string MessageFormat = "类: {0} Id字段: {1}的值: {2} 与其他Id字段值重复, 请修改";
  50. private const string Description = "唯一Id字段禁止重复.";
  51. public static readonly DiagnosticDescriptor Rule =
  52. new DiagnosticDescriptor(DiagnosticIds.UniqueIdDuplicateAnalyzerRuleId,
  53. Title,
  54. MessageFormat,
  55. DiagnosticCategories.Model,
  56. DiagnosticSeverity.Error,
  57. true,
  58. Description);
  59. }
  60. }