Skip to content

Is.Ordered.By() with a field throws NullReferenceException #2292

@rprouse

Description

@rprouse

The following code throws a NullReferenceException because Name is a field, not a property, This is unintuitive for users, so we should probably handle public fields. At the very least, we should give a better error message.

void Main()
{
	Skill[] skills = new[]
	{
		new Skill("aaaa"),
		new Skill("kkkk"),
		new Skill("zzzz")
	};

	var result = Is.Ordered.By("Name").ApplyTo(skills);
}

public class Skill
{
	public string Name;

	public Skill(string name)
	{
		Name = name;
	}
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions