Some fixes to make persistent.capnp compile

This commit is contained in:
Christian Köllner 2019-10-04 01:07:47 +02:00
parent b5dd02c53f
commit 45a3f16426
7 changed files with 1427 additions and 290 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8467,7 +8467,7 @@ namespace Capnproto_test.Capnp.Test
} }
[TypeId(0x8839ed86c9794287UL), Proxy(typeof(DeepNestInterfaceProxy<>)), Skeleton(typeof(DeepNestInterfaceSkeleton<>))] [TypeId(0x8839ed86c9794287UL), Proxy(typeof(DeepNestInterfaceProxy<>)), Skeleton(typeof(DeepNestInterfaceSkeleton<>))]
public interface IDeepNestInterface<TQuux> : IDisposable public interface IDeepNestInterface<TQuux> : IDisposable where TQuux : class
{ {
Task Call(CancellationToken cancellationToken_ = default); Task Call(CancellationToken cancellationToken_ = default);
} }
@ -8599,7 +8599,7 @@ namespace Capnproto_test.Capnp.Test
} }
[TypeId(0xc9e749e8dd54da5cUL), Proxy(typeof(InterfaceProxy<>)), Skeleton(typeof(InterfaceSkeleton<>))] [TypeId(0xc9e749e8dd54da5cUL), Proxy(typeof(InterfaceProxy<>)), Skeleton(typeof(InterfaceSkeleton<>))]
public interface IInterface<TQux> : IDisposable public interface IInterface<TQux> : IDisposable where TQux : class
{ {
Task<(TQux, Capnproto_test.Capnp.Test.TestGenerics<Capnproto_test.Capnp.Test.TestAllTypes, Capnproto_test.Capnp.Test.TestAnyPointer>)> Call(Capnproto_test.Capnp.Test.TestGenerics<TFoo, TBar>.Inner2<string> arg_, CancellationToken cancellationToken_ = default); Task<(TQux, Capnproto_test.Capnp.Test.TestGenerics<Capnproto_test.Capnp.Test.TestAllTypes, Capnproto_test.Capnp.Test.TestAnyPointer>)> Call(Capnproto_test.Capnp.Test.TestGenerics<TFoo, TBar>.Inner2<string> arg_, CancellationToken cancellationToken_ = default);
} }
@ -9105,7 +9105,7 @@ namespace Capnproto_test.Capnp.Test
} }
[TypeId(0xdf9ccdeb81a704c9UL), Proxy(typeof(TestImplicitMethodParamsInGenericProxy<>)), Skeleton(typeof(TestImplicitMethodParamsInGenericSkeleton<>))] [TypeId(0xdf9ccdeb81a704c9UL), Proxy(typeof(TestImplicitMethodParamsInGenericProxy<>)), Skeleton(typeof(TestImplicitMethodParamsInGenericSkeleton<>))]
public interface ITestImplicitMethodParamsInGeneric<TV> : IDisposable public interface ITestImplicitMethodParamsInGeneric<TV> : IDisposable where TV : class
{ {
Task<Capnproto_test.Capnp.Test.TestGenerics<TT, TU>> Call<TT, TU>(TT foo, TU bar, CancellationToken cancellationToken_ = default) Task<Capnproto_test.Capnp.Test.TestGenerics<TT, TU>> Call<TT, TU>(TT foo, TU bar, CancellationToken cancellationToken_ = default)
where TT : class where TU : class; where TT : class where TU : class;
@ -15412,7 +15412,7 @@ namespace Capnproto_test.Capnp.Test
} }
[TypeId(0xea72cc77253798cdUL), Proxy(typeof(TestAuthenticatedBootstrapProxy<>)), Skeleton(typeof(TestAuthenticatedBootstrapSkeleton<>))] [TypeId(0xea72cc77253798cdUL), Proxy(typeof(TestAuthenticatedBootstrapProxy<>)), Skeleton(typeof(TestAuthenticatedBootstrapSkeleton<>))]
public interface ITestAuthenticatedBootstrap<TVatId> : IDisposable public interface ITestAuthenticatedBootstrap<TVatId> : IDisposable where TVatId : class
{ {
Task<TVatId> GetCallerId(CancellationToken cancellationToken_ = default); Task<TVatId> GetCallerId(CancellationToken cancellationToken_ = default);
} }

View File

@ -70,7 +70,29 @@ namespace CapnpC.CSharp.Generator.Tests
public void ThenTheGeneratedOutputMustMatchTheReference() public void ThenTheGeneratedOutputMustMatchTheReference()
{ {
Assert.IsTrue(_result.IsSuccess, $"Tool invocation failed: {_result.Exception?.Message}"); Assert.IsTrue(_result.IsSuccess, $"Tool invocation failed: {_result.Exception?.Message}");
Assert.AreEqual(_referenceOutputContent, _result.GeneratedFiles.Single().GeneratedContent); string generated = _result.GeneratedFiles.Single().GeneratedContent;
bool equals = _referenceOutputContent.Equals(generated);
if (!equals)
{
string path = Path.ChangeExtension(Path.GetTempFileName(), ".capnp.cs");
File.WriteAllText(path, generated);
string[] refLines = _referenceOutputContent.Split(Environment.NewLine);
string[] actLines = generated.Split(Environment.NewLine);
int mismatchLine = 0;
for (int i = 0; i < Math.Min(refLines.Length, actLines.Length); i++)
{
if (!refLines[i].Equals(actLines[i]))
{
mismatchLine = i + 1;
break;
}
}
Assert.Fail(
$"Reference output does not match. Expected: <{_referenceOutputContent.Substring(0, 100)}...>, actual: <{generated.Substring(0, 100)}...>, see {path}, first mismatch line: {mismatchLine}");
}
} }
[Then(@"the invocation must fail")] [Then(@"the invocation must fail")]

View File

@ -206,7 +206,8 @@ namespace CapnpC.CSharp.Generator.CodeGen
if (def.GenericParameters.Count > 0) if (def.GenericParameters.Count > 0)
{ {
return GenericName(name.Identifier).AddTypeArgumentListArguments(); var args = Enumerable.Repeat(OmittedTypeArgument(), def.GenericParameters.Count);
return GenericName(name.Identifier).AddTypeArgumentListArguments(args.ToArray());
} }
else else
{ {

View File

@ -56,7 +56,7 @@ namespace CapnpC.CSharp.Generator.CodeGen
{ {
foreach (var arg in method.Params) foreach (var arg in method.Params)
{ {
list.Add(Parameter(Identifier(arg.Name)) list.Add(Parameter(Identifier(IdentifierRenamer.ToNonKeyword(arg.Name)))
.WithType(_names.MakeTypeSyntax(arg.Type, method.DeclaringInterface, TypeUsage.DomainClass))); .WithType(_names.MakeTypeSyntax(arg.Type, method.DeclaringInterface, TypeUsage.DomainClass)));
} }
} }
@ -108,7 +108,9 @@ namespace CapnpC.CSharp.Generator.CodeGen
if (type.GenericParameters.Count > 0) if (type.GenericParameters.Count > 0)
{ {
ifaceDecl = ifaceDecl.AddTypeParameterListParameters(MakeTypeParameters(type).ToArray()); ifaceDecl = ifaceDecl
.AddTypeParameterListParameters(MakeTypeParameters(type).ToArray())
.AddConstraintClauses(MakeTypeParameterConstraints(type).ToArray());
} }
if (type.Superclasses.Count == 0) if (type.Superclasses.Count == 0)
@ -185,7 +187,7 @@ namespace CapnpC.CSharp.Generator.CodeGen
yield return AssignmentExpression( yield return AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression, SyntaxKind.SimpleAssignmentExpression,
_names.GetCodeIdentifier(methodParam).IdentifierName, _names.GetCodeIdentifier(methodParam).IdentifierName,
IdentifierName(methodParam.Name)); IdentifierName(IdentifierRenamer.ToNonKeyword(methodParam.Name)));
} }
} }
@ -461,7 +463,7 @@ namespace CapnpC.CSharp.Generator.CodeGen
yield return AssignmentExpression( yield return AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression, SyntaxKind.SimpleAssignmentExpression,
_names.GetCodeIdentifier(arg).IdentifierName, _names.GetCodeIdentifier(arg).IdentifierName,
IdentifierName(arg.Name)); IdentifierName(IdentifierRenamer.ToNonKeyword(arg.Name)));
} }
} }

View File

@ -8,10 +8,6 @@
<PackageReferenceVersion Condition="'$(PackageReferenceVersion)'==''">$(Version)*</PackageReferenceVersion> <PackageReferenceVersion Condition="'$(PackageReferenceVersion)'==''">$(Version)*</PackageReferenceVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<CapnpFiles Remove="capnp\persistent.capnp" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Capnp.Net.Runtime" Version="$(PackageReferenceVersion)" /> <PackageReference Include="Capnp.Net.Runtime" Version="$(PackageReferenceVersion)" />
<PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="$(PackageReferenceVersion)" /> <PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="$(PackageReferenceVersion)" />
@ -30,6 +26,9 @@
<WorkingDirectory>$(ProjectDir)</WorkingDirectory> <WorkingDirectory>$(ProjectDir)</WorkingDirectory>
<ImportPaths>$(ProjectDir);%(ImportPaths)</ImportPaths> <ImportPaths>$(ProjectDir);%(ImportPaths)</ImportPaths>
</CapnpFiles> </CapnpFiles>
<CapnpFiles Update="capnp\persistent.capnp">
<ImportPaths>$(ProjectDir);%(ImportPaths)</ImportPaths>
</CapnpFiles>
<CapnpFiles Update="capnp\rpc-twoparty.capnp"> <CapnpFiles Update="capnp\rpc-twoparty.capnp">
<WorkingDirectory>$(ProjectDir)</WorkingDirectory> <WorkingDirectory>$(ProjectDir)</WorkingDirectory>
<ImportPaths>$(ProjectDir);%(ImportPaths)</ImportPaths> <ImportPaths>$(ProjectDir);%(ImportPaths)</ImportPaths>

View File

@ -7,13 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MsBuildGenerationTest", "Ms
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
AppVeyor|Any CPU = AppVeyor|Any CPU
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D2CFBABF-7028-4761-9B24-6054008F41A0}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU
{D2CFBABF-7028-4761-9B24-6054008F41A0}.AppVeyor|Any CPU.Build.0 = Release|Any CPU
{D2CFBABF-7028-4761-9B24-6054008F41A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D2CFBABF-7028-4761-9B24-6054008F41A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2CFBABF-7028-4761-9B24-6054008F41A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {D2CFBABF-7028-4761-9B24-6054008F41A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2CFBABF-7028-4761-9B24-6054008F41A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {D2CFBABF-7028-4761-9B24-6054008F41A0}.Release|Any CPU.ActiveCfg = Release|Any CPU