Skip to content

Commit

Permalink
Protogen rewrite; initial scratch can parse descriptor.proto; once we…
Browse files Browse the repository at this point in the history
… have the emit basics, all of these types will be backported to use the generated versions
  • Loading branch information
mgravell committed May 20, 2017
1 parent 354daf0 commit c22bd32
Show file tree
Hide file tree
Showing 21 changed files with 1,664 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Directory.build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.2.0</VersionPrefix>
<VersionPrefix>2.3.0</VersionPrefix>
<RootNamespace>ProtoBuf</RootNamespace>
<Authors>Marc Gravell</Authors>
<OutputType>Library</OutputType>
Expand Down
43 changes: 43 additions & 0 deletions src/protobuf-net.Test/Schemas/SchemaTests.cs
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);
}
}
}
}

0 comments on commit c22bd32

Please sign in to comment.