123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
-
- using System;
- using System.Collections.Generic;
- using ICSharpCode.Decompiler;
- using Mono.Cecil;
- namespace ICSharpCode.ILSpy
- {
-
-
-
- public abstract class Language
- {
-
-
-
- public abstract string Name { get; }
-
-
-
- public abstract string FileExtension { get; }
- public virtual string ProjectFileExtension
- {
- get { return null; }
- }
- public virtual void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, TypeToString(method.DeclaringType, true) + "." + method.Name);
- }
- public virtual void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, TypeToString(property.DeclaringType, true) + "." + property.Name);
- }
- public virtual void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, TypeToString(field.DeclaringType, true) + "." + field.Name);
- }
- public virtual void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, TypeToString(ev.DeclaringType, true) + "." + ev.Name);
- }
- public virtual void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, TypeToString(type, true));
- }
- public virtual void DecompileNamespace(string nameSpace, IEnumerable<TypeDefinition> types, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, nameSpace);
- }
- public virtual void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
- {
- WriteCommentLine(output, assembly.FileName);
- if (assembly.AssemblyDefinition != null) {
- var name = assembly.AssemblyDefinition.Name;
- if (name.IsWindowsRuntime) {
- WriteCommentLine(output, name.Name + " [WinRT]");
- } else {
- WriteCommentLine(output, name.FullName);
- }
- } else {
- WriteCommentLine(output, assembly.ModuleDefinition.Name);
- }
- }
- public virtual void WriteCommentLine(ITextOutput output, string comment)
- {
- output.WriteLine("// " + comment);
- }
-
-
-
- public virtual string TypeToString(TypeReference type, bool includeNamespace, ICustomAttributeProvider typeAttributes = null)
- {
- if (includeNamespace)
- return type.FullName;
- else
- return type.Name;
- }
-
-
-
-
- public virtual string GetTooltip(MemberReference member)
- {
- if (member is TypeReference)
- return TypeToString((TypeReference)member, true);
- else
- return member.ToString();
- }
- public virtual string FormatPropertyName(PropertyDefinition property, bool? isIndexer = null)
- {
- if (property == null)
- throw new ArgumentNullException("property");
- return property.Name;
- }
-
- public virtual string FormatTypeName(TypeDefinition type)
- {
- if (type == null)
- throw new ArgumentNullException("type");
- return type.Name;
- }
-
-
-
- public override string ToString()
- {
- return Name;
- }
- public virtual bool ShowMember(MemberReference member)
- {
- return true;
- }
-
-
-
- public virtual MemberReference GetOriginalCodeLocation(MemberReference member)
- {
- return member;
- }
- }
- }
|