Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
[test] Calling the ctor of a class with a nested struct
This fails with

```
       Stack Trace:

          Child exception:
            System.BadImageFormatException: Could not resolve field token 0x04000014
          File name: 'System.Reflection.Metadata.ApplyUpdate.Test.ReflectionAddNewType'
          /Users/alklig/work/dotnet-runtime/runtime/src/libraries/System.Runtime.Loader/tests/ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.ReflectionAddNewType/ReflectionAddNewType.cs(29,0):
          at
          System.Reflection.Metadata.ApplyUpdate.Test.ReflectionAddNewType.ZExistingClass.ExistingMethod()

```
  • Loading branch information
lambdageek committed Oct 4, 2022
commit 6d2d4ee5150bb0bb263e4c1b37905d1848565843
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class PreviousNestedClass {
public event EventHandler<string> E;
public void R() { E(this,"123"); }
}

public static void ExistingMethod () {}
}

[AttributeUsage(AttributeTargets.All, AllowMultiple=true, Inherited=false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public class NewNestedClass {};
public static DateTime NewStaticField;

public static double NewProp { get; set; }

public static void ExistingMethod ()
{
// modified
NewStaticField2 = new AnotherAddedClass();
}

public static AnotherAddedClass NewStaticField2;
}

[AttributeUsage(AttributeTargets.All, AllowMultiple=true, Inherited=false)]
Expand Down Expand Up @@ -87,3 +95,22 @@ public interface INewInterface : IExistingInterface {
public enum NewEnum {
Red, Yellow, Green
}

public class AnotherAddedClass
{
public struct NewNestedStruct
{
public double D;
public object O;
}

public NewNestedStruct S;

public AnotherAddedClass()
{
S = new NewNestedStruct {
D = 1234.0,
O = "1234",
};
}
}
2 changes: 2 additions & 0 deletions src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ public static void TestReflectionAddNewType()
var i = (System.Reflection.Metadata.ApplyUpdate.Test.ReflectionAddNewType.IExistingInterface)o;

Assert.Equal("123", i.ItfMethod(123));

System.Reflection.Metadata.ApplyUpdate.Test.ReflectionAddNewType.ZExistingClass.ExistingMethod ();
});
}
}
Expand Down