-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Labels
EnhancementAreas for improvementAreas for improvement
Description
If a call to a base constructor in a child constructor contains a collection expression, ILSpy will incorrectly attempt to instantiate the collection in the constructor body then make an illegal call to the base constructor's underlying function:
Input Code:
public class TestClass
{
public readonly float Weight;
public readonly List<string> Things;
public TestClass(float weight, List<string> things)
{
Weight = weight;
Things = things;
}
}
public class ChildClass : TestClass
{
public ChildClass() : base(1.0f, ["foo", "bar", "baz"]){}
}
Erroneous Output:
public class TestClass
{
public readonly float Weight;
public readonly List<string> Things;
public TestClass(float weight, List<string> things)
{
Weight = weight;
Things = things;
}
}
public class ChildClass : TestClass
{
public ChildClass()
{
int num = 3;
List<string> obj = new List<string>(num);
CollectionsMarshal.SetCount<string>(obj, num);
global::System.Span<string> span = CollectionsMarshal.AsSpan<string>(obj);
int num2 = 0;
span[num2] = "foo";
num2++;
span[num2] = "bar";
span[num2 + 1] = "baz";
base._002Ector(1f, obj);
}
}
Details
- Product in use: ILSpyCmd
- Version in use: current main @ 61f82d0
Metadata
Metadata
Assignees
Labels
EnhancementAreas for improvementAreas for improvement