ctaggart / froto

Froto: F# Protocol Buffers
MIT License
146 stars 27 forks source link

TypeProvider fails with "Specified method is not supported" #71

Closed EHotwagner closed 7 years ago

EHotwagner commented 7 years ago

I am trying to use blizzards sc2 proto files provided here: https://github.com/Blizzard/s2client-proto The first problem is the use of the not supported "import" statement. I concatenated the content of the files to fix this.

Then i got the following error in debug.proto: "Specified method is not supported" in this section:

// Issue various useful commands to the game engine.
message DebugCommand {
  oneof command {
    DebugDraw draw = 1;
    //gamestatemessage is broken with the Froto Typeprovider
    //DebugGameState game_state = 2; 
    DebugCreateUnit create_unit = 3;
    DebugKillUnit kill_unit = 4;
    DebugTestProcess test_process = 5;
    DebugSetScore score = 6;                // Useful only for single-player "curriculum" maps.
    DebugEndGame end_game = 7;
    DebugSetUnitValue unit_value = 8;
    DebugChat chat = 9;                     // TODO.
  }
}

enum DebugGameState {
  show_map = 1;
  control_enemy = 2;
  food = 3;
  free = 4;
  all_resources = 5;
  god = 6;
  minerals = 7;
  gas = 8;
  cooldown = 9;
  tech_tree = 10;
  upgrade = 11;
  fast_build = 12;
}

Any ideas why and how to fix this?

jhugard commented 7 years ago

I worked on the parser but never really looked at the TypeProvider. DebugGameState is the only enum in that list so that may be a clue. However, I'm not sure what's wrong because the generator does appear to support enum values in a oneof (see here).

Could you try adding an unknown=0; as the first member of DebugGameState?

Are there any additional error details? Stack trace, line numbers, etc.?

jhugard commented 7 years ago

@takemyoxygen could you add an enum to the oneof in type_provider_test.proto and write a unit test? Also might be useful to include the TypeProvider tests in the main Froto.sln.

takemyoxygen commented 7 years ago

@jhugard, I'll try to have a look on the weekend

EHotwagner commented 7 years ago

I will investigate further after the weekend. Thanks for taking a look.

jhugard commented 7 years ago

@EHotwagner PR #65 could probably be merged as-is to provide import support to the parser, but it's not hooked into the TypeProvider yet. @ctaggart I'd intended to do all of Issue #48 with that PR, but might be worth merging just for what it currently does.

ctaggart commented 7 years ago

Sounds good @jhugard.

EHotwagner commented 7 years ago

I did add unknown=0; with no effect. A basic proto file with only DebugCommand as a message and only DebugGameState in the oneof does work tough.

The error mesage i get is: "The type provider 'Froto.TypeProvider.ProtocolBuffersTypeProviderCreator' reported an error: Specified method is not supported."

Parse.fromFile genereates a nice Ast List tough. Is the roslyn example the current way of working without the TypeProvider?

jhugard commented 7 years ago

I would truly love to see you successful with F# and SC2: both are close to my heart. However, to be honest, while Froto may be useful for some base cases it still needs some attention to get it finished it up.

Froto has three approaches from three different authors: the TypeProvider, Roslyn code gen, and a model for source gen of either records or classes. The first two have some rough edges, and there isn't a released generator for the third.

If the TypeProvider isn't working for you, the Roslyn approach might be worth a try, but then again it might not support oneof.

As a last-ditch effort, the serializer record model is pretty simple to generate, so you could probably hand-write everything in the SC2 API in a few hours, but that kinda defeats the purpose of having an IDL. If you do go this route, let me know and I'll try to remember how oneof support works.

Some time back, as an experiment I wrote a plug-in for protoc.exe in golang which generated code using the record model. The result still needed hand editing to get it to compile, so was never released. It was a bit discouraging that the resulting DLL was not significantly smaller (in bytes) than generated C++ code, which was one of my main goals. On top of that, politically there was no way I'd be able to move the prototype into production, so never finished any of this up.

EHotwagner commented 7 years ago

Thanks a lot. This gives me enough points to start from.

takemyoxygen commented 7 years ago

@EHotwagner, @jhugard, I hope #72 should fix the NotSupported error. I tried to use the type provider with the proto from https://github.com/Blizzard/s2client-proto (compiled in one file, with syntax, package and import directives removed) and it worked fine. It still requires some work to implement import in the type provider.

EHotwagner commented 7 years ago

Great. Thx a lot.