Task <CompilerMetadataReference[]> CreateCompilerMetadataReferencesAsync(AssemblyReferenceResolver assemblyReferenceResolver, IEnumerable <string> extraAssemblyReferences, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var modules = new HashSet <ModuleDef>(new MetadataReferenceFinder(sourceModule, cancellationToken).Find(extraAssemblyReferences)); var mdRefs = new List <CompilerMetadataReference>(); foreach (var module in modules) { cancellationToken.ThrowIfCancellationRequested(); CompilerMetadataReference?cmr; if (module.IsManifestModule) { cmr = assemblyReferenceResolver.Create(module.Assembly); } else { cmr = assemblyReferenceResolver.Create(module); } if (cmr == null) { continue; } mdRefs.Add(cmr.Value); } return(Task.FromResult(mdRefs.ToArray())); }
protected EditCodeVM(IRawModuleBytesProvider rawModuleBytesProvider, IOpenFromGAC openFromGAC, IOpenAssembly openAssembly, ILanguageCompiler languageCompiler, IDecompiler decompiler, ModuleDef sourceModule) { Debug.Assert(decompiler.CanDecompile(DecompilationType.TypeMethods)); this.openFromGAC = openFromGAC; this.openAssembly = openAssembly; this.languageCompiler = languageCompiler; this.decompiler = decompiler; this.sourceModule = sourceModule; this.assemblyReferenceResolver = new AssemblyReferenceResolver(rawModuleBytesProvider, sourceModule.Context.AssemblyResolver, sourceModule, makeEverythingPublic); }
public EditCodeVM(IImageManager imageManager, IOpenFromGAC openFromGAC, IOpenAssembly openAssembly, ILanguageCompiler languageCompiler, ILanguage language, MethodDef methodToEdit) { Debug.Assert(language.CanDecompile(DecompilationType.TypeMethods)); this.imageManager = imageManager; this.openFromGAC = openFromGAC; this.openAssembly = openAssembly; this.languageCompiler = languageCompiler; this.language = language; this.methodToEdit = methodToEdit; this.assemblyReferenceResolver = new AssemblyReferenceResolver(methodToEdit.Module.Context.AssemblyResolver, methodToEdit.Module, makeEverythingPublic); StartDecompileAsync(methodToEdit).ContinueWith(t => { var ex = t.Exception; Debug.Assert(ex == null); }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
public EditCodeVM(IOpenFromGAC openFromGAC, IOpenAssembly openAssembly, ILanguageCompiler languageCompiler, IDecompiler decompiler, MethodDef methodToEdit, IList <MethodSourceStatement> statementsInMethodToEdit) { Debug.Assert(decompiler.CanDecompile(DecompilationType.TypeMethods)); this.openFromGAC = openFromGAC; this.openAssembly = openAssembly; this.languageCompiler = languageCompiler; this.decompiler = decompiler; this.methodToEdit = methodToEdit; var methodSourceStatement = statementsInMethodToEdit.Count == 0 ? (MethodSourceStatement?)null : statementsInMethodToEdit[0]; this.assemblyReferenceResolver = new AssemblyReferenceResolver(methodToEdit.Module.Context.AssemblyResolver, methodToEdit.Module, makeEverythingPublic); StartDecompileAsync(methodToEdit, methodSourceStatement).ContinueWith(t => { var ex = t.Exception; Debug.Assert(ex == null); }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }