error : “Timestamp” is not defined. – .net core and gRPC

Hi everyone,

I’m currently testing out gRPC with .NET Core and hit the following error when attempting to add a timestamp field to my proto file:

error : “Timestamp” is not defined.

My proto file was as follows:

syntax = “proto3”;
import “google/protobuf/timestamp.proto”;

option csharp_namespace = “publisher_api”;

package Weather;

// The weather forecast service definition
service Weather {

// Gets weather forecast
rpc Forecast(WeatherForecastRequest) returns (WeatherForecastResponse);
}

// The request message
message WeatherForecastRequest {

}

// The response message
message WeatherForecastResponse {
timestamp date = 1;
int32 temperatureC = 2;
int32 temperatureF = 3;
string summary = 4;
}

The solution was to fully qualify the timestamp namespace:


message WeatherForecastResponse {
google.protobuf.Timestamp date = 1;
int32 temperatureC = 2;
int32 temperatureF = 3;
string summary = 4;
}

Also ensure that you’ve added the protobuff package:

dotnet add package Google.Protobuf

See the following repo for a full example: https://github.com/Buzzology/microservicesDockerRabbitMQ


by

Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: