Skip to content

GetResolver is only called on first resolve #2

@janschreier

Description

@janschreier

I hope I understood the meaning of this extension correctly. I would expect to get a different logger for every class that is resolved and needs an ILogger. Currently only the first resolve leads to a new ILogger-object which is passed to all other classes that also need an ILogger.

From my understanding the following test should result in two different loggerinstances but the test fails as they are the same (just paste it into the existing test class, I was unsure if I should have made this a pull-request since I could not provide a solution):

[TestMethod]
public void NLog_different()
{
	LoggedType2 instance2 = _container.Resolve<LoggedType2>();
	Assert.AreNotSame(instance2.Logger,
		_instance.Logger);
}

public class LoggedType2
{
	public LoggedType2(ILogger log)
	{
		Logger = log;
	}
	public ILogger Logger { get; }
}

I hope I made this issue clear enough as I am fairly new to Unity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions