title: C# 9 records: how to specify a generic type T that must be a record
body: <p>I am experimenting with the C# 9 RC, converting an existing application to use the new <code>record</code> construct and associated <code>with</code> keyword.</p>
  <p>A high proportion  of my defined record types implement this interface (modified to use the <code>init</code> keyword instead of <code>set</code>):</p>
  <pre><code>public interface IHasModifiedDate
  {
      DateTime ModifiedDate {get; init;}
  }
  </code></pre>
  <p>(Note: the specific classes that implement this interface don't - and can't - have a common superclass).</p>
  <p>I am trying to update a generic helper function that allows the modified date to be updated (where 'updated' <em>now</em> means: create a new instance with just that field change, using <code>with</code>) i.e.:</p>
  <pre><code>public static T UpdateModifiedDate&lt;T&gt;(T obj, DateTime whenTo) where T: IHasModifiedDate 
  {
      return obj with {ModifiedDate = whenTo};
  }
  </code></pre>
  <p>This gives the (reasonable) compile error: <em>The receiver type 'T' is not a valid record type</em>, and hence the <code>with</code> keyword cannot be used.</p>
  <p>I would like to be able to add the constraint on T specifying that T is in fact a <code>record</code> (in the same way that you can specify that T must be a class) e.g:</p>
  <pre><code>public static T UpdateModifiedDate&lt;T&gt;(T obj, DateTime whenTo) where T: record, IHasModifiedDate 
  {
      return obj with {ModifiedDate = when};
  }
  </code></pre>
  <p>but the <code>record</code> keyword is not recognised in this context.</p>
  <p>Is there any other way to specify that T is a record?</p>