diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index c95d2f1a1b9..7ab48dc56e2 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; @@ -72,12 +73,17 @@ namespace {{packageName}}.Model if (other == null) return false; - return {{#vars}} + return {{#vars}}{{#isNotContainer}} ( this.{{name}} == other.{{name}} || this.{{name}} != null && this.{{name}}.Equals(other.{{name}}) - ){{#hasMore}} && {{/hasMore}}{{/vars}}; + ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}} + ( + this.{{name}} == other.{{name}} || + this.{{name}} != null && + this.{{name}}.SequenceEqual(other.{{name}}) + ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}; } /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs index 6b39196b2b7..7d3f0936dce 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs index 8346e1cc6d8..1f786769d55 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs index 3c5264fe8c8..d85d8a8be7e 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; @@ -126,15 +127,15 @@ namespace IO.Swagger.Model this.Name != null && this.Name.Equals(other.Name) ) && -// ( -// this.PhotoUrls == other.PhotoUrls || -// this.PhotoUrls != null && -// this.PhotoUrls.Equals(other.PhotoUrls) -// ) && + ( + this.PhotoUrls == other.PhotoUrls || + this.PhotoUrls != null && + this.PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && ( this.Tags == other.Tags || this.Tags != null && - this.Tags.Equals(other.Tags) + this.Tags.SequenceEqual(other.Tags) ) && ( this.Status == other.Status || diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs index 6e8f84b89e9..8b2cbe08474 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs index aff43555136..d2c1e3a46eb 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index 31e5cba141b..05585bff932 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,8 +2,25 @@ - + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index 6fe0de92cac..0227a2d9113 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -1,5 +1,6 @@ using NUnit.Framework; using System; +using System.Linq; using System.IO; using System.Collections.Generic; using IO.Swagger.Api; @@ -166,7 +167,7 @@ namespace SwaggerClient.TestPet p1.Category = category1; p1.PhotoUrls = photoUrls1; - // create pet + // create pet 2 Pet p2 = new Pet(); p2.Id = petId; p2.Name = "Csharp test"; @@ -185,9 +186,25 @@ namespace SwaggerClient.TestPet p2.Category = category2; p2.PhotoUrls = photoUrls2; + // p1 and p2 should be equal (both object and attribute level) Assert.IsTrue (category1.Equals (category2)); - Assert.IsTrue (tag1.Equals (tag2)); - Assert.IsTrue (p1.Equals(p2)); + Assert.IsTrue (tags1.SequenceEqual (tags2)); + Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls)); + + Assert.IsTrue (p1.Equals (p2)); + + // update attribute to that p1 and p2 are not equal + category2.Name = "new category name"; + Assert.IsFalse(category1.Equals (category2)); + + tags2 = new List (); + Assert.IsFalse (tags1.SequenceEqual (tags2)); + + // photoUrls has not changed so it should be equal + Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls)); + + Assert.IsFalse (p1.Equals (p2)); + } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index 5e020c8b222..924934c4623 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb index 915a2952654..d0d7f1b3ccf 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index 5e020c8b222..924934c4623 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb index 915a2952654..d0d7f1b3ccf 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb differ