Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using deprecated protobuf API #2045

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/GRPC/Serialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public struct ProtobufDeserializer<Message: SwiftProtobuf.Message>: MessageDeser
var buffer = byteBuffer
// '!' is okay; we can always read 'readableBytes'.
let data = buffer.readData(length: buffer.readableBytes)!
return try Message(serializedData: data)
return try Message(serializedBytes: data)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ extension ReflectionService {
"""
)
}
return try Google_Protobuf_FileDescriptorProto(serializedData: serializedData)
return try Google_Protobuf_FileDescriptorProto(serializedBytes: serializedData)
}

static func readSerializedFileDescriptorProtos(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ final class SerializationTests: GRPCTestCase {
.deletingLastPathComponent().appendingPathComponent("echo.grpc.reflection")
let base64EncodedData = try! Data(contentsOf: binaryFileURL)
let binaryData = Data(base64Encoded: base64EncodedData)!
self
.fileDescriptorProto =
try! Google_Protobuf_FileDescriptorProto(serializedData: binaryData)
self.fileDescriptorProto = try! Google_Protobuf_FileDescriptorProto(serializedBytes: binaryData)
}

func testFileDescriptorMetadata() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ final class ReflectionServiceIntegrationTests: GRPCTestCase {
// response can't be nil as we just checked it.
let receivedFileDescriptorProto =
try Google_Protobuf_FileDescriptorProto(
serializedData: (message.fileDescriptorResponse
.fileDescriptorProto[0])
serializedBytes: message.fileDescriptorResponse.fileDescriptorProto[0]
)

XCTAssertEqual(receivedFileDescriptorProto.name, "bar1.proto")
Expand Down Expand Up @@ -177,7 +176,7 @@ final class ReflectionServiceIntegrationTests: GRPCTestCase {
let receivedData: [Google_Protobuf_FileDescriptorProto]
do {
receivedData = try message.fileDescriptorResponse.fileDescriptorProto.map {
try Google_Protobuf_FileDescriptorProto(serializedData: $0)
try Google_Protobuf_FileDescriptorProto(serializedBytes: $0)
}
} catch {
return XCTFail("Could not serialize data received as a message.")
Expand Down Expand Up @@ -221,7 +220,7 @@ final class ReflectionServiceIntegrationTests: GRPCTestCase {
let receivedData: [Google_Protobuf_FileDescriptorProto]
do {
receivedData = try message.fileDescriptorResponse.fileDescriptorProto.map {
try Google_Protobuf_FileDescriptorProto(serializedData: $0)
try Google_Protobuf_FileDescriptorProto(serializedBytes: $0)
}
} catch {
return XCTFail("Could not serialize data received as a message.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ final class ReflectionServiceUnitTests: GRPCTestCase {
switch serializedFileDescriptorProtosResult {
case .success(let serializedFileDescriptorProtos):
let fileDescriptorProtos = try serializedFileDescriptorProtos.map {
try Google_Protobuf_FileDescriptorProto(serializedData: $0)
try Google_Protobuf_FileDescriptorProto(serializedBytes: $0)
}
// Tests that the functions returns all the transitive dependencies, with their services and
// methods, together with the initial proto, as serialized data.
Expand Down Expand Up @@ -233,7 +233,7 @@ final class ReflectionServiceUnitTests: GRPCTestCase {
switch serializedFileDescriptorProtosResult {
case .success(let serializedFileDescriptorProtos):
let fileDescriptorProtos = try serializedFileDescriptorProtos.map {
try Google_Protobuf_FileDescriptorProto(serializedData: $0)
try Google_Protobuf_FileDescriptorProto(serializedBytes: $0)
}
// Tests that the functions returns all the tranzitive dependencies, with their services and
// methods, together with the initial proto, as serialized data.
Expand Down Expand Up @@ -292,7 +292,7 @@ final class ReflectionServiceUnitTests: GRPCTestCase {
switch serializedFileDescriptorProtosResult {
case .success(let serializedFileDescriptorProtos):
let fileDescriptorProtos = try serializedFileDescriptorProtos.map {
try Google_Protobuf_FileDescriptorProto(serializedData: $0)
try Google_Protobuf_FileDescriptorProto(serializedBytes: $0)
}
// Test that we get only 4 serialized File Descriptor Protos as response.
XCTAssertEqual(fileDescriptorProtos.count, 4)
Expand Down
Loading