Skip to content

Commit

Permalink
Proposed solution making sure the default assemblies are always ignor…
Browse files Browse the repository at this point in the history
…ed when the adats is hit before it is initialised from the bootstrapper.
  • Loading branch information
albertjan committed Jun 1, 2012
1 parent 61199ae commit 6e1ddd0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Expand Up @@ -70,19 +70,24 @@ public void Should_not_be_valid_if_any_types_null()
[Fact]
public void Should_set_ignored_assemblies_on_appdomainassemblytypescanner_when_creating_default_config()
{
//Given
AppDomainAssemblyTypeScanner.IgnoredAssemblies = null;

//When
var config = NancyInternalConfiguration.Default;

//Then
AppDomainAssemblyTypeScanner.Types.Where(t => config.IgnoredAssemblies.Any(f => f(t.Assembly))).Count().
ShouldEqual(0);
}

[Fact]
public void Should_update_ignored_assemblies_on_appdomianassemblystypescanner_when_adding_one_to_the_config()
{
//Given & When
var config = NancyInternalConfiguration.Default.WithIgnoredAssembly(f => f.FullName.StartsWith("Machine."));

//Then
AppDomainAssemblyTypeScanner.Types.Where (t => config.IgnoredAssemblies.Any (f => f (t.Assembly))).Count ().
ShouldEqual (0);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Nancy/Bootstrapper/AppDomainAssemblyTypeScanner.cs
Expand Up @@ -61,6 +61,10 @@ public static IEnumerable<Type> Types
{
get
{
if (!nancyAssembliesLoaded)
{
LoadNancyAssemblies();
}
return types;
}
}
Expand Down Expand Up @@ -141,6 +145,13 @@ private static void UpdateAssemblies()
/// </summary>
public static void LoadNancyAssemblies()
{
//If the ignoredassemblies is null at this point get the default ignored assemblies from the internal config.
//These will get updates when the user adjusts them.

This comment has been minimized.

Copy link
@albertjan

albertjan Jun 1, 2012

Owner

updated

if (IgnoredAssemblies == null)
{
IgnoredAssemblies = NancyInternalConfiguration.DefaultIgnoredAssemblies;
}

if (nancyAssembliesLoaded)
{
return;
Expand Down
4 changes: 1 addition & 3 deletions src/Nancy/Bootstrapper/NancyBootstrapperBase.cs
Expand Up @@ -53,8 +53,6 @@ public abstract class NancyBootstrapperBase<TContainer> : INancyBootstrapper, IN
/// </summary>
protected NancyBootstrapperBase()
{
AppDomainAssemblyTypeScanner.LoadNancyAssemblies();

this.ApplicationPipelines = new Pipelines();
this.conventions = new NancyConventions();
}
Expand Down Expand Up @@ -209,7 +207,7 @@ public void Initialise()
{
throw new InvalidOperationException("Configuration is invalid");
}

this.ApplicationContainer = this.GetApplicationContainer();

this.RegisterBootstrapperTypes(this.ApplicationContainer);
Expand Down

0 comments on commit 6e1ddd0

Please sign in to comment.