-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hot_reload] assorted hot reload fixes for cumulative property updates (
#85351) * [hot_reload] remove unneeded assertion `is_addition` is already defined as `token_index-1 >= delta_info->count[token_table].prev_gen_rows` so: 1. the assertion as written is wrong for cumulative updates that add new properties or events 2. the assertion would be trivially true if it was updated to use `delta_info->count[token_table].prev_gen_rows`. Fixes the ability to cumulatively add new properties * Update generation on MonoClassMetadataUpdateInfo when adding members Give recompute_ginst_update_info something to work with. * assert that generic instances don't call hot_reload_get_property token-based lookup should only happen for class defs or GTDs * update regression test
- Loading branch information
1 parent
0c17737
commit 0b30b3b
Showing
5 changed files
with
112 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...pdate/System.Reflection.Metadata.ApplyUpdate.Test.AddInstanceField/AddInstanceField_v2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
using System; | ||
|
||
|
||
namespace System.Reflection.Metadata.ApplyUpdate.Test | ||
{ | ||
public class AddInstanceField | ||
{ | ||
public AddInstanceField () { | ||
_doubleField2 = 5.5; | ||
_stringField2 = "New Initial Value"; | ||
NewStructField = new NewStruct { | ||
D = -1985.0, | ||
O = new int[2] { 15, 17 }, | ||
}; | ||
// a little bit ldflda testing | ||
IncRefDouble (ref NewStructField.D); | ||
IncRefDouble (ref _doubleField2); | ||
|
||
AddedStringAutoProp = "abcd"; | ||
|
||
AddedEvent += MyHandler; | ||
|
||
void MyHandler (object sender, double data) { | ||
} | ||
} | ||
|
||
public void IncRefDouble (ref double d) | ||
{ | ||
d += 1.0; | ||
} | ||
|
||
public string GetStringField => _stringField2; | ||
public double GetDoubleField => _doubleField2; | ||
|
||
private string _stringField; | ||
private string _stringField2; | ||
private double _doubleField; | ||
private double _doubleField2; | ||
|
||
private int[] _intArrayFieldWithInit = new[] { 2, 4, 6, 8, 10, 12 }; | ||
private int[] _intArrayFieldWithInit2 = new[] { 1, 3, 5, 7, 9, 11 }; | ||
|
||
public void TestMethod () { | ||
_stringField = "spqr"; | ||
_stringField2 = "4567"; | ||
_doubleField = 2.71828; | ||
_doubleField2 = 0.707106; | ||
AddedStringAutoProp = AddedStringAutoProp + "Test"; | ||
} | ||
|
||
public int GetIntArrayLength() => _intArrayFieldWithInit2?.Length ?? -1; | ||
public int GetIntArrayElt(int i) => _intArrayFieldWithInit2[i]; | ||
|
||
public struct NewStruct | ||
{ | ||
public double D; | ||
public object O; | ||
} | ||
|
||
public NewStruct NewStructField; | ||
|
||
public string GetStringProp => AddedStringAutoProp; | ||
|
||
public string AddedStringAutoProp { get; set; } | ||
|
||
public event EventHandler<double> ExistingEvent; | ||
public event EventHandler<double> AddedEvent; | ||
|
||
public double Accumulator; | ||
|
||
private void AccumHandler (object sender, double value) => Accumulator += value; | ||
|
||
public double FireEvents() { | ||
Accumulator = 0.0; | ||
ExistingEvent += AccumHandler; | ||
ExistingEvent(this, 123.0); | ||
ExistingEvent -= AccumHandler; | ||
|
||
AddedEvent += AccumHandler; | ||
AddedEvent(this, 123.0); | ||
AddedEvent -= AccumHandler; | ||
|
||
return Accumulator; | ||
} | ||
|
||
public double AddedFirstProp {get => 0.0; set { Console.WriteLine (value+value); } } | ||
public short AddedSecondProp {get; set; } | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.AddInstanceField/deltascript.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"changes": [ | ||
{"document": "AddInstanceField.cs", "update": "AddInstanceField_v1.cs"}, | ||
{"document": "AddInstanceField.cs", "update": "AddInstanceField_v2.cs"}, | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters