Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ public void TestMethod () {
}

}
public class AddStaticField2
{
public static int Test()
{
return -1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@ public void TestMethod () {
}

}
public class AddStaticField2
{
private static int A {get; set;}
public static int Test()
{
A = 11;
return A + A;
}
}
}
3 changes: 3 additions & 0 deletions src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ public static void TestAddStaticField()

string result = x.GetField;
Assert.Equal("4567", result);

int aa = System.Reflection.Metadata.ApplyUpdate.Test.AddStaticField2.Test();
Assert.Equal(22, aa);
});
}

Expand Down
16 changes: 8 additions & 8 deletions src/mono/mono/metadata/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,11 @@ compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int
while ((field = mono_class_get_fields_internal (p, &iter))) {
MonoType *type;

/* metadata-update: added fields aren't stored in the object, don't
* contribute to the GC descriptor. */
if (m_field_is_from_update (field))
continue;

if (static_fields) {
if (!(field->type->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA)))
continue;
Expand All @@ -847,11 +852,6 @@ compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int
if (m_type_is_byref (field->type))
break;

/* metadadta-update: added fields aren't stored in the object, don't
* contribute to the GC descriptor. */
if (m_field_is_from_update (field))
continue;

int field_offset = m_field_get_offset (field);

if (static_fields && (field->offset == -1 || field->offset == -2))
Expand Down Expand Up @@ -2211,13 +2211,13 @@ mono_class_create_runtime_vtable (MonoClass *klass, MonoError *error)

iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
/* metadata-update: added fields are stored external to the object, and don't contribute to the bitmap */
if (m_field_is_from_update (field))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
if (mono_field_is_deleted (field))
continue;
/* metadata-update: added fields are stored external to the object, and don't contribute to the bitmap */
if (m_field_is_from_update (field))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_LITERAL)) {
gint32 special_static = m_class_has_no_special_static_fields (klass) ? SPECIAL_STATIC_NONE : field_is_special_static (klass, field);
if (special_static != SPECIAL_STATIC_NONE) {
Expand Down