Пример #1
0
        void RunTransformsAndGenerateCode(ref BuilderState state, IDecompilerOutput output, DecompilationContext ctx, IAstTransform additionalTransform = null)
        {
            var astBuilder = state.AstBuilder;

            astBuilder.RunTransformations(transformAbortCondition);
            if (additionalTransform != null)
            {
                additionalTransform.Run(astBuilder.SyntaxTree);
            }
            AddXmlDocumentation(ref state, langSettings.Settings, astBuilder);
            astBuilder.GenerateCode(output);
        }
Пример #2
0
 internal static void AddXmlDocumentation(ref BuilderState state, DecompilerSettings settings, AstBuilder astBuilder)
 {
     if (settings.ShowXmlDocumentation)
     {
         try {
             new AddXmlDocTransform(state.State.XmlDoc_StringBuilder).Run(astBuilder.SyntaxTree);
         }
         catch (XmlException ex) {
             string[] msg            = (" Exception while reading XmlDoc: " + ex.ToString()).Split(newLineChars, StringSplitOptions.RemoveEmptyEntries);
             var      insertionPoint = astBuilder.SyntaxTree.FirstChild;
             for (int i = 0; i < msg.Length; i++)
             {
                 astBuilder.SyntaxTree.InsertChildBefore(insertionPoint, new Comment(msg[i], CommentType.Documentation), Roles.Comment);
             }
         }
     }
 }
Пример #3
0
        BuilderState CreateAstBuilder(DecompilationContext ctx, DecompilerSettings settings, ModuleDef currentModule = null, TypeDef currentType = null, bool isSingleMember = false)
        {
            if (currentModule == null)
            {
                currentModule = currentType.Module;
            }
            if (isSingleMember)
            {
                settings = settings.Clone();
                settings.UsingDeclarations = false;
            }
            var cache = ctx.GetOrCreate <BuilderCache>();
            var state = new BuilderState(ctx, cache);

            state.AstBuilder.Context.CurrentModule     = currentModule;
            state.AstBuilder.Context.CancellationToken = ctx.CancellationToken;
            state.AstBuilder.Context.CurrentType       = currentType;
            state.AstBuilder.Context.Settings          = settings;
            return(state);
        }
Пример #4
0
		BuilderState CreateAstBuilder(DecompilationContext ctx, DecompilerSettings settings, ModuleDef currentModule = null, TypeDef currentType = null, bool isSingleMember = false) {
			if (currentModule == null)
				currentModule = currentType.Module;
			if (isSingleMember) {
				settings = settings.Clone();
				settings.UsingDeclarations = false;
			}
			var cache = ctx.GetOrCreate<BuilderCache>();
			var state = new BuilderState(ctx, cache);
			state.AstBuilder.Context.CurrentModule = currentModule;
			state.AstBuilder.Context.CancellationToken = ctx.CancellationToken;
			state.AstBuilder.Context.CurrentType = currentType;
			state.AstBuilder.Context.Settings = settings;
			return state;
		}
Пример #5
0
		internal static void AddXmlDocumentation(ref BuilderState state, DecompilerSettings settings, AstBuilder astBuilder) { 
			if (settings.ShowXmlDocumentation) {
				try {
					new AddXmlDocTransform(state.State.XmlDoc_StringBuilder).Run(astBuilder.SyntaxTree);
				}
				catch (XmlException ex) {
					string[] msg = (" Exception while reading XmlDoc: " + ex.ToString()).Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
					var insertionPoint = astBuilder.SyntaxTree.FirstChild;
					for (int i = 0; i < msg.Length; i++)
						astBuilder.SyntaxTree.InsertChildBefore(insertionPoint, new Comment(msg[i], CommentType.Documentation), Roles.Comment);
				}
			}
		}
Пример #6
0
		void RunTransformsAndGenerateCode(ref BuilderState state, ITextOutput output, DecompilationContext ctx, IAstTransform additionalTransform = null) {
			var astBuilder = state.AstBuilder;
			astBuilder.RunTransformations(transformAbortCondition);
			if (additionalTransform != null) {
				additionalTransform.Run(astBuilder.SyntaxTree);
			}
			AddXmlDocumentation(ref state, langSettings.Settings, astBuilder);
			astBuilder.GenerateCode(output);
		}