EggEgg.CSharp-ProtoParser
1.1.1-rc50
This is a prerelease version of EggEgg.CSharp-ProtoParser.
dotnet add package EggEgg.CSharp-ProtoParser --version 1.1.1-rc50
NuGet\Install-Package EggEgg.CSharp-ProtoParser -Version 1.1.1-rc50
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EggEgg.CSharp-ProtoParser" Version="1.1.1-rc50" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EggEgg.CSharp-ProtoParser --version 1.1.1-rc50
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EggEgg.CSharp-ProtoParser, 1.1.1-rc50"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EggEgg.CSharp-ProtoParser as a Cake Addin #addin nuget:?package=EggEgg.CSharp-ProtoParser&version=1.1.1-rc50&prerelease // Install EggEgg.CSharp-ProtoParser as a Cake Tool #tool nuget:?package=EggEgg.CSharp-ProtoParser&version=1.1.1-rc50&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
csharp-protoparser
csharp-protoparser is a .proto file parser compatiable with go-protoparser.
Changelog
v1.1.1
- Supported Comments for fields, messages and enums definitions. Known issue: Comment before message definition's left curly will be lost (protoparser issue).
// Comment message AbilityActionBlink // This inline comment won't be parsed at all { // Inline comment behind left curly
v1.1.0
- Fixed the issue whereby
arm64
CPU arch devices are accidentally recognized asx64
CPU arch. - Fixed the issue whereby using multiple versions of this nuget on the same device may conflict with each other.
- Now
ProtoParser.ParseFromDirectoryAsync
support an optional parameterdirFilter
so as you can filter files with a certain pattern. - Added representation of
import
,package
andoption
inProtoResult
. You can refer toProtoResult
definition for more information. Notice the""
inimport
definitions will be wiped out (while inParse...AsRaw
it will not).
Breaking Changes
- Due to overloads' probable conflict, these methods of
ProtoParser
are renamed:ParseFromDirectoryAsync(string dirPath, string outputPath)
→ParseFromDirectoryAndOutputAsync(string dirPath, string outputPath, string dirFilter = "*.proto")
and its syncronous version.ParseFromFilesAsync(IEnumerable<string> fileList, string outputPath)
→ParseFromFilesAndOutputAsync(IEnumerable<string> fileList, string outputPath, string dirFilter = "*.proto")
and its syncronous version.
Usage
Simple:
using YYHEggEgg.ProtoParser;
using YYHEggEgg.ProtoParser.RawProtoHandler;
string protoText = @"<Fill in with a .proto file content>";
// Very simple parse.
ProtoJsonResult parseres = await ProtoParser.ParseFromTextAsync(protoText);
var files = new string[] { "file1.proto", "file2.proto" };
var filesParsed = await ProtoParser.ParseFromFilesAsync(files);
// The key of dictionary is the FULL PATH of the provided file(s)
// The value of dictionary is ProtoJsonResult
Console.WriteLine(JsonSerializer.Serialize(filesParsed["D:\\test\\protos\\file1.proto"]));
// Or you can let the input be a directory's all .proto files:
var dir = "test/protos";
// Returns a similar dictionary as below.
var dirParsed = await ProtoParser.ParseFromDirectoryAsync(dir, "*.proto");
// You may want to output content to directory, not memory:
await ProtoParser.ParseFromDirectoryAndOutputAsync(dir, "Proto2json_Output");
// But you need to process them yourself.
var dirParsedOne = ProtoJsonRawDataAnalyzer.AnalyzeRawProto(
JsonSerializer.Deserialize<Proto>(File.ReadAllText("D:\\Proto2json_Output\\file1.proto.json"))
// If needed, add param: 'ProtoContext.Default.Proto' to Deserialize to make it Aot compatiable (.NET 8.0+ only)
);
// Or you may dislike ProtoJsonResult; it's OK to use the original data structure from go-protoparser.
// Just add 'AsRaw' to methods' name.
Proto unorderedProto = await ProtoParser.ParseFromTextAsRawAsync(protoText);
// There're syncronous methods; but it's recommended to use asyncronous ones.
Proto unorderedProto2 = ProtoParser.ParseFromTextAsRaw(protoText);
Principle
The package simply packs built go-proto2json
inside, and extract the program from the embedded resources to a temp path when needed.
The package will check whether the program's SHA256 is correct before every run, so don't need to worry potential errors. By the way, invoke less times of methods (e.g. using ParseFromFilesAsync
with a file list instead of individual ParseFromTextAsync
calls) can make the performance better!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.1-rc50 | 7 | 8/20/2024 |
1.1.0-rc53 | 1 | 5/27/2024 |
1.1.0-rc52 | 21 | 5/6/2024 |
1.1.0-beta51 | 6 | 4/6/2024 |
1.1.0-beta50 | 10 | 3/6/2024 |
1.0.0-rc54 | 2 | 2/26/2024 |
1.0.0-rc53 | 2 | 2/26/2024 |
1.0.0-rc52 | 1 | 2/25/2024 |
1.0.0-dev03 | 2 | 2/22/2024 |
1.0.0-dev02 | 1 | 2/22/2024 |
1.0.0-dev01 | 2 | 2/22/2024 |
1.0.0-beta51 | 1 | 2/25/2024 |
1.0.0-beta50 | 2 | 2/23/2024 |
csharp-protoparser is a .proto file parser compatiable with go-protoparser.