title: Can `typeof(T).IsAssignableFrom(x.GetType())` be safely rewritten as `x is T`?
body: <blockquote>
    <p><strong>Note: This is not a duplicate of <a href="https://stackoverflow.com/questions/3013694/use-of-isassignablefrom-and-is-keyword-in-c-sharp">"Use of IsAssignableFrom and “is” keyword in C#"</a>.</strong> That other question asks about <code>typeof(T).IsAssignableFrom(type))</code>, where <code>type</code> is not an <code>object</code> but a <code>Type</code>.</p>
    
    <p>This seems trivial &mdash; I can hear you saying, "Just call <code>x.GetType()</code>!" &mdash; but due to the COM-related corner case mentioned below, that call causes problems, which is why I'm asking about the rewrite.</p>
  </blockquote>
  
  <p>… or are there rare special cases where the two might give different results?</p>
  
  <p>I stumbled upon a type check of the form:</p>
  
  <pre><code>typeof(TValue).IsAssignableFrom(value.GetType())
  </code></pre>
  
  <p>where <code>TValue</code> is a generic type parameter (without any constraints) and <code>value</code> is an <code>object</code>.</p>
  
  <p>I am not entirely sure whether it is safe to rewrite the above simply as:</p>
  
  <pre><code>value is TValue
  </code></pre>
  
  <p>To my current knowledge, the two tests are equivalent with the exception of COM objects. <code>is</code> should trigger a proper <code>QueryInterface</code>, while <code>IsAssignableFrom</code> might get confused by the <code>__ComObject</code> RCW wrapper type and report a false negative.</p>
  
  <p>Are there any other differences between <code>is</code> and the shown use of <code>IsAssignableFrom</code>?</p>