Example #1
0
 public virtual void WriteTypeDeclarationsOnly(TypeDefinition member, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers = false)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(member, Language);
     this.currentWritingInfo   = new WritingInfo(member);
     WriteTypeDeclarationsOnlyInternal(member, writeDocumentation, showCompilerGeneratedMembers);
 }
Example #2
0
 public List <WritingInfo> WriteType(TypeDefinition type, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers, bool writeFullyQualifiedNames)
 {
     this.writeNamespacesandUsings = false;
     this.writeFullyQualifiedNames = writeFullyQualifiedNames;
     this.currentNamespace         = GetCurrentNamespace(type);
     return(base.Write(type, writerContextService, writeDocumentation, showCompilerGeneratedMembers));
 }
 public virtual void WriteTypeDeclarationsOnly(TypeDefinition member, IWriterContextService writerContextService)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(member, Language);
     this.currentWritingInfo   = new WritingInfo(member);
     WriteTypeDeclarationsOnlyInternal(member);
 }
		public List<WritingInfo> WriteType(TypeDefinition type, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers, bool writeFullyQualifiedNames)
		{
			this.writeNamespacesandUsings = false;
			this.writeFullyQualifiedNames = writeFullyQualifiedNames;
			this.currentNamespace = GetCurrentNamespace(type);
			return base.Write(type, writerContextService, writeDocumentation, showCompilerGeneratedMembers);
		}
 public JustAssemblyVisualBasicWriter(IMemberDefinition member, IWriterContextService writerContextService,
                                      ILanguage language, IFormatter formatter, IExceptionFormatter exceptionFormatter, IWriterSettings settings)
     : base(language, formatter, exceptionFormatter, settings)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = this.writerContextService.GetWriterContext(member, language);
 }
Example #6
0
 public JustAssemblyCSharpWriter(IMemberDefinition member, IWriterContextService writerContextService,
                                 ILanguage language, IFormatter formatter, IExceptionFormatter exceptionFormatter, bool writeExceptionsAsComments)
     : base(language, formatter, exceptionFormatter, writeExceptionsAsComments)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = this.writerContextService.GetWriterContext(member, language);
 }
Example #7
0
        public void WriteAssemblyAttributes(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
        {
            IntermediateLanguageAttributeWriter attributeWriter = new IntermediateLanguageAttributeWriter(this.Language, this.formatter, this.exceptionFormatter, this.Settings);

            attributeWriter.ExceptionThrown += OnExceptionThrown;
            attributeWriter.WriteAssemblyAttributes(assembly, attributesToIgnore);
            attributeWriter.ExceptionThrown -= OnExceptionThrown;
        }
 public virtual void WriteModuleAttributes(ModuleDefinition module, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
 {
     this.SetAssemblyContext(new AssemblySpecificContext());
     V_1 = writerContextService.GetModuleContext(module, this.get_Language());
     this.SetModuleContext(V_1);
     this.WriteModuleAttributesInternal(module, V_1.get_ModuleNamespaceUsings(), writeUsings, attributesToIgnore);
     return;
 }
 public void WriteAssemblyAttributes(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
 {
     stackVariable8 = new IntermediateLanguageAttributeWriter(this.get_Language(), this.formatter, this.exceptionFormatter, this.get_Settings());
     stackVariable8.add_ExceptionThrown(new EventHandler <Exception>(this.OnExceptionThrown));
     stackVariable8.WriteAssemblyAttributes(assembly, attributesToIgnore);
     stackVariable8.remove_ExceptionThrown(new EventHandler <Exception>(this.OnExceptionThrown));
     return;
 }
 public void WriteAssemblyInfo(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> assemblyAttributesToIgnore = null, ICollection <string> moduleAttributesToIgnore = null)
 {
     V_0 = writerContextService.GetAssemblyContext(assembly, this.get_Language());
     this.SetAssemblyContext(V_0);
     V_1 = writerContextService.GetModuleContext(assembly.get_MainModule(), this.get_Language());
     this.SetModuleContext(V_1);
     this.WriteAssemblyInfoInternal(assembly, V_0.get_AssemblyNamespaceUsings(), V_1.get_ModuleNamespaceUsings(), writeUsings, assemblyAttributesToIgnore, moduleAttributesToIgnore);
     return;
 }
 public virtual void WriteBody(IMemberDefinition member, IWriterContextService writerContextService)
 {
     this.writerContextService = writerContextService;
     this.currentWritingInfo   = new WritingInfo(member);
     this.writingInfos         = new List <WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     this.writerContext = writerContextService.GetWriterContext(member, Language);
     WriteBodyInternal(member);
 }
Example #12
0
 public void WriteBody(IMemberDefinition member, IWriterContextService writerContextService, bool writeFullQualifiedNames)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(member, Language);
     this.currentWritingInfo   = new WritingInfo(member);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List <WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WriteBodyInternal(member, writeFullQualifiedNames);
 }
		public virtual void WriteAssemblyAttributes(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection<string> attributesToIgnore = null)
		{
			AssemblySpecificContext assemblyContext = writerContextService.GetAssemblyContext(assembly, Language);
			SetAssemblyContext(assemblyContext);

			ModuleSpecificContext mainModuleContext = writerContextService.GetModuleContext(assembly.MainModule, Language);
			SetModuleContext(mainModuleContext);

			WriteAssemblyAttributesInternal(assembly, assemblyContext.AssemblyNamespaceUsings, mainModuleContext.ModuleNamespaceUsings, writeUsings, attributesToIgnore);
		}
 public override void WriteBody(IMemberDefinition member, IWriterContextService writerContextService)
 {
     this.writerContextService = writerContextService;
     this.writerContext = writerContextService.GetWriterContext(member, Language);
     this.currentWritingInfo = new WritingInfo(member);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List<WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WriteBodyInternal(member);
 }
        private string WriteAssemblyInfo(AssemblyDefinition assembly, out bool createdNewFile)
        {
            string fileContent;
            IAssemblyAttributeWriter writer = null;

            using (StringWriter stringWriter = new StringWriter())
            {
                IWriterSettings settings = new WriterSettings(writeExceptionsAsComments: true);
                writer = language.GetAssemblyAttributeWriter(new PlainTextFormatter(stringWriter), this.exceptionFormater, settings);
                IWriterContextService writerContextService = this.GetWriterContextService();
                writer.ExceptionThrown += OnExceptionThrown;
                writerContextService.ExceptionThrown += OnExceptionThrown;

                // "Duplicate 'TargetFramework' attribute" when having it written in AssemblyInfo
                writer.WriteAssemblyInfo(assembly, writerContextService, true,
                                         new string[1] {
                    "System.Runtime.Versioning.TargetFrameworkAttribute"
                }, new string[1] {
                    "System.Security.UnverifiableCodeAttribute"
                });

                fileContent = stringWriter.ToString();

                writer.ExceptionThrown -= OnExceptionThrown;
                writerContextService.ExceptionThrown -= OnExceptionThrown;
            }

            string parentDirectory = Path.GetDirectoryName(this.TargetPath);
            string relativePath    = filePathsService.GetAssemblyInfoRelativePath();
            string fullPath        = Path.Combine(parentDirectory, relativePath);

            string dirPath = Path.GetDirectoryName(fullPath);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            if (File.Exists(fullPath) && assembly.MainModule.Types.FirstOrDefault(x => x.FullName == "Properties.AssemblyInfo") != null)
            {
                createdNewFile = false;
                PushAssemblyAttributes(fullPath, fileContent, writer);
            }
            else
            {
                createdNewFile = true;
                using (StreamWriter fileWriter = new StreamWriter(fullPath, false, Encoding.UTF8))
                {
                    fileWriter.Write(fileContent);
                }
            }

            return(relativePath);
        }
		public virtual void WriteModuleAttributes(ModuleDefinition module, IWriterContextService writerContextService, bool writeUsings = false, ICollection<string> attributesToIgnore = null)
		{
			AssemblySpecificContext assemblyContext = new AssemblySpecificContext();
			SetAssemblyContext(assemblyContext);

			ModuleSpecificContext moduleContext = writerContextService.GetModuleContext(module, Language);
			SetModuleContext(moduleContext);


			WriteModuleAttributesInternal(module, moduleContext.ModuleNamespaceUsings, writeUsings, attributesToIgnore);
		}
Example #17
0
		public override void WriteBody(IMemberDefinition member, IWriterContextService writerContextService)
		{
			this.writerContextService = writerContextService;
			this.writerContext = writerContextService.GetWriterContext(member, this.get_Language());
			this.currentWritingInfo = new WritingInfo(member);
			this.UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
			this.writingInfos = new List<WritingInfo>();
			this.writingInfos.Add(this.currentWritingInfo);
			this.WriteBodyInternal(member);
			return;
		}
Example #18
0
        public virtual void WriteAssemblyAttributes(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
        {
            AssemblySpecificContext assemblyContext = writerContextService.GetAssemblyContext(assembly, Language);

            SetAssemblyContext(assemblyContext);

            ModuleSpecificContext mainModuleContext = writerContextService.GetModuleContext(assembly.MainModule, Language);

            SetModuleContext(mainModuleContext);

            WriteAssemblyAttributesInternal(assembly, assemblyContext.AssemblyNamespaceUsings, mainModuleContext.ModuleNamespaceUsings, writeUsings, attributesToIgnore);
        }
 public List<WritingInfo> WritePartialTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService, Dictionary<string, ICollection<string>> fieldsToSkip = null)
 {
     this.writerContextService = writerContextService;
     this.writerContext = writerContextService.GetWriterContext(type, Language);
     this.CurrentType = type;
     this.currentWritingInfo = new WritingInfo(type);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List<WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WritePartialTypeAndNamespacesInternal(type, fieldsToSkip);
     return writingInfos;
 }
 public List <WritingInfo> WritePartialTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService, Dictionary <string, ICollection <string> > fieldsToSkip = null)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(type, Language);
     this.CurrentType          = type;
     this.currentWritingInfo   = new WritingInfo(type);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List <WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WritePartialTypeAndNamespacesInternal(type, fieldsToSkip);
     return(writingInfos);
 }
Example #21
0
 public List <WritingInfo> WritePartialTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService, bool showCompilerGeneratedMembers, bool writeFullyQualifiedNames, bool writeDocumentation, Dictionary <string, ICollection <string> > fieldsToSkip = null)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(type, Language);
     this.CurrentType          = type;
     this.currentWritingInfo   = new WritingInfo(type);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List <WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WritePartialTypeAndNamespacesInternal(type, showCompilerGeneratedMembers, writeFullyQualifiedNames, writeDocumentation, fieldsToSkip);
     return(writingInfos);
 }
		public List<WritingInfo> WriteTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers, bool writeFullyQualifiedNames)
		{
			this.writerContextService = writerContextService;
			this.writerContext = writerContextService.GetWriterContext(type, Language);
			this.CurrentType = type;
			this.currentNamespace = GetCurrentNamespace(type);
			this.currentWritingInfo = new WritingInfo(type);
			UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
			this.writingInfos = new List<WritingInfo>();
			this.writingInfos.Add(this.currentWritingInfo);
			WriteTypeAndNamespacesInternal(type, writeDocumentation, showCompilerGeneratedMembers, writeFullyQualifiedNames);
            return writingInfos;
		}
Example #23
0
 public List <WritingInfo> WriteTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers, bool writeFullyQualifiedNames)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(type, Language);
     this.CurrentType          = type;
     this.currentNamespace     = GetCurrentNamespace(type);
     this.currentWritingInfo   = new WritingInfo(type);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List <WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WriteTypeAndNamespacesInternal(type, writeDocumentation, showCompilerGeneratedMembers, writeFullyQualifiedNames);
     return(writingInfos);
 }
Example #24
0
        public virtual void WriteModuleAttributes(ModuleDefinition module, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
        {
            AssemblySpecificContext assemblyContext = new AssemblySpecificContext();

            SetAssemblyContext(assemblyContext);

            ModuleSpecificContext moduleContext = writerContextService.GetModuleContext(module, Language);

            SetModuleContext(moduleContext);


            WriteModuleAttributesInternal(module, moduleContext.ModuleNamespaceUsings, writeUsings, attributesToIgnore);
        }
 public List <WritingInfo> WriteTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService)
 {
     this.writerContextService = writerContextService;
     this.writerContext        = writerContextService.GetWriterContext(type, Language);
     this.CurrentType          = type;
     this.currentNamespace     = GetCurrentNamespace(type);
     this.currentWritingInfo   = new WritingInfo(type);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List <WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WriteTypeAndNamespacesInternal(type);
     return(writingInfos);
 }
Example #26
0
        public virtual List <WritingInfo> Write(IMemberDefinition member, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers = false)
        {
            this.writerContextService = writerContextService;
            this.writerContext        = writerContextService.GetWriterContext(member, Language);

            if (member is TypeDefinition)
            {
                this.CurrentType = member as TypeDefinition;
            }

            this.currentWritingInfo = new WritingInfo(member);
            UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
            this.writingInfos = new List <WritingInfo>();
            this.writingInfos.Add(this.currentWritingInfo);

            WriteInternal(member, writeDocumentation, showCompilerGeneratedMembers);

            return(writingInfos);
        }
        public virtual List <WritingInfo> Write(IMemberDefinition member, IWriterContextService writerContextService)
        {
            this.writerContextService = writerContextService;
            this.writerContext        = writerContextService.GetWriterContext(member, Language);

            if (member is TypeDefinition)
            {
                this.CurrentType = member as TypeDefinition;
            }

            this.currentWritingInfo = new WritingInfo(member);
            UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
            this.writingInfos = new List <WritingInfo>();
            this.writingInfos.Add(this.currentWritingInfo);

            WriteInternal(member);

            return(writingInfos);
        }
        public void WriteTypeDeclaration(TypeDefinition type, IWriterContextService writerContextService)
        {
            this.writerContextService = writerContextService;
            this.writerContext        = writerContextService.GetWriterContext(type, Language);
            this.currentWritingInfo   = new WritingInfo(type);

            WriteAttributes(type, new string[] { "System.Reflection.DefaultMemberAttribute" });

            membersStack.Push(type);
            if (this.ShouldWriteAsDelegate(type))
            {
                WriteDelegate(type);
                WriteLine();
                membersStack.Pop();
                return;
            }

            WriteTypeDeclaration(type);
            WriteLine();

            membersStack.Pop();
        }
		public List<WritingInfo> WritePartialTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService, bool showCompilerGeneratedMembers, bool writeFullyQualifiedNames, bool writeDocumentation, Dictionary<string, ICollection<string>> fieldsToSkip = null)
		{
			this.writerContextService = writerContextService;
			this.writerContext = writerContextService.GetWriterContext(type, Language);
			this.CurrentType = type;
			this.currentWritingInfo = new WritingInfo(type);
			UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
			this.writingInfos = new List<WritingInfo>();
			this.writingInfos.Add(this.currentWritingInfo);
			WritePartialTypeAndNamespacesInternal(type, showCompilerGeneratedMembers, writeFullyQualifiedNames, writeDocumentation, fieldsToSkip);
            return writingInfos;
		}
 public List<WritingInfo> WriteType(TypeDefinition type, IWriterContextService writerContextService)
 {
     this.writeNamespacesandUsings = false;
     this.currentNamespace = GetCurrentNamespace(type);
     return base.Write(type, writerContextService);
 }
        public bool WriteTypeToFile(TypeDefinition type, IProjectItemFileWriter itemWriter, Dictionary <string, ICollection <string> > membersToSkip, bool shouldBePartial,
                                    ILanguage language, out List <WritingInfo> writingInfos, out string theCodeString)
        {
            theCodeString = string.Empty;
            writingInfos  = null;
            StringWriter theWriter = new StringWriter();

            bool showCompilerGeneratedMembers = Utilities.IsVbInternalTypeWithoutRootNamespace(type) ||
                                                Utilities.IsVbInternalTypeWithRootNamespace(type);

            IFormatter      formatter = GetFormatter(theWriter);
            IWriterSettings settings  = new WriterSettings(writeExceptionsAsComments: true,
                                                           writeFullyQualifiedNames: decompilationPreferences.WriteFullNames,
                                                           writeDocumentation: decompilationPreferences.WriteDocumentation,
                                                           showCompilerGeneratedMembers: showCompilerGeneratedMembers,
                                                           writeLargeNumbersInHex: decompilationPreferences.WriteLargeNumbersInHex);
            ILanguageWriter writer = language.GetWriter(formatter, this.exceptionFormater, settings);

            IWriterContextService writerContextService = this.GetWriterContextService();

            writer.ExceptionThrown += OnExceptionThrown;
            writerContextService.ExceptionThrown += OnExceptionThrown;

            bool exceptionOccurred = false;

            try
            {
                if (!(writer is INamespaceLanguageWriter))
                {
                    writingInfos = writer.Write(type, writerContextService);
                }
                else
                {
                    if (shouldBePartial)
                    {
                        writingInfos = (writer as INamespaceLanguageWriter).WritePartialTypeAndNamespaces(type, writerContextService, membersToSkip);
                    }
                    else
                    {
                        writingInfos = (writer as INamespaceLanguageWriter).WriteTypeAndNamespaces(type, writerContextService);
                    }
                }

                this.RecordGeneratedFileData(type, itemWriter.FullSourceFilePath, theWriter, formatter, writerContextService, writingInfos);

                MemoryStream sourceFileStream = new MemoryStream(Encoding.UTF8.GetBytes(theWriter.ToString()));
                itemWriter.CreateProjectSourceFile(sourceFileStream);
                sourceFileStream.Close();
                theWriter.Close();
            }
            catch (Exception e)
            {
                exceptionOccurred = true;

                string[] exceptionMessageLines     = exceptionFormater.Format(e, type.FullName, itemWriter.FullSourceFilePath);
                string   exceptionMessage          = string.Join(Environment.NewLine, exceptionMessageLines);
                string   commentedExceptionMessage = language.CommentLines(exceptionMessage);
                itemWriter.CreateProjectSourceFile(new MemoryStream(Encoding.UTF8.GetBytes(commentedExceptionMessage)));

                OnExceptionThrown(this, e);
            }

            theCodeString = theWriter.ToString();

            writer.ExceptionThrown -= OnExceptionThrown;
            writerContextService.ExceptionThrown -= OnExceptionThrown;

            return(exceptionOccurred || writerContextService.ExceptionsWhileDecompiling.Any());
        }
 protected virtual void RecordGeneratedFileData(TypeDefinition type, string sourceFilePath, StringWriter theWriter, IFormatter formatter, IWriterContextService writerContextService, List <WritingInfo> writingInfos)
 {
 }
        public void WriteTypeDeclaration(TypeDefinition type, IWriterContextService writerContextService, bool showCompilerGeneratedMembers = false)
        {
            this.writerContextService = writerContextService;
            this.writerContext = writerContextService.GetWriterContext(type, Language);
            this.currentWritingInfo = new WritingInfo(type);

            WriteAttributes(type, new string[] { "System.Reflection.DefaultMemberAttribute" });

            membersStack.Push(type);
            if (type.IsDelegate())
            {
                WriteDelegate(type);
                WriteLine();
                membersStack.Pop();
                return;
            }

            WriteTypeDeclaration(type);
            WriteLine();

            membersStack.Pop();
        }
 public void WriteModuleAttributes(ModuleDefinition module, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
 {
     return;
 }
        public void WriteAssemblyAttributes(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection<string> attributesToIgnore = null)
        {
			IntermediateLanguageAttributeWriter attributeWriter = new IntermediateLanguageAttributeWriter(this.Language, this.formatter, this.exceptionFormatter, this.WriteExceptionsAsComments, this.shouldGenerateBlocks);
			attributeWriter.WriteAssemblyAttributes(assembly, attributesToIgnore);
		}
		public void WriteModuleAttributes(ModuleDefinition module, IWriterContextService writerContextService, bool writeUsings = false, ICollection<string> attributesToIgnore = null)
		{
		}
		public void WriteAssemblyInfo(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, 
			ICollection<string> assemblyAttributesToIgnore = null, ICollection<string> moduleAttributesToIgnore = null)
		{
			WriteAssemblyAttributes(assembly, writerContextService, writeUsings, assemblyAttributesToIgnore);
			WriteModuleAttributes(assembly.MainModule, writerContextService, writeUsings, moduleAttributesToIgnore);
		}
        protected virtual void RecordGeneratedFileData(TypeDefinition type, string sourceFilePath, StringWriter theWriter, IFormatter formatter, IWriterContextService writerContextService, List<WritingInfo> writingInfos)
        {

        }
 public List <WritingInfo> WriteType(TypeDefinition type, IWriterContextService writerContextService)
 {
     this.writeNamespacesandUsings = false;
     this.currentNamespace         = GetCurrentNamespace(type);
     return(base.Write(type, writerContextService));
 }
		public void WriteBody(IMemberDefinition member, IWriterContextService writerContextService, bool writeFullQualifiedNames)
		{
			this.writerContextService = writerContextService;
			this.writerContext = writerContextService.GetWriterContext(member, Language);
			this.currentWritingInfo = new WritingInfo(member);
			UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
			this.writingInfos = new List<WritingInfo>();
			this.writingInfos.Add(this.currentWritingInfo);
			WriteBodyInternal(member, writeFullQualifiedNames);
		}
 public void WriteAssemblyInfo(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> assemblyAttributesToIgnore = null, ICollection <string> moduleAttributesToIgnore = null)
 {
     this.WriteAssemblyAttributes(assembly, writerContextService, writeUsings, assemblyAttributesToIgnore);
     this.WriteModuleAttributes(assembly.get_MainModule(), writerContextService, writeUsings, moduleAttributesToIgnore);
     return;
 }
 public List<WritingInfo> WriteTypeAndNamespaces(TypeDefinition type, IWriterContextService writerContextService)
 {
     this.writerContextService = writerContextService;
     this.writerContext = writerContextService.GetWriterContext(type, Language);
     this.CurrentType = type;
     this.currentNamespace = GetCurrentNamespace(type);
     this.currentWritingInfo = new WritingInfo(type);
     UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
     this.writingInfos = new List<WritingInfo>();
     this.writingInfos.Add(this.currentWritingInfo);
     WriteTypeAndNamespacesInternal(type);
     return writingInfos;
 }
        public virtual List<WritingInfo> Write(IMemberDefinition member, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers = false)
        {
            this.writerContextService = writerContextService;
            this.writerContext = writerContextService.GetWriterContext(member, Language);

            if (member is TypeDefinition)
            {
                this.CurrentType = member as TypeDefinition;
            }

            this.currentWritingInfo = new WritingInfo(member);
            UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
            this.writingInfos = new List<WritingInfo>();
            this.writingInfos.Add(this.currentWritingInfo);

            WriteInternal(member, writeDocumentation, showCompilerGeneratedMembers);

            return writingInfos;
        }
Example #44
0
        protected override void RecordGeneratedFileData(TypeDefinition type, string sourceFilePath, StringWriter theWriter, IFormatter formatter, IWriterContextService writerContextService, List <WritingInfo> writingInfos)
        {
            lock (recordGeneratedFileDataLock)
            {
                if (!(formatter is AvalonEditCodeFormatter))
                {
                    throw new Exception("Unexpected formatter type.");
                }

                AvalonEditCodeFormatter languageCodeFormatter = formatter as AvalonEditCodeFormatter;

                JustDecompile.EngineInfrastructure.ICodeViewerResults originalcodeViewerResults = languageCodeFormatter.GetSourceCode();

                if (!(originalcodeViewerResults is JustDecompile.EngineInfrastructure.DecompiledSourceCode))
                {
                    throw new Exception("Unexpected code viewer results type.");
                }

                JustDecompile.EngineInfrastructure.DecompiledSourceCode decompiledSourceCode = originalcodeViewerResults as JustDecompile.EngineInfrastructure.DecompiledSourceCode;

                ICodeViewerResults             codeViewerResults = new CodeViewerResults(decompiledSourceCode);
                Dictionary <uint, IOffsetSpan> memberDeclarationToCodePostionMap = GetMemberDeclarationToCodePostionMap(writingInfos);
                Dictionary <uint, IOffsetSpan> memberTokenToDocumentationMap     = GetMemberTokenToDocumentationMap(writingInfos);
                Dictionary <uint, IOffsetSpan> memberTokenToAttributesMap        = GetMemberTokenToAttributesMap(writingInfos);
                Dictionary <uint, IOffsetSpan> memberTokenToDecompiledCodeMap    = GetMemberTokenToDecompiledCodeMap(writingInfos);
                ICollection <uint>             membersWithExceptions             = GetMembersWithExceptions(writingInfos);

                IDecompilationResults typeDecompilationResults = new DecompilationResults(sourceFilePath, codeViewerResults, memberDeclarationToCodePostionMap,
                                                                                          memberTokenToDocumentationMap, memberTokenToAttributesMap, memberTokenToDecompiledCodeMap, membersWithExceptions);

                uint moduleToken = type.Module.MetadataToken.ToUInt32();
                if (!this.decompilationResults.ContainsKey(moduleToken))
                {
                    this.decompilationResults.Add(moduleToken, new Dictionary <uint, IDecompilationResults>());
                }

                Dictionary <uint, IDecompilationResults> moduleTypes = this.decompilationResults[moduleToken];
                moduleTypes.Add(type.MetadataToken.ToUInt32(), typeDecompilationResults);
            }
        }
 public virtual void WriteTypeDeclarationsOnly(TypeDefinition member, IWriterContextService writerContextService, bool writeDocumentation, bool showCompilerGeneratedMembers = false)
 {
     this.writerContextService = writerContextService;
     this.writerContext = writerContextService.GetWriterContext(member, Language);
     this.currentWritingInfo = new WritingInfo(member);
     WriteTypeDeclarationsOnlyInternal(member, writeDocumentation, showCompilerGeneratedMembers);
 }
        public void WriteAssemblyAttributes(AssemblyDefinition assembly, IWriterContextService writerContextService, bool writeUsings = false, ICollection <string> attributesToIgnore = null)
        {
            IntermediateLanguageAttributeWriter attributeWriter = new IntermediateLanguageAttributeWriter(this.Language, this.formatter, this.exceptionFormatter, this.WriteExceptionsAsComments, this.shouldGenerateBlocks);

            attributeWriter.WriteAssemblyAttributes(assembly, attributesToIgnore);
        }