Skip to content

Commit 33efd7a

Browse files
authored
Merge pull request aeron-io#460 from MarketFactory/dotnet-alpha2
dotnet support alpha2
2 parents 1c08c35 + 043214c commit 33efd7a

File tree

15 files changed

+101
-64
lines changed

15 files changed

+101
-64
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ gocode/src/extension2
9595
# csharp
9696
csharp/*/bin
9797
csharp/*/obj
98+
csharp/.nuget/nuget.exe
9899
csharp/.nuget/sbe-tool*.nupkg
99100
csharp/.nuget/sbe-tool-all.jar
100101
csharp/.nuget/examples/bin

csharp/.nuget/SBE.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>sbe-tool</id>
5-
<version>0.1.7.0-alpha-1</version>
5+
<version>0.1.7.1-alpha-2</version>
66
<title>Simple Binary Encoding for .NET</title>
77
<authors>MarketFactory Inc, Adaptive Consulting</authors>
88
<owners>MarketFactory Inc, Adaptive Consulting</owners>

csharp/.nuget/do-release.sh

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,13 @@ ROOTDIR=`dirname $0`
66
VERSIONTXT=`cat $ROOTDIR/../../version.txt`
77
VERSION=${VERSIONTXT%-SNAPSHOT} # Seems to be what's used
88

9-
# Write the version info into the assembly
10-
# Note we're using 0.VersionNumber during alpha/beta
11-
ASSEMBLYINFO=$ROOTDIR/../GlobalAssemblyInfo.cs
12-
(cat << @EOF
13-
[assembly: System.Reflection.AssemblyCopyright("Copyright © 2017 MarketFactory Inc. Copyright © Adaptive 2014. All rights reserved.")]
14-
#if DEBUG
15-
[assembly: System.Reflection.AssemblyDescription("Debug")]
16-
#else
17-
[assembly: System.Reflection.AssemblyDescription("Release")]
18-
#endif
19-
[assembly: System.Reflection.AssemblyVersion("VERSION")]
20-
[assembly: System.Reflection.AssemblyFileVersion("VERSION")]
21-
[assembly: System.Reflection.AssemblyInformationalVersion("VERSION")]
22-
@EOF
23-
)| sed -e "s+VERSION+0.$VERSION+g" > $ASSEMBLYINFO.new
24-
25-
# Copy in if new
26-
if cmp $ASSEMBLYINFO $ASSEMBLYINFO.new
27-
then
28-
rm $ASSEMBLYINFO.new
29-
else
30-
cp $ASSEMBLYINFO.new $ASSEMBLYINFO
31-
fi
32-
339
# Copy in the jar
3410
cp $ROOTDIR/../../sbe-tool/build/libs/sbe-tool-$VERSIONTXT-all.jar $ROOTDIR/sbe-tool-all.jar
3511

3612
# Build the nuget package
37-
NUGET=$ROOTDIR/../packages/NuGet.CommandLine.3.5.0/tools/NuGet.exe
13+
NUGET=$ROOTDIR/nuget.exe
14+
if [ ! -f $NUGET ]; then echo nuget.exe not found. Obtain it from https://dist.nuget.org/index.html; exit 1; fi
15+
3816
$NUGET pack $ROOTDIR/sbe.nuspec
3917

4018

csharp/.nuget/examples/CarExample.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class Example
2121
{
22-
public static void Main()
22+
public static void ExampleMain()
2323
{
2424
// This byte array is used for encoding and decoding, this is what you would send on the wire or save to disk
2525
var byteBuffer = new byte[4096];
@@ -230,23 +230,23 @@ public static void Decode(Car car,
230230
sb.Append("\ncar.engine.Booster.BoostType=").Append(engine.Booster.BoostType);
231231
sb.Append("\ncar.engine.Booster.HorsePower=").Append(engine.Booster.HorsePower);
232232

233-
var fuelFiguresGroup = car.FuelFigures; // decode a repeatable group (we will change the API to support foreach soon)
233+
// The first way to access a repeating group is by using Next()
234+
var fuelFiguresGroup = car.FuelFigures;
234235
while (fuelFiguresGroup.HasNext)
235236
{
236237
var fuelFigures = fuelFiguresGroup.Next();
237238
sb.Append("\ncar.fuelFigures.speed=").Append(fuelFigures.Speed);
238239
sb.Append("\ncar.fuelFigures.mpg=").Append(fuelFigures.Mpg);
239240
}
240241

241-
// the nested group
242-
var performanceFiguresGroup = car.PerformanceFigures;
243-
while (performanceFiguresGroup.HasNext)
242+
// The second way to access a repeating group is to use an iterator
243+
foreach (Car.PerformanceFiguresGroup performanceFigures in car.PerformanceFigures)
244244
{
245-
var performanceFigures = performanceFiguresGroup.Next();
246245
sb.Append("\ncar.performanceFigures.octaneRating=").Append(performanceFigures.OctaneRating);
247246

247+
// The third way to access a repeating group is loop over the count of elements
248248
var accelerationGroup = performanceFigures.Acceleration;
249-
while (accelerationGroup.HasNext)
249+
for (int i = 0; i < accelerationGroup.Count; i++)
250250
{
251251
var acceleration = accelerationGroup.Next();
252252
sb.Append("\ncar.performanceFigures.acceleration.mph=").Append(acceleration.Mph);

csharp/.nuget/examples/baseline/Car.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ public static string SomeNumbersMetaAttribute(MetaAttribute metaAttribute)
228228
return "";
229229
}
230230

231-
public const uint SomeNumbersNullValue = 4294967294U;
231+
public const uint SomeNumbersNullValue = 4294967295U;
232232
public const uint SomeNumbersMinValue = 0U;
233-
public const uint SomeNumbersMaxValue = 4294967293U;
233+
public const uint SomeNumbersMaxValue = 4294967294U;
234234

235235
public const int SomeNumbersLength = 5;
236236

@@ -509,6 +509,14 @@ public FuelFiguresGroup Next()
509509
return this;
510510
}
511511

512+
public System.Collections.IEnumerator GetEnumerator()
513+
{
514+
while (this.HasNext)
515+
{
516+
yield return this.Next();
517+
}
518+
}
519+
512520
public const int SpeedId = 11;
513521
public const int SpeedSinceVersion = 0;
514522
public const int SpeedDeprecated = 0;
@@ -716,6 +724,14 @@ public PerformanceFiguresGroup Next()
716724
return this;
717725
}
718726

727+
public System.Collections.IEnumerator GetEnumerator()
728+
{
729+
while (this.HasNext)
730+
{
731+
yield return this.Next();
732+
}
733+
}
734+
719735
public const int OctaneRatingId = 14;
720736
public const int OctaneRatingSinceVersion = 0;
721737
public const int OctaneRatingDeprecated = 0;
@@ -836,6 +852,14 @@ public AccelerationGroup Next()
836852
return this;
837853
}
838854

855+
public System.Collections.IEnumerator GetEnumerator()
856+
{
857+
while (this.HasNext)
858+
{
859+
yield return this.Next();
860+
}
861+
}
862+
839863
public const int MphId = 16;
840864
public const int MphSinceVersion = 0;
841865
public const int MphDeprecated = 0;

csharp/.nuget/examples/baseline/VarStringEncoding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void Wrap(DirectBuffer buffer, int offset, int actingVersion)
2121

2222
public const int Size = -1;
2323

24-
public const uint LengthNullValue = 4294967294U;
24+
public const uint LengthNullValue = 4294967295U;
2525
public const uint LengthMinValue = 0U;
2626
public const uint LengthMaxValue = 1073741824U;
2727

csharp/README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,23 @@ Roadmap
3434
-------
3535
The csharp generator is as of May 2017 a preview release. API stability is not guaranteed. Documentation is a work in progress. The current roadmap contains:
3636

37-
* Documentation
37+
* Improved Documentation
3838
* Testing/bug fixes
3939
* Better nuget Packaging
40-
* Dotnet core support (The code is known to work but is not built/distributed for dotnet core)
41-
* Possible changes to make soem objects iterable
40+
* Dotnet standard 2.9 support when available
41+
* Possible changes to make group objects accessible without requiring
42+
a linear progression.
43+
44+
Nuget Package
45+
-------------
46+
The nuget package can be built using ~csharp/.nuget/do-release.sh. It has a dependency on the [nuget.exe]
47+
(https://dist.nuget.org/index.html).
48+
49+
Before release it will probbalty be necessary to copy in changed files for the example contained in the published nuget
50+
package. This is a manual process for now.
51+
52+
Once the nuget package is built it can be tested within the example project by adding a local disk path to the nuget
53+
file locations and then updating sbe-tool within the example.
4254

4355

4456
Want to build things yourself?
@@ -48,5 +60,7 @@ For now you can:
4860
* build the SBE csharp generator using `gradlew`
4961
* generate the csharp codecs using `gradlew GenerateCSharpCodecs`
5062
* Use the [Visual Studio 2017 Community solution](https://github.com/real-logic/simple-binary-encoding/blob/master/csharp/csharp.sln) to build the solution, run the unit tests, examples and benchmarks
63+
* Use the command script
64+
* [csharpbuild.cmd](https://github.com/real-logic/simple-binary-encoding/blob/master/csharp/csharpbuild.cmd) to build the dotnet core support
5165
* Use the bash script [runtests.sh](https://github.com/real-logic/simple-binary-encoding/blob/master/csharp/runtests.sh) to run the tests
5266
* Build the nuget package via [do-release.sh](https://github.com/real-logic/simple-binary-encoding/blob/master/csharp/.nuget/do-release.sh) although this remains a largely manual process.

csharp/csharp.sln

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26430.6
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sbe-dll", "sbe-dll\sbe-dll.csproj", "{CE883FD9-14A5-409C-AEBC-86BEA4E3C502}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sbe-dll", "sbe-dll\sbe-dll.csproj", "{CE883FD9-14A5-409C-AEBC-86BEA4E3C502}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sbe-samples-car", "sbe-samples\sbe-samples-car.csproj", "{1B325F15-0C54-49F5-A4B9-16088222CC0E}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sbe-samples-car", "sbe-samples\sbe-samples-car.csproj", "{1B325F15-0C54-49F5-A4B9-16088222CC0E}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sbe-samples-extension", "sbe-samples\sbe-samples-extension.csproj", "{3B325F15-0C54-49F5-A4B9-16088222CC0E}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sbe-samples-extension", "sbe-samples\sbe-samples-extension.csproj", "{3B325F15-0C54-49F5-A4B9-16088222CC0E}"
1111
EndProject
12-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DF19E161-4491-4C5E-9393-70B1CD14315E}"
13-
ProjectSection(SolutionItems) = preProject
14-
README.md = README.md
15-
EndProjectSection
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sbe-benchmarks", "sbe-benchmarks\sbe-benchmarks.csproj", "{B4A22C65-AC09-43A7-B7D6-141A0B9EC0E0}"
1613
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sbe-benchmarks", "sbe-benchmarks\sbe-benchmarks.csproj", "{B4A22C65-AC09-43A7-B7D6-141A0B9EC0E0}"
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sbe-generated", "sbe-generated\sbe-generated.csproj", "{A623D315-CC7F-40D9-ACC1-3A5253FA141D}"
1815
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sbe-generated", "sbe-generated\sbe-generated.csproj", "{A623D315-CC7F-40D9-ACC1-3A5253FA141D}"
20-
EndProject
21-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sbe-tests", "sbe-tests\sbe-tests.csproj", "{385951E3-F332-462D-9D4C-DD17A8DBACB3}"
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sbe-tests", "sbe-tests\sbe-tests.csproj", "{385951E3-F332-462D-9D4C-DD17A8DBACB3}"
2217
EndProject
2318
Global
2419
GlobalSection(SolutionConfigurationPlatforms) = preSolution

csharp/sbe-samples/CarExample.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class Example
2121
{
22-
public static void Main()
22+
public static void ExampleMain()
2323
{
2424
// This byte array is used for encoding and decoding, this is what you would send on the wire or save to disk
2525
var byteBuffer = new byte[4096];
@@ -230,23 +230,23 @@ public static void Decode(Car car,
230230
sb.Append("\ncar.engine.Booster.BoostType=").Append(engine.Booster.BoostType);
231231
sb.Append("\ncar.engine.Booster.HorsePower=").Append(engine.Booster.HorsePower);
232232

233-
var fuelFiguresGroup = car.FuelFigures; // decode a repeatable group (we will change the API to support foreach soon)
233+
// The first way to access a repeating group is by using Next()
234+
var fuelFiguresGroup = car.FuelFigures;
234235
while (fuelFiguresGroup.HasNext)
235236
{
236237
var fuelFigures = fuelFiguresGroup.Next();
237238
sb.Append("\ncar.fuelFigures.speed=").Append(fuelFigures.Speed);
238239
sb.Append("\ncar.fuelFigures.mpg=").Append(fuelFigures.Mpg);
239240
}
240241

241-
// the nested group
242-
var performanceFiguresGroup = car.PerformanceFigures;
243-
while (performanceFiguresGroup.HasNext)
242+
// The second way to access a repeating group is to use an iterator
243+
foreach (Car.PerformanceFiguresGroup performanceFigures in car.PerformanceFigures)
244244
{
245-
var performanceFigures = performanceFiguresGroup.Next();
246245
sb.Append("\ncar.performanceFigures.octaneRating=").Append(performanceFigures.OctaneRating);
247246

247+
// The third way to access a repeating group is loop over the count of elements
248248
var accelerationGroup = performanceFigures.Acceleration;
249-
while (accelerationGroup.HasNext)
249+
for (int i = 0; i < accelerationGroup.Count; i++)
250250
{
251251
var acceleration = accelerationGroup.Next();
252252
sb.Append("\ncar.performanceFigures.acceleration.mph=").Append(acceleration.Mph);

csharp/sbe-samples/ExtensionExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class Example
2222
{
23-
public static void Main()
23+
public static void ExampleMain()
2424
{
2525
// This byte array is used for encoding and decoding, this is what you would send on the wire or save to disk
2626
var byteBuffer = new byte[4096];
@@ -318,7 +318,7 @@ static ExtensionExample()
318318
}
319319
}
320320

321-
public static void Main()
321+
public static void ExtensionMain()
322322
{
323323
// This byte array is used for encoding and decoding, this is what ou would send on the wire or save to disk
324324
var byteBuffer = new byte[4096];

0 commit comments

Comments
 (0)