Ejemplo n.º 1
0
    public static void CleanReferences(ModuleDefinition module, BaseModuleWeaver weaver, Action <string> log)
    {
        if (!weaver.ShouldCleanReference)
        {
            return;
        }

        var weaverLibName = weaver.GetType().Assembly.GetName().Name.ReplaceCaseless(".Fody", "");

        log($"\tRemoving reference to '{weaverLibName}'.");

        var referenceToRemove = module.AssemblyReferences.FirstOrDefault(x => x.Name == weaverLibName);

        if (referenceToRemove != null)
        {
            module.AssemblyReferences.Remove(referenceToRemove);
        }

        var copyLocalFilesToRemove = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
        {
            weaverLibName + ".dll",
            weaverLibName + ".xml",
            weaverLibName + ".pdb",
            weaverLibName + ".mdb" // TODO: Remove this when mdb becomes redundant
        };

        weaver.ReferenceCopyLocalPaths.RemoveAll(refPath => copyLocalFilesToRemove.Contains(Path.GetFileName(refPath)));
    }
Ejemplo n.º 2
0
    public static void CleanReferences(ModuleDefinition module, BaseModuleWeaver weaver, Action <string> log)
    {
        if (!weaver.ShouldCleanReference)
        {
            return;
        }

        var weaverName        = weaver.GetType().Assembly.GetName().Name.ReplaceCaseless(".Fody", "");
        var referenceToRemove = module.AssemblyReferences
                                .FirstOrDefault(x => x.Name == weaverName);

        if (referenceToRemove == null)
        {
            return;
        }

        module.AssemblyReferences.Remove(referenceToRemove);
        log($"\tRemoving reference to '{weaverName}'.");
    }