Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 13 20:05
    jeremydmiller closed #157
  • Sep 13 20:05

    jeremydmiller on master

    FINALLY, a fix for the List<T> … (compare)

  • Sep 13 20:03
    jeremydmiller commented #157
  • Sep 13 18:53
    jeremydmiller closed #181
  • Sep 13 18:53

    jeremydmiller on master

    HowDoIBuild() mechanics work. C… bumping to 3.1.0, rake addition… documentation for the new diagn… and 1 more (compare)

  • Sep 13 15:33
    jeremydmiller closed #172
  • Sep 13 15:33
    jeremydmiller commented #172
  • Sep 13 15:07
    jorhar commented #157
  • Sep 13 15:06
    jorhar commented #157
  • Sep 11 13:51
    CDargis commented #157
  • Sep 11 13:51
    jeremydmiller commented #157
  • Sep 11 13:47
    CDargis commented #157
  • Sep 11 01:08
    jeremydmiller commented #157
  • Sep 11 00:05
    jbogard commented #157
  • Sep 10 23:27
    jeremydmiller commented #157
  • Sep 10 22:50
    jeremydmiller commented #157
  • Sep 10 21:43
    CDargis commented #157
  • Sep 10 21:42
    CDargis commented #157
  • Sep 10 21:40
    CDargis commented #157
  • Sep 10 21:37
    CDargis commented #157
anaximander23
@anaximander23
if I'm resolving the DbContext out of the container, and it's registered using services.AddDbContextPool<MyDbContext>(options => { /* etc */} );
then is that all that's needed for it to respect the pooling?
or is that using still going to be disposing the instances and thereby negating the pooling?
Jeremy D. Miller
@jeremydmiller
I honestly don’t know
anaximander23
@anaximander23
fair enough
I'll try it and see what happens
just pushed some simple documentation for the inverse syntax
just wrestling with that last test now
named registrations
Jeremy D. Miller
@jeremydmiller
You aren’t expecting the Ninject style registration to honor the Forward type behavior are you? Where it’s the exact same object resolved for both service types?
anaximander23
@anaximander23
that's the rough plan, and it works so far
[Fact]
public void when_singleton_both_interfaces_give_same_instance()
{
    var container = new Container(services =>
    {
        services.Use<Implementation>()
            .Singleton()
            .For<IServiceA>()
            .For<IServiceB>();
    });

    var instanceA = container.GetInstance<IServiceA>();
    var instanceB = container.GetInstance<IServiceB>();

    Assert.Same(instanceA, instanceB);
}
that passes
Jeremy D. Miller
@jeremydmiller
Okay
You can use the Shouldly extensions in the Lamar tests if you wanna make that stuff be more readable
anaximander23
@anaximander23
because that's basically what I needed it for
one implementation, two interfaces, have to use the same instance
oh, cool
I'll swap that over
Jeremy D. Miller
@jeremydmiller
That behavior definitely needs to be documented. You can just slurp the test code right into the docs as a short cut for authoring content. That’s what I do most of the time;)
anaximander23
@anaximander23
done ;)
Jeremy D. Miller
@jeremydmiller
Cool, cool, thank you!
I think I’m coincidentally into Lamar code this week, so it works out well for a 3.1 release this week
anaximander23
@anaximander23
so yeah, the only place it isn't working now is with named registrations
[Fact]
public void when_named_instance_is_consistent_with_name()
{
    var container = new Container(services =>
    {
        services.Use<Implementation>()
            .Named("Group1")
            .For<IServiceA>()
            .For<IServiceB>();

        services.Use<Implementation>()
            .Named("Group2")
            .For<IServiceA>()
            .For<IServiceB>();
    });

    var instanceA1 = container.GetInstance<IServiceA>("Group1");
    var instanceB1 = container.GetInstance<IServiceB>("Group1");

    var instanceA2 = container.GetInstance<IServiceA>("Group2");
    var instanceB2 = container.GetInstance<IServiceB>("Group2");

    Assert.Same(instanceA1, instanceB1);
    Assert.Same(instanceA2, instanceB2);

    Assert.NotSame(instanceA1, instanceA2);
    Assert.NotSame(instanceB1, instanceB2);
}
that's my only failing test, and so far, I can't work out why
Jeremy D. Miller
@jeremydmiller
You’ve got to set the name independently on both new Instances that you register
anaximander23
@anaximander23
using instanceExpression.Use(c => (TService)c.GetInstance(typeof(TImpl), _name)); ?
Jeremy D. Miller
@jeremydmiller
And add .Named(_name) to that as well
anaximander23
@anaximander23
ah
let's try that
...looks good!
ok, I'll push that change and open a PR
let me know if there's anything else you need from me to merge it
Jeremy D. Miller
@jeremydmiller
Will do. It’ll be later today before I get a chance to review much though
anaximander23
@anaximander23
oh, wait, Shouldly syntax
I'll fix that
might not be right now, but if not, I'll push it this evening
Jeremy D. Miller
@jeremydmiller
No rush on my part
anaximander23
@anaximander23
done
managed to find a little time
zgrummons
@zgrummons
is it possible to run a scan to register types without a registry? like, i have a folder of algorithms i want to benchmark that all implement IAlgorithm. and I'd like to be able to just drop a new class file into the folder and have lamar pick it up without having to go in and register the type
Justin Haygood
@jhaygood86

@zgrummons I think a convention will do that https://jasperfx.github.io/lamar/documentation/ioc/registration/auto-registration-and-conventions/

There's custom conventions, though if they all implement IAlgorithm, a simple x.AddAllTypesOf<IAlgorithm>() in your Scan function should do the trick

zgrummons
@zgrummons

hm, do you have have to specify a namespace since they're in a folder? i tried this

_.Scan(x =>
{
    x.TheCallingAssembly();
    x.AddAllTypesOf<IAlgorithm>();
});

and asking lamar for an IEnumerable<IAlgorithm> returns with count 0

i feel like i'm missing something simple
Jeremy D. Miller
@jeremydmiller
@zgrummons Are you searching over the right assemblies? And check the type scanning assemblies too
Justin Haygood
@jhaygood86
And I think the classes have to be public as well. That one bites me a lot.
zgrummons
@zgrummons
you nailed it justin, set the classes to public and everything worked
thank you to both of y'all