-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protogen rewrite; initial scratch can parse descriptor.proto; once we…
… have the emit basics, all of these types will be backported to use the generated versions
- Loading branch information
Showing
21 changed files
with
1,664 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.IO; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ProtoBuf.Schemas | ||
{ | ||
public class SchemaTests | ||
{ | ||
private ITestOutputHelper _output; | ||
public SchemaTests(ITestOutputHelper output) => _output = output; | ||
[Theory] | ||
[InlineData(@"Schemas\descriptor.proto")] | ||
public void CanParse(string path) | ||
{ | ||
Schema schema; | ||
using (var proto = File.OpenText(path)) | ||
{ | ||
schema = Schema.Parse(proto); | ||
} | ||
foreach (var msg in schema.Messages) | ||
{ | ||
WriteMessage(msg, 0); | ||
} | ||
} | ||
private string Indent(int count) => new string(' ', count); | ||
private void WriteMessage(Message msg, int indent) | ||
{ | ||
_output.WriteLine($"{Indent(indent++)}{msg}"); | ||
foreach (var field in msg.Fields) | ||
{ | ||
_output.WriteLine($"{Indent(indent)}{field}"); | ||
} | ||
foreach (var res in msg.Reservations) | ||
{ | ||
_output.WriteLine($"{Indent(indent)}-{res}"); | ||
} | ||
foreach (var subMsg in msg.Messages) | ||
{ | ||
WriteMessage(subMsg, indent); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.