Beispiel #1
0
        public override void VisitEventStatement(EventStatementSyntax node)
        {
            // VisitEventBlock() から来た場合は、二重登録になってしまうので飛ばす
            if (node.Parent is EventBlockSyntax)
            {
                base.VisitEventStatement(node);
                return;
            }

            var startLength = node.Span.Start;
            var endLength   = node.Span.End;

            WalkEventBlockOrEventStatement(node, startLength, endLength);

            base.VisitEventStatement(node);
        }
        public override SyntaxNode VisitEventStatement(EventStatementSyntax node)
        {
            //var parameters = new[] {  Parameter(ModifiedIdentifier("value")).WithAsClause(generator.GetType(node)) };
            //node = node.WithAccessorList(
            //    AccessorList(
            //        List(new AccessorDeclarationSyntax[]
            //        {
            //            AccessorDeclaration(SyntaxKind.AddAccessorDeclaration)
            //                .WithExpressionBody(
            //                    ArrowExpressionClause(ExecutePipeline(node.Type, parameters)))
            //                .WithSemicolon(),
            //            AccessorDeclaration(SyntaxKind.RemoveAccessorDeclaration)
            //                .WithExpressionBody(
            //                    ArrowExpressionClause(ExecutePipeline(node.Type, parameters)))
            //                .WithSemicolon()
            //        })));

            //return base.VisitEventDeclaration(node);

            return(base.VisitEventStatement(node));
        }
Beispiel #3
0
        private void WalkEventBlockOrEventStatement(EventStatementSyntax node, int startLength, int endLength)
        {
            var parentNamespace = GetNamespace(DefineKinds.Event, startLength, endLength);
            var defineName      = node.ChildTokens().FirstOrDefault(x => x.Kind() == SyntaxKind.IdentifierToken).ToString();
            var defineType      = string.Empty;

            // Public Event Clicked As EventHandler 系の宣言の場合
            if (node.ChildNodes().OfType <SimpleAsClauseSyntax>().Any())
            {
                var asNode = node.ChildNodes().OfType <SimpleAsClauseSyntax>().FirstOrDefault();
                defineType = asNode.ChildNodes().FirstOrDefault().ToString();
            }

            // Public Event Moved(sender As Object, e As EventArgs) 系の宣言の場合
            var methodArguments = new List <MethodArgument>();

            if (node.ChildNodes().OfType <ParameterListSyntax>().Any())
            {
                if (node.ChildNodes().OfType <ParameterListSyntax>().FirstOrDefault().ChildNodes().Any())
                {
                    var listNode = node.ChildNodes().OfType <ParameterListSyntax>().FirstOrDefault();
                    methodArguments = GetMethodArguments(listNode);
                }
            }

            UserDefinitions.Add(new UserDefinition
            {
                DefineKinds     = DefineKinds.Event,
                Namespace       = parentNamespace,
                DefineName      = defineName,
                DefineFullName  = $"{parentNamespace}.{defineName}",
                MethodArguments = methodArguments,
                ReturnType      = ConvertCSharpType(defineType),
                SourceFile      = SourceFile,
                StartLength     = startLength,
                EndLength       = endLength,
            });
        }
 public override void VisitEventStatement(EventStatementSyntax node) =>
 TryAddPublicApi(node);