mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
Fixed broken .gitignore
This commit is contained in:
parent
ede2441008
commit
edb30a7bce
1
.gitignore
vendored
1
.gitignore
vendored
@ -336,4 +336,3 @@ ASALocalRun/
|
||||
# Capnp code behind
|
||||
.capnp.cs
|
||||
/globalPackages
|
||||
*.cs
|
||||
|
4
CapnpC.CSharp.MsBuild.Generation/AssemblyAttributes.cs
Normal file
4
CapnpC.CSharp.MsBuild.Generation/AssemblyAttributes.cs
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security;
|
||||
|
99
CapnpC.CSharp.MsBuild.Generation/CapnpCodeBehindGenerator.cs
Normal file
99
CapnpC.CSharp.MsBuild.Generation/CapnpCodeBehindGenerator.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using CapnpC.CSharp.Generator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public class CapnpCodeBehindGenerator : IDisposable
|
||||
{
|
||||
|
||||
public void InitializeProject(string projectPath)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public CsFileGeneratorResult GenerateCodeBehindFile(CapnpGenJob job)
|
||||
{
|
||||
string capnpFile = job.CapnpPath;
|
||||
|
||||
// Works around a weird capnp.exe behavior: When the input file is empty, it will spit out an exception dump
|
||||
// instead of a parse error. But the parse error is nice because it contains a generated ID. We want the parse error!
|
||||
// Workaround: Generate a temporary file that contains a single line break (such that it is not empty...)
|
||||
try
|
||||
{
|
||||
if (File.Exists(capnpFile) && new FileInfo(capnpFile).Length == 0)
|
||||
{
|
||||
string tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".capnp");
|
||||
|
||||
File.WriteAllText(tempFile, Environment.NewLine);
|
||||
try
|
||||
{
|
||||
var jobCopy = new CapnpGenJob()
|
||||
{
|
||||
CapnpPath = tempFile,
|
||||
WorkingDirectory = job.WorkingDirectory
|
||||
};
|
||||
|
||||
jobCopy.AdditionalArguments.AddRange(job.AdditionalArguments);
|
||||
|
||||
return GenerateCodeBehindFile(jobCopy);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
var args = new List<string>();
|
||||
args.AddRange(job.AdditionalArguments);
|
||||
args.Add(capnpFile);
|
||||
|
||||
var result = CapnpCompilation.InvokeCapnpAndGenerate(args, job.WorkingDirectory);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
if (result.GeneratedFiles.Count == 1)
|
||||
{
|
||||
return new CsFileGeneratorResult(
|
||||
result.GeneratedFiles[0],
|
||||
capnpFile + ".cs",
|
||||
result.Messages);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CsFileGeneratorResult(
|
||||
"Code generation produced more than one file. This is not supported.",
|
||||
result.Messages);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (result.ErrorCategory)
|
||||
{
|
||||
case CapnpProcessFailure.NotFound:
|
||||
return new CsFileGeneratorResult("Unable to find capnp.exe - please install capnproto on your system first.");
|
||||
|
||||
case CapnpProcessFailure.BadInput:
|
||||
return new CsFileGeneratorResult("Invalid schema", result.Messages);
|
||||
|
||||
case CapnpProcessFailure.BadOutput:
|
||||
return new CsFileGeneratorResult(
|
||||
"Internal error: capnp.exe produced a binary code generation request which was not understood by the backend",
|
||||
result.Messages);
|
||||
|
||||
default:
|
||||
throw new NotSupportedException("Invalid error category");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public class CapnpFileCodeBehindGenerator : ICapnpcCsharpGenerator
|
||||
{
|
||||
public CapnpFileCodeBehindGenerator(TaskLoggingHelper log)
|
||||
{
|
||||
Log = log ?? throw new ArgumentNullException(nameof(log));
|
||||
}
|
||||
|
||||
public TaskLoggingHelper Log { get; }
|
||||
|
||||
public IEnumerable<string> GenerateFilesForProject(
|
||||
string projectPath,
|
||||
List<CapnpGenJob> capnpFiles,
|
||||
string projectFolder)
|
||||
{
|
||||
using (var capnpCodeBehindGenerator = new CapnpCodeBehindGenerator())
|
||||
{
|
||||
capnpCodeBehindGenerator.InitializeProject(projectPath);
|
||||
|
||||
var codeBehindWriter = new CodeBehindWriter(null);
|
||||
|
||||
if (capnpFiles == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var genJob in capnpFiles)
|
||||
{
|
||||
Log.LogMessage(MessageImportance.Normal, "Generate {0}, working dir = {1}, options = {2}",
|
||||
genJob.CapnpPath,
|
||||
genJob.WorkingDirectory,
|
||||
string.Join(" ", genJob.AdditionalArguments));
|
||||
|
||||
var generatorResult = capnpCodeBehindGenerator.GenerateCodeBehindFile(genJob);
|
||||
|
||||
if (!generatorResult.Success)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(generatorResult.Error))
|
||||
{
|
||||
Log.LogError("{0}", generatorResult.Error);
|
||||
}
|
||||
|
||||
if (generatorResult.Messages != null)
|
||||
{
|
||||
foreach (var message in generatorResult.Messages)
|
||||
{
|
||||
if (message.IsParseSuccess)
|
||||
{
|
||||
Log.LogError(
|
||||
subcategory: null,
|
||||
errorCode: null,
|
||||
helpKeyword: null,
|
||||
file: genJob.CapnpPath,
|
||||
lineNumber: message.Line,
|
||||
columnNumber: message.Column,
|
||||
endLineNumber: message.Line,
|
||||
endColumnNumber: message.EndColumn == 0 ? message.Column : message.EndColumn,
|
||||
"{0}",
|
||||
message.MessageText);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.LogError("{0}", message.FullMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var resultedFile = codeBehindWriter.WriteCodeBehindFile(generatorResult.Filename, generatorResult);
|
||||
|
||||
yield return FileSystemHelper.GetRelativePath(resultedFile, projectFolder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
CapnpC.CSharp.MsBuild.Generation/CapnpGenJob.cs
Normal file
11
CapnpC.CSharp.MsBuild.Generation/CapnpGenJob.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public class CapnpGenJob
|
||||
{
|
||||
public string CapnpPath { get; set; }
|
||||
public string WorkingDirectory { get; set; }
|
||||
public List<string> AdditionalArguments { get; } = new List<string>();
|
||||
}
|
||||
}
|
38
CapnpC.CSharp.MsBuild.Generation/CodeBehindWriter.cs
Normal file
38
CapnpC.CSharp.MsBuild.Generation/CodeBehindWriter.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public class CodeBehindWriter
|
||||
{
|
||||
public CodeBehindWriter(TaskLoggingHelper log)
|
||||
{
|
||||
Log = log;
|
||||
}
|
||||
|
||||
public TaskLoggingHelper Log { get; }
|
||||
|
||||
public string WriteCodeBehindFile(string outputPath, CsFileGeneratorResult testFileGeneratorResult)
|
||||
{
|
||||
string directoryPath = Path.GetDirectoryName(outputPath) ?? throw new InvalidOperationException();
|
||||
Log?.LogWithNameTag(Log.LogMessage, directoryPath);
|
||||
|
||||
Log?.LogWithNameTag(Log.LogMessage, $"Writing data to {outputPath}; path = {directoryPath}; generatedFilename = {testFileGeneratorResult.Filename}");
|
||||
|
||||
if (File.Exists(outputPath))
|
||||
{
|
||||
if (!FileSystemHelper.FileCompareContent(outputPath, testFileGeneratorResult.GeneratedCode))
|
||||
{
|
||||
File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode);
|
||||
}
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
}
|
51
CapnpC.CSharp.MsBuild.Generation/CsFileGeneratorResult.cs
Normal file
51
CapnpC.CSharp.MsBuild.Generation/CsFileGeneratorResult.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using CapnpC.CSharp.Generator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public class CsFileGeneratorResult
|
||||
{
|
||||
public CsFileGeneratorResult(FileGenerationResult generatorResult, string fileName, IReadOnlyList<CapnpMessage> messages)
|
||||
{
|
||||
if (generatorResult == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(generatorResult));
|
||||
}
|
||||
|
||||
Filename = fileName ?? throw new ArgumentNullException(nameof(fileName));
|
||||
|
||||
Error = generatorResult.Exception?.Message;
|
||||
GeneratedCode = generatorResult.GeneratedContent;
|
||||
Messages = messages;
|
||||
}
|
||||
|
||||
public CsFileGeneratorResult(string error)
|
||||
{
|
||||
Error = error;
|
||||
}
|
||||
|
||||
public CsFileGeneratorResult(string error, IReadOnlyList<CapnpMessage> messages)
|
||||
{
|
||||
Error = error;
|
||||
Messages = messages;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The error, if any.
|
||||
/// </summary>
|
||||
public string Error { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The generated code.
|
||||
/// </summary>
|
||||
public string GeneratedCode { get; }
|
||||
|
||||
public IReadOnlyList<CapnpMessage> Messages { get; }
|
||||
|
||||
public bool Success => Error == null;
|
||||
|
||||
public string Filename { get; }
|
||||
}
|
||||
}
|
112
CapnpC.CSharp.MsBuild.Generation/FileSystemHelper.cs
Normal file
112
CapnpC.CSharp.MsBuild.Generation/FileSystemHelper.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public static class FileSystemHelper
|
||||
{
|
||||
public static void CopyFileToFolder(string filePath, string folderName)
|
||||
{
|
||||
File.Copy(filePath, Path.Combine(folderName, Path.GetFileName(filePath)));
|
||||
}
|
||||
|
||||
public static string GetRelativePath(string path, string basePath)
|
||||
{
|
||||
path = Path.GetFullPath(path);
|
||||
basePath = Path.GetFullPath(basePath);
|
||||
if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase))
|
||||
return "."; // the "this folder"
|
||||
|
||||
if (path.StartsWith(basePath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
|
||||
return path.Substring(basePath.Length + 1);
|
||||
|
||||
//handle different drives
|
||||
string pathRoot = Path.GetPathRoot(path);
|
||||
if (!String.Equals(pathRoot, Path.GetPathRoot(basePath), StringComparison.OrdinalIgnoreCase))
|
||||
return path;
|
||||
|
||||
//handle ".." pathes
|
||||
string[] pathParts = path.Substring(pathRoot.Length).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
string[] basePathParts = basePath.Substring(pathRoot.Length).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
|
||||
int commonFolderCount = 0;
|
||||
while (commonFolderCount < pathParts.Length && commonFolderCount < basePathParts.Length &&
|
||||
String.Equals(pathParts[commonFolderCount], basePathParts[commonFolderCount], StringComparison.OrdinalIgnoreCase))
|
||||
commonFolderCount++;
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < basePathParts.Length - commonFolderCount; i++)
|
||||
{
|
||||
result.Append("..");
|
||||
result.Append(Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
if (pathParts.Length - commonFolderCount == 0)
|
||||
return result.ToString().TrimEnd(Path.DirectorySeparatorChar);
|
||||
|
||||
result.Append(String.Join(Path.DirectorySeparatorChar.ToString(), pathParts, commonFolderCount, pathParts.Length - commonFolderCount));
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
// This method accepts two strings the represent two files to
|
||||
// compare. A return value of true indicates that the contents of the files
|
||||
// are the same. A return value of any other value indicates that the
|
||||
// files are not the same.
|
||||
public static bool FileCompare(string filePath1, string filePath2)
|
||||
{
|
||||
int file1byte;
|
||||
int file2byte;
|
||||
|
||||
// Determine if the same file was referenced two times.
|
||||
if (String.Equals(filePath1, filePath2, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
// Return true to indicate that the files are the same.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Open the two files.
|
||||
using (FileStream fs1 = new FileStream(filePath1, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using (FileStream fs2 = new FileStream(filePath2, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
// Check the file sizes. If they are not the same, the files
|
||||
// are not the same.
|
||||
if (fs1.Length != fs2.Length)
|
||||
{
|
||||
// Return false to indicate files are different
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read and compare a byte from each file until either a
|
||||
// non-matching set of bytes is found or until the end of
|
||||
// file1 is reached.
|
||||
do
|
||||
{
|
||||
// Read one byte from each file.
|
||||
file1byte = fs1.ReadByte();
|
||||
file2byte = fs2.ReadByte();
|
||||
} while ((file1byte == file2byte) && (file1byte != -1));
|
||||
}
|
||||
}
|
||||
// Return the success of the comparison. "file1byte" is
|
||||
// equal to "file2byte" at this point only if the files are
|
||||
// the same.
|
||||
return ((file1byte - file2byte) == 0);
|
||||
}
|
||||
|
||||
// This method accepts two strings the represent two files to
|
||||
// compare. A return value of true indicates that the contents of the files
|
||||
// are the same. A return value of any other value indicates that the
|
||||
// files are not the same.
|
||||
public static bool FileCompareContent(string filePath1, string fileContent)
|
||||
{
|
||||
var currentFileContent = File.ReadAllText(filePath1);
|
||||
|
||||
return string.CompareOrdinal(currentFileContent, fileContent) == 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Resources;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public class GenerateCapnpFileCodeBehindTask : Task
|
||||
{
|
||||
public GenerateCapnpFileCodeBehindTask()
|
||||
{
|
||||
CodeBehindGenerator = new CapnpFileCodeBehindGenerator(Log);
|
||||
}
|
||||
|
||||
public ICapnpcCsharpGenerator CodeBehindGenerator { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ProjectPath { get; set; }
|
||||
|
||||
public string ProjectFolder => Path.GetDirectoryName(ProjectPath);
|
||||
|
||||
public ITaskItem[] CapnpFiles { get; set; }
|
||||
|
||||
[Output]
|
||||
public ITaskItem[] GeneratedFiles { get; private set; }
|
||||
|
||||
static CapnpGenJob ToGenJob(ITaskItem item)
|
||||
{
|
||||
var job = new CapnpGenJob()
|
||||
{
|
||||
CapnpPath = item.GetMetadata("FullPath"),
|
||||
WorkingDirectory = item.GetMetadata("WorkingDirectory")
|
||||
};
|
||||
|
||||
string importPaths = item.GetMetadata("ImportPaths");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(importPaths))
|
||||
{
|
||||
job.AdditionalArguments.AddRange(importPaths.Split(new char[] { ';' },
|
||||
StringSplitOptions.RemoveEmptyEntries).Select(p => $"-I\"{p.TrimEnd('\\')}\""));
|
||||
}
|
||||
|
||||
string sourcePrefix = item.GetMetadata("SourcePrefix");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sourcePrefix))
|
||||
{
|
||||
job.AdditionalArguments.Add(sourcePrefix);
|
||||
}
|
||||
|
||||
|
||||
string verbose = item.GetMetadata("Verbose");
|
||||
|
||||
if ("true".Equals(verbose, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
job.AdditionalArguments.Add("--verbose");
|
||||
}
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentProcess = Process.GetCurrentProcess();
|
||||
|
||||
Log.LogWithNameTag(Log.LogMessage, $"process: {currentProcess.ProcessName}, pid: {currentProcess.Id}, CD: {Environment.CurrentDirectory}");
|
||||
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
Log.LogWithNameTag(Log.LogMessage, " " + assembly.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.LogWithNameTag(Log.LogMessage, $"Error when dumping process info: {e}");
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
|
||||
var generator = CodeBehindGenerator ?? new CapnpFileCodeBehindGenerator(Log);
|
||||
|
||||
Log.LogWithNameTag(Log.LogMessage, "Starting GenerateCapnpFileCodeBehind");
|
||||
|
||||
var capnpFiles = CapnpFiles?.Select(ToGenJob).ToList() ?? new List<CapnpGenJob>();
|
||||
|
||||
var generatedFiles = generator.GenerateFilesForProject(
|
||||
ProjectPath,
|
||||
capnpFiles,
|
||||
ProjectFolder);
|
||||
|
||||
GeneratedFiles = generatedFiles.Select(file => new TaskItem { ItemSpec = file }).ToArray();
|
||||
|
||||
return !Log.HasLoggedErrors;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.InnerException != null)
|
||||
{
|
||||
if (e.InnerException is FileLoadException fle)
|
||||
{
|
||||
Log?.LogWithNameTag(Log.LogError, $"FileLoadException Filename: {fle.FileName}");
|
||||
Log?.LogWithNameTag(Log.LogError, $"FileLoadException FusionLog: {fle.FusionLog}");
|
||||
Log?.LogWithNameTag(Log.LogError, $"FileLoadException Message: {fle.Message}");
|
||||
}
|
||||
|
||||
Log?.LogWithNameTag(Log.LogError, e.InnerException.ToString());
|
||||
}
|
||||
|
||||
Log?.LogWithNameTag(Log.LogError, e.ToString());
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
|
||||
}
|
||||
}
|
||||
|
||||
private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Log.LogWithNameTag(Log.LogMessage, args.Name);
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
22
CapnpC.CSharp.MsBuild.Generation/Helper/LogExtensions.cs
Normal file
22
CapnpC.CSharp.MsBuild.Generation/Helper/LogExtensions.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public static class LogExtensions
|
||||
{
|
||||
public static void LogWithNameTag(
|
||||
this TaskLoggingHelper loggingHelper,
|
||||
Action<string, object[]> loggingMethod,
|
||||
string message,
|
||||
params object[] messageArgs)
|
||||
{
|
||||
string fullMessage = $"[Cap'n Proto] {message}";
|
||||
loggingMethod?.Invoke(fullMessage, messageArgs);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CapnpC.CSharp.MsBuild.Generation
|
||||
{
|
||||
public interface ICapnpcCsharpGenerator
|
||||
{
|
||||
IEnumerable<string> GenerateFilesForProject(string projectPath, List<CapnpGenJob> jobs, string projectFolder);
|
||||
}
|
||||
}
|
412
MsBuildGenerationTest/AddressBook.capnp.cs
Normal file
412
MsBuildGenerationTest/AddressBook.capnp.cs
Normal file
@ -0,0 +1,412 @@
|
||||
using Capnp;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapnpGen
|
||||
{
|
||||
public class Person : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Id = reader.Id;
|
||||
Name = reader.Name;
|
||||
Email = reader.Email;
|
||||
Phones = reader.Phones.ToReadOnlyList(_ => CapnpSerializable.Create<CapnpGen.Person.PhoneNumber>(_));
|
||||
Employment = CapnpSerializable.Create<CapnpGen.Person.@employment>(reader.Employment);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Id = Id;
|
||||
writer.Name = Name;
|
||||
writer.Email = Email;
|
||||
writer.Phones.Init(Phones, (_s1, _v1) => _v1?.serialize(_s1));
|
||||
Employment?.serialize(writer.Employment);
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public uint Id
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string Email
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IReadOnlyList<CapnpGen.Person.PhoneNumber> Phones
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CapnpGen.Person.@employment Employment
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public uint Id => ctx.ReadDataUInt(0UL, 0U);
|
||||
public string Name => ctx.ReadText(0, "");
|
||||
public string Email => ctx.ReadText(1, "");
|
||||
public IReadOnlyList<CapnpGen.Person.PhoneNumber.READER> Phones => ctx.ReadList(2).Cast(CapnpGen.Person.PhoneNumber.READER.create);
|
||||
public @employment.READER Employment => new @employment.READER(ctx);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(1, 4);
|
||||
}
|
||||
|
||||
public uint Id
|
||||
{
|
||||
get => this.ReadDataUInt(0UL, 0U);
|
||||
set => this.WriteData(0UL, value, 0U);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.ReadText(0, "");
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
|
||||
public string Email
|
||||
{
|
||||
get => this.ReadText(1, "");
|
||||
set => this.WriteText(1, value, "");
|
||||
}
|
||||
|
||||
public ListOfStructsSerializer<CapnpGen.Person.PhoneNumber.WRITER> Phones
|
||||
{
|
||||
get => BuildPointer<ListOfStructsSerializer<CapnpGen.Person.PhoneNumber.WRITER>>(2);
|
||||
set => Link(2, value);
|
||||
}
|
||||
|
||||
public @employment.WRITER Employment
|
||||
{
|
||||
get => Rewrap<@employment.WRITER>();
|
||||
}
|
||||
}
|
||||
|
||||
public class @employment : ICapnpSerializable
|
||||
{
|
||||
public enum WHICH : ushort
|
||||
{
|
||||
Unemployed = 0,
|
||||
Employer = 1,
|
||||
School = 2,
|
||||
SelfEmployed = 3,
|
||||
undefined = 65535
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
switch (reader.which)
|
||||
{
|
||||
case WHICH.Unemployed:
|
||||
which = reader.which;
|
||||
break;
|
||||
case WHICH.Employer:
|
||||
Employer = reader.Employer;
|
||||
break;
|
||||
case WHICH.School:
|
||||
School = reader.School;
|
||||
break;
|
||||
case WHICH.SelfEmployed:
|
||||
which = reader.which;
|
||||
break;
|
||||
}
|
||||
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
private WHICH _which = WHICH.undefined;
|
||||
private object _content;
|
||||
public WHICH which
|
||||
{
|
||||
get => _which;
|
||||
set
|
||||
{
|
||||
if (value == _which)
|
||||
return;
|
||||
_which = value;
|
||||
switch (value)
|
||||
{
|
||||
case WHICH.Unemployed:
|
||||
break;
|
||||
case WHICH.Employer:
|
||||
_content = null;
|
||||
break;
|
||||
case WHICH.School:
|
||||
_content = null;
|
||||
break;
|
||||
case WHICH.SelfEmployed:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.which = which;
|
||||
switch (which)
|
||||
{
|
||||
case WHICH.Unemployed:
|
||||
break;
|
||||
case WHICH.Employer:
|
||||
writer.Employer = Employer;
|
||||
break;
|
||||
case WHICH.School:
|
||||
writer.School = School;
|
||||
break;
|
||||
case WHICH.SelfEmployed:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public string Employer
|
||||
{
|
||||
get => _which == WHICH.Employer ? (string)_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.Employer;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string School
|
||||
{
|
||||
get => _which == WHICH.School ? (string)_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.School;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0);
|
||||
public string Employer => which == WHICH.Employer ? ctx.ReadText(3, "") : default;
|
||||
public string School => which == WHICH.School ? ctx.ReadText(3, "") : default;
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
}
|
||||
|
||||
public WHICH which
|
||||
{
|
||||
get => (WHICH)this.ReadDataUShort(32U, (ushort)0);
|
||||
set => this.WriteData(32U, (ushort)value, (ushort)0);
|
||||
}
|
||||
|
||||
public string Employer
|
||||
{
|
||||
get => which == WHICH.Employer ? this.ReadText(3, "") : default;
|
||||
set => this.WriteText(3, value, "");
|
||||
}
|
||||
|
||||
public string School
|
||||
{
|
||||
get => which == WHICH.School ? this.ReadText(3, "") : default;
|
||||
set => this.WriteText(3, value, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PhoneNumber : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Number = reader.Number;
|
||||
TheType = reader.TheType;
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Number = Number;
|
||||
writer.TheType = TheType;
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public string Number
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CapnpGen.Person.PhoneNumber.Type TheType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public string Number => ctx.ReadText(0, "");
|
||||
public CapnpGen.Person.PhoneNumber.Type TheType => (CapnpGen.Person.PhoneNumber.Type)ctx.ReadDataUShort(0UL, (ushort)0);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(1, 1);
|
||||
}
|
||||
|
||||
public string Number
|
||||
{
|
||||
get => this.ReadText(0, "");
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
|
||||
public CapnpGen.Person.PhoneNumber.Type TheType
|
||||
{
|
||||
get => (CapnpGen.Person.PhoneNumber.Type)this.ReadDataUShort(0UL, (ushort)0);
|
||||
set => this.WriteData(0UL, (ushort)value, (ushort)0);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type : ushort
|
||||
{
|
||||
mobile,
|
||||
home,
|
||||
work
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AddressBook : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
People = reader.People.ToReadOnlyList(_ => CapnpSerializable.Create<CapnpGen.Person>(_));
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.People.Init(People, (_s1, _v1) => _v1?.serialize(_s1));
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public IReadOnlyList<CapnpGen.Person> People
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public IReadOnlyList<CapnpGen.Person.READER> People => ctx.ReadList(0).Cast(CapnpGen.Person.READER.create);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 1);
|
||||
}
|
||||
|
||||
public ListOfStructsSerializer<CapnpGen.Person.WRITER> People
|
||||
{
|
||||
get => BuildPointer<ListOfStructsSerializer<CapnpGen.Person.WRITER>>(0);
|
||||
set => Link(0, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
MsBuildGenerationTest/Program.cs
Normal file
12
MsBuildGenerationTest/Program.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace MsBuildGenerationTest
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
10
MsBuildGenerationTest/capnp/c++.capnp.cs
Normal file
10
MsBuildGenerationTest/capnp/c++.capnp.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Capnp;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capnp.Annotations
|
||||
{
|
||||
}
|
1559
MsBuildGenerationTest/capnp/compat/json-test.capnp.cs
Normal file
1559
MsBuildGenerationTest/capnp/compat/json-test.capnp.cs
Normal file
File diff suppressed because it is too large
Load Diff
536
MsBuildGenerationTest/capnp/compat/json.capnp.cs
Normal file
536
MsBuildGenerationTest/capnp/compat/json.capnp.cs
Normal file
@ -0,0 +1,536 @@
|
||||
using Capnp;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capnp.Json
|
||||
{
|
||||
public class Value : ICapnpSerializable
|
||||
{
|
||||
public enum WHICH : ushort
|
||||
{
|
||||
Null = 0,
|
||||
Boolean = 1,
|
||||
Number = 2,
|
||||
String = 3,
|
||||
Array = 4,
|
||||
Object = 5,
|
||||
TheCall = 6,
|
||||
undefined = 65535
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
switch (reader.which)
|
||||
{
|
||||
case WHICH.Null:
|
||||
which = reader.which;
|
||||
break;
|
||||
case WHICH.Boolean:
|
||||
Boolean = reader.Boolean;
|
||||
break;
|
||||
case WHICH.Number:
|
||||
Number = reader.Number;
|
||||
break;
|
||||
case WHICH.String:
|
||||
String = reader.String;
|
||||
break;
|
||||
case WHICH.Array:
|
||||
Array = reader.Array.ToReadOnlyList(_ => CapnpSerializable.Create<Capnp.Json.Value>(_));
|
||||
break;
|
||||
case WHICH.Object:
|
||||
Object = reader.Object.ToReadOnlyList(_ => CapnpSerializable.Create<Capnp.Json.Value.Field>(_));
|
||||
break;
|
||||
case WHICH.TheCall:
|
||||
TheCall = CapnpSerializable.Create<Capnp.Json.Value.Call>(reader.TheCall);
|
||||
break;
|
||||
}
|
||||
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
private WHICH _which = WHICH.undefined;
|
||||
private object _content;
|
||||
public WHICH which
|
||||
{
|
||||
get => _which;
|
||||
set
|
||||
{
|
||||
if (value == _which)
|
||||
return;
|
||||
_which = value;
|
||||
switch (value)
|
||||
{
|
||||
case WHICH.Null:
|
||||
break;
|
||||
case WHICH.Boolean:
|
||||
_content = false;
|
||||
break;
|
||||
case WHICH.Number:
|
||||
_content = 0;
|
||||
break;
|
||||
case WHICH.String:
|
||||
_content = null;
|
||||
break;
|
||||
case WHICH.Array:
|
||||
_content = null;
|
||||
break;
|
||||
case WHICH.Object:
|
||||
_content = null;
|
||||
break;
|
||||
case WHICH.TheCall:
|
||||
_content = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.which = which;
|
||||
switch (which)
|
||||
{
|
||||
case WHICH.Null:
|
||||
break;
|
||||
case WHICH.Boolean:
|
||||
writer.Boolean = Boolean.Value;
|
||||
break;
|
||||
case WHICH.Number:
|
||||
writer.Number = Number.Value;
|
||||
break;
|
||||
case WHICH.String:
|
||||
writer.String = String;
|
||||
break;
|
||||
case WHICH.Array:
|
||||
writer.Array.Init(Array, (_s1, _v1) => _v1?.serialize(_s1));
|
||||
break;
|
||||
case WHICH.Object:
|
||||
writer.Object.Init(Object, (_s1, _v1) => _v1?.serialize(_s1));
|
||||
break;
|
||||
case WHICH.TheCall:
|
||||
TheCall?.serialize(writer.TheCall);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public bool? Boolean
|
||||
{
|
||||
get => _which == WHICH.Boolean ? (bool? )_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.Boolean;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double? Number
|
||||
{
|
||||
get => _which == WHICH.Number ? (double? )_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.Number;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string String
|
||||
{
|
||||
get => _which == WHICH.String ? (string)_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.String;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<Capnp.Json.Value> Array
|
||||
{
|
||||
get => _which == WHICH.Array ? (IReadOnlyList<Capnp.Json.Value>)_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.Array;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<Capnp.Json.Value.Field> Object
|
||||
{
|
||||
get => _which == WHICH.Object ? (IReadOnlyList<Capnp.Json.Value.Field>)_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.Object;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Capnp.Json.Value.Call TheCall
|
||||
{
|
||||
get => _which == WHICH.TheCall ? (Capnp.Json.Value.Call)_content : null;
|
||||
set
|
||||
{
|
||||
_which = WHICH.TheCall;
|
||||
_content = value;
|
||||
}
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0);
|
||||
public bool Boolean => which == WHICH.Boolean ? ctx.ReadDataBool(16UL, false) : default;
|
||||
public double Number => which == WHICH.Number ? ctx.ReadDataDouble(64UL, 0) : default;
|
||||
public string String => which == WHICH.String ? ctx.ReadText(0, "") : default;
|
||||
public IReadOnlyList<Capnp.Json.Value.READER> Array => which == WHICH.Array ? ctx.ReadList(0).Cast(Capnp.Json.Value.READER.create) : default;
|
||||
public IReadOnlyList<Capnp.Json.Value.Field.READER> Object => which == WHICH.Object ? ctx.ReadList(0).Cast(Capnp.Json.Value.Field.READER.create) : default;
|
||||
public Capnp.Json.Value.Call.READER TheCall => which == WHICH.TheCall ? ctx.ReadStruct(0, Capnp.Json.Value.Call.READER.create) : default;
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(2, 1);
|
||||
}
|
||||
|
||||
public WHICH which
|
||||
{
|
||||
get => (WHICH)this.ReadDataUShort(0U, (ushort)0);
|
||||
set => this.WriteData(0U, (ushort)value, (ushort)0);
|
||||
}
|
||||
|
||||
public bool Boolean
|
||||
{
|
||||
get => which == WHICH.Boolean ? this.ReadDataBool(16UL, false) : default;
|
||||
set => this.WriteData(16UL, value, false);
|
||||
}
|
||||
|
||||
public double Number
|
||||
{
|
||||
get => which == WHICH.Number ? this.ReadDataDouble(64UL, 0) : default;
|
||||
set => this.WriteData(64UL, value, 0);
|
||||
}
|
||||
|
||||
public string String
|
||||
{
|
||||
get => which == WHICH.String ? this.ReadText(0, "") : default;
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
|
||||
public ListOfStructsSerializer<Capnp.Json.Value.WRITER> Array
|
||||
{
|
||||
get => which == WHICH.Array ? BuildPointer<ListOfStructsSerializer<Capnp.Json.Value.WRITER>>(0) : default;
|
||||
set => Link(0, value);
|
||||
}
|
||||
|
||||
public ListOfStructsSerializer<Capnp.Json.Value.Field.WRITER> Object
|
||||
{
|
||||
get => which == WHICH.Object ? BuildPointer<ListOfStructsSerializer<Capnp.Json.Value.Field.WRITER>>(0) : default;
|
||||
set => Link(0, value);
|
||||
}
|
||||
|
||||
public Capnp.Json.Value.Call.WRITER TheCall
|
||||
{
|
||||
get => which == WHICH.TheCall ? BuildPointer<Capnp.Json.Value.Call.WRITER>(0) : default;
|
||||
set => Link(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class Field : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Name = reader.Name;
|
||||
Value = CapnpSerializable.Create<Capnp.Json.Value>(reader.Value);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Name = Name;
|
||||
Value?.serialize(writer.Value);
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Capnp.Json.Value Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public string Name => ctx.ReadText(0, "");
|
||||
public Capnp.Json.Value.READER Value => ctx.ReadStruct(1, Capnp.Json.Value.READER.create);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 2);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.ReadText(0, "");
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
|
||||
public Capnp.Json.Value.WRITER Value
|
||||
{
|
||||
get => BuildPointer<Capnp.Json.Value.WRITER>(1);
|
||||
set => Link(1, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Call : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Function = reader.Function;
|
||||
Params = reader.Params.ToReadOnlyList(_ => CapnpSerializable.Create<Capnp.Json.Value>(_));
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Function = Function;
|
||||
writer.Params.Init(Params, (_s1, _v1) => _v1?.serialize(_s1));
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public string Function
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IReadOnlyList<Capnp.Json.Value> Params
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public string Function => ctx.ReadText(0, "");
|
||||
public IReadOnlyList<Capnp.Json.Value.READER> Params => ctx.ReadList(1).Cast(Capnp.Json.Value.READER.create);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 2);
|
||||
}
|
||||
|
||||
public string Function
|
||||
{
|
||||
get => this.ReadText(0, "");
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
|
||||
public ListOfStructsSerializer<Capnp.Json.Value.WRITER> Params
|
||||
{
|
||||
get => BuildPointer<ListOfStructsSerializer<Capnp.Json.Value.WRITER>>(1);
|
||||
set => Link(1, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FlattenOptions : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Prefix = reader.Prefix;
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Prefix = Prefix;
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
Prefix = Prefix ?? "";
|
||||
}
|
||||
|
||||
public string Prefix
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public string Prefix => ctx.ReadText(0, "");
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 1);
|
||||
}
|
||||
|
||||
public string Prefix
|
||||
{
|
||||
get => this.ReadText(0, "");
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DiscriminatorOptions : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Name = reader.Name;
|
||||
ValueName = reader.ValueName;
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Name = Name;
|
||||
writer.ValueName = ValueName;
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string ValueName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public string Name => ctx.ReadText(0, "");
|
||||
public string ValueName => ctx.ReadText(1, "");
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 2);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this.ReadText(0, "");
|
||||
set => this.WriteText(0, value, "");
|
||||
}
|
||||
|
||||
public string ValueName
|
||||
{
|
||||
get => this.ReadText(1, "");
|
||||
set => this.WriteText(1, value, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
393
MsBuildGenerationTest/capnp/rpc-twoparty.capnp.cs
Normal file
393
MsBuildGenerationTest/capnp/rpc-twoparty.capnp.cs
Normal file
@ -0,0 +1,393 @@
|
||||
using Capnp;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capnp.Rpc.Twoparty
|
||||
{
|
||||
public enum Side : ushort
|
||||
{
|
||||
server,
|
||||
client
|
||||
}
|
||||
|
||||
public class VatId : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Side = reader.Side;
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.Side = Side;
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public Capnp.Rpc.Twoparty.Side Side
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public Capnp.Rpc.Twoparty.Side Side => (Capnp.Rpc.Twoparty.Side)ctx.ReadDataUShort(0UL, (ushort)0);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(1, 0);
|
||||
}
|
||||
|
||||
public Capnp.Rpc.Twoparty.Side Side
|
||||
{
|
||||
get => (Capnp.Rpc.Twoparty.Side)this.ReadDataUShort(0UL, (ushort)0);
|
||||
set => this.WriteData(0UL, (ushort)value, (ushort)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ProvisionId : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
JoinId = reader.JoinId;
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.JoinId = JoinId;
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public uint JoinId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public uint JoinId => ctx.ReadDataUInt(0UL, 0U);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(1, 0);
|
||||
}
|
||||
|
||||
public uint JoinId
|
||||
{
|
||||
get => this.ReadDataUInt(0UL, 0U);
|
||||
set => this.WriteData(0UL, value, 0U);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RecipientId : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ThirdPartyCapId : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JoinKeyPart : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
JoinId = reader.JoinId;
|
||||
PartCount = reader.PartCount;
|
||||
PartNum = reader.PartNum;
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.JoinId = JoinId;
|
||||
writer.PartCount = PartCount;
|
||||
writer.PartNum = PartNum;
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public uint JoinId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ushort PartCount
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ushort PartNum
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public uint JoinId => ctx.ReadDataUInt(0UL, 0U);
|
||||
public ushort PartCount => ctx.ReadDataUShort(32UL, (ushort)0);
|
||||
public ushort PartNum => ctx.ReadDataUShort(48UL, (ushort)0);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(1, 0);
|
||||
}
|
||||
|
||||
public uint JoinId
|
||||
{
|
||||
get => this.ReadDataUInt(0UL, 0U);
|
||||
set => this.WriteData(0UL, value, 0U);
|
||||
}
|
||||
|
||||
public ushort PartCount
|
||||
{
|
||||
get => this.ReadDataUShort(32UL, (ushort)0);
|
||||
set => this.WriteData(32UL, value, (ushort)0);
|
||||
}
|
||||
|
||||
public ushort PartNum
|
||||
{
|
||||
get => this.ReadDataUShort(48UL, (ushort)0);
|
||||
set => this.WriteData(48UL, value, (ushort)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JoinResult : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
JoinId = reader.JoinId;
|
||||
Succeeded = reader.Succeeded;
|
||||
Cap = CapnpSerializable.Create<AnyPointer>(reader.Cap);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
writer.JoinId = JoinId;
|
||||
writer.Succeeded = Succeeded;
|
||||
writer.Cap.SetObject(Cap);
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public uint JoinId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool Succeeded
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public AnyPointer Cap
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public uint JoinId => ctx.ReadDataUInt(0UL, 0U);
|
||||
public bool Succeeded => ctx.ReadDataBool(32UL, false);
|
||||
public DeserializerState Cap => ctx.StructReadPointer(0);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(1, 1);
|
||||
}
|
||||
|
||||
public uint JoinId
|
||||
{
|
||||
get => this.ReadDataUInt(0UL, 0U);
|
||||
set => this.WriteData(0UL, value, 0U);
|
||||
}
|
||||
|
||||
public bool Succeeded
|
||||
{
|
||||
get => this.ReadDataBool(32UL, false);
|
||||
set => this.WriteData(32UL, value, false);
|
||||
}
|
||||
|
||||
public DynamicSerializerState Cap
|
||||
{
|
||||
get => BuildPointer<DynamicSerializerState>(0);
|
||||
set => Link(0, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2641
MsBuildGenerationTest/capnp/rpc.capnp.cs
Normal file
2641
MsBuildGenerationTest/capnp/rpc.capnp.cs
Normal file
File diff suppressed because it is too large
Load Diff
4309
MsBuildGenerationTest/capnp/schema.capnp.cs
Normal file
4309
MsBuildGenerationTest/capnp/schema.capnp.cs
Normal file
File diff suppressed because it is too large
Load Diff
67
MsBuildGenerationTest/capnp/test-import.capnp.cs
Normal file
67
MsBuildGenerationTest/capnp/test-import.capnp.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using Capnp;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapnpGen
|
||||
{
|
||||
public class TestImport : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Field = CapnpSerializable.Create<Capnproto_test.Capnp.Test.TestAllTypes>(reader.Field);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
Field?.serialize(writer.Field);
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public Capnproto_test.Capnp.Test.TestAllTypes Field
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public Capnproto_test.Capnp.Test.TestAllTypes.READER Field => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestAllTypes.READER.create);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 1);
|
||||
}
|
||||
|
||||
public Capnproto_test.Capnp.Test.TestAllTypes.WRITER Field
|
||||
{
|
||||
get => BuildPointer<Capnproto_test.Capnp.Test.TestAllTypes.WRITER>(0);
|
||||
set => Link(0, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
MsBuildGenerationTest/capnp/test-import2.capnp.cs
Normal file
97
MsBuildGenerationTest/capnp/test-import2.capnp.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using Capnp;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapnpGen
|
||||
{
|
||||
public class TestImport2 : ICapnpSerializable
|
||||
{
|
||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||
{
|
||||
var reader = READER.create(arg_);
|
||||
Foo = CapnpSerializable.Create<Capnproto_test.Capnp.Test.TestAllTypes>(reader.Foo);
|
||||
Bar = CapnpSerializable.Create<Capnp.Schema.Node>(reader.Bar);
|
||||
Baz = CapnpSerializable.Create<CapnpGen.TestImport>(reader.Baz);
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
public void serialize(WRITER writer)
|
||||
{
|
||||
Foo?.serialize(writer.Foo);
|
||||
Bar?.serialize(writer.Bar);
|
||||
Baz?.serialize(writer.Baz);
|
||||
}
|
||||
|
||||
void ICapnpSerializable.Serialize(SerializerState arg_)
|
||||
{
|
||||
serialize(arg_.Rewrap<WRITER>());
|
||||
}
|
||||
|
||||
public void applyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public Capnproto_test.Capnp.Test.TestAllTypes Foo
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Capnp.Schema.Node Bar
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CapnpGen.TestImport Baz
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public struct READER
|
||||
{
|
||||
readonly DeserializerState ctx;
|
||||
public READER(DeserializerState ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public static READER create(DeserializerState ctx) => new READER(ctx);
|
||||
public static implicit operator DeserializerState(READER reader) => reader.ctx;
|
||||
public static implicit operator READER(DeserializerState ctx) => new READER(ctx);
|
||||
public Capnproto_test.Capnp.Test.TestAllTypes.READER Foo => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestAllTypes.READER.create);
|
||||
public Capnp.Schema.Node.READER Bar => ctx.ReadStruct(1, Capnp.Schema.Node.READER.create);
|
||||
public CapnpGen.TestImport.READER Baz => ctx.ReadStruct(2, CapnpGen.TestImport.READER.create);
|
||||
}
|
||||
|
||||
public class WRITER : SerializerState
|
||||
{
|
||||
public WRITER()
|
||||
{
|
||||
this.SetStruct(0, 3);
|
||||
}
|
||||
|
||||
public Capnproto_test.Capnp.Test.TestAllTypes.WRITER Foo
|
||||
{
|
||||
get => BuildPointer<Capnproto_test.Capnp.Test.TestAllTypes.WRITER>(0);
|
||||
set => Link(0, value);
|
||||
}
|
||||
|
||||
public Capnp.Schema.Node.WRITER Bar
|
||||
{
|
||||
get => BuildPointer<Capnp.Schema.Node.WRITER>(1);
|
||||
set => Link(1, value);
|
||||
}
|
||||
|
||||
public CapnpGen.TestImport.WRITER Baz
|
||||
{
|
||||
get => BuildPointer<CapnpGen.TestImport.WRITER>(2);
|
||||
set => Link(2, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16200
MsBuildGenerationTest/capnp/test.capnp.cs
Normal file
16200
MsBuildGenerationTest/capnp/test.capnp.cs
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user