C# 11 added support for required properties.
public class Example
{
public required string Value { get; set; }
}
How do I detect that the property is declared as required by reflection?
Please note this is a different question from Return a list of all required properties in a class because that question is from 2017 about a custom attribute, this is about required
property keyword which is new in C# 11 (2022).
PropertyInfo prop = typeof(Example).GetProperty("Value");
//bool isRequired = prop ...?