Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions priv/protos/common_types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
syntax = "proto3";

package common;

// Common messages to be imported by other proto files

message Address {
string street = 1;
string city = 2;
string state = 3;
string postal_code = 4;
string country = 5;
}

message Coordinates {
double latitude = 1;
double longitude = 2;
double altitude = 3;
}

message Money {
string currency_code = 1;
int64 units = 2;
int32 nanos = 3;
}

enum Priority {
PRIORITY_UNSPECIFIED = 0;
LOW = 1;
MEDIUM = 2;
HIGH = 3;
CRITICAL = 4;
}

message TimeRange {
int64 start_time = 1;
int64 end_time = 2;
}
46 changes: 11 additions & 35 deletions priv/protos/custom_prefix_service.proto
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
syntax = "proto2";
syntax = "proto3";

import "google/protobuf/timestamp.proto";
import "google/protobuf/any.proto";

package testserviceV2;
package custom_prefix;

// This proto demonstrates Elixir-specific custom module prefix option
import "elixirpb.proto";
option (elixirpb.file).module_prefix = "HLW";

service TestService {
rpc CallFunction (TestRequest) returns (TestReply) {}
}

message TestRequest {
required string name = 1;
optional Enum enum = 2;
oneof test_oneof {
string label = 3;
int32 value = 4;
}
map<string, int32> g = 5;
repeated google.protobuf.Any instrument = 6;
extensions 10 to 20;
}

message Location {
optional double latitude = 1;
optional double longitude = 2;
}
option (elixirpb.file).module_prefix = "CustomPrefix";

extend TestRequest {
optional string data = 10;
optional Location location = 11;
// Simple service to test custom module prefix generation
service PrefixService {
rpc Echo (EchoRequest) returns (EchoResponse) {}
}

message TestReply {
required google.protobuf.Timestamp today = 2;
message EchoRequest {
string message = 1;
}

enum Enum {
A = 0;
B = 1;
message EchoResponse {
string reply = 1;
}
153 changes: 153 additions & 0 deletions priv/protos/edge_cases.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
syntax = "proto3";

package edge_cases;

// Empty service (no methods) - edge case
service EmptyService {
}

// Service with unusual but valid patterns
service EdgeCaseService {
// Method names with underscores and different conventions
rpc process_data (Request) returns (Response) {}
rpc ProcessData (Request) returns (Response) {}
rpc PROCESS_DATA (Request) returns (Response) {}

// Empty request or response
rpc EmptyInput (EmptyMessage) returns (Response) {}
rpc EmptyOutput (Request) returns (EmptyMessage) {}
rpc BothEmpty (EmptyMessage) returns (EmptyMessage) {}
}

message EmptyMessage {
// Intentionally empty message
}

message Request {
string data = 1;
}

message Response {
string result = 1;
}

// Unusual field numbering
message SparseFieldNumbers {
string field_1 = 1;
string field_536870911 = 536870911; // Max field number (2^29 - 1)
}

// Many fields
message ManyFields {
string field_001 = 1;
string field_002 = 2;
string field_003 = 3;
string field_004 = 4;
string field_005 = 5;
string field_006 = 6;
string field_007 = 7;
string field_008 = 8;
string field_009 = 9;
string field_010 = 10;
string field_011 = 11;
string field_012 = 12;
string field_013 = 13;
string field_014 = 14;
string field_015 = 15;
string field_016 = 16;
string field_017 = 17;
string field_018 = 18;
string field_019 = 19;
string field_020 = 20;
}

// Complex enum
enum DetailedStatus {
// Enum with zero value (required in proto3)
DETAILED_STATUS_UNSPECIFIED = 0;

// Various naming patterns
status_active = 1;
STATUS_INACTIVE = 2;
Status_Pending = 3;

// Negative enum values (valid but unusual)
ERROR_STATE = -1;
CRITICAL_ERROR = -100;

// Large enum values
MAX_STATUS = 2147483647; // Max int32
}

// Multiple oneofs in one message
message MultipleOneofs {
oneof first_choice {
string option_a1 = 1;
int32 option_a2 = 2;
}

oneof second_choice {
string option_b1 = 3;
int32 option_b2 = 4;
}

oneof third_choice {
string option_c1 = 5;
int32 option_c2 = 6;
}

string regular_field = 7;
}

// Nested maps
message NestedMaps {
map<string, InnerMap> outer_map = 1;
map<int32, string> int_key_map = 2;
map<int64, int64> numeric_map = 3;
map<bool, string> bool_key_map = 4;
}

message InnerMap {
map<string, string> data = 1;
map<string, int32> counts = 2;
}

// Circular reference patterns (different from recursive_message.proto)
message CircularA {
CircularB b_field = 1;
string data = 2;
}

message CircularB {
CircularC c_field = 1;
string data = 2;
}

message CircularC {
CircularA a_field = 1;
string data = 2;
}

// Reserved with various patterns
message WithReservedFields {
string active_field_1 = 1;

reserved 2, 15, 9 to 11;
reserved "foo", "bar", "old_field";

string active_field_16 = 16;

reserved 100 to max;
}

// Unicode and special characters in comments
message UnicodeTest {
// Field with emoji in comment: 🚀 rocket
string rocket_field = 1;

// Mathematical symbols: ∑ ∫ π
double pi_field = 2;

// Various languages: 你好 مرحبا שלום
string greeting = 3;
}
5 changes: 0 additions & 5 deletions priv/protos/empty_service.proto

This file was deleted.

27 changes: 0 additions & 27 deletions priv/protos/helloworld.proto

This file was deleted.

63 changes: 63 additions & 0 deletions priv/protos/imports_test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
syntax = "proto3";

package imports_test;

// Import from local proto file
import "common_types.proto";

// Import from google protos
import "google/protobuf/timestamp.proto";

// Service demonstrating cross-file type usage
service ImportTestService {
rpc CreateUser (UserRequest) returns (UserResponse) {}
rpc UpdateLocation (LocationUpdate) returns (LocationResponse) {}
}

message UserRequest {
string name = 1;
string email = 2;

// Using imported type from common_types.proto
common.Address address = 3;
common.Coordinates location = 4;

// Using imported google type
google.protobuf.Timestamp registered_at = 5;
}

message UserResponse {
string user_id = 1;
common.Priority priority = 2;
google.protobuf.Timestamp created_at = 3;

// Nested message that uses imported types
message Profile {
common.Address billing_address = 1;
common.Address shipping_address = 2;
repeated common.Coordinates recent_locations = 3;
}

Profile profile = 4;
}

message LocationUpdate {
string user_id = 1;
common.Coordinates new_location = 2;
google.protobuf.Timestamp timestamp = 3;
}

message LocationResponse {
bool success = 1;
common.Coordinates confirmed_location = 2;

// Map using imported types
map<string, common.TimeRange> visit_history = 3;
}

// Message demonstrating repeated imported types
message BulkOperation {
repeated common.Address addresses = 1;
repeated common.Money transactions = 2;
map<string, common.Priority> task_priorities = 3;
}
Loading