예제 #1
0
        private static IEnumerable <EventFieldDeclarationSyntax> SplitEventFieldDeclaration(EventFieldDeclarationSyntax fieldDeclaration)
        {
            SeparatedSyntaxList <VariableDeclaratorSyntax> variables = fieldDeclaration.Declaration.Variables;

            EventFieldDeclarationSyntax fieldDeclaration2 = fieldDeclaration.WithoutTrivia();

            for (int i = 0; i < variables.Count; i++)
            {
                EventFieldDeclarationSyntax newDeclaration = EventFieldDeclaration(
                    fieldDeclaration2.AttributeLists,
                    fieldDeclaration2.Modifiers,
                    VariableDeclaration(
                        fieldDeclaration2.Declaration.Type,
                        SingletonSeparatedList(variables[i])));

                if (i == 0)
                {
                    newDeclaration = newDeclaration.WithLeadingTrivia(fieldDeclaration.GetLeadingTrivia());
                }

                if (i == variables.Count - 1)
                {
                    newDeclaration = newDeclaration.WithTrailingTrivia(fieldDeclaration.GetTrailingTrivia());
                }

                yield return(newDeclaration.WithFormatterAnnotation());
            }
        }