public DecompilationContext(MethodSpecificContext methodContext, TypeSpecificContext typeContext, ModuleSpecificContext moduleContext, AssemblySpecificContext assemblyContext) { this.MethodContext = methodContext; this.TypeContext = typeContext; this.ModuleContext = moduleContext; this.AssemblyContext = assemblyContext; }
public DecompilationContext(MethodSpecificContext methodContext, TypeSpecificContext typeContext, ModuleSpecificContext moduleContext, AssemblySpecificContext assemblyContext) { this.MethodContext = methodContext; this.TypeContext = typeContext; this.ModuleContext = moduleContext; this.AssemblyContext = assemblyContext; }
public override AssemblySpecificContext GetAssemblyContext(AssemblyDefinition assembly, ILanguage language) { if (this.cacheService.IsAssemblyContextInCache(assembly, language, this.renameInvalidMembers)) { return(this.cacheService.GetAssemblyContextFromCache(assembly, language, this.renameInvalidMembers)); } V_0 = new AssemblySpecificContext(this.GetAssemblyNamespaceUsings(assembly)); V_1 = TypeCollisionWriterContextService.assemblyContextsLocker; V_2 = false; try { Monitor.Enter(V_1, ref V_2); if (!this.cacheService.IsAssemblyContextInCache(assembly, language, this.renameInvalidMembers)) { this.cacheService.AddAssemblyContextToCache(assembly, language, this.renameInvalidMembers, V_0); } } finally { if (V_2) { Monitor.Exit(V_1); } } return(V_0); }
public override AssemblySpecificContext GetAssemblyContext(AssemblyDefinition assembly, ILanguage language) { if (this.cacheService.IsAssemblyContextInCache(assembly, language, this.renameInvalidMembers)) { return(this.cacheService.GetAssemblyContextFromCache(assembly, language, this.renameInvalidMembers)); } V_0 = new AssemblySpecificContext(this.GetAssemblyNamespaceUsings(assembly)); this.cacheService.AddAssemblyContextToCache(assembly, language, this.renameInvalidMembers, V_0); return(V_0); }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { string moduleKey = GetModuleKey(assembly.MainModule, language, renameInvalidMembers); if (assemblyContextsCache.ContainsKey(moduleKey)) { throw new Exception("Key already in AssemblyContextsCache"); } assemblyContextsCache.Add(moduleKey, assemblyContext); }
public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language) { TypeSpecificContext typeContext; DecompiledType decompiledType; if (member is TypeDefinition && member == Utilities.GetOuterMostDeclaringType(member)) { TypeDefinition type = member as TypeDefinition; Dictionary <string, DecompiledType> decompiledTypes = GetNestedDecompiledTypes(type, language); TypeSpecificContext cachedTypeContext = GetTypeContext(type, language, decompiledTypes); typeContext = new TypeSpecificContext( cachedTypeContext.CurrentType, cachedTypeContext.MethodDefinitionToNameMap, cachedTypeContext.BackingFieldToNameMap, cachedTypeContext.UsedNamespaces, new HashSet <string>(), cachedTypeContext.FieldAssignmentData, cachedTypeContext.AutoImplementedProperties, cachedTypeContext.AutoImplementedEvents, cachedTypeContext.ExplicitlyImplementedMembers, cachedTypeContext.ExceptionWhileDecompiling ); if (!decompiledTypes.TryGetValue(type.FullName, out decompiledType)) { throw new Exception("Decompiled type not found in decompiled types cache."); } } else { decompiledType = GetDecompiledType(member, language); typeContext = decompiledType.TypeContext; } Dictionary <string, MethodSpecificContext> methodContexts = new Dictionary <string, MethodSpecificContext>(); Dictionary <string, Statement> decompiledStatements = new Dictionary <string, Statement>(); foreach (KeyValuePair <string, DecompiledMember> decompiledPair in decompiledType.DecompiledMembers) { methodContexts.Add(decompiledPair.Key, decompiledPair.Value.Context); decompiledStatements.Add(decompiledPair.Key, decompiledPair.Value.Statement); } TypeDefinition declaringType = Utilities.GetDeclaringTypeOrSelf(member); AssemblySpecificContext assemblyContext = GetAssemblyContext(declaringType.Module.Assembly, language); ModuleSpecificContext moduleContext = GetModuleContext(declaringType.Module, language); WriterContext writerContext = new WriterContext(assemblyContext, moduleContext, typeContext, methodContexts, decompiledStatements); return(writerContext); }
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 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); }
private WriterContext GetWriterContextForType(TypeDefinition type, ILanguage language) { TypeDefinition outerMostDeclaringType = Utilities.GetOuterMostDeclaringType(type); Dictionary <string, DecompiledType> decompiledTypes; if (this.cacheService.AreNestedDecompiledTypesInCache(outerMostDeclaringType, language, this.renameInvalidMembers)) { decompiledTypes = this.cacheService.GetNestedDecompiledTypesFromCache(outerMostDeclaringType, language, this.renameInvalidMembers); } else { decompiledTypes = GetNestedDecompiledTypes(outerMostDeclaringType, language); this.cacheService.AddNestedDecompiledTypesToCache(outerMostDeclaringType, language, this.renameInvalidMembers, decompiledTypes); } TypeSpecificContext typeContext = GetTypeContext(outerMostDeclaringType, language, decompiledTypes); AddTypeContextsToCache(decompiledTypes, outerMostDeclaringType, language); Dictionary <string, MethodSpecificContext> methodContexts = new Dictionary <string, MethodSpecificContext>(); Dictionary <string, Statement> decompiledStatements = new Dictionary <string, Statement>(); DecompiledType decompiledType; if (!decompiledTypes.TryGetValue(type.FullName, out decompiledType)) { throw new Exception("Decompiled type missing from DecompiledTypes cache."); } else { // If members were taken from the cache, generated filter methods must be added to decompiled type. if (typeContext.GeneratedFilterMethods.Count > 0) { AddGeneratedFilterMethodsToDecompiledType(decompiledType, typeContext, language); } foreach (DecompiledMember decompiledMember in decompiledType.DecompiledMembers.Values) { methodContexts.Add(decompiledMember.MemberFullName, decompiledMember.Context); decompiledStatements.Add(decompiledMember.MemberFullName, decompiledMember.Statement); } } AssemblySpecificContext assemblyContext = GetAssemblyContext(outerMostDeclaringType.Module.Assembly, language); ModuleSpecificContext moduleContext = GetModuleContext(outerMostDeclaringType.Module, language); WriterContext writerContext = new WriterContext(assemblyContext, moduleContext, typeContext, methodContexts, decompiledStatements); return(writerContext); }
public override AssemblySpecificContext GetAssemblyContext(AssemblyDefinition assembly, ILanguage language) { if (this.cacheService.IsAssemblyContextInCache(assembly, language, this.renameInvalidMembers)) { return(this.cacheService.GetAssemblyContextFromCache(assembly, language, this.renameInvalidMembers)); } ICollection <string> assemblyNamespaceUsings = GetAssemblyNamespaceUsings(assembly); AssemblySpecificContext assemblyContext = new AssemblySpecificContext(assemblyNamespaceUsings); this.cacheService.AddAssemblyContextToCache(assembly, language, this.renameInvalidMembers, assemblyContext); return(assemblyContext); }
public override AssemblySpecificContext GetAssemblyContext(AssemblyDefinition assembly, ILanguage language) { if (this.cacheService.IsAssemblyContextInCache(assembly, language, this.renameInvalidMembers)) { return this.cacheService.GetAssemblyContextFromCache(assembly, language, this.renameInvalidMembers); } ICollection<string> assemblyNamespaceUsings = GetAssemblyNamespaceUsings(assembly); AssemblySpecificContext assemblyContext = new AssemblySpecificContext(assemblyNamespaceUsings); this.cacheService.AddAssemblyContextToCache(assembly, language, this.renameInvalidMembers, assemblyContext); return assemblyContext; }
public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language) { AssemblySpecificContext assemblyContext = new AssemblySpecificContext(); ModuleSpecificContext moduleContext = new ModuleSpecificContext(); TypeSpecificContext typeContext = new TypeSpecificContext(Utilities.GetDeclaringTypeOrSelf(member)); DecompiledType decompiledType = GetDecompiledType(member, language); Dictionary<string, MethodSpecificContext> methodContexts = new Dictionary<string, MethodSpecificContext>(); Dictionary<string, Statement> decompiledStatements = new Dictionary<string, Statement>(); foreach (KeyValuePair<string, DecompiledMember> decompiledPair in decompiledType.DecompiledMembers) { methodContexts.Add(decompiledPair.Key, decompiledPair.Value.Context); decompiledStatements.Add(decompiledPair.Key, decompiledPair.Value.Statement); } WriterContext writerContext = new WriterContext(assemblyContext, moduleContext, typeContext, methodContexts, decompiledStatements); return writerContext; }
public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language) { AssemblySpecificContext assemblyContext = new AssemblySpecificContext(); ModuleSpecificContext moduleContext = new ModuleSpecificContext(); TypeSpecificContext typeContext = new TypeSpecificContext(Utilities.GetDeclaringTypeOrSelf(member)); DecompiledType decompiledType = GetDecompiledType(member, language); Dictionary <string, MethodSpecificContext> methodContexts = new Dictionary <string, MethodSpecificContext>(); Dictionary <string, Statement> decompiledStatements = new Dictionary <string, Statement>(); foreach (KeyValuePair <string, DecompiledMember> decompiledPair in decompiledType.DecompiledMembers) { methodContexts.Add(decompiledPair.Key, decompiledPair.Value.Context); decompiledStatements.Add(decompiledPair.Key, decompiledPair.Value.Statement); } WriterContext writerContext = new WriterContext(assemblyContext, moduleContext, typeContext, methodContexts, decompiledStatements); return(writerContext); }
public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language) { V_0 = new AssemblySpecificContext(); V_1 = new ModuleSpecificContext(); V_2 = new TypeSpecificContext(Utilities.GetDeclaringTypeOrSelf(member)); stackVariable8 = this.GetDecompiledType(member, language); V_3 = new Dictionary <string, MethodSpecificContext>(); V_4 = new Dictionary <string, Statement>(); V_5 = stackVariable8.get_DecompiledMembers().GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); V_3.Add(V_6.get_Key(), V_6.get_Value().get_Context()); V_4.Add(V_6.get_Key(), V_6.get_Value().get_Statement()); } } finally { ((IDisposable)V_5).Dispose(); } return(new WriterContext(V_0, V_1, V_2, V_3, V_4)); }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { assemblyContextsCache.Add(GetModuleKey(assembly.MainModule, language, renameInvalidMembers), assemblyContext); }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { }
protected abstract void SetAssemblyContext(AssemblySpecificContext assemblyContext);
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { assemblyContextsCache.Add(GetModuleKey(assembly.MainModule, language, renameInvalidMembers), assemblyContext); }
protected override void SetAssemblyContext(AssemblySpecificContext assemblyContext) { writer.InternalAssemblyContext = assemblyContext; }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { DefaultDecompilationCacheService.assemblyContextsCache.Add(this.GetModuleKey(assembly.get_MainModule(), language, renameInvalidMembers), assemblyContext); return; }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { string moduleKey = GetModuleKey(assembly.MainModule, language, renameInvalidMembers); if (assemblyContextsCache.ContainsKey(moduleKey)) { throw new Exception("Key already in AssemblyContextsCache"); } assemblyContextsCache.Add(moduleKey, assemblyContext); }
protected override void SetAssemblyContext(AssemblySpecificContext assemblyContext) { this.writer.set_InternalAssemblyContext(assemblyContext); return; }
public void AddAssemblyContextToCache(AssemblyDefinition assembly, ILanguage language, bool renameInvalidMembers, AssemblySpecificContext assemblyContext) { V_0 = this.GetModuleKey(assembly.get_MainModule(), language, renameInvalidMembers); if (ProjectGenerationDecompilationCacheService.assemblyContextsCache.ContainsKey(V_0)) { throw new Exception("Key already in AssemblyContextsCache"); } ProjectGenerationDecompilationCacheService.assemblyContextsCache.Add(V_0, assemblyContext); return; }