Test mutually recursive dependencies between nodes.

This commit is contained in:
Kuba Ober 2019-08-30 13:55:41 -04:00
parent 2460467fa4
commit 8b210d8b66
7 changed files with 54 additions and 3 deletions

View File

@ -129,5 +129,15 @@ namespace capnpc_csharp.Tests.Properties {
return ((byte[])(obj)); return ((byte[])(obj));
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] UnitTest4_capnp {
get {
object obj = ResourceManager.GetObject("UnitTest4_capnp", resourceCulture);
return ((byte[])(obj));
}
}
} }
} }

View File

@ -139,4 +139,7 @@
<data name="UnitTest11_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="UnitTest11_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UnitTest11.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>..\Resources\UnitTest11.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="UnitTest4_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UnitTest4.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root> </root>

Binary file not shown.

View File

@ -0,0 +1,16 @@
@0xf463d204f5208b43;
$import "/capnp/c++.capnp".namespace("UnitTest4");
interface Node {
getInfo @0 () -> Info;
}
struct Info {
node @0 :Node;
classes @1 :Classes;
}
struct Classes {
i1 @0 :import "UnitTest4b.capnp".I1.Classes;
i2 @1: Void;
}

View File

@ -0,0 +1,15 @@
@0x8151238e9f9884c8;
$import "/capnp/c++.capnp".namespace("UnitTest4");
using Base = import "UnitTest4.capnp";
interface I1 {
interface Node extends (Base.Node) {}
struct Classes {
sub @0: Sub;
}
struct Sub {
const prototype :Base.Classes = ( i1 = (sub = ()) );
data @0: Bool;
}
}

View File

@ -45,6 +45,13 @@ namespace CapnpC
// Should not throw // Should not throw
} }
[TestMethod]
public void Test04MutualDependencies()
{
LoadAndGenerate(Resources.UnitTest4_capnp, 4);
// Should not throw
}
[TestMethod] [TestMethod]
public void Test10ImportedNamespaces() public void Test10ImportedNamespaces()
{ {

View File

@ -688,7 +688,7 @@ namespace CapnpC.Model
{ {
var def = ProcessNode(id, state, true, tag); var def = ProcessNode(id, state, true, tag);
var typeDef = def as TypeDefinition; var typeDef = def as TypeDefinition;
if (def == null) if (typeDef == null)
throw new ArgumentException( throw new ArgumentException(
$"Expected node {id.StrId()} to be a TypeDefinition but got {def.GetType().Name} instead.", $"Expected node {id.StrId()} to be a TypeDefinition but got {def.GetType().Name} instead.",
nameof(id)); nameof(id));
@ -748,10 +748,10 @@ namespace CapnpC.Model
=> node.DisplayName.Substring((int)node.DisplayNamePrefixLength); => node.DisplayName.Substring((int)node.DisplayNamePrefixLength);
public static string StrId(this Schema.Node.Reader node) public static string StrId(this Schema.Node.Reader node)
=> $"0x{node.Id.ToString("X")}"; => $"0x{node.Id:X}";
public static string StrId(this ulong nodeId) public static string StrId(this ulong nodeId)
=> $"0x{nodeId.ToString("X")}"; => $"0x{nodeId:X}";
public static NodeKind GetKind(this Schema.Node.Reader node) public static NodeKind GetKind(this Schema.Node.Reader node)
{ {