title: How to get the method options from protobuf descriptor?
body: <p>I try to parse the .proto file with the protobuf compiler. But here is a confusing problem that I can't get the options for method.</p>
  
  <p>It seems that my options are treated as "unknown fields" but not the options.</p>
  
  <p>Is there any way to solve the problem? Thanks.</p>
  
  <p>(I hate to paste a lot of code here, but I think it's essential to fully describe the problem. Sorry for that.)</p>
  
  <p>(Env: g++ 4.7, Ubuntu 16.04, Protobuf 3.0.0)</p>
  
  <pre><code>#include &lt;google/protobuf/descriptor.h&gt;
  #include &lt;google/protobuf/descriptor.pb.h&gt;
  #include &lt;google/protobuf/dynamic_message.h&gt;
  #include &lt;google/protobuf/compiler/importer.h&gt;
  
  using namespace std;
  using namespace google::protobuf;
  using namespace google::protobuf::compiler;
  
  #define print(x) std::cout &lt;&lt; x &lt;&lt; std::endl
  #define input(x) std::cin &gt;&gt; x
  
  int main() {
      DiskSourceTree sourceTree;
      sourceTree.MapPath("", "./");
      sourceTree.MapPath("", "./protobuf/include/");
      Importer importer(&amp;sourceTree, NULL);
  
      auto fd = importer.Import("example.proto");
      assert(fd);
  
      int service_count = fd-&gt;service_count();
  
      for (int i = 0; i &lt; service_count; i++) {
          auto service_d = fd-&gt;service(i);
          int method_count = service_d-&gt;method_count();
          for (int j = 0; j &lt; method_count; j++) {
              auto method_d = service_d-&gt;method(j);
              print(method_d-&gt;options().unknown_fields().field_count());$ 
              print("&gt;&gt; " &lt;&lt; method_d-&gt;options().uninterpreted_option_size());
          }
      }
      return 0;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>// lrpc.proto
  syntax = "proto3";
  package lrpc;
  import "google/protobuf/descriptor.proto";
  
  
  extend google.protobuf.MethodOptions {
      int32 CmdID      = 50000;
      string OptString = 50001;
      string Usage     = 50002;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>// example.proto
  syntax = "proto3";
  
  package foobar;
  
  import "google/protobuf/wrappers.proto";
  import "google/protobuf/empty.proto";
  
  import "lrpc.proto";
  
  message SearchRequest {
      // ... 
  }
  
  message SearchResponse {
      // ...
  }
  
  service SearchService {
      rpc Search( SearchRequest ) returns( SearchResponse ) {
          option( lrpc.CmdID ) = 1;
      }
  }
  </code></pre>
  
  <hr>