mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
Merge branch 'master' of https://github.com/c80k/capnproto-dotnetcore
This commit is contained in:
commit
dbe6c29f8b
14
README.md
14
README.md
@ -1,4 +1,5 @@
|
|||||||
# capnproto-dotnetcore
|
# capnproto-dotnetcore [](https://ci.appveyor.com/project/c80k/capnproto-dotnetcore/branch/master)
|
||||||
|
|
||||||
A Cap'n Proto implementation for .NET Standard 2.0 (credits to [lostinplace](https://github.com/lostinplace)) and .NET Core 2.1.
|
A Cap'n Proto implementation for .NET Standard 2.0 (credits to [lostinplace](https://github.com/lostinplace)) and .NET Core 2.1.
|
||||||
|
|
||||||
["Cap'n Proto is an insanely fast data interchange format and capability-based RPC system."](https://capnproto.org/) Whilst the original implementation is written in C++ there are several ports to other languages. This is a C# implementation for .NET Core.
|
["Cap'n Proto is an insanely fast data interchange format and capability-based RPC system."](https://capnproto.org/) Whilst the original implementation is written in C++ there are several ports to other languages. This is a C# implementation for .NET Core.
|
||||||
@ -13,9 +14,7 @@ The overall deployment consists of two components:
|
|||||||
|
|
||||||
### Code generator back end: Windows
|
### Code generator back end: Windows
|
||||||
|
|
||||||
Disclaimer: The mid-term goal is to provide the C# code generator backend as Chocolatey package. It turns out that setting up a correct package verification process (which is a requirement for package approval) requires more effort than expected. See [Issue: Not on Chocolatey](https://github.com/c80k/capnproto-dotnetcore/issues/6) for instructions on how to create and install the package locally. Read on to get an impression on how it's supposed to work in the future.
|
The C# code generator back end is available as [Chocolatey](https://chocolatey.org/) package. You may choose between two flavors: The portable version requires a .NET Core 2.1 (or higher) runtime or SDK (type `dotnet` at command line prompt to check whether you already have one). This is the recommended variant. To install, type
|
||||||
|
|
||||||
The C# code generator back end will be available as [Chocolatey](https://chocolatey.org/) package. You may choose between two flavors: The portable version requires a .NET Core 2.1 (or higher) runtime or SDK (type `dotnet` at command line prompt to check whether you already have one). This is the recommended variant. To install, type
|
|
||||||
|
|
||||||
```
|
```
|
||||||
choco install capnpc-csharp
|
choco install capnpc-csharp
|
||||||
@ -50,10 +49,11 @@ vcpkg install capnproto
|
|||||||
```
|
```
|
||||||
|
|
||||||
Solution/project structure is as follows:
|
Solution/project structure is as follows:
|
||||||
- Capnp.Net.sln contains three projects:
|
- Capnp.Net.sln contains these projects:
|
||||||
* Capnp.Net.Runtime is the runtime implementation, a .NET assembly.
|
* Capnp.Net.Runtime is the runtime implementation, a .NET assembly.
|
||||||
* capnpc-csharp is the compiler backend for C# language
|
* capnpc-csharp is the generator backend for C# language.
|
||||||
* Capnp.Net.Runtime.Tests is an MS Unit Testing assembly, containing - you guessed it - the test suite
|
* Capnp.Net.Runtime.Tests is an MS Unit Testing assembly, containing - you guessed it - the test suite.
|
||||||
|
* capnpc-csharp.tests contains the generator backend test suite.
|
||||||
- CapnpCompatTest.sln compiles to a native x86 executable which depends on the original Cap'n Proto C++ implementation. It is (partially) required by the test suite for interoperability testing.
|
- CapnpCompatTest.sln compiles to a native x86 executable which depends on the original Cap'n Proto C++ implementation. It is (partially) required by the test suite for interoperability testing.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using capnpc_csharp.Tests.Properties;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -17,7 +16,7 @@ namespace capnpc_csharp.Tests
|
|||||||
bool _success;
|
bool _success;
|
||||||
Exception _generateException;
|
Exception _generateException;
|
||||||
|
|
||||||
Stream LoadResource(string name)
|
internal static Stream LoadResource(string name)
|
||||||
{
|
{
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
string[] names = assembly.GetManifestResourceNames();
|
string[] names = assembly.GetManifestResourceNames();
|
||||||
|
143
capnpc-csharp.tests/Properties/Resources.Designer.cs
generated
143
capnpc-csharp.tests/Properties/Resources.Designer.cs
generated
@ -1,143 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Dieser Code wurde von einem Tool generiert.
|
|
||||||
// Laufzeitversion:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
|
||||||
// der Code erneut generiert wird.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace capnpc_csharp.Tests.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
|
||||||
/// </summary>
|
|
||||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
|
||||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
|
||||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
|
||||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("capnpc_csharp.Tests.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
|
||||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] schema_with_offsets_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("schema_with_offsets_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest1_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest1_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest10_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest10_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest11_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest11_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest2_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest2_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest20_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest20_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest3_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest3_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
internal static byte[] UnitTest4_capnp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("UnitTest4_capnp", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="UnitTest10_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\UnitTest10.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<data name="UnitTest20_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\UnitTest20.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<data name="UnitTest3_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\UnitTest3.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<data name="UnitTest2_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\UnitTest2.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<data name="UnitTest1_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\UnitTest1.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<data name="schema_with_offsets_capnp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\schema-with-offsets.capnp.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<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>
|
|
||||||
</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>
|
|
Binary file not shown.
@ -1,29 +1,30 @@
|
|||||||
using capnpc_csharp.Tests.Properties;
|
|
||||||
using Capnp;
|
using Capnp;
|
||||||
|
using Model = CapnpC.Model;
|
||||||
|
using Generator = CapnpC.Generator;
|
||||||
|
using CodeGeneratorRequest = CapnpC.Schema.CodeGeneratorRequest;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace CapnpC
|
namespace capnpc_csharp.Tests
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTests
|
public class CodeGeneratorUnitTests
|
||||||
{
|
{
|
||||||
static readonly Dictionary<int, string> GeneratedCode = new Dictionary<int, string>();
|
static readonly Dictionary<int, string> GeneratedCode = new Dictionary<int, string>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test00Enumerant()
|
public void Test00Enumerant()
|
||||||
{
|
{
|
||||||
var model = Load(Resources.UnitTest1_capnp);
|
var model = Load("UnitTest1.capnp.bin");
|
||||||
Assert.AreEqual("@byte", GetTypeDef(0xc8461867c409f5d4, model).Enumerants[0].Literal);
|
Assert.AreEqual("@byte", GetTypeDef(0xc8461867c409f5d4, model).Enumerants[0].Literal);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test01NestedClash()
|
public void Test01NestedClash()
|
||||||
{
|
{
|
||||||
var run = LoadAndGenerate(Resources.UnitTest1_capnp, 1);
|
var run = LoadAndGenerate("UnitTest1.capnp.bin", 1);
|
||||||
var structFoo = GetTypeDef(0x93db6ba5509bac24, run.Model);
|
var structFoo = GetTypeDef(0x93db6ba5509bac24, run.Model);
|
||||||
var names = run.CodeGen.GetNames();
|
var names = run.CodeGen.GetNames();
|
||||||
var fieldName = names.GetCodeIdentifier(structFoo.Fields[0]).ToString();
|
var fieldName = names.GetCodeIdentifier(structFoo.Fields[0]).ToString();
|
||||||
@ -34,28 +35,28 @@ namespace CapnpC
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test02ForwardInheritance()
|
public void Test02ForwardInheritance()
|
||||||
{
|
{
|
||||||
LoadAndGenerate(Resources.UnitTest2_capnp, 2);
|
LoadAndGenerate("UnitTest2.capnp.bin", 2);
|
||||||
// Should not throw
|
// Should not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test03NonGeneratedNodeSkip()
|
public void Test03NonGeneratedNodeSkip()
|
||||||
{
|
{
|
||||||
LoadAndGenerate(Resources.UnitTest3_capnp, 3);
|
LoadAndGenerate("UnitTest3.capnp.bin", 3);
|
||||||
// Should not throw
|
// Should not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test04MutualDependencies()
|
public void Test04MutualDependencies()
|
||||||
{
|
{
|
||||||
LoadAndGenerate(Resources.UnitTest4_capnp, 4);
|
LoadAndGenerate("UnitTest4.capnp.bin", 4);
|
||||||
// Should not throw
|
// Should not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test10ImportedNamespaces()
|
public void Test10ImportedNamespaces()
|
||||||
{
|
{
|
||||||
var run = LoadAndGenerate(Resources.UnitTest10_capnp, 10);
|
var run = LoadAndGenerate("UnitTest10.capnp.bin", 10);
|
||||||
var outerTypeDef = run.FirstFile.NestedTypes.First();
|
var outerTypeDef = run.FirstFile.NestedTypes.First();
|
||||||
var outerType = Model.Types.FromDefinition(outerTypeDef);
|
var outerType = Model.Types.FromDefinition(outerTypeDef);
|
||||||
var innerType = outerTypeDef.Fields[0].Type;
|
var innerType = outerTypeDef.Fields[0].Type;
|
||||||
@ -76,21 +77,21 @@ namespace CapnpC
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test11ImportedConst()
|
public void Test11ImportedConst()
|
||||||
{
|
{
|
||||||
LoadAndGenerate(Resources.UnitTest11_capnp, 11);
|
LoadAndGenerate("UnitTest11.capnp.bin", 11);
|
||||||
// Should not throw
|
// Should not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test20AnnotationAndConst()
|
public void Test20AnnotationAndConst()
|
||||||
{
|
{
|
||||||
LoadAndGenerate(Resources.UnitTest20_capnp, 20);
|
LoadAndGenerate("UnitTest20.capnp.bin", 20);
|
||||||
// Should not throw
|
// Should not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Test30SchemaCapnp()
|
public void Test30SchemaCapnp()
|
||||||
{
|
{
|
||||||
LoadAndGenerate(Resources.schema_with_offsets_capnp);
|
LoadAndGenerate("schema-with-offsets.capnp.bin");
|
||||||
// Should not throw
|
// Should not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,10 +106,10 @@ namespace CapnpC
|
|||||||
static Generator.CodeGenerator NewGeneratorFor(Model.SchemaModel model)
|
static Generator.CodeGenerator NewGeneratorFor(Model.SchemaModel model)
|
||||||
=> new Generator.CodeGenerator(model, new Generator.GeneratorOptions());
|
=> new Generator.CodeGenerator(model, new Generator.GeneratorOptions());
|
||||||
|
|
||||||
Run LoadAndGenerate(byte[] input, int? testNum = null)
|
Run LoadAndGenerate(string inputName, int? testNum = null)
|
||||||
{
|
{
|
||||||
var run = new Run();
|
var run = new Run();
|
||||||
run.Model = Load(input);
|
run.Model = Load(inputName);
|
||||||
run.CodeGen = NewGeneratorFor(run.Model);
|
run.CodeGen = NewGeneratorFor(run.Model);
|
||||||
run.FirstFile = run.Model.FilesToGenerate.First();
|
run.FirstFile = run.Model.FilesToGenerate.First();
|
||||||
run.Code = run.CodeGen.Transform(run.FirstFile);
|
run.Code = run.CodeGen.Transform(run.FirstFile);
|
||||||
@ -137,16 +138,16 @@ namespace CapnpC
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Model.SchemaModel Load(byte[] data)
|
static Model.SchemaModel Load(string inputName)
|
||||||
{
|
{
|
||||||
WireFrame segments;
|
WireFrame segments;
|
||||||
var input = new MemoryStream(data);
|
var input = CodeGeneratorSteps.LoadResource(inputName);
|
||||||
using (input)
|
using (input)
|
||||||
{
|
{
|
||||||
segments = Framing.ReadSegments(input);
|
segments = Framing.ReadSegments(input);
|
||||||
}
|
}
|
||||||
var dec = DeserializerState.CreateRoot(segments);
|
var dec = DeserializerState.CreateRoot(segments);
|
||||||
var reader = Schema.CodeGeneratorRequest.Reader.Create(dec);
|
var reader = CodeGeneratorRequest.Reader.Create(dec);
|
||||||
var model = Model.SchemaModel.Create(reader);
|
var model = Model.SchemaModel.Create(reader);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="*.cs" />
|
<Compile Remove="*.cs" />
|
||||||
<Compile Remove="Embedded Resources\test.cs" />
|
<Compile Remove="Embedded Resources\test.cs" />
|
||||||
<Compile Remove="Resources\test.cs" />
|
|
||||||
<None Remove="Embedded Resources\null.bin" />
|
<None Remove="Embedded Resources\null.bin" />
|
||||||
<None Remove="Embedded Resources\test.capnp" />
|
<None Remove="Embedded Resources\test.capnp" />
|
||||||
<None Remove="Embedded Resources\test.capnp.bin" />
|
<None Remove="Embedded Resources\test.capnp.bin" />
|
||||||
@ -38,21 +37,14 @@
|
|||||||
<EmbeddedResource Include="Embedded Resources\null.bin" />
|
<EmbeddedResource Include="Embedded Resources\null.bin" />
|
||||||
<EmbeddedResource Include="Embedded Resources\test.capnp.bin" />
|
<EmbeddedResource Include="Embedded Resources\test.capnp.bin" />
|
||||||
<EmbeddedResource Include="Embedded Resources\test.cs" />
|
<EmbeddedResource Include="Embedded Resources\test.cs" />
|
||||||
</ItemGroup>
|
<EmbeddedResource Include="Embedded Resources\UnitTest1.capnp.bin" />
|
||||||
|
<EmbeddedResource Include="Embedded Resources\UnitTest2.capnp.bin" />
|
||||||
<ItemGroup>
|
<EmbeddedResource Include="Embedded Resources\UnitTest3.capnp.bin" />
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<EmbeddedResource Include="Embedded Resources\UnitTest4.capnp.bin" />
|
||||||
<DesignTime>True</DesignTime>
|
<EmbeddedResource Include="Embedded Resources\UnitTest10.capnp.bin" />
|
||||||
<AutoGen>True</AutoGen>
|
<EmbeddedResource Include="Embedded Resources\UnitTest11.capnp.bin" />
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<EmbeddedResource Include="Embedded Resources\UnitTest20.capnp.bin" />
|
||||||
</Compile>
|
<EmbeddedResource Include="Embedded Resources\schema-with-offsets.capnp.bin" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user