title: Issue understanding how validator is injected
body: <p>I've been looking at some code in our base regarding fluent validation and stumbled upon this endpoint declaration, which doesn't seem to complicated at first.</p>
  <pre><code>public async Task&lt;IActionResult&gt; SomeEndpoint(
       ClassA myInstance,
       [FromServices] MyValidator&lt;ClassA, ClassB, int&gt; validator)
  {
      await validator.ValidateAndThrowAsync(myInstance);
  }
  </code></pre>
  <p>This is the structure of the validator:</p>
  <pre><code>public class MyValidator&lt;T1, T2, T3&gt; : AbstractValidator&lt;T1&gt;
      where T1 : class, new()
      where T2 : class, new()
  {
     
      public MyValidator(
          T1 c1
          T2 c2)
      {
          RuleFor(_ =&gt; _).CustomAsync((relation, context, cancellationToken) =&gt; ValidateAsync(relation, context, cancellationToken));
      }
      
      protected virtual async Task ValidateAsync(T1, CustomContext context, CancellationToken cancellation)
      {
         // some validation
      }
  }
  </code></pre>
  <p>Now I thought, ok. Since this has was injected from the IoC Container, it has to be added somewhere. But I found nothing. The only thing I found regarding fluent validation was
  this:</p>
  <pre><code>private void BuildMvc(IMvcBuilder builder)
  {
      builder.AddFluentValidation();
  }
  </code></pre>
  <p>Now it seems like the validators are automatically inserted.</p>
  <p>We are using an old fluent validation package: &quot;FluentValidation.AspNetCore&quot; Version=&quot;7.6.104&quot;</p>
  <p>Now I wanted to write a test, which does exactly the same thing, but my validator is just not inserted into the Ioc-Container automatically and I'm not sure what I am missing.</p>
  <p>Here's the code:</p>
  <p>The validator:</p>
  <pre><code>    public class TestValidator&lt;T1, T2, T3&gt; : AbstractValidator&lt;T1&gt;
          where T1 : class, new()
          where T2 : class, new()
      {
          public TestValidator(
              T1 c1,
              T2 c2)
          {
          }
      }
  </code></pre>
  <p>The testcase:</p>
  <pre><code>[Fact]
  public async Task CanValidateAutomatically()
  {
      IWebHostBuilder builder = new WebHostBuilder()
                 .UseStartup&lt;MyStartup&gt;()
                 .UseEnvironment(&quot;Testing&quot;);
  
      using (TestServer server = new TestServer(builder))
      {
          using (HttpClient client = server.CreateClient())
          {
              HttpResponseMessage response = await client.PostAsync(
                  &quot;api/checkValidator&quot;,
                  new StringContent(&quot;test&quot;, Encoding.UTF8, &quot;application/vnd.api+json&quot;));
          }
      }
  } 
  </code></pre>
  <p>The testcontroller:</p>
  <pre><code>[Route(&quot;api&quot;)]
  public class ApiController : ControllerBase
  {
      [HttpPost(&quot;checkValidator&quot;)]
      public async Task&lt;IActionResult&gt; PostManyToManyRelationshipDedicatedUsersNew(
          [FromServices] TestValidator&lt;A, B, int&gt; validator)
      {
          await validator.ValidateAndThrowAsync(new A());
          return Ok();
      }
  }
  </code></pre>
  <p>The startupclass:</p>
  <pre><code>public class MyStartup
  {
      public void Configure(IServiceProvider serviceProvider,
              IApplicationBuilder app,
              IHostingEnvironment env,
              IApplicationLifetime applicationLifetime)
      {
          app.UseMvc();
      }
  
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddOptions();
          services.AddMvc().AddFluentValidation();
          services.AddScoped&lt;A&gt;();
          services.AddScoped&lt;B&gt;();
          // I was hoping this line wasn't needed
          services.AddScoped&lt;TestValidator&lt;A, B, int&gt;&gt;();
      }
  }
  </code></pre>
  <p>I don't get what I have to do to make fluent validation automatically register my generic testvalidator and I can't find any difference between the base code I was looking at and my testcase. Maybe someone has an idea to make the test work without manually adding the Validator to the serviceCollection.</p>