コード例 #1
0
        public static IEnumerable <Tuple <SyntaxTree, SyntaxNode> > MakeChanges(Compilation compilation)
        {
            var objectType = compilation.GetTypeByMetadataName("System.Object");

            var changedNodes = new List <Tuple <SyntaxTree, SyntaxNode> >();

            // get changes for retro methods
            var methodChanges = GetRetroMethods(compilation, objectType);

            // apply changes and remove generics by syntax tree
            foreach (var treeGroup in methodChanges.GroupBy(x => x.Key.SyntaxTree))
            {
                var root = treeGroup.Key.GetRoot();

                var treeAfterReplace = root.ReplaceNodes(treeGroup.Select(x => x.Key), (x, y) => methodChanges[x]);

                var clean = new RemoveGenericNames().Visit(
                    new RemoveGenericClass().Visit(treeAfterReplace));

                yield return(new Tuple <SyntaxTree, SyntaxNode>(treeGroup.Key, clean));
            }
        }
コード例 #2
0
ファイル: Generator.cs プロジェクト: mpielikis/gencast
        public static IEnumerable<Tuple<SyntaxTree, SyntaxNode>> MakeChanges(Compilation compilation)
        {
            var objectType = compilation.GetTypeByMetadataName("System.Object");

            var changedNodes = new List<Tuple<SyntaxTree, SyntaxNode>>();

            // get changes for retro methods
            var methodChanges = GetRetroMethods(compilation, objectType);

            // apply changes and remove generics by syntax tree
            foreach (var treeGroup in methodChanges.GroupBy(x => x.Key.SyntaxTree))
            {
                var root = treeGroup.Key.GetRoot();

                var treeAfterReplace = root.ReplaceNodes(treeGroup.Select(x => x.Key), (x, y) => methodChanges[x]);

                var clean = new RemoveGenericNames().Visit(
                    new RemoveGenericClass().Visit(treeAfterReplace));

                yield return new Tuple<SyntaxTree, SyntaxNode>(treeGroup.Key, clean);
            }

        }