protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

C# JsonFormatter does not output proto2 extension information

Open Jensaarai opened this issue 5 years ago • 6 comments

What version of protobuf and what language are you using? Version: v3.26.1 Language: C#

What operating system (Linux, Windows, ...) and version? N/A

What runtime / compiler are you using (e.g., python version or gcc version) N/A

What did you do? JsonFormatter does not output proto2 extension information.

      [Test]
      public void FormatExtensionFields()
      {
        var formatter = JsonFormatter.Default;

        var message = new TestProtos.Proto2.TestAllExtensions();
        message.SetExtension(TestProtos.Proto2.UnittestExtensions.OptionalBoolExtension, true);
        message.SetExtension(
          TestProtos.Proto2.UnittestExtensions.OptionalNestedMessageExtension,
          new TestProtos.Proto2.TestAllTypes.Types.NestedMessage
          {
            Bb = 123
          });

        AssertJson("{ 'optionalBoolExtension': true, 'nestedMessage': { 'bb': 123 } }", formatter.Format(message));
      }

Result:

 FormatExtensionFields
   Source: JsonFormatterTest.cs line 55
   Duration: 85 ms

  Message: 
      Expected string length 65 but was 3. Strings differ at index 2.
      Expected: "{ "optionalBoolExtension": true, "nestedMessage": { "bb": 123..."
      But was:  "{ }"
      -------------^
    
  Stack Trace: 
    JsonFormatterTest.AssertJson(String expectedJsonWithApostrophes, String actualJson) line 640
    JsonFormatterTest.FormatExtensionFields() line 68

Jensaarai avatar Feb 24 '20 19:02 Jensaarai

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Mar 27 '24 10:03 github-actions[bot]

Updated code as the package/namespace for the extensions changed. The behavior is the same, though, this still doesn't work.

Jensaarai avatar Mar 30 '24 00:03 Jensaarai

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Jun 29 '24 10:06 github-actions[bot]

As far as I'm aware this has not been fixed.

Jensaarai avatar Jul 01 '24 17:07 Jensaarai

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Oct 01 '24 10:10 github-actions[bot]

As far as I'm aware this has not been fixed.

Jensaarai avatar Oct 12 '24 01:10 Jensaarai

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Jan 10 '25 10:01 github-actions[bot]

As far as I'm aware this has not been fixed.

Jensaarai avatar Jan 19 '25 00:01 Jensaarai

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Apr 20 '25 10:04 github-actions[bot]