Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sorting by name from 'Record' class type #1055

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ public void When_name_contains_unallowed_characters_then_they_are_converted_to_v
{
Type = JsonObjectType.String
};

var generator = new CSharpGenerator(schema);

// Act
var output = generator.GenerateFile("MyClass");

Expand Down Expand Up @@ -1596,7 +1596,7 @@ public async Task When_record_no_setter_in_class_and_constructor_provided()
Assert.Contains(@"public string Street { get; }", output);
Assert.DoesNotContain(@"public string Street { get; set; }", output);

Assert.Contains("public Address(string @city, string @street)", output);
Assert.Contains("public Address(string @street, string @city)", output);

AssertCompile(output);
}
Expand Down Expand Up @@ -1665,11 +1665,11 @@ public async Task When_record_has_inheritance()

Assert.Contains("protected AbstractAddress(string @city, string @streetName)", output);

Assert.Contains("public PostAddress(string @city, int @houseNumber, string @streetName, string @zip)", output);
Assert.Contains("public PostAddress(string @zip, int @houseNumber, string @city, string @streetName)", output);
Assert.Contains(": base(city, streetName)", output);

Assert.Contains("public PersonAddress(string @addressee, string @city, int @houseNumber, string @streetName, string @zip)", output);
Assert.Contains(": base(city, houseNumber, streetName, zip)", output);
Assert.Contains("public PersonAddress(string @addressee, string @zip, int @houseNumber, string @city, string @streetName)", output);
Assert.Contains(": base(zip, houseNumber, city, streetName)", output);

AssertCompile(output);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{% assign skipComma = true -%}
{% assign skipComma = true -%}
{% if HasInheritance %}
{% assign parentProperties = BaseClass.AllProperties -%}
{% else %}
{% assign parentProperties = "" | empty -%}
{% endif %}

{% assign sortedProperties = AllProperties | sort: "Name" -%}
{% assign sortedParentProperties = parentProperties | sort: "Name" -%}

[Newtonsoft.Json.JsonConstructor]
{% if IsAbstract %}protected{% else %}public{% endif %} {{ClassName}}({% for property in sortedProperties -%}{% if skipComma -%}{% assign skipComma = false %}{% else %}, {% endif -%} {{ property.Type }} @{{ property.Name | lowercamelcase }}{% endfor -%})
{% if IsAbstract %}protected{% else %}public{% endif %} {{ClassName}}({% for property in AllProperties -%}{% if skipComma -%}{% assign skipComma = false %}{% else %}, {% endif -%} {{ property.Type }} @{{ property.Name | lowercamelcase }}{% endfor -%})
{% assign skipComma = true -%}
{% if HasInheritance -%}
: base({% for property in sortedParentProperties -%}{% if skipComma -%}{% assign skipComma = false %}{% else %}, {% endif -%}{{ property.Name | lowercamelcase }}{% endfor -%})
: base({% for property in parentProperties -%}{% if skipComma -%}{% assign skipComma = false %}{% else %}, {% endif -%}{{ property.Name | lowercamelcase }}{% endfor -%})
{% endif -%}
{
{% for property in Properties -%}
Expand Down