Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] Add ToString #853

Merged
merged 14 commits into from
Jun 4, 2021
Merged

Conversation

MFrpurdy
Copy link
Contributor

@MFrpurdy MFrpurdy commented Jun 3, 2021

#852

  • Added ToString generation methods.
  • In testing these changes user rca22 discovered that data types without encodings - for raw data - were not working correctly. The ToString would not work and the newly added Get/Set to/from String methods would also not work. Fixed.

Example:

[Car](sbeTemplateId=1|sbeSchemaId=1|sbeSchemaVersion=0|sbeBlockLength=45):SerialNumber=1234|ModelYear=2013|Available=T|Code=A|SomeNumbers=[0,1,2,3]|VehicleCode=abcdef|Extras={SportsPack, CruiseControl}|DiscountedModel=C|Engine=(Capacity=2000|NumCylinders=4|MaxRpm=9000|ManufacturerCode=123|Fuel=Petrol|Efficiency=35|BoosterEnabled=T|Booster=(BoostType=NITROUS|HorsePower=200))|FuelFigures=[(Speed=30|Mpg=35.9|UsageDescription='Urban Cycle'),(Speed=55|Mpg=49|UsageDescription='Combined Cycle'),(Speed=75|Mpg=40|UsageDescription='Highway Cycle')]|PerformanceFigures=[(OctaneRating=95|Acceleration=[(Mph=30|Seconds=4),(Mph=60|Seconds=7.5),(Mph=100|Seconds=12.2)]),(OctaneRating=99|Acceleration=[(Mph=30|Seconds=3.8),(Mph=60|Seconds=7.1),(Mph=100|Seconds=11.8)])]|Manufacturer='Honda'|Model='Civic VTi'|ActivationCode='abcdef'

case BEGIN_COMPOSITE:
{
append(sb, indent, "if (this." + fieldName + " != null)");
append(sb, indent, " this." + fieldName + ".BuildString(builder);");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocks without braces is not good practice and easy to introduce bugs with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also saw an small indenting issue which I fixed.

@mjpt777
Copy link
Contributor

mjpt777 commented Jun 3, 2021

Looks good. If you fix the generated code to always put code blocks in curly brackets then I'll merge.

@mjpt777 mjpt777 merged commit 91aabea into real-logic:master Jun 4, 2021
mjpt777 added a commit that referenced this pull request Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants