Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 19 19:47
    seankain edited #185
  • Sep 19 19:42
    seankain opened #185
  • Sep 16 13:52
    jeremydmiller milestoned #184
  • Sep 16 13:52
    jeremydmiller milestoned #182
  • Sep 16 13:52
    jeremydmiller milestoned #181
  • Sep 16 13:52
    jeremydmiller milestoned #180
  • Sep 16 13:52
    jeremydmiller milestoned #165
  • Sep 16 13:52
    jeremydmiller milestoned #157
  • Sep 16 13:36

    jeremydmiller on master

    fixing test data (compare)

  • Sep 16 13:23

    jeremydmiller on master

    bumping versions, cleanup on do… (compare)

  • Sep 16 13:22

    jeremydmiller on gh-pages

    Documentation Update for 3.1.0 (compare)

  • Sep 16 13:21
    jeremydmiller closed #165
  • Sep 16 13:21
    jeremydmiller commented #165
  • Sep 16 02:27
    matthawley commented #173
  • Sep 16 02:21
    jeremydmiller closed #173
  • Sep 16 02:21
    jeremydmiller commented #173
  • Sep 16 00:28
    matthawley commented #173
  • Sep 16 00:25
    matthawley commented #173
  • Sep 16 00:17
    jeremydmiller commented #173
  • Sep 15 20:24
    jeremydmiller commented #178
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
Jeremy D. Miller
@jeremydmiller
New release, 3.1.0 up above ^^^
Mark Warpool
@CodingGorilla
:thumbsup:
Jeremy D. Miller
@jeremydmiller
And after this, I switch to Jasper later today. Finally.