Giter VIP home page Giter VIP logo

Comments (6)

whatyouhide avatar whatyouhide commented on May 25, 2024

@tony612 can you try a quick patch, which is calling Code.ensure_loaded(type) before calling type.key(1) in the changes made in my PR?

from protobuf.

tony612 avatar tony612 commented on May 25, 2024

@whatyouhide I tried, but only using ensure_loaded doesn't work. I think it's because we have a file like this

defmodule Foo.Msg do
  use Protobuf, syntax: :proto3
  field :type, 0, type: Foo.Enum, enum: true
end

defmodule Foo.Enum do
  use Protobuf, enum: true, syntax: :proto3
  field :UNKNOWN, 0
end

And Elixir can't compile a file like this, we have to write a file like

defmodule Foo.Enum do
  use Protobuf, enum: true, syntax: :proto3
  field :UNKNOWN, 0
end

defmodule Foo.Msg do
  use Protobuf, syntax: :proto3
  field :type, 0, type: Foo.Enum, enum: true
end

I tried adjuting the ordering of the generated code in this branch https://github.com/tony612/protobuf-elixir/compare/fix-gen-order?expand=1

This branch just put enum in the first in generated files, I'm not sure if this can cover every case, but our protos can be compiled successfully with it.

from protobuf.

whatyouhide avatar whatyouhide commented on May 25, 2024

@tony612 looks good to me :)

from protobuf.

jared-mackey avatar jared-mackey commented on May 25, 2024

I am having issues with this on 0.7.1.

I am having an issue with enums defined in the same file are being generated at the bottom of the file. My work around is to move them to the top of the file but that has to be done every time we regenerate them.

@whatyouhide @tony612

from protobuf.

tony612 avatar tony612 commented on May 25, 2024

@mackeyja92 Could you regenerate the code after upgrading protoc plugin?

mix escript.install hex protobuf 0.7.1

The escript version is different from the protobuf version in mix.exs.

from protobuf.

jared-mackey avatar jared-mackey commented on May 25, 2024

@tony612 Yes. That solved it for me. Thank you!

from protobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.