EggEgg.CSharp-ProtoParser
1.1.0
dotnet add package EggEgg.CSharp-ProtoParser --version 1.1.0
NuGet\Install-Package EggEgg.CSharp-ProtoParser -Version 1.1.0
<PackageReference Include="EggEgg.CSharp-ProtoParser" Version="1.1.0" />
paket add EggEgg.CSharp-ProtoParser --version 1.1.0
#r "nuget: EggEgg.CSharp-ProtoParser, 1.1.0"
// Install EggEgg.CSharp-ProtoParser as a Cake Addin #addin nuget:?package=EggEgg.CSharp-ProtoParser&version=1.1.0 // Install EggEgg.CSharp-ProtoParser as a Cake Tool #tool nuget:?package=EggEgg.CSharp-ProtoParser&version=1.1.0
csharp-protoparser
csharp-protoparser is a .proto file parser compatiable with go-protoparser.
Changelog
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. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
csharp-protoparser is a .proto file parser compatiable with go-protoparser.