GRPC C# - Where are the well known grpc types stored to reference them? Unable to import google.protobuf.Timestamp

Viewed 450

I have a very simple protobuf file as below

syntax = "proto3";

option csharp_namespace = "GrpcService1.Protos";

import "google/protobuf/timestamp.proto";
import "Protos/ReportingStatus.proto";

package GrpcService1;

service MetricReportingService {
    rpc ReportMetricData(MetricMessage) returns (StatusMessage);
}
message MetricMessage {
    int32 id = 1;
    int32 value = 2;
    google.protobuf.Timestamp last_updated = 3;
}

message StatusMessage {
    ReportingStatus status = 1;
}

When I build the solution I get the below error

1>Protos/MetricProducer.proto(16,9): error : "google.protobuf.TimeStamp" is not defined.

I am using Visual Studio 2019 Ver 16.10.0. I have added the Grpc.aspnetcore meta package. I have tried to see if the well known proto files are installed elsewhere but am not sure how the well known proto types are referenced. Any help will be appreciated.

2 Answers

Change

google.protobuf.TimeStamp last_updated = 3;

to

google.protobuf.Timestamp last_updated = 3;

Sounds strange but restarting Visual Studio and rebuilding did the trick. Maybe I should have walked away and taken a break earlier. :-)

Related