コード例 #1
0
        /// <summary>
        /// 返回所有HttpApi诊断器
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private IEnumerable <HttpApiDiagnostic> GetHttpApiDiagnostics(HttpApiContext context)
        {
            yield return(new AttributeDiagnostic(context));

            yield return(new ReturnTypeDiagnostic(context));

            yield return(new RefParameterDiagnostic(context));

            yield return(new NotMethodDefindedDiagnostic(context));

            yield return(new GenericMethodDiagnostic(context));
        }
コード例 #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="context">上下文</param>
        public override void Initialize(AnalysisContext context)
        {
            context.RegisterSyntaxNodeAction(syntaxNodeContext =>
            {
                var httpApiContext = new HttpApiContext(syntaxNodeContext);
                if (httpApiContext.IsHtttApi == true)
                {
                    foreach (var item in this.GetHttpApiDiagnostics(httpApiContext))
                    {
                        item.Report();
                    }
                }
            }, SyntaxKind.InterfaceDeclaration);

            context.RegisterSyntaxNodeAction(syntaxContext =>
            {
                var invocationContext = new InvocationContext(syntaxContext);
                foreach (var item in this.GetInvocationDiagnostics(invocationContext))
                {
                    item.Report();
                }
            }, SyntaxKind.InvocationExpression);
        }
コード例 #3
0
 /// <summary>
 /// HttpApi诊断器
 /// </summary>
 /// <param name="context">上下文</param>
 public HttpApiDiagnostic(HttpApiContext context)
 {
     this.Context = context;
 }