This commit is contained in:
Xpl0itR 2023-05-02 18:23:30 +01:00
parent 3fe8077e7f
commit 253983430d
Signed by: Xpl0itR
GPG Key ID: 91798184109676AD
3 changed files with 16 additions and 15 deletions

View File

@ -6,13 +6,13 @@ using protodec;
const string indent = " ";
const string help = """
Usage: protodec(.exe) [options] <target_assembly_path> <out_path>
Options:
--skip_enums Skip parsing enums and replace references to then with int32.
--include_runtime_assemblies Add the assemblies of the current runtime to the search path.
Usage: protodec(.exe) <target_assembly_path> <out_path> [options]
Arguments:
target_assembly_path Either a single assembly or a directory of assemblies to be parsed.
out_path An existing directory to output into individual files, otherwise output to a single file.
Options:
--skip_enums Skip parsing enums and replace references to then with int32.
--include_runtime_assemblies Add the assemblies of the current runtime to the search path.
""";
if (args.Length < 2)

View File

@ -97,9 +97,9 @@ public sealed class Protodec
else
{
ParseMessage(type, skipEnums);
message.Imports.Add(type.Name);
}
message.Imports.Add(type.Name);
return type.Name;
}
}
@ -120,7 +120,7 @@ public sealed class Protodec
?.ConstructorArguments[0]
.Value
as string
?? TranslateEnumFieldName(field.Name);
?? TranslateEnumFieldName(enumEnum.Name, field.Name);
protoEnum.Fields.Add(enumFieldId, enumFieldName);
}
@ -131,7 +131,6 @@ public sealed class Protodec
}
else
{
message.Imports.Add(protoEnum.Name);
Enums.Add(protoEnum.Name, protoEnum);
}
}
@ -161,8 +160,10 @@ public sealed class Protodec
name.IsBeebyted() ? name : name.ToSnakeCaseLower();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static string TranslateEnumFieldName(string name) =>
name.IsBeebyted() ? name : name.ToSnakeCaseUpper();
private static string TranslateEnumFieldName(string enumName, string fieldName) =>
enumName.IsBeebyted()
? enumName + '_' + fieldName.ToSnakeCaseUpper()
: (enumName + fieldName).ToSnakeCaseUpper();
private bool TryParseWriteToMethod(Type targetClass)
{

View File

@ -5,14 +5,14 @@ A tool to decompile protobuf parser/serializer classes compiled by [protoc](http
Usage
-----
```
Usage: protodec(.exe) [options] <target_assembly_path> <out_path>
Options:
--skip_enums Skip parsing enums and replace references to then with int32.
--include_runtime_assemblies Add the assemblies of the current runtime to the search path.
Usage: protodec(.exe) <target_assembly_path> <out_path> [options]
Arguments:
target_assembly_path Either a single assembly or a directory of assemblies to be parsed.
out_path An existing directory to output into individual files, otherwise output to a single file.
```
Options:
--skip_enums Skip parsing enums and replace references to then with int32.
--include_runtime_assemblies Add the assemblies of the current runtime to the search path.
```
Limitations
-----------