Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Build callbacks do not fire for module registration #849

Closed
alexmg opened this issue May 2, 2017 · 0 comments
Closed

Build callbacks do not fire for module registration #849

alexmg opened this issue May 2, 2017 · 0 comments
Assignees
Labels

Comments

@alexmg
Copy link
Member

alexmg commented May 2, 2017

This issue is present in Autofac 4.5.

[Fact]
public void BuildCallbacksInvokedWhenRegisteredInModuleLoad()
{
	var module = new BuildCallbackModule();

	var builder = new ContainerBuilder();
	builder.RegisterModule(module);
	builder.Build();

	Assert.Equal(2, module.Called);
}

public class BuildCallbackModule : Module
{
	public int Called { get; private set; }

	protected override void Load(ContainerBuilder builder)
	{
		void BuildCallback(IContainer c)
		{
			Called++;
		}

		builder.RegisterBuildCallback(BuildCallback)
			.RegisterBuildCallback(BuildCallback);
	}
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant