support the latest protobuf, version 0.9.0 (#24)
Stop using `CodedBufferWriter.writeRawBytes` and create a custom buffer instead
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d23615..d0cf84c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.11
+
+* Added support for protobuf 0.9.0.
+
## 0.1.10
* Update the SDK dependency to 2.0.0-dev.17.0.
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 534f086..e34112d 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -2,14 +2,22 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:typed_data';
+
import 'package:protobuf/protobuf.dart';
List<int> protoToDelimitedBuffer(GeneratedMessage message) {
- var buffer = message.writeToBuffer();
+ var messageBuffer = new CodedBufferWriter();
+ message.writeToCodedBufferWriter(messageBuffer);
- var writer = new CodedBufferWriter();
- writer.writeInt32NoTag(buffer.length);
- writer.writeRawBytes(buffer);
+ var delimiterBuffer = new CodedBufferWriter();
+ delimiterBuffer.writeInt32NoTag(messageBuffer.lengthInBytes);
- return writer.toBuffer();
+ var result = new Uint8List(
+ messageBuffer.lengthInBytes + delimiterBuffer.lengthInBytes);
+
+ delimiterBuffer.writeTo(result);
+ messageBuffer.writeTo(result, delimiterBuffer.lengthInBytes);
+
+ return result;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index b091189..58f036c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: bazel_worker
-version: 0.1.10
+version: 0.1.11
description: Tools for creating a bazel persistent worker.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/bazel_worker
@@ -9,7 +9,7 @@
dependencies:
async: ">1.9.0 <3.0.0"
- protobuf: ">=0.8.0 <0.9.0"
+ protobuf: ">=0.8.0 <0.10.0"
dev_dependencies:
- test: ^0.12.0
+ test: ^1.2.0