Exemplo n.º 1
0
        void RunTransformsAndGenerateCode(ref BuilderState state, IDecompilerOutput output, DecompilationContext ctx, IAstTransform?additionalTransform = null)
        {
            var astBuilder = state.AstBuilder;

            astBuilder.RunTransformations(transformAbortCondition);
            if (additionalTransform is not null)
            {
                additionalTransform.Run(astBuilder.SyntaxTree);
            }
            var settings = GetDecompilerSettings();

            CSharpDecompiler.AddXmlDocumentation(ref state, settings, astBuilder);
            var csharpUnit = astBuilder.SyntaxTree;

            csharpUnit.AcceptVisitor(new ICSharpCode.NRefactory.CSharp.InsertParenthesesVisitor()
            {
                InsertParenthesesForReadability = true
            });
            GenericGrammarAmbiguityVisitor.ResolveAmbiguities(csharpUnit);
            var unit             = csharpUnit.AcceptVisitor(new CSharpToVBConverterVisitor(state.AstBuilder.Context.CurrentModule, new ILSpyEnvironmentProvider(state.State.XmlDoc_StringBuilder)), null);
            var outputFormatter  = new VBTextOutputFormatter(output, astBuilder.Context);
            var formattingPolicy = CreateVBFormattingOptions(settings);

            unit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null);
        }