Beispiel #1
0
        static TypeCache CacheTypes(BaseModuleWeaver weaver,
                                    Func <string, AssemblyDefinition> resolver)
        {
            var typeCache = new TypeCache(resolver);

            typeCache.BuildAssembliesToScan(weaver);
            return(typeCache);
        }
Beispiel #2
0
    public void Execute()
    {
        ResolveEventHandler assemblyResolve = CurrentDomain_AssemblyResolve;

        try
        {
            SplitUpReferences();
            GetSymbolProviders();
            assemblyResolver = new AssemblyResolver(Logger, SplitReferences);
            ReadModule();
            if (ModuleDefinition.Types.Any(x => x.Name == "ProcessedByFody"))
            {
                Logger.LogWarning($"The assembly has already been processed by Fody. Weaving aborted. Path: {AssemblyFilePath} ");
                return;
            }
            AppDomain.CurrentDomain.AssemblyResolve += assemblyResolve;
            TypeCache = new TypeCache(assemblyResolver.Resolve);
            InitialiseWeavers();

            TypeCache.BuildAssembliesToScan(weaverInstances.Select(x => x.Instance));
            InitialiseTypeSystem();
            ExecuteWeavers();
            AddWeavingInfo();
            FindStrongNameKey();
            WriteModule();
            ModuleDefinition?.Dispose();
            CleanupTempSymbolsAndAssembly();
            ExecuteAfterWeavers();
            DisposeWeavers();
        }
        catch (Exception exception)
        {
            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
            Logger.LogException(exception);
        }
        finally
        {
            ModuleDefinition?.Dispose();
            CleanupTempSymbolsAndAssembly();
            assemblyResolver?.Dispose();
        }
    }
Beispiel #3
0
    public void Execute()
    {
        ResolveEventHandler assemblyResolve = CurrentDomain_AssemblyResolve;

        try
        {
            SplitUpReferences();
            GetSymbolProviders();
            assemblyResolver = new AssemblyResolver(Logger, SplitReferences);
            ReadModule();
            AppDomain.CurrentDomain.AssemblyResolve += assemblyResolve;
            TypeCache = new TypeCache(assemblyResolver.Resolve);
            InitialiseWeavers();

            TypeCache.BuildAssembliesToScan(weaverInstances.Select(x => x.Instance));
            InitialiseTypeSystem();
            ExecuteWeavers();
            AddWeavingInfo();
            FindStrongNameKey();
            WriteModule();
            ModuleDefinition?.Dispose();
            CleanupTempSymbolsAndAssembly();
            ExecuteAfterWeavers();
            DisposeWeavers();
        }
        catch (Exception exception)
        {
            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
            Logger.LogException(exception);
        }
        finally
        {
            ModuleDefinition?.Dispose();
            CleanupTempSymbolsAndAssembly();
            assemblyResolver?.Dispose();
        }
    }