title: Why does Newtonsoft Replace function only replace the value if it is changed?
body: <p>Take the following code:</p>
  
  <pre><code>JProperty toke = new JProperty("value", new JValue(50)); //toke.Value is 50
  toke.Value.Replace(new JValue(20)); //toke.Value is 20
  </code></pre>
  
  <p>This works as expected. Now examine the following code:</p>
  
  <pre><code>JValue val0 = new JValue(50);
  JProperty toke = new JProperty("value", val0); //toke.Value is 50
  JValue val1 = new JValue(20);
  toke.Value.Replace(val1); //toke.Value is 20
  </code></pre>
  
  <p>This also works as expected, but there is an important detail. val0 is no longer part of the toke's JSON tree, and val1 <strong>is</strong> part of the JSON tree; this means that val0 has no valid parent, while val1 does.</p>
  
  <p>Now take this code.</p>
  
  <pre><code>JValue val0 = new JValue(50);
  JProperty toke = new JProperty("value", val0); //toke.Value is 50
  JValue val1 = new JValue(50);
  toke.Value.Replace(val1); //toke.Value is 50
  </code></pre>
  
  <p>The behavior is different; val0 <strong>is still</strong> part of toke's JSON tree, and val1 is not. Now val0 has a valid parent, while val1 does not.</p>
  
  <p>This is a critical distinction, and if you are using Newtonsoft JSON tree's to represent a structure, and storing JTokens as references into the tree, the way the references are structure can change based on the value being Replaced, which seems incorrect.</p>
  
  <p>Is there any flaw with my reasoning? Or is behavior incorrect, as I believe it is?</p>