I have the following interface:
public interface IEmailModel
{
    EmailAddressDto? Receiver { get; set; }
}
now I want to implement it for records. Try this:
public record EmailModelSendConfirmationToUserAndSuperadmin(EmailAddressDto? Receiver = null) : IEmailModel;
it's ok, no errors
try this:
public record EmailModelSendConfirmationEmailCodeToUser(string link, EmailAddressDto? Receiver = null) : IEmailModel;
here I get
'EmailModelSendConfirmationEmailCodeToUser' does not implement interface member 'IEmailModel.Receiver.set'. 'EmailModelSendConfirmationEmailCodeToUser.Receiver.init' cannot implement 'IEmailModel.Receiver.set'.
I really don't understand why should be implemented set if parameter can be nullable, but ok
I change my interface to:
public interface IEmailModel
{
    EmailAddressDto? Receiver { get; init; }
}
Class EmailModelSendConfirmationEmailCodeToUser no error, but class EmailModelSendConfirmationToUserAndSuperadmin has:
'EmailModelSendConfirmationToUserAndSuperadmin' does not implement interface member 'IEmailModel.Receiver.init'. 'EmailModelSendConfirmationToUserAndSuperadmin.Receiver.set' cannot implement 'IEmailModel.Receiver.init'.
why so and how to implement this interface for records?
                        
From Positional syntax for property definition section of the docs:
So either remove
setor change it toinit:Alternatively use "simple" property:
You can check that positional parameters for
recordtypes are turned by the compiler intoinitproperties in decomplication @sharplab, note that both classes work for me.