I'm looking for a way to add comments on record properties, in C# 9
When I try this code :
public record Person
{
/// <summary>
/// Gets the first name.
/// </summary>
public string FirstName { get; init; }
/// <summary>
/// Gets the last name.
/// </summary>
public string LastName { get; init; }
}
I get this warning :
Non-nullable property 'FirstName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
When I try :
public record Person(string firstName, string lastName);
I get this warning:
Missing XML comment for publicly visible type or member 'Person.firstName'
This does not work either.
/// <summary>
/// Person.
/// </summary>
/// <param name="FirstName">Get the first name.</param>
/// <param name="LastName">Get the last name.</param>
public record Person(string FirstName, string LastName);
Gives warning:
XML comment has a param tag for 'FirstName', but there is no parameter by that name
param
on the type? learn.microsoft.com/en-us/dotnet/csharp/programming-guide/… – GiovannagiovanniF#
, i'd say this question might answer your question as the code for defining the type is similiar (please correct me if i'm wrong as i'd like to know the answer myself). – Cache