[cleanup][fidl] Remove sync Dart FIDL bindings

Change-Id: I0591aadb7db8bf0fa42b347a93cf152db5d98ac6
diff --git a/bin/fidlgen_dart/backend/generator.go b/bin/fidlgen_dart/backend/generator.go
index ab14300..817a6d0 100644
--- a/bin/fidlgen_dart/backend/generator.go
+++ b/bin/fidlgen_dart/backend/generator.go
@@ -69,12 +69,7 @@
 	template.Must(tmpls.Parse(templates.Union))
 	template.Must(tmpls.Parse(templates.XUnion))
 
-	err := writeFile(config.OutputBase+"/fidl.dart", "GenerateLibraryFile", tmpls, tree, dartfmt)
-	if err != nil {
-		return err
-	}
-
-	err = writeFile(config.OutputBase+"/fidl_async.dart", "GenerateAsyncFile", tmpls, tree, dartfmt)
+	err := writeFile(config.OutputBase+"/fidl_async.dart", "GenerateAsyncFile", tmpls, tree, dartfmt)
 	if err != nil {
 		return err
 	}
diff --git a/bin/fidlgen_dart/backend/ir/ir.go b/bin/fidlgen_dart/backend/ir/ir.go
index 8c48cd8..61fe0cf 100644
--- a/bin/fidlgen_dart/backend/ir/ir.go
+++ b/bin/fidlgen_dart/backend/ir/ir.go
@@ -1235,7 +1235,6 @@
 		}
 		library := types.ParseLibraryName(l.Name)
 		root.Imports = append(root.Imports, Import{
-			URL:       fmt.Sprintf("package:fidl_%s/fidl.dart", formatLibraryName(library)),
 			LocalName: libraryPrefix(library),
 			AsyncURL:  fmt.Sprintf("package:fidl_%s/fidl_async.dart", formatLibraryName(library)),
 		})
diff --git a/bin/fidlgen_dart/backend/templates/library.tmpl.go b/bin/fidlgen_dart/backend/templates/library.tmpl.go
index 4433e6c..54e7b86 100644
--- a/bin/fidlgen_dart/backend/templates/library.tmpl.go
+++ b/bin/fidlgen_dart/backend/templates/library.tmpl.go
@@ -6,88 +6,6 @@
 
 // Library is the top-level template.
 const Library = `
-{{- define "GenerateLibraryFile" -}}
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// WARNING: This file is machine generated by fidlgen.
-
-library {{ .LibraryName }};
-
-import 'dart:async';
-import 'dart:developer';
-import 'dart:typed_data';
-
-import 'package:fidl/fidl.dart' as $fidl;
-import 'package:meta/meta.dart';
-import 'package:zircon/zircon.dart' as $zx;
-
-{{ range .Imports -}}
-import '{{ .URL }}' as {{ .LocalName }};
-{{ end -}}
-
-// These imports improve deduplication by making uses of {fidl.dart},
-// {fidl_async.dart} and {fidl.dart, fidl_async.dart} generate equivalent
-// packages. In AOT, the dead code will be removed by tree shaking.
-// ignore: unused_import
-import 'fidl_async.dart' as $strongly_connect_async;
-
-// ignore_for_file: always_specify_types
-// ignore_for_file: avoid_positional_boolean_parameters
-// ignore_for_file: avoid_returning_null
-// ignore_for_file: cascade_invocations
-// ignore_for_file: constant_identifier_names
-// ignore_for_file: one_member_abstracts
-// ignore_for_file: prefer_constructors_over_static_methods
-// ignore_for_file: prefer_single_quotes
-// ignore_for_file: public_member_api_docs
-// ignore_for_file: unused_import
-// ignore_for_file: unused_local_variable
-// ignore_for_file: non_constant_identifier_names
-// ignore_for_file: library_prefixes
-// ignore_for_file: prefer_typing_uninitialized_variables
-// ignore_for_file: avoid_js_rounded_ints
-// ignore_for_file: unnecessary_parenthesis
-// ignore_for_file: always_put_required_named_parameters_first
-// ignore_for_file: prefer_generic_function_type_aliases
-// ignore_for_file: prefer_equal_for_default_values
-
-{{ range $const := .Consts -}}
-{{ template "ConstDeclaration" $const }}
-{{ end -}}
-{{ range $enum := .Enums -}}
-{{ template "EnumDeclaration" $enum }}
-{{ end -}}
-{{ range $bits := .Bits -}}
-{{ template "BitsDeclaration" $bits }}
-{{ end -}}
-{{ range $union := .Unions -}}
-{{ template "UnionDeclaration" $union }}
-{{ end -}}
-{{ range $xunion := .XUnions -}}
-{{ template "XUnionDeclaration" $xunion }}
-{{ end -}}
-{{ range $struct := .Structs -}}
-{{ template "StructDeclaration" $struct }}
-{{ end -}}
-{{ range $table := .Tables -}}
-{{ template "TableDeclaration" $table }}
-{{ end -}}
-{{ range $interface := .Interfaces -}}
-{{ template "InterfaceDeclaration" $interface }}
-{{ end -}}
-{{- end -}}
-
-{{- define "ExportNames" -}}
-{{ if . }}
-export 'fidl.dart' show {{ range $index, $item := . }}
-{{- if $index }}, {{ end -}}
-{{ .Name -}}
-{{ end -}};
-{{ end -}}
-{{- end -}}
-
 {{- define "GenerateAsyncFile" -}}
 // Copyright 2018 The Fuchsia Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
diff --git a/bin/fidlgen_dart/goldens/bits.test.test.fidl.json b/bin/fidlgen_dart/goldens/bits.test.test.fidl.json
index b7c1ab7..6b7c7ee 100644
--- a/bin/fidlgen_dart/goldens/bits.test.test.fidl.json
+++ b/bin/fidlgen_dart/goldens/bits.test.test.fidl.json
@@ -9,6 +9,7 @@
         "kind": "primitive",
         "subtype": "uint32"
       },
+      "mask": "3",
       "members": [
         {
           "name": "MY_FIRST_BIT",
@@ -16,7 +17,8 @@
             "kind": "literal",
             "literal": {
               "kind": "numeric",
-              "value": "1"
+              "value": "1",
+              "expression": "1"
             }
           }
         },
@@ -26,7 +28,8 @@
             "kind": "literal",
             "literal": {
               "kind": "numeric",
-              "value": "2"
+              "value": "2",
+              "expression": "2"
             }
           }
         }
diff --git a/bin/fidlgen_dart/goldens/bits.test.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/bits.test.test.fidl.json_async.dart.golden
index 613eabd..11adb43 100644
--- a/bin/fidlgen_dart/goldens/bits.test.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/bits.test.test.fidl.json_async.dart.golden
@@ -46,8 +46,9 @@
 // ignore_for_file: comment_references
 
 class MyBits extends $fidl.Bits {
-  static const MyBits myFirstBit = MyBits._(1);
-  static const MyBits myOtherBit = MyBits._(2);
+  static const MyBits myFirstBit = MyBits._(0x1);
+  static const MyBits myOtherBit = MyBits._(0x2);
+  static const MyBits $none = MyBits._(0);
 
   const MyBits._(this.$value);
 
@@ -55,6 +56,10 @@
     return MyBits._($value | other.$value);
   }
 
+  MyBits operator &(MyBits other) {
+    return MyBits._($value & other.$value);
+  }
+
   @override
   final int $value;
 
@@ -64,10 +69,10 @@
       return null;
     }
     List<String> parts = [];
-    if ($value & 1 != 0) {
+    if ($value & 0x1 != 0) {
       parts.add(r'MyBits.myFirstBit');
     }
-    if ($value & 2 != 0) {
+    if ($value & 0x2 != 0) {
       parts.add(r'MyBits.myOtherBit');
     }
     if (parts.isEmpty) {
diff --git a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json
index d70bbae..bbca9a1 100644
--- a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json
+++ b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json
@@ -25,7 +25,8 @@
         "kind": "literal",
         "literal": {
           "kind": "numeric",
-          "value": "4"
+          "value": "4",
+          "expression": "4"
         }
       }
     }
@@ -66,6 +67,27 @@
           "maybe_request_size": 16,
           "maybe_request_alignment": 8,
           "has_response": false
+        },
+        {
+          "ordinal": 325918733,
+          "generated_ordinal": 325918733,
+          "name": "OnEvent",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/doc_comments.test.fidl",
+            "line": 53,
+            "column": 8
+          },
+          "has_request": false,
+          "maybe_attributes": [
+            {
+              "name": "Doc",
+              "value": " event comment #1\n\n event comment #3\n"
+            }
+          ],
+          "has_response": true,
+          "maybe_response": [],
+          "maybe_response_size": 16,
+          "maybe_response_alignment": 8
         }
       ]
     }
@@ -208,10 +230,10 @@
   ],
   "xunion_declarations": [],
   "declaration_order": [
-    "test.name/Interface",
-    "test.name/Struct",
     "test.name/Union",
     "test.name/Table",
+    "test.name/Struct",
+    "test.name/Interface",
     "test.name/C"
   ],
   "declarations": {
diff --git a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden
index da55111..02e9624 100644
--- a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden
@@ -48,7 +48,7 @@
 /// const comment #1
 ///
 /// const comment #3
-const int c = 4;
+const int c = 0x4;
 
 enum UnionTag {
   field,
@@ -206,6 +206,13 @@
   response: null,
   name: r"Interface.Method",
 );
+// onEvent:  -> ()
+const int _kInterface_OnEvent_Ordinal = 325918733;
+const $fidl.MethodType _kInterface_OnEvent_Type = $fidl.MethodType(
+  request: null,
+  response: null,
+  name: r"Interface.OnEvent",
+);
 
 /// interface comment #1
 ///
@@ -219,6 +226,11 @@
   ///
   /// method comment #3
   $async.Future<void> method();
+
+  /// event comment #1
+  ///
+  /// event comment #3
+  $async.Stream<void> get onEvent;
 }
 
 class InterfaceData implements $fidl.ServiceData<Interface> {
@@ -243,6 +255,9 @@
       : super($fidl.AsyncProxyController<Interface>(
             $serviceName: null, $interfaceName: r'Interface')) {
     ctrl.onResponse = _handleResponse;
+    ctrl.whenClosed.then((_) {
+      _onEventEventStreamController.close();
+    }, onError: (_) {});
   }
 
   @override
@@ -251,6 +266,24 @@
   void _handleEvent($fidl.Message $message) {
     final $fidl.Decoder $decoder = $fidl.Decoder($message);
     switch ($message.ordinal) {
+      case _kInterface_OnEvent_Ordinal:
+        final String _name = _kInterface_OnEvent_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kInterface_OnEvent_Type.response;
+          $decoder.claimMemory(16);
+          _onEventEventStreamController.add(null);
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError(
+              $fidl.FidlError('Exception handling event $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         ctrl.proxyError(
             $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
@@ -297,10 +330,42 @@
       ctrl.sendMessage($encoder.message);
     });
   }
+
+  final _onEventEventStreamController =
+      $async.StreamController<void>.broadcast();
+
+  /// event comment #1
+  ///
+  /// event comment #3
+  @override
+  $async.Stream<void> get onEvent => _onEventEventStreamController.stream;
 }
 
 class InterfaceBinding extends $fidl.AsyncBinding<Interface> {
-  InterfaceBinding() : super(r"Interface");
+  InterfaceBinding() : super(r"Interface") {
+    final List<$async.StreamSubscription<dynamic>> $subscriptions = [];
+    void $unsubscribe() {
+      for (final $sub in $subscriptions) {
+        $sub.cancel();
+      }
+      $subscriptions.clear();
+    }
+
+    whenBound.then((_) {
+      if (impl.onEvent != null) {
+        $subscriptions.add(impl.onEvent.listen(($response) {
+          final $fidl.Encoder $encoder = $fidl.Encoder();
+          $encoder.encodeMessageHeader(_kInterface_OnEvent_Ordinal, 0);
+          $encoder.alloc(16 - $fidl.kMessageHeaderSize);
+          final List<$fidl.MemberType> $types =
+              _kInterface_OnEvent_Type.response;
+
+          sendMessage($encoder.message);
+        }));
+      }
+    });
+    whenClosed.then((_) => $unsubscribe());
+  }
 
   @override
   void handleMessage($fidl.Message $message, $fidl.MessageSink $respond) {
diff --git a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_test.dart.golden b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_test.dart.golden
index 1b3dfaf..864e51d 100644
--- a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_test.dart.golden
+++ b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_test.dart.golden
@@ -29,4 +29,9 @@
   $async.Future<void> method() {
     return $async.Future.error(UnimplementedError());
   }
+
+  @override
+  $async.Stream<void> get onEvent {
+    return $async.Stream.fromFuture($async.Future.error(UnimplementedError()));
+  }
 }
diff --git a/bin/fidlgen_dart/goldens/empty_struct.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/empty_struct.test.fidl.json_async.dart.golden
index 5d171be..2c58e3a 100644
--- a/bin/fidlgen_dart/goldens/empty_struct.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/empty_struct.test.fidl.json_async.dart.golden
@@ -47,7 +47,7 @@
 
 class Empty extends $fidl.Struct {
   const Empty({
-    this.reserved: 0,
+    this.reserved: 0x0,
   });
   Empty.clone(
     Empty $orig, {
diff --git a/bin/fidlgen_dart/goldens/goldens.txt b/bin/fidlgen_dart/goldens/goldens.txt
index 1c9bc86..30cb686 100644
--- a/bin/fidlgen_dart/goldens/goldens.txt
+++ b/bin/fidlgen_dart/goldens/goldens.txt
@@ -14,6 +14,10 @@
 ordinal_switch.test.fidl.json_async.dart.golden
 ordinal_switch.test.fidl.json_sync.dart.golden
 ordinal_switch.test.fidl.json_test.dart.golden
+protocol_request.test.fidl.json
+protocol_request.test.fidl.json_async.dart.golden
+protocol_request.test.fidl.json_sync.dart.golden
+protocol_request.test.fidl.json_test.dart.golden
 protocols.test.fidl.json
 protocols.test.fidl.json_async.dart.golden
 protocols.test.fidl.json_sync.dart.golden
diff --git a/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json
new file mode 100644
index 0000000..e03f742
--- /dev/null
+++ b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json
@@ -0,0 +1,183 @@
+{
+  "version": "0.0.1",
+  "name": "test.name",
+  "library_dependencies": [],
+  "bits_declarations": [],
+  "const_declarations": [],
+  "enum_declarations": [],
+  "interface_declarations": [
+    {
+      "name": "test.name/Child",
+      "location": {
+        "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+        "line": 3,
+        "column": 10
+      },
+      "methods": []
+    },
+    {
+      "name": "test.name/Parent",
+      "location": {
+        "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+        "line": 6,
+        "column": 10
+      },
+      "methods": [
+        {
+          "ordinal": 915586153,
+          "generated_ordinal": 915586153,
+          "name": "GetChild",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+            "line": 7,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [],
+          "maybe_request_size": 16,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "identifier",
+                "identifier": "test.name/Child",
+                "nullable": false
+              },
+              "name": "c",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+                "line": 7,
+                "column": 26
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
+        },
+        {
+          "ordinal": 1068158078,
+          "generated_ordinal": 1068158078,
+          "name": "GetChildRequest",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+            "line": 8,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [],
+          "maybe_request_size": 16,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "request",
+                "subtype": "test.name/Child",
+                "nullable": false
+              },
+              "name": "r",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+                "line": 8,
+                "column": 42
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
+        },
+        {
+          "ordinal": 1275478777,
+          "generated_ordinal": 1275478777,
+          "name": "TakeChild",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+            "line": 9,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "identifier",
+                "identifier": "test.name/Child",
+                "nullable": false
+              },
+              "name": "c",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+                "line": 9,
+                "column": 21
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_request_size": 24,
+          "maybe_request_alignment": 8,
+          "has_response": false
+        },
+        {
+          "ordinal": 1589872250,
+          "generated_ordinal": 1589872250,
+          "name": "TakeChildRequest",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+            "line": 10,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "request",
+                "subtype": "test.name/Child",
+                "nullable": false
+              },
+              "name": "r",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocol_request.test.fidl",
+                "line": 10,
+                "column": 37
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_request_size": 24,
+          "maybe_request_alignment": 8,
+          "has_response": false
+        }
+      ]
+    }
+  ],
+  "struct_declarations": [],
+  "table_declarations": [],
+  "union_declarations": [],
+  "xunion_declarations": [],
+  "declaration_order": [
+    "test.name/Parent",
+    "test.name/Child"
+  ],
+  "declarations": {
+    "test.name/Child": "interface",
+    "test.name/Parent": "interface"
+  }
+}
diff --git a/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden
new file mode 100644
index 0000000..8f8f8fc
--- /dev/null
+++ b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden
@@ -0,0 +1,454 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// WARNING: This file is machine generated by fidlgen.
+
+library fidl_test_name_async;
+
+import 'dart:async' as $async;
+import 'dart:core' hide Set;
+import 'dart:developer';
+import 'dart:typed_data';
+
+import 'package:fidl/fidl.dart' as $fidl;
+import 'package:meta/meta.dart';
+import 'package:zircon/zircon.dart' as $zx;
+
+// These imports improve deduplication by making uses of {fidl.dart},
+// {fidl_async.dart} and {fidl.dart, fidl_async.dart} generate equivalent
+// packages. In AOT, the dead code will be removed by tree shaking.
+// ignore: unused_import
+import 'fidl.dart' as $strongly_connect_sync;
+
+// ignore_for_file: always_specify_types
+// ignore_for_file: avoid_positional_boolean_parameters
+// ignore_for_file: avoid_returning_null
+// ignore_for_file: cascade_invocations
+// ignore_for_file: constant_identifier_names
+// ignore_for_file: one_member_abstracts
+// ignore_for_file: prefer_constructors_over_static_methods
+// ignore_for_file: prefer_single_quotes
+// ignore_for_file: public_member_api_docs
+// ignore_for_file: unused_import
+// ignore_for_file: unused_local_variable
+// ignore_for_file: non_constant_identifier_names
+// ignore_for_file: library_prefixes
+// ignore_for_file: prefer_typing_uninitialized_variables
+// ignore_for_file: avoid_js_rounded_ints
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: always_put_required_named_parameters_first
+// ignore_for_file: prefer_generic_function_type_aliases
+// ignore_for_file: prefer_equal_for_default_values
+// ignore_for_file: avoid_catches_without_on_clauses
+// ignore_for_file: unused_shown_name
+// ignore_for_file: unnecessary_lambdas
+// ignore_for_file: comment_references
+
+// ignore: unused_element, avoid_private_typedef_functions
+typedef _VoidCallback = void Function();
+
+abstract class Child extends $fidl.Service {
+  static const String $serviceName = null;
+  @override
+  $fidl.ServiceData get $serviceData => ChildData();
+}
+
+class ChildData implements $fidl.ServiceData<Child> {
+  const ChildData();
+
+  @override
+  String getName() {
+    return Child.$serviceName;
+  }
+
+  @override
+  $fidl.AsyncBinding getBinding() {
+    return ChildBinding();
+  }
+}
+
+class ChildProxy extends $fidl.AsyncProxy<Child> implements Child {
+  ChildProxy()
+      : super($fidl.AsyncProxyController<Child>(
+            $serviceName: null, $interfaceName: r'Child')) {
+    ctrl.onResponse = _handleResponse;
+  }
+
+  @override
+  $fidl.ServiceData get $serviceData => ChildData();
+
+  void _handleEvent($fidl.Message $message) {
+    final $fidl.Decoder $decoder = $fidl.Decoder($message);
+    switch ($message.ordinal) {
+      default:
+        ctrl.proxyError(
+            $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
+        ctrl.close();
+        break;
+    }
+  }
+
+  void _handleResponse($fidl.Message $message) {
+    final int $txid = $message.txid;
+    if ($txid == 0) {
+      _handleEvent($message);
+      return;
+    }
+    final $async.Completer $completer = ctrl.getCompleter($txid);
+    if ($completer == null) {
+      $message.closeHandles();
+      return;
+    }
+    final $fidl.Decoder $decoder = $fidl.Decoder($message);
+    switch ($message.ordinal) {
+      default:
+        ctrl.proxyError(
+            $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
+        ctrl.close();
+        break;
+    }
+  }
+}
+
+class ChildBinding extends $fidl.AsyncBinding<Child> {
+  ChildBinding() : super(r"Child");
+
+  @override
+  void handleMessage($fidl.Message $message, $fidl.MessageSink $respond) {
+    final $fidl.Decoder $decoder = $fidl.Decoder($message);
+    switch ($message.ordinal) {
+      default:
+        throw $fidl.FidlError(r'Unexpected message name for ChildBinding');
+    }
+  }
+}
+
+// getChild: () -> ($fidl.InterfaceHandle<Child> c)
+const int _kParent_GetChild_Ordinal = 915586153;
+const $fidl.MethodType _kParent_GetChild_Type = $fidl.MethodType(
+  request: null,
+  response: <$fidl.MemberType>[
+    $fidl.MemberType<$fidl.InterfaceHandle<Child>>(
+        type: $fidl.InterfaceHandleType<Child>(nullable: false), offset: 16),
+  ],
+  name: r"Parent.GetChild",
+);
+// getChildRequest: () -> ($fidl.InterfaceRequest<Child> r)
+const int _kParent_GetChildRequest_Ordinal = 1068158078;
+const $fidl.MethodType _kParent_GetChildRequest_Type = $fidl.MethodType(
+  request: null,
+  response: <$fidl.MemberType>[
+    $fidl.MemberType<$fidl.InterfaceRequest<Child>>(
+        type: $fidl.InterfaceRequestType<Child>(nullable: false), offset: 16),
+  ],
+  name: r"Parent.GetChildRequest",
+);
+// takeChild: ($fidl.InterfaceHandle<Child> c)
+const int _kParent_TakeChild_Ordinal = 1275478777;
+const $fidl.MethodType _kParent_TakeChild_Type = $fidl.MethodType(
+  request: <$fidl.MemberType>[
+    $fidl.MemberType<$fidl.InterfaceHandle<Child>>(
+        type: $fidl.InterfaceHandleType<Child>(nullable: false), offset: 16),
+  ],
+  response: null,
+  name: r"Parent.TakeChild",
+);
+// takeChildRequest: ($fidl.InterfaceRequest<Child> r)
+const int _kParent_TakeChildRequest_Ordinal = 1589872250;
+const $fidl.MethodType _kParent_TakeChildRequest_Type = $fidl.MethodType(
+  request: <$fidl.MemberType>[
+    $fidl.MemberType<$fidl.InterfaceRequest<Child>>(
+        type: $fidl.InterfaceRequestType<Child>(nullable: false), offset: 16),
+  ],
+  response: null,
+  name: r"Parent.TakeChildRequest",
+);
+
+abstract class Parent extends $fidl.Service {
+  static const String $serviceName = null;
+  @override
+  $fidl.ServiceData get $serviceData => ParentData();
+  $async.Future<$fidl.InterfaceHandle<Child>> getChild();
+  $async.Future<$fidl.InterfaceRequest<Child>> getChildRequest();
+  $async.Future<void> takeChild($fidl.InterfaceHandle<Child> c);
+  $async.Future<void> takeChildRequest($fidl.InterfaceRequest<Child> r);
+}
+
+class ParentData implements $fidl.ServiceData<Parent> {
+  const ParentData();
+
+  @override
+  String getName() {
+    return Parent.$serviceName;
+  }
+
+  @override
+  $fidl.AsyncBinding getBinding() {
+    return ParentBinding();
+  }
+}
+
+class ParentProxy extends $fidl.AsyncProxy<Parent> implements Parent {
+  ParentProxy()
+      : super($fidl.AsyncProxyController<Parent>(
+            $serviceName: null, $interfaceName: r'Parent')) {
+    ctrl.onResponse = _handleResponse;
+  }
+
+  @override
+  $fidl.ServiceData get $serviceData => ParentData();
+
+  void _handleEvent($fidl.Message $message) {
+    final $fidl.Decoder $decoder = $fidl.Decoder($message);
+    switch ($message.ordinal) {
+      default:
+        ctrl.proxyError(
+            $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
+        ctrl.close();
+        break;
+    }
+  }
+
+  void _handleResponse($fidl.Message $message) {
+    final int $txid = $message.txid;
+    if ($txid == 0) {
+      _handleEvent($message);
+      return;
+    }
+    final $async.Completer $completer = ctrl.getCompleter($txid);
+    if ($completer == null) {
+      $message.closeHandles();
+      return;
+    }
+    final $fidl.Decoder $decoder = $fidl.Decoder($message);
+    switch ($message.ordinal) {
+      case _kParent_GetChild_Ordinal:
+        final String _name = _kParent_GetChild_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types = _kParent_GetChild_Type.response;
+          $decoder.claimMemory(24);
+          // ignore: prefer_const_declarations
+          final $response = $types[0].decode($decoder, 0);
+
+          $completer.complete($response);
+
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError($fidl.FidlError(
+              'Exception handling method response $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
+      case _kParent_GetChildRequest_Ordinal:
+        final String _name = _kParent_GetChildRequest_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kParent_GetChildRequest_Type.response;
+          $decoder.claimMemory(24);
+          // ignore: prefer_const_declarations
+          final $response = $types[0].decode($decoder, 0);
+
+          $completer.complete($response);
+
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError($fidl.FidlError(
+              'Exception handling method response $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
+      default:
+        ctrl.proxyError(
+            $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
+        ctrl.close();
+        break;
+    }
+  }
+
+  @override
+  $async.Future<$fidl.InterfaceHandle<Child>> getChild() async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(_kParent_GetChild_Ordinal, 0);
+    final $completer = $async.Completer<$fidl.InterfaceHandle<Child>>();
+    ctrl.sendMessageWithResponse($encoder.message, $completer);
+    return $completer.future;
+  }
+
+  @override
+  $async.Future<$fidl.InterfaceRequest<Child>> getChildRequest() async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(_kParent_GetChildRequest_Ordinal, 0);
+    final $completer = $async.Completer<$fidl.InterfaceRequest<Child>>();
+    ctrl.sendMessageWithResponse($encoder.message, $completer);
+    return $completer.future;
+  }
+
+  @override
+  $async.Future<void> takeChild($fidl.InterfaceHandle<Child> c) async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(_kParent_TakeChild_Ordinal, 0);
+    $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+    final List<$fidl.MemberType> $types = _kParent_TakeChild_Type.request;
+    $types[0].encode($encoder, c, 0);
+    return $async.Future.sync(() {
+      ctrl.sendMessage($encoder.message);
+    });
+  }
+
+  @override
+  $async.Future<void> takeChildRequest($fidl.InterfaceRequest<Child> r) async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(_kParent_TakeChildRequest_Ordinal, 0);
+    $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+    final List<$fidl.MemberType> $types =
+        _kParent_TakeChildRequest_Type.request;
+    $types[0].encode($encoder, r, 0);
+    return $async.Future.sync(() {
+      ctrl.sendMessage($encoder.message);
+    });
+  }
+}
+
+class ParentBinding extends $fidl.AsyncBinding<Parent> {
+  ParentBinding() : super(r"Parent");
+
+  @override
+  void handleMessage($fidl.Message $message, $fidl.MessageSink $respond) {
+    final $fidl.Decoder $decoder = $fidl.Decoder($message);
+    switch ($message.ordinal) {
+      case _kParent_GetChild_Ordinal:
+        final String _name = _kParent_GetChild_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types = _kParent_GetChild_Type.request;
+          $decoder.claimMemory(16);
+          final $async.Future<$fidl.InterfaceHandle<Child>> $future =
+              impl.getChild();
+          $future.then(($response) {
+            final $fidl.Encoder $encoder = $fidl.Encoder();
+            $encoder.encodeMessageHeader(
+                _kParent_GetChild_Ordinal, $message.txid);
+            $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+            final List<$fidl.MemberType> $types =
+                _kParent_GetChild_Type.response;
+            $types[0].encode($encoder, $response, 0);
+            $respond($encoder.message);
+          }, onError: (_e) {
+            close();
+            print('Exception handling method call $_name: $_e');
+          });
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
+      case _kParent_GetChildRequest_Ordinal:
+        final String _name = _kParent_GetChildRequest_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kParent_GetChildRequest_Type.request;
+          $decoder.claimMemory(16);
+          final $async.Future<$fidl.InterfaceRequest<Child>> $future =
+              impl.getChildRequest();
+          $future.then(($response) {
+            final $fidl.Encoder $encoder = $fidl.Encoder();
+            $encoder.encodeMessageHeader(
+                _kParent_GetChildRequest_Ordinal, $message.txid);
+            $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+            final List<$fidl.MemberType> $types =
+                _kParent_GetChildRequest_Type.response;
+            $types[0].encode($encoder, $response, 0);
+            $respond($encoder.message);
+          }, onError: (_e) {
+            close();
+            print('Exception handling method call $_name: $_e');
+          });
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
+      case _kParent_TakeChild_Ordinal:
+        final String _name = _kParent_TakeChild_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types = _kParent_TakeChild_Type.request;
+          $decoder.claimMemory(24);
+          final $async.Future<void> $future = impl.takeChild(
+            $types[0].decode($decoder, 0),
+          );
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
+      case _kParent_TakeChildRequest_Ordinal:
+        final String _name = _kParent_TakeChildRequest_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kParent_TakeChildRequest_Type.request;
+          $decoder.claimMemory(24);
+          final $async.Future<void> $future = impl.takeChildRequest(
+            $types[0].decode($decoder, 0),
+          );
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
+      default:
+        throw $fidl.FidlError(r'Unexpected message name for ParentBinding');
+    }
+  }
+}
diff --git a/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_test.dart.golden b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_test.dart.golden
new file mode 100644
index 0000000..d890d0b
--- /dev/null
+++ b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_test.dart.golden
@@ -0,0 +1,49 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// WARNING: This file is machine generated by fidlgen.
+
+library fidl_test_name_test;
+
+import 'dart:async' as $async;
+import 'dart:core' hide Error, Future, Match, Set, Stream, Type;
+import 'dart:typed_data';
+
+import 'package:fidl/fidl.dart' as $fidl;
+import 'package:meta/meta.dart';
+import 'package:zircon/zircon.dart' as $zx;
+
+import './fidl_async.dart';
+
+// ignore_for_file: always_specify_types
+// ignore_for_file: constant_identifier_names
+// ignore_for_file: one_member_abstracts
+// ignore_for_file: public_member_api_docs
+// ignore_for_file: unused_import
+// ignore_for_file: library_prefixes
+// ignore_for_file: unused_shown_name
+
+class Child$TestBase extends Child {}
+
+class Parent$TestBase extends Parent {
+  @override
+  $async.Future<$fidl.InterfaceHandle<Child>> getChild() {
+    return $async.Future.error(UnimplementedError());
+  }
+
+  @override
+  $async.Future<$fidl.InterfaceRequest<Child>> getChildRequest() {
+    return $async.Future.error(UnimplementedError());
+  }
+
+  @override
+  $async.Future<void> takeChild($fidl.InterfaceHandle<Child> c) {
+    return $async.Future.error(UnimplementedError());
+  }
+
+  @override
+  $async.Future<void> takeChildRequest($fidl.InterfaceRequest<Child> r) {
+    return $async.Future.error(UnimplementedError());
+  }
+}
diff --git a/bin/fidlgen_dart/goldens/protocols.test.fidl.json b/bin/fidlgen_dart/goldens/protocols.test.fidl.json
index d3bb4f5..4f0ea19 100644
--- a/bin/fidlgen_dart/goldens/protocols.test.fidl.json
+++ b/bin/fidlgen_dart/goldens/protocols.test.fidl.json
@@ -25,7 +25,8 @@
             "kind": "literal",
             "literal": {
               "kind": "numeric",
-              "value": "1"
+              "value": "1",
+              "expression": "1"
             }
           }
         },
@@ -40,7 +41,8 @@
             "kind": "literal",
             "literal": {
               "kind": "numeric",
-              "value": "2"
+              "value": "2",
+              "expression": "2"
             }
           }
         }
@@ -566,6 +568,62 @@
           ],
           "maybe_response_size": 24,
           "maybe_response_alignment": 8
+        },
+        {
+          "ordinal": 1691201382,
+          "generated_ordinal": 1691201382,
+          "name": "MutateSocket",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+            "line": 29,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "a",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 29,
+                "column": 33
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_request_size": 24,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "b",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 29,
+                "column": 55
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
         }
       ]
     },
@@ -573,7 +631,7 @@
       "name": "test.name/SocketControlProtocol",
       "location": {
         "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-        "line": 32,
+        "line": 33,
         "column": 10
       },
       "maybe_attributes": [
@@ -589,7 +647,7 @@
           "name": "MethodA",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 33,
+            "line": 34,
             "column": 5
           },
           "has_request": true,
@@ -602,7 +660,7 @@
               "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 33,
+                "line": 34,
                 "column": 19
               },
               "size": 8,
@@ -619,7 +677,7 @@
               "name": "b",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 33,
+                "line": 34,
                 "column": 28
               },
               "size": 8,
@@ -639,7 +697,7 @@
           "name": "EventA",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 34,
+            "line": 35,
             "column": 8
           },
           "has_request": false,
@@ -653,7 +711,7 @@
               "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 34,
+                "line": 35,
                 "column": 21
               },
               "size": 8,
@@ -670,7 +728,7 @@
               "name": "b",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 34,
+                "line": 35,
                 "column": 30
               },
               "size": 8,
@@ -689,7 +747,7 @@
           "name": "MethodB",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 35,
+            "line": 36,
             "column": 5
           },
           "has_request": true,
@@ -702,7 +760,7 @@
               "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 35,
+                "line": 36,
                 "column": 19
               },
               "size": 8,
@@ -719,7 +777,7 @@
               "name": "b",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 35,
+                "line": 36,
                 "column": 28
               },
               "size": 8,
@@ -741,7 +799,7 @@
               "name": "result",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 35,
+                "line": 36,
                 "column": 41
               },
               "size": 8,
@@ -753,6 +811,62 @@
           ],
           "maybe_response_size": 24,
           "maybe_response_alignment": 8
+        },
+        {
+          "ordinal": 255772213,
+          "generated_ordinal": 255772213,
+          "name": "MutateSocket",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+            "line": 37,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "a",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 37,
+                "column": 33
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_request_size": 24,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "b",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 37,
+                "column": 55
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
         }
       ]
     },
@@ -760,7 +874,7 @@
       "name": "test.name/ChannelProtocol",
       "location": {
         "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-        "line": 39,
+        "line": 41,
         "column": 10
       },
       "maybe_attributes": [
@@ -776,106 +890,6 @@
           "name": "MethodA",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 40,
-            "column": 5
-          },
-          "has_request": true,
-          "maybe_request": [
-            {
-              "type": {
-                "kind": "primitive",
-                "subtype": "int64"
-              },
-              "name": "a",
-              "location": {
-                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 40,
-                "column": 19
-              },
-              "size": 8,
-              "max_out_of_line": 0,
-              "alignment": 8,
-              "offset": 16,
-              "max_handles": 0
-            },
-            {
-              "type": {
-                "kind": "primitive",
-                "subtype": "int64"
-              },
-              "name": "b",
-              "location": {
-                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 40,
-                "column": 28
-              },
-              "size": 8,
-              "max_out_of_line": 0,
-              "alignment": 8,
-              "offset": 24,
-              "max_handles": 0
-            }
-          ],
-          "maybe_request_size": 32,
-          "maybe_request_alignment": 8,
-          "has_response": false
-        },
-        {
-          "ordinal": 477676034,
-          "generated_ordinal": 477676034,
-          "name": "EventA",
-          "location": {
-            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 41,
-            "column": 8
-          },
-          "has_request": false,
-          "has_response": true,
-          "maybe_response": [
-            {
-              "type": {
-                "kind": "primitive",
-                "subtype": "int64"
-              },
-              "name": "a",
-              "location": {
-                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 41,
-                "column": 21
-              },
-              "size": 8,
-              "max_out_of_line": 0,
-              "alignment": 8,
-              "offset": 16,
-              "max_handles": 0
-            },
-            {
-              "type": {
-                "kind": "primitive",
-                "subtype": "int64"
-              },
-              "name": "b",
-              "location": {
-                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 41,
-                "column": 30
-              },
-              "size": 8,
-              "max_out_of_line": 0,
-              "alignment": 8,
-              "offset": 24,
-              "max_handles": 0
-            }
-          ],
-          "maybe_response_size": 32,
-          "maybe_response_alignment": 8
-        },
-        {
-          "ordinal": 180770075,
-          "generated_ordinal": 180770075,
-          "name": "MethodB",
-          "location": {
-            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
             "line": 42,
             "column": 5
           },
@@ -918,6 +932,18 @@
           ],
           "maybe_request_size": 32,
           "maybe_request_alignment": 8,
+          "has_response": false
+        },
+        {
+          "ordinal": 477676034,
+          "generated_ordinal": 477676034,
+          "name": "EventA",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+            "line": 43,
+            "column": 8
+          },
+          "has_request": false,
           "has_response": true,
           "maybe_response": [
             {
@@ -925,45 +951,46 @@
                 "kind": "primitive",
                 "subtype": "int64"
               },
-              "name": "result",
+              "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 42,
-                "column": 41
+                "line": 43,
+                "column": 21
               },
               "size": 8,
               "max_out_of_line": 0,
               "alignment": 8,
               "offset": 16,
               "max_handles": 0
+            },
+            {
+              "type": {
+                "kind": "primitive",
+                "subtype": "int64"
+              },
+              "name": "b",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 43,
+                "column": 30
+              },
+              "size": 8,
+              "max_out_of_line": 0,
+              "alignment": 8,
+              "offset": 24,
+              "max_handles": 0
             }
           ],
-          "maybe_response_size": 24,
+          "maybe_response_size": 32,
           "maybe_response_alignment": 8
-        }
-      ]
-    },
-    {
-      "name": "test.name/KitchenSink",
-      "location": {
-        "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-        "line": 47,
-        "column": 10
-      },
-      "maybe_attributes": [
+        },
         {
-          "name": "Transport",
-          "value": "Channel, SocketControl, OvernetInternal"
-        }
-      ],
-      "methods": [
-        {
-          "ordinal": 450577456,
-          "generated_ordinal": 450577456,
-          "name": "MethodA",
+          "ordinal": 180770075,
+          "generated_ordinal": 180770075,
+          "name": "MethodB",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 48,
+            "line": 44,
             "column": 5
           },
           "has_request": true,
@@ -976,7 +1003,7 @@
               "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 48,
+                "line": 44,
                 "column": 19
               },
               "size": 8,
@@ -993,7 +1020,150 @@
               "name": "b",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 48,
+                "line": 44,
+                "column": 28
+              },
+              "size": 8,
+              "max_out_of_line": 0,
+              "alignment": 8,
+              "offset": 24,
+              "max_handles": 0
+            }
+          ],
+          "maybe_request_size": 32,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "primitive",
+                "subtype": "int64"
+              },
+              "name": "result",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 44,
+                "column": 41
+              },
+              "size": 8,
+              "max_out_of_line": 0,
+              "alignment": 8,
+              "offset": 16,
+              "max_handles": 0
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
+        },
+        {
+          "ordinal": 1258480262,
+          "generated_ordinal": 1258480262,
+          "name": "MutateSocket",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+            "line": 45,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "a",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 45,
+                "column": 33
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_request_size": 24,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "b",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 45,
+                "column": 55
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
+        }
+      ]
+    },
+    {
+      "name": "test.name/KitchenSink",
+      "location": {
+        "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+        "line": 50,
+        "column": 10
+      },
+      "maybe_attributes": [
+        {
+          "name": "Transport",
+          "value": "Channel, SocketControl, OvernetInternal"
+        }
+      ],
+      "methods": [
+        {
+          "ordinal": 450577456,
+          "generated_ordinal": 450577456,
+          "name": "MethodA",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+            "line": 51,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "primitive",
+                "subtype": "int64"
+              },
+              "name": "a",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 51,
+                "column": 19
+              },
+              "size": 8,
+              "max_out_of_line": 0,
+              "alignment": 8,
+              "offset": 16,
+              "max_handles": 0
+            },
+            {
+              "type": {
+                "kind": "primitive",
+                "subtype": "int64"
+              },
+              "name": "b",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 51,
                 "column": 28
               },
               "size": 8,
@@ -1013,7 +1183,7 @@
           "name": "EventA",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 49,
+            "line": 52,
             "column": 8
           },
           "has_request": false,
@@ -1027,7 +1197,7 @@
               "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 49,
+                "line": 52,
                 "column": 21
               },
               "size": 8,
@@ -1044,7 +1214,7 @@
               "name": "b",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 49,
+                "line": 52,
                 "column": 30
               },
               "size": 8,
@@ -1063,7 +1233,7 @@
           "name": "MethodB",
           "location": {
             "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-            "line": 50,
+            "line": 53,
             "column": 5
           },
           "has_request": true,
@@ -1076,7 +1246,7 @@
               "name": "a",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 50,
+                "line": 53,
                 "column": 19
               },
               "size": 8,
@@ -1093,7 +1263,7 @@
               "name": "b",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 50,
+                "line": 53,
                 "column": 28
               },
               "size": 8,
@@ -1115,7 +1285,7 @@
               "name": "result",
               "location": {
                 "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
-                "line": 50,
+                "line": 53,
                 "column": 41
               },
               "size": 8,
@@ -1127,6 +1297,62 @@
           ],
           "maybe_response_size": 24,
           "maybe_response_alignment": 8
+        },
+        {
+          "ordinal": 115851270,
+          "generated_ordinal": 115851270,
+          "name": "MutateSocket",
+          "location": {
+            "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+            "line": 54,
+            "column": 5
+          },
+          "has_request": true,
+          "maybe_request": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "a",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 54,
+                "column": 33
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_request_size": 24,
+          "maybe_request_alignment": 8,
+          "has_response": true,
+          "maybe_response": [
+            {
+              "type": {
+                "kind": "handle",
+                "subtype": "socket",
+                "nullable": false
+              },
+              "name": "b",
+              "location": {
+                "filename": "garnet/go/src/fidl/compiler/backend/typestest/protocols.test.fidl",
+                "line": 54,
+                "column": 55
+              },
+              "size": 4,
+              "max_out_of_line": 0,
+              "alignment": 4,
+              "offset": 16,
+              "max_handles": 1
+            }
+          ],
+          "maybe_response_size": 24,
+          "maybe_response_alignment": 8
         }
       ]
     }
diff --git a/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden
index 2c15fa1..d80b331 100644
--- a/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden
@@ -48,16 +48,16 @@
 class ErrorEnun extends $fidl.Enum {
   factory ErrorEnun(int _v) {
     switch (_v) {
-      case 1:
+      case 0x1:
         return errFoo;
-      case 2:
+      case 0x2:
         return errBar;
       default:
         return null;
     }
   }
-  static const ErrorEnun errFoo = ErrorEnun._(1);
-  static const ErrorEnun errBar = ErrorEnun._(2);
+  static const ErrorEnun errFoo = ErrorEnun._(0x1);
+  static const ErrorEnun errBar = ErrorEnun._(0x2);
 
   const ErrorEnun._(this.$value);
 
@@ -82,9 +82,9 @@
   @override
   String toString() {
     switch ($value) {
-      case 1:
+      case 0x1:
         return r'ErrorEnun.errFoo';
-      case 2:
+      case 0x2:
         return r'ErrorEnun.errBar';
       default:
         return null;
@@ -255,7 +255,7 @@
 
 class WithErrorSyntaxErrorAsPrimitiveResponse extends $fidl.Struct {
   const WithErrorSyntaxErrorAsPrimitiveResponse({
-    this.reserved: 0,
+    this.reserved: 0x0,
   });
   WithErrorSyntaxErrorAsPrimitiveResponse.clone(
     WithErrorSyntaxErrorAsPrimitiveResponse $orig, {
@@ -301,7 +301,7 @@
 
 class WithErrorSyntaxErrorAsEnumResponse extends $fidl.Struct {
   const WithErrorSyntaxErrorAsEnumResponse({
-    this.reserved: 0,
+    this.reserved: 0x0,
   });
   WithErrorSyntaxErrorAsEnumResponse.clone(
     WithErrorSyntaxErrorAsEnumResponse $orig, {
@@ -1300,6 +1300,20 @@
   ],
   name: r"OvernetInternalProtocol.MethodB",
 );
+// mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
+const int _kOvernetInternalProtocol_MutateSocket_Ordinal = 1691201382;
+const $fidl.MethodType _kOvernetInternalProtocol_MutateSocket_Type =
+    $fidl.MethodType(
+  request: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  response: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  name: r"OvernetInternalProtocol.MutateSocket",
+);
 
 class OvernetInternalProtocol$EventA$Response {
   final int a;
@@ -1317,6 +1331,7 @@
   $async.Future<void> methodA(int a, int b);
   $async.Stream<OvernetInternalProtocol$EventA$Response> get eventA;
   $async.Future<int> methodB(int a, int b);
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a);
 }
 
 class OvernetInternalProtocolData
@@ -1416,6 +1431,28 @@
           Timeline.finishSync();
         }
         break;
+      case _kOvernetInternalProtocol_MutateSocket_Ordinal:
+        final String _name = _kOvernetInternalProtocol_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kOvernetInternalProtocol_MutateSocket_Type.response;
+          $decoder.claimMemory(24);
+          // ignore: prefer_const_declarations
+          final $response = $types[0].decode($decoder, 0);
+
+          $completer.complete($response);
+
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError($fidl.FidlError(
+              'Exception handling method response $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         ctrl.proxyError(
             $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
@@ -1469,6 +1506,26 @@
     ctrl.sendMessageWithResponse($encoder.message, $completer);
     return $completer.future;
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(
+        _kOvernetInternalProtocol_MutateSocket_Ordinal, 0);
+    $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+    final List<$fidl.MemberType> $types =
+        _kOvernetInternalProtocol_MutateSocket_Type.request;
+    $types[0].encode($encoder, a, 0);
+    final $completer = $async.Completer<$zx.Socket>();
+    ctrl.sendMessageWithResponse($encoder.message, $completer);
+    return $completer.future;
+  }
 }
 
 class OvernetInternalProtocolBinding
@@ -1558,6 +1615,38 @@
           Timeline.finishSync();
         }
         break;
+      case _kOvernetInternalProtocol_MutateSocket_Ordinal:
+        final String _name = _kOvernetInternalProtocol_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kOvernetInternalProtocol_MutateSocket_Type.request;
+          $decoder.claimMemory(24);
+          final $async.Future<$zx.Socket> $future = impl.mutateSocket(
+            $types[0].decode($decoder, 0),
+          );
+          $future.then(($response) {
+            final $fidl.Encoder $encoder = $fidl.Encoder();
+            $encoder.encodeMessageHeader(
+                _kOvernetInternalProtocol_MutateSocket_Ordinal, $message.txid);
+            $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+            final List<$fidl.MemberType> $types =
+                _kOvernetInternalProtocol_MutateSocket_Type.response;
+            $types[0].encode($encoder, $response, 0);
+            $respond($encoder.message);
+          }, onError: (_e) {
+            close();
+            print('Exception handling method call $_name: $_e');
+          });
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         throw $fidl.FidlError(
             r'Unexpected message name for OvernetInternalProtocolBinding');
@@ -1597,6 +1686,20 @@
   ],
   name: r"SocketControlProtocol.MethodB",
 );
+// mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
+const int _kSocketControlProtocol_MutateSocket_Ordinal = 255772213;
+const $fidl.MethodType _kSocketControlProtocol_MutateSocket_Type =
+    $fidl.MethodType(
+  request: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  response: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  name: r"SocketControlProtocol.MutateSocket",
+);
 
 class SocketControlProtocol$EventA$Response {
   final int a;
@@ -1614,6 +1717,7 @@
   $async.Future<void> methodA(int a, int b);
   $async.Stream<SocketControlProtocol$EventA$Response> get eventA;
   $async.Future<int> methodB(int a, int b);
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a);
 }
 
 class SocketControlProtocolData
@@ -1713,6 +1817,28 @@
           Timeline.finishSync();
         }
         break;
+      case _kSocketControlProtocol_MutateSocket_Ordinal:
+        final String _name = _kSocketControlProtocol_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kSocketControlProtocol_MutateSocket_Type.response;
+          $decoder.claimMemory(24);
+          // ignore: prefer_const_declarations
+          final $response = $types[0].decode($decoder, 0);
+
+          $completer.complete($response);
+
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError($fidl.FidlError(
+              'Exception handling method response $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         ctrl.proxyError(
             $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
@@ -1766,6 +1892,26 @@
     ctrl.sendMessageWithResponse($encoder.message, $completer);
     return $completer.future;
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(
+        _kSocketControlProtocol_MutateSocket_Ordinal, 0);
+    $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+    final List<$fidl.MemberType> $types =
+        _kSocketControlProtocol_MutateSocket_Type.request;
+    $types[0].encode($encoder, a, 0);
+    final $completer = $async.Completer<$zx.Socket>();
+    ctrl.sendMessageWithResponse($encoder.message, $completer);
+    return $completer.future;
+  }
 }
 
 class SocketControlProtocolBinding
@@ -1855,6 +2001,38 @@
           Timeline.finishSync();
         }
         break;
+      case _kSocketControlProtocol_MutateSocket_Ordinal:
+        final String _name = _kSocketControlProtocol_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kSocketControlProtocol_MutateSocket_Type.request;
+          $decoder.claimMemory(24);
+          final $async.Future<$zx.Socket> $future = impl.mutateSocket(
+            $types[0].decode($decoder, 0),
+          );
+          $future.then(($response) {
+            final $fidl.Encoder $encoder = $fidl.Encoder();
+            $encoder.encodeMessageHeader(
+                _kSocketControlProtocol_MutateSocket_Ordinal, $message.txid);
+            $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+            final List<$fidl.MemberType> $types =
+                _kSocketControlProtocol_MutateSocket_Type.response;
+            $types[0].encode($encoder, $response, 0);
+            $respond($encoder.message);
+          }, onError: (_e) {
+            close();
+            print('Exception handling method call $_name: $_e');
+          });
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         throw $fidl.FidlError(
             r'Unexpected message name for SocketControlProtocolBinding');
@@ -1894,6 +2072,19 @@
   ],
   name: r"ChannelProtocol.MethodB",
 );
+// mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
+const int _kChannelProtocol_MutateSocket_Ordinal = 1258480262;
+const $fidl.MethodType _kChannelProtocol_MutateSocket_Type = $fidl.MethodType(
+  request: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  response: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  name: r"ChannelProtocol.MutateSocket",
+);
 
 class ChannelProtocol$EventA$Response {
   final int a;
@@ -1911,6 +2102,7 @@
   $async.Future<void> methodA(int a, int b);
   $async.Stream<ChannelProtocol$EventA$Response> get eventA;
   $async.Future<int> methodB(int a, int b);
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a);
 }
 
 class ChannelProtocolData implements $fidl.ServiceData<ChannelProtocol> {
@@ -2008,6 +2200,28 @@
           Timeline.finishSync();
         }
         break;
+      case _kChannelProtocol_MutateSocket_Ordinal:
+        final String _name = _kChannelProtocol_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kChannelProtocol_MutateSocket_Type.response;
+          $decoder.claimMemory(24);
+          // ignore: prefer_const_declarations
+          final $response = $types[0].decode($decoder, 0);
+
+          $completer.complete($response);
+
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError($fidl.FidlError(
+              'Exception handling method response $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         ctrl.proxyError(
             $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
@@ -2061,6 +2275,25 @@
     ctrl.sendMessageWithResponse($encoder.message, $completer);
     return $completer.future;
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(_kChannelProtocol_MutateSocket_Ordinal, 0);
+    $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+    final List<$fidl.MemberType> $types =
+        _kChannelProtocol_MutateSocket_Type.request;
+    $types[0].encode($encoder, a, 0);
+    final $completer = $async.Completer<$zx.Socket>();
+    ctrl.sendMessageWithResponse($encoder.message, $completer);
+    return $completer.future;
+  }
 }
 
 class ChannelProtocolBinding extends $fidl.AsyncBinding<ChannelProtocol> {
@@ -2148,6 +2381,38 @@
           Timeline.finishSync();
         }
         break;
+      case _kChannelProtocol_MutateSocket_Ordinal:
+        final String _name = _kChannelProtocol_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kChannelProtocol_MutateSocket_Type.request;
+          $decoder.claimMemory(24);
+          final $async.Future<$zx.Socket> $future = impl.mutateSocket(
+            $types[0].decode($decoder, 0),
+          );
+          $future.then(($response) {
+            final $fidl.Encoder $encoder = $fidl.Encoder();
+            $encoder.encodeMessageHeader(
+                _kChannelProtocol_MutateSocket_Ordinal, $message.txid);
+            $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+            final List<$fidl.MemberType> $types =
+                _kChannelProtocol_MutateSocket_Type.response;
+            $types[0].encode($encoder, $response, 0);
+            $respond($encoder.message);
+          }, onError: (_e) {
+            close();
+            print('Exception handling method call $_name: $_e');
+          });
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         throw $fidl.FidlError(
             r'Unexpected message name for ChannelProtocolBinding');
@@ -2187,6 +2452,19 @@
   ],
   name: r"KitchenSink.MethodB",
 );
+// mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
+const int _kKitchenSink_MutateSocket_Ordinal = 115851270;
+const $fidl.MethodType _kKitchenSink_MutateSocket_Type = $fidl.MethodType(
+  request: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  response: <$fidl.MemberType>[
+    $fidl.MemberType<$zx.Socket>(
+        type: $fidl.SocketType(nullable: false), offset: 16),
+  ],
+  name: r"KitchenSink.MutateSocket",
+);
 
 class KitchenSink$EventA$Response {
   final int a;
@@ -2204,6 +2482,7 @@
   $async.Future<void> methodA(int a, int b);
   $async.Stream<KitchenSink$EventA$Response> get eventA;
   $async.Future<int> methodB(int a, int b);
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a);
 }
 
 class KitchenSinkData implements $fidl.ServiceData<KitchenSink> {
@@ -2301,6 +2580,28 @@
           Timeline.finishSync();
         }
         break;
+      case _kKitchenSink_MutateSocket_Ordinal:
+        final String _name = _kKitchenSink_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kKitchenSink_MutateSocket_Type.response;
+          $decoder.claimMemory(24);
+          // ignore: prefer_const_declarations
+          final $response = $types[0].decode($decoder, 0);
+
+          $completer.complete($response);
+
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          ctrl.proxyError($fidl.FidlError(
+              'Exception handling method response $_name: $_e'));
+          ctrl.close();
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         ctrl.proxyError(
             $fidl.FidlError('Unexpected message ordinal: ${$message.ordinal}'));
@@ -2352,6 +2653,25 @@
     ctrl.sendMessageWithResponse($encoder.message, $completer);
     return $completer.future;
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) async {
+    if (!ctrl.isBound) {
+      return $async.Future.error(
+          $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'),
+          StackTrace.current);
+    }
+
+    final $fidl.Encoder $encoder = $fidl.Encoder();
+    $encoder.encodeMessageHeader(_kKitchenSink_MutateSocket_Ordinal, 0);
+    $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+    final List<$fidl.MemberType> $types =
+        _kKitchenSink_MutateSocket_Type.request;
+    $types[0].encode($encoder, a, 0);
+    final $completer = $async.Completer<$zx.Socket>();
+    ctrl.sendMessageWithResponse($encoder.message, $completer);
+    return $completer.future;
+  }
 }
 
 class KitchenSinkBinding extends $fidl.AsyncBinding<KitchenSink> {
@@ -2439,6 +2759,38 @@
           Timeline.finishSync();
         }
         break;
+      case _kKitchenSink_MutateSocket_Ordinal:
+        final String _name = _kKitchenSink_MutateSocket_Type.name;
+        try {
+          Timeline.startSync(_name);
+          final List<$fidl.MemberType> $types =
+              _kKitchenSink_MutateSocket_Type.request;
+          $decoder.claimMemory(24);
+          final $async.Future<$zx.Socket> $future = impl.mutateSocket(
+            $types[0].decode($decoder, 0),
+          );
+          $future.then(($response) {
+            final $fidl.Encoder $encoder = $fidl.Encoder();
+            $encoder.encodeMessageHeader(
+                _kKitchenSink_MutateSocket_Ordinal, $message.txid);
+            $encoder.alloc(24 - $fidl.kMessageHeaderSize);
+            final List<$fidl.MemberType> $types =
+                _kKitchenSink_MutateSocket_Type.response;
+            $types[0].encode($encoder, $response, 0);
+            $respond($encoder.message);
+          }, onError: (_e) {
+            close();
+            print('Exception handling method call $_name: $_e');
+          });
+          // ignore: avoid_catches_without_on_clauses
+        } catch (_e) {
+          close();
+          print('Exception handling method call $_name: $_e');
+          rethrow;
+        } finally {
+          Timeline.finishSync();
+        }
+        break;
       default:
         throw $fidl.FidlError(
             r'Unexpected message name for KitchenSinkBinding');
diff --git a/bin/fidlgen_dart/goldens/protocols.test.fidl.json_test.dart.golden b/bin/fidlgen_dart/goldens/protocols.test.fidl.json_test.dart.golden
index c223b4b..367ad9e 100644
--- a/bin/fidlgen_dart/goldens/protocols.test.fidl.json_test.dart.golden
+++ b/bin/fidlgen_dart/goldens/protocols.test.fidl.json_test.dart.golden
@@ -94,6 +94,11 @@
   $async.Future<int> methodB(int a, int b) {
     return $async.Future.error(UnimplementedError());
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) {
+    return $async.Future.error(UnimplementedError());
+  }
 }
 
 class SocketControlProtocol$TestBase extends SocketControlProtocol {
@@ -111,6 +116,11 @@
   $async.Future<int> methodB(int a, int b) {
     return $async.Future.error(UnimplementedError());
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) {
+    return $async.Future.error(UnimplementedError());
+  }
 }
 
 class ChannelProtocol$TestBase extends ChannelProtocol {
@@ -128,6 +138,11 @@
   $async.Future<int> methodB(int a, int b) {
     return $async.Future.error(UnimplementedError());
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) {
+    return $async.Future.error(UnimplementedError());
+  }
 }
 
 class KitchenSink$TestBase extends KitchenSink {
@@ -145,4 +160,9 @@
   $async.Future<int> methodB(int a, int b) {
     return $async.Future.error(UnimplementedError());
   }
+
+  @override
+  $async.Future<$zx.Socket> mutateSocket($zx.Socket a) {
+    return $async.Future.error(UnimplementedError());
+  }
 }
diff --git a/bin/fidlgen_dart/goldens/tables.test.fidl.json b/bin/fidlgen_dart/goldens/tables.test.fidl.json
index a61086a..78f3d19 100644
--- a/bin/fidlgen_dart/goldens/tables.test.fidl.json
+++ b/bin/fidlgen_dart/goldens/tables.test.fidl.json
@@ -247,9 +247,9 @@
   "union_declarations": [],
   "xunion_declarations": [],
   "declaration_order": [
+    "test.name/SimpleTable",
     "test.name/OlderSimpleTable",
     "test.name/NewerSimpleTable",
-    "test.name/SimpleTable",
     "test.name/EmptyTable"
   ],
   "declarations": {
diff --git a/bin/fidlgen_dart/regen.sh b/bin/fidlgen_dart/regen.sh
index f4e7104..c8fd5e4 100755
--- a/bin/fidlgen_dart/regen.sh
+++ b/bin/fidlgen_dart/regen.sh
@@ -39,8 +39,6 @@
         -json "${GOLDENS_DIR}/${json_name}" \
         -output-base "${GOLDENS_DIR}" \
         -include-base "${GOLDENS_DIR}"
-    mv "${GOLDENS_DIR}/fidl.dart" "${GOLDENS_DIR}/${dart_sync_name}"
-    $DARTFMT -w "${GOLDENS_DIR}/${dart_sync_name}"
     mv "${GOLDENS_DIR}/fidl_async.dart" "${GOLDENS_DIR}/${dart_async_name}"
     $DARTFMT -w "${GOLDENS_DIR}/${dart_async_name}"
     mv "${GOLDENS_DIR}/fidl_test.dart" "${GOLDENS_DIR}/${dart_test_name}"