We can't use positional records with XML comments because there is no way to provide comments for the properties. There is a Roslyn bug open for this at https://github.com/dotnet/roslyn/issues/44571. This would be the ideal solution.
We can create init properties instead and comment them as usual. This works.
/// <summary>A product.</summary>
public record Product
{
/// <summary>Gets or sets the unique identifier.</summary>
public int Id { get; init; }
}
Using the [SwaggerSchema] attribute in a positional record doesn't seem to work. Please can support for this be added?
public record Product([SwaggerSchema("The product identifier")] int Id);
@RehanSaeed You should be able to target the backing property by doing something like this:
public record Product([property: SwaggerSchema("The product identifier")] int Id);
The corresponding documentation for Positional Record Members can be found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/records#positional-record-members
Most helpful comment
@RehanSaeed You should be able to target the backing property by doing something like this:
The corresponding documentation for Positional Record Members can be found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/records#positional-record-members