Closed ZachBray closed 6 years ago
Thanks for the report @ZachBray. Can you try the latest to confirm it works for you?
It looks much healthier now. Thank you!
@billsegall, will this fix make it into the "sbe-tool" NuGet package or should I package it up myself for use on our project?
I'll try and get a new package out this week.
nuget.org has an update. Thanks for the report and patch.
Great! Thank you for the package update.
Hi guys,
Sorry I've discovered another issue related to this. Not sure how I didn't notice it earlier.
The code generated is now valid C# and it works for decoding. When encoding we use the same property.
public SimpleCompositeV0 Value
{
get
{
if (_actingVersion < 42) return null;
_value.Wrap(_buffer, _offset + 0, _actingVersion);
return _value;
}
}
Unfortunately WrapForEncode(...)
does not initialize _actingVersion
to anything. Therefore, encoding fails.
I'll attach a PR that fixes this momentarily.
I've merged the change. However it feels wrong to wrapForEncode and then decode. I think the Java design of separate encoders and decoders is a safer and cleaner approach.
it feels wrong to wrapForEncode and then decode
FYI we're not calling WrapForEncode(...)
then decoding, we're still encoding, but we need to access the property in order to encode/write the composite fields which necessitates a Wrap(...)
. I believe composites use the same Wrap(...)
mechanism for encoding and decoding on the C# side.
separate encoders and decoders is a safer and cleaner approach
👍
Thanks for this great library! :-)
I think this is an issue for @billsegall, as it relates to the CSharp code generation.
We're generating code using the
sbe-tool:1.7.6
JAR.When we have the following structure in the schema file
the C# code that is generated does not compile.
This code fragment is representative of the problem:
If
actingVersion
were prefixed with an underscore I believe it would fix the issue.It looks like it may come from this line: https://github.com/real-logic/simple-binary-encoding/blob/4b64c6f4a678f6ccb5604c5f5e0b2cade3e5bfa2/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpGenerator.java#L700
Full schema
Generated class