From 606cb7ed2c55d5bda8aad2c88e5b0af09230fb3b Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Tue, 28 Feb 2017 10:51:19 -0800 Subject: There might be duplicated enum values when allow_alias is true. Add PreferredAlias into OriginalNameAttribute to remove the duplication (#2727) --- csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs') diff --git a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs index 302f8143..3b5bf773 100644 --- a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs @@ -66,6 +66,18 @@ namespace Google.Protobuf AssertJson("{ 'c': 0 }", formatter.Format(new ForeignMessage())); } + [Test] + public void EnumAllowAlias() + { + var message = new TestEnumAllowAlias + { + Value = TestEnumWithDupValue.Foo2, + }; + var actualText = JsonFormatter.Default.Format(message); + var expectedText = "{ 'value': 'FOO1' }"; + AssertJson(expectedText, actualText); + } + [Test] public void AllSingleFields() { -- cgit v1.2.3