Skip to content

erroneous compilation with 'Call' as rpc identifier #963

Closed
@kaduvert

Description

@kaduvert

i'm not sure if my .proto is valid but it worked for other things so assumed so:

syntax = "proto3";

message Default {
  string id = 1;
  string content = 2;
  optional string auth = 3;
}

service DefaultService {
  rpc Call(Default) returns (Default);
}

so the problem seems to be that the rpc of DefaultService is named Call, which causes problems when compiling for dart:

//
//  Generated code. Do not modify.
//  source: default.proto
//
// @dart = 2.12

// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:async' as $async;
import 'dart:core' as $core;

import 'package:grpc/service_api.dart' as $grpc;
import 'package:protobuf/protobuf.dart' as $pb;

import 'default.pb.dart' as $0;

export 'default.pb.dart';

@$pb.GrpcServiceName('DefaultService')
class DefaultServiceClient extends $grpc.Client {
  static final _$call = $grpc.ClientMethod<$0.Default, $0.Default>(
      '/DefaultService/Call',
      ($0.Default value) => value.writeToBuffer(),
      ($core.List<$core.int> value) => $0.Default.fromBuffer(value));

  DefaultServiceClient($grpc.ClientChannel channel,
      {$grpc.CallOptions? options,
      $core.Iterable<$grpc.ClientInterceptor>? interceptors})
      : super(channel, options: options,
        interceptors: interceptors);

  $grpc.ResponseFuture<$0.Default> call($0.Default request, {$grpc.CallOptions? options}) {
    return $createUnaryCall(_$call, request, options: options);
  }
}

@$pb.GrpcServiceName('DefaultService')
abstract class DefaultServiceBase extends $grpc.Service {
  $core.String get $name => 'DefaultService';

  DefaultServiceBase() {
    $addMethod($grpc.ServiceMethod<$0.Default, $0.Default>(
        'Call',
        call_Pre,
        false,
        false,
        ($core.List<$core.int> value) => $0.Default.fromBuffer(value),
        ($0.Default value) => value.writeToBuffer()));
  }

  $async.Future<$0.Default> call_Pre($grpc.ServiceCall call, $async.Future<$0.Default> request) async {
    // 1)
    return call(call, await request);
  }

  // 2)
  $async.Future<$0.Default> call($grpc.ServiceCall call, $0.Default request);
}

this file is called default.pbgrpc.dart and is part of the output

the problem:
so when trying to execute it, it complains about how something is wrong at 1) and how call doesnt work

my temporary workaround and possible fix inspiration:
renaming the function that's trying to be called at 1) and 2) to asdasd

I'm using protoc 29.2 on linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions