Skip to content

Commit

Permalink
Added opt out flag fixes #62
Browse files Browse the repository at this point in the history
  • Loading branch information
distantcam committed Apr 29, 2014
1 parent 6448522 commit a7e5b73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Fody/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Configuration
public Configuration(XElement config)
{
// Defaults
OptOut = true;
IncludeDebugSymbols = true;
DisableCompression = false;
CreateTemporaryAssemblies = false;
Expand All @@ -22,6 +23,11 @@ public Configuration(XElement config)
return;
}

if (config.Attribute("IncludeAssemblies") != null || config.Element("IncludeAssemblies") != null)
{
OptOut = false;
}

ReadBool(config, "IncludeDebugSymbols", b => IncludeDebugSymbols = b);
ReadBool(config, "DisableCompression", b => DisableCompression = b);
ReadBool(config, "CreateTemporaryAssemblies", b => CreateTemporaryAssemblies = b);
Expand All @@ -38,6 +44,7 @@ public Configuration(XElement config)
}
}

public bool OptOut { get; private set; }
public bool IncludeDebugSymbols { get; private set; }
public bool DisableCompression { get; private set; }
public bool CreateTemporaryAssemblies { get; private set; }
Expand Down
17 changes: 10 additions & 7 deletions Fody/ResourceEmbedder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class ModuleWeaver : IDisposable
readonly List<Stream> streams = new List<Stream>();
string cachePath;

void EmbedResources(Configuration config)
private void EmbedResources(Configuration config)
{
if (ReferenceCopyLocalPaths == null)
{
Expand Down Expand Up @@ -97,7 +97,7 @@ void EmbedResources(Configuration config)
}
}

IEnumerable<string> GetFilteredReferences(IEnumerable<string> onlyBinaries, Configuration config)
private IEnumerable<string> GetFilteredReferences(IEnumerable<string> onlyBinaries, Configuration config)
{
if (config.IncludeAssemblies.Any())
{
Expand Down Expand Up @@ -126,17 +126,20 @@ IEnumerable<string> GetFilteredReferences(IEnumerable<string> onlyBinaries, Conf
}
yield break;
}
foreach (var file in onlyBinaries)
if (config.OptOut)
{
if (config.Unmanaged32Assemblies.All(x => x != Path.GetFileNameWithoutExtension(file)) &&
config.Unmanaged64Assemblies.All(x => x != Path.GetFileNameWithoutExtension(file)))
foreach (var file in onlyBinaries)
{
yield return file;
if (config.Unmanaged32Assemblies.All(x => x != Path.GetFileNameWithoutExtension(file)) &&
config.Unmanaged64Assemblies.All(x => x != Path.GetFileNameWithoutExtension(file)))
{
yield return file;
}
}
}
}

string Embed(string prefix, string fullPath, bool compress)
private string Embed(string prefix, string fullPath, bool compress)
{
var resourceName = String.Format("{0}{1}", prefix, Path.GetFileName(fullPath).ToLowerInvariant());
if (ModuleDefinition.Resources.Any(x => x.Name == resourceName))
Expand Down

0 comments on commit a7e5b73

Please sign in to comment.