This pull request updates the CSharpClientGeneratorFactory to use CSharpClassStyle.Record when the GenerateNativeRecords setting is true. This change adds proper support for generating contracts as immutable records
Here's an example of a generated immutable record using the changes in this pull request
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.8.0 (NJsonSchema v11.0.1.0 (Newtonsoft.Json v13.0.0.0))")]
public partial record Tag
{
[JsonConstructor]
public Tag(long @id, string @name)
{
this.Id = @id;
this.Name = @name;
}
[JsonPropertyName("id")]
public long Id { get; init; }
[JsonPropertyName("name")]
public string Name { get; init; }
private IDictionary<string, object> _additionalProperties;
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties
{
get { return _additionalProperties ?? (_additionalProperties = new Dictionary<string, object>()); }
set { _additionalProperties = value; }
}
}
This implements #407
This pull request updates the
CSharpClientGeneratorFactory
to useCSharpClassStyle.Record
when theGenerateNativeRecords
setting is true. This change adds proper support for generating contracts as immutable recordsHere's an example of a generated immutable record using the changes in this pull request
using the following .refitter settings file