Exemple #1
0
        public TransformationResult <LocalDeclarationStatementSyntax> Transform(CompilationUnitSyntax root)
        {
            var variable    = _local.Declaration.Variables.Single();
            var newVariable = variable.WithInitializer(variable.Initializer.WithValue(_foreach.F(ToAggregate)));
            var newLocal    = _local.WithDeclaration(
                _local.Declaration
                .WithVariables(
                    newVariable.ItemToSeparatedList()));

            root = root.TrackNodes(_local, _foreach);
            root = root.RemoveNode(root.GetCurrentNode(_foreach), SyntaxRemoveOptions.KeepDirectives);

            return(root.Transform(root.GetCurrentNode(_local), newLocal));
        }