title: VS2019 Roslyn Compiler Generic Constraint Method Resolution
body: <p>We recently found an issue in our code base, where VS2019 Compiled code fine but VS 2017 Failed.</p>
  
  <p>I've created an extension method for Union which has a generic ISet as a Generic Constraint</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  public static class Extensions
  {
      public static S Union&lt;S, T&gt;(this S self, IEnumerable&lt;T&gt; other) where S : ISet&lt;T&gt;, new()
      {
          //For simplicity issues since this is a compilation based question
          return default(S);
      }
  
      public static void Test()
      {
          var values = new[] { 1, 2, 3 };
          var values1 = new[] { 1, 2, 3, 4 };
  
          values.Union(values1);
      }
  }
  </code></pre>
  
  <p>Union generates a compilation error stating that the int[] is not convertible to ISet.</p>
  
  <p>It was my understanding that method resolution originally ignored Generic constraints.  But it seems that this code Compiles in 2019.</p>
  
  <p>I haven't seen anywhere in the release notes which states that they've resolved this bug or added a new feature to improve method resolution for generic methods.</p>
  
  <p>I'm looking for more information about this matter,
  Was this a bug fix by microsoft or an intended feature? </p>