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#,C++,Java] Generate DTOs for non-perf-sensitive usecases. #957

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c5067e6
[C#] Generate DTOs from SBE IR for non-perf-sensitive usecases.
ZachBray Sep 27, 2023
440a0b0
[Java] Start to introduce property based testing (PBT).
ZachBray Oct 5, 2023
9d038c9
[Java] Fix typos.
ZachBray Oct 5, 2023
e988b51
[Java] Move property tests to their own source set.
ZachBray Oct 5, 2023
5118d06
[Java] Suppress javadoc warnings in propertyTest source set.
ZachBray Oct 6, 2023
3ccb3e8
[Java] Split apart schema generation files.
ZachBray Oct 6, 2023
31d8d48
[Java] Extend PBT to generate arbitrary encoded messages.
ZachBray Oct 6, 2023
41c01ba
[Java] Test DTOs preserve information.
ZachBray Oct 7, 2023
dd36f31
[Java,C#] Make dotnet executable customisable in tests.
ZachBray Oct 10, 2023
c03e53e
[Java] Extend schema generation to include bitsets with gaps.
ZachBray Oct 10, 2023
5377d9a
[Java] Use arbitrary fixed-length arrays in property tests.
ZachBray Oct 10, 2023
0d3a6bc
[Java] Model optional fields in property-based tests.
ZachBray Oct 11, 2023
ead428c
[Java, C#] Add a GitHub workflow for slow checks.
ZachBray Oct 11, 2023
a207daf
[Java] Extend arbitrary varData encodings.
ZachBray Oct 11, 2023
a83ee9a
[Java, C#] Tidy up encoded message writing in tests.
ZachBray Oct 12, 2023
d312555
[C#] Upgrade to latest LTS .NET version.
ZachBray Oct 12, 2023
ff99679
[C#] Generate DTOs using C# 9+ records.
ZachBray Oct 12, 2023
a58e36c
[C#] Use more-idiomatic null representations.
ZachBray Oct 17, 2023
8f6b74f
[IR] Change default float and double values to minimum representable …
ZachBray Oct 18, 2023
92331c8
[C#] Add validation to DTOs and improve use of records.
ZachBray Oct 18, 2023
3f4168e
[C#] Support DTO generation via system property.
ZachBray Oct 18, 2023
04ee2f7
[C#] Extend tests to cover extended schemas.
ZachBray Oct 19, 2023
cc6514d
[C#] Address some of Martin's feedback re "added" var data representa…
ZachBray Nov 9, 2023
b19227e
[C#] Address feedback around encode/decode methods.
ZachBray Nov 10, 2023
64f6516
[C++] Generate DTOs for non-perf-sensitive usecases.
ZachBray Nov 2, 2023
4ff1e11
[C++] Only build DTOs with compilers that support C++ 17.
ZachBray Nov 2, 2023
b8b3e01
[C++] Improve naming conventions in DTOs.
ZachBray Nov 3, 2023
bc3e523
[C++] Support "to string" without specification of buffer length.
ZachBray Nov 3, 2023
fd06b2d
[C++] Fix issues with length computation.
ZachBray Nov 3, 2023
4cc68f1
[C++] Address feedback from Todd re var data representation.
ZachBray Nov 9, 2023
57fcebd
[C++] Add PBT for C++ DTOs.
ZachBray Nov 11, 2023
f05f63a
[Java, C++, C#] Ensure buffer is large enough to contain message.
ZachBray Nov 13, 2023
79b4c61
[CI] Fix dependency conflict in JQwik.
ZachBray Nov 11, 2023
3d7a381
[CI] Upload slow test artifacts upon failure.
ZachBray Nov 13, 2023
d6ca75d
[C#] Provide path to SBE.dll for C# property tests in CI.
ZachBray Nov 13, 2023
1a7a9dc
[Java] Adjust copyright banners.
ZachBray May 1, 2024
bdfbc8f
[Java] Add support for DTO generation.
ZachBray May 13, 2024
a8fa1a4
[Java] Extend property-based tests to exercise Java DTOs.
ZachBray May 14, 2024
3e95123
[Java] Avoid checking parentMessage.actingVersion inside composite.
ZachBray May 15, 2024
e4479b2
[Java] Fix remaining DTO issues uncovered with PBT.
ZachBray May 15, 2024
eacdb50
[Java] Tidy up spacing.
ZachBray May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Expand Up @@ -88,7 +88,7 @@ jobs:
fail-fast: false
matrix:
language: [ 'csharp' ]
dotnet: [ '3.1.x' ]
dotnet: [ '8.0.x' ]
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/slow.yml
@@ -0,0 +1,62 @@
name: Slow checks

on:
workflow_dispatch:
branches:
- '**'
schedule:
- cron: '0 12 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.java.installations.auto-detect=false -Dorg.gradle.warning.mode=fail'

permissions:
contents: read

jobs:
property-tests:
name: Property tests
runs-on: ubuntu-22.04
strategy:
matrix:
java: [ '21' ]
dotnet: [ '8.0.x' ]
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
run: |
java -Xinternalversion
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
echo "BUILD_JAVA_VERSION=${{ matrix.java }}" >> $GITHUB_ENV
- name: Setup java 8 to run the Gradle script
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 8
- name: Setup dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Build .NET library
run: ./csharp/build.sh
- name: Run property tests
run: ./gradlew propertyTest
- name: Upload test results
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: property-tests
path: sbe-tool/build/reports/tests/propertyTest
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -119,4 +119,7 @@ rust/Cargo.lock
.DS_Store
/sbe-tool/src/main/golang/uk_co_real_logic_sbe_ir_generated/

# JQwik
*.jqwik-database

/generated/
122 changes: 102 additions & 20 deletions build.gradle
Expand Up @@ -31,6 +31,7 @@ buildscript {

plugins {
id 'java-library'
id 'jvm-test-suite'
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id 'com.github.ben-manes.versions' version '0.51.0'
}
Expand All @@ -57,6 +58,8 @@ def checkstyleVersion = '9.3'
def hamcrestVersion = '2.2'
def mockitoVersion = '4.11.0'
def junitVersion = '5.10.2'
def jqwikVersion = '1.8.1'
def jsonVersion = '20230618'
def jmhVersion = '1.37'
def agronaVersion = '1.21.1'
def agronaVersionRange = '[1.21.1,2.0[' // allow any release >= 1.21.1 and < 2.0.0
Expand Down Expand Up @@ -164,6 +167,7 @@ jar.enabled = false

subprojects {
apply plugin: 'java-library'
apply plugin: 'jvm-test-suite'
apply plugin: 'checkstyle'

group = sbeGroup
Expand Down Expand Up @@ -216,22 +220,34 @@ subprojects {
}
}

test {
useJUnitPlatform()
testing {
suites {
test {
useJUnitJupiter junitVersion

testLogging {
for (def level : LogLevel.values())
{
def testLogging = get(level)
testLogging.exceptionFormat = 'full'
testLogging.events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
}
}
targets {
all {
testTask.configure {
useJUnitPlatform()

javaLauncher.set(toolchainLauncher)
testLogging {
for (def level : LogLevel.values())
{
def testLogging = get(level)
testLogging.exceptionFormat = 'full'
testLogging.events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
}
}

javaLauncher.set(toolchainLauncher)

systemProperty 'sbe.enable.ir.precedence.checks', 'true'
systemProperty 'sbe.enable.test.precedence.checks', 'true'
systemProperty 'sbe.enable.ir.precedence.checks', 'true'
systemProperty 'sbe.enable.test.precedence.checks', 'true'
}
}
}
}
}
}
}

Expand All @@ -248,11 +264,6 @@ project(':sbe-tool') {
prefer(agronaVersion)
}
}
testImplementation files('build/classes/java/generated')
testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}"
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}

def generatedDir = 'build/generated-src'
Expand All @@ -269,11 +280,55 @@ project(':sbe-tool') {

compileGeneratedJava {
dependsOn 'generateTestCodecs'
dependsOn 'generateTestDtos'
classpath += sourceSets.main.runtimeClasspath
}

compileTestJava.dependsOn compileGeneratedJava

testing {
suites {
test {
dependencies {
implementation files('build/classes/java/generated')
implementation "org.hamcrest:hamcrest:${hamcrestVersion}"
implementation "org.mockito:mockito-core:${mockitoVersion}"
implementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
Comment on lines +293 to +296
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we're using jvm-test-suites to add new source sets in a Gradle 9 compatible manner.
Here implementation means testImplementation in old money.

Copy link
Contributor Author

@ZachBray ZachBray Oct 19, 2023

Choose a reason for hiding this comment

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

Proof

 zach@worky-ii  ~/src/real-logic/simple-binary-encoding   feature/dtos ⍟6  ↵ 1  ./gradlew sbe-tool:dependencies

Project ':sbe-tool'

annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies

api - API dependencies for source set 'main'. (n)
--- org.agrona:agrona:[1.19.2,2.0[ (n)

apiElements - API elements for main. (n)
No dependencies

checkstyle - The Checkstyle libraries to be used for this project.
--- com.puppycrawl.tools:checkstyle:9.3
+--- info.picocli:picocli:4.6.2
+--- org.antlr:antlr4-runtime:4.9.3
+--- commons-beanutils:commons-beanutils:1.9.4
| --- commons-collections:commons-collections:3.2.2
+--- com.google.guava:guava:31.0.1-jre
| +--- com.google.guava:failureaccess:1.0.1
| +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
| +--- com.google.code.findbugs:jsr305:3.0.2
| +--- org.checkerframework:checker-qual:3.12.0
| +--- com.google.errorprone:error_prone_annotations:2.7.1
| --- com.google.j2objc:j2objc-annotations:1.3
+--- org.reflections:reflections:0.10.2
| +--- org.javassist:javassist:3.28.0-GA
| --- com.google.code.findbugs:jsr305:3.0.2
--- net.sf.saxon:Saxon-HE:10.6

compileClasspath - Compile classpath for source set 'main'.
--- org.agrona:agrona:{strictly [1.19.2,2.0[; prefer 1.19.2} -> 1.19.2

compileOnly - Compile only dependencies for source set 'main'. (n)
No dependencies

compileOnlyApi - Compile only API dependencies for source set 'main'. (n)
No dependencies

default - Configuration for default artifacts. (n)
No dependencies

generatedAnnotationProcessor - Annotation processors and their dependencies for source set 'generated'.
No dependencies

generatedCompileClasspath - Compile classpath for source set 'generated'.
No dependencies

generatedCompileOnly - Compile only dependencies for source set 'generated'. (n)
No dependencies

generatedImplementation - Implementation only dependencies for source set 'generated'. (n)
No dependencies

generatedRuntimeClasspath - Runtime classpath of source set 'generated'.
No dependencies

generatedRuntimeOnly - Runtime only dependencies for source set 'generated'. (n)
No dependencies

implementation - Implementation only dependencies for source set 'main'. (n)
No dependencies

javadocElements - javadoc elements for main. (n)
No dependencies

mainSourceElements - List of source directories contained in the Main SourceSet. (n)
No dependencies

propertyTestAnnotationProcessor - Annotation processors and their dependencies for source set 'property test'.
No dependencies

propertyTestCompileClasspath - Compile classpath for source set 'property test'.
+--- project :sbe-tool ()
+--- net.jqwik:jqwik:1.8.0
| +--- org.apiguardian:apiguardian-api:1.1.2
| +--- net.jqwik:jqwik-api:1.8.0
| | +--- org.apiguardian:apiguardian-api:1.1.2
| | +--- org.opentest4j:opentest4j:1.3.0
| | --- org.junit.platform:junit-platform-commons:1.10.0
| | +--- org.junit:junit-bom:5.10.0
| | | +--- org.junit.jupiter:junit-jupiter:5.10.0 (c)
| | | +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (c)
| | | +--- org.junit.jupiter:junit-jupiter-params:5.10.0 (c)
| | | --- org.junit.platform:junit-platform-commons:1.10.0 (c)
| | --- org.apiguardian:apiguardian-api:1.1.2
| +--- net.jqwik:jqwik-web:1.8.0
| | +--- org.apiguardian:apiguardian-api:1.1.2
| | +--- net.jqwik:jqwik-api:1.8.0 (
)
| | --- org.opentest4j:opentest4j:1.3.0
| --- net.jqwik:jqwik-time:1.8.0
| +--- org.apiguardian:apiguardian-api:1.1.2
| +--- net.jqwik:jqwik-api:1.8.0 ()
| --- org.opentest4j:opentest4j:1.3.0
+--- org.json:json:20230618
+--- org.junit.jupiter:junit-jupiter:5.10.0
| +--- org.junit:junit-bom:5.10.0 (
)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.0
| | +--- org.junit:junit-bom:5.10.0 ()
| | +--- org.opentest4j:opentest4j:1.3.0
| | +--- org.junit.platform:junit-platform-commons:1.10.0 (
)
| | --- org.apiguardian:apiguardian-api:1.1.2
| --- org.junit.jupiter:junit-jupiter-params:5.10.0
| +--- org.junit:junit-bom:5.10.0 ()
| +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (
)
| --- org.apiguardian:apiguardian-api:1.1.2
--- org.agrona:agrona:{strictly [1.19.2,2.0[; prefer 1.19.2} -> 1.19.2

propertyTestCompileOnly - Compile only dependencies for source set 'property test'. (n)
No dependencies

propertyTestImplementation - Implementation only dependencies for source set 'property test'. (n)
+--- project sbe-tool (n)
+--- net.jqwik:jqwik:1.8.0 (n)
--- org.json:json:20230618 (n)

propertyTestRuntimeClasspath - Runtime classpath of source set 'property test'.
+--- project :sbe-tool ()
+--- net.jqwik:jqwik:1.8.0
| +--- org.apiguardian:apiguardian-api:1.1.2
| +--- net.jqwik:jqwik-api:1.8.0
| | +--- org.apiguardian:apiguardian-api:1.1.2
| | +--- org.opentest4j:opentest4j:1.3.0
| | --- org.junit.platform:junit-platform-commons:1.10.0
| | --- org.junit:junit-bom:5.10.0
| | +--- org.junit.jupiter:junit-jupiter:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.10.0 (c)
| | +--- org.junit.platform:junit-platform-commons:1.10.0 (c)
| | +--- org.junit.platform:junit-platform-engine:1.10.0 (c)
| | --- org.junit.platform:junit-platform-launcher:1.10.0 (c)
| +--- net.jqwik:jqwik-web:1.8.0
| | +--- org.apiguardian:apiguardian-api:1.1.2
| | +--- net.jqwik:jqwik-api:1.8.0 (
)
| | --- org.opentest4j:opentest4j:1.3.0
| +--- net.jqwik:jqwik-time:1.8.0
| | +--- org.apiguardian:apiguardian-api:1.1.2
| | +--- net.jqwik:jqwik-api:1.8.0 ()
| | --- org.opentest4j:opentest4j:1.3.0
| --- net.jqwik:jqwik-engine:1.8.0
| +--- org.junit.platform:junit-platform-engine:1.10.0
| | +--- org.junit:junit-bom:5.10.0 (
)
| | +--- org.opentest4j:opentest4j:1.3.0
| | --- org.junit.platform:junit-platform-commons:1.10.0 ()
| +--- org.apiguardian:apiguardian-api:1.1.2
| +--- net.jqwik:jqwik-api:1.8.0 (
)
| +--- org.opentest4j:opentest4j:1.3.0
| --- org.junit.platform:junit-platform-commons:1.10.0 ()
+--- org.json:json:20230618
+--- org.junit.jupiter:junit-jupiter:5.10.0
| +--- org.junit:junit-bom:5.10.0 (
)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.0
| | +--- org.junit:junit-bom:5.10.0 ()
| | +--- org.opentest4j:opentest4j:1.3.0
| | --- org.junit.platform:junit-platform-commons:1.10.0 (
)
| +--- org.junit.jupiter:junit-jupiter-params:5.10.0
| | +--- org.junit:junit-bom:5.10.0 ()
| | --- org.junit.jupiter:junit-jupiter-api:5.10.0 (
)
| --- org.junit.jupiter:junit-jupiter-engine:5.10.0
| +--- org.junit:junit-bom:5.10.0 ()
| +--- org.junit.platform:junit-platform-engine:1.10.0 (
)
| --- org.junit.jupiter:junit-jupiter-api:5.10.0 ()
+--- org.junit.platform:junit-platform-launcher -> 1.10.0
| +--- org.junit:junit-bom:5.10.0 (
)
| --- org.junit.platform:junit-platform-engine:1.10.0 (*)
--- org.agrona:agrona:{strictly [1.19.2,2.0[; prefer 1.19.2} -> 1.19.2

propertyTestRuntimeOnly - Runtime only dependencies for source set 'property test'. (n)
No dependencies

runtimeClasspath - Runtime classpath of source set 'main'.
--- org.agrona:agrona:{strictly [1.19.2,2.0[; prefer 1.19.2} -> 1.19.2

runtimeElements - Elements of runtime for main. (n)
No dependencies

runtimeOnly - Runtime only dependencies for source set 'main'. (n)
No dependencies

signatures (n)
No dependencies

sourcesElements - sources elements for main. (n)
No dependencies

testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies

testCompileClasspath - Compile classpath for source set 'test'.
+--- org.agrona:agrona:{strictly [1.19.2,2.0[; prefer 1.19.2} -> 1.19.2
+--- org.hamcrest:hamcrest:2.2
+--- org.mockito:mockito-core:4.11.0
| +--- net.bytebuddy:byte-buddy:1.12.19
| --- net.bytebuddy:byte-buddy-agent:1.12.19
+--- org.junit.jupiter:junit-jupiter-params:5.10.0
| +--- org.junit:junit-bom:5.10.0
| | +--- org.junit.jupiter:junit-jupiter:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.10.0 (c)
| | --- org.junit.platform:junit-platform-commons:1.10.0 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.0
| | +--- org.junit:junit-bom:5.10.0 ()
| | +--- org.opentest4j:opentest4j:1.3.0
| | +--- org.junit.platform:junit-platform-commons:1.10.0
| | | +--- org.junit:junit-bom:5.10.0 (
)
| | | --- org.apiguardian:apiguardian-api:1.1.2
| | --- org.apiguardian:apiguardian-api:1.1.2
| --- org.apiguardian:apiguardian-api:1.1.2
--- org.junit.jupiter:junit-jupiter:5.10.0
+--- org.junit:junit-bom:5.10.0 ()
+--- org.junit.jupiter:junit-jupiter-api:5.10.0 (
)
--- org.junit.jupiter:junit-jupiter-params:5.10.0 (*)

testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies

testImplementation - Implementation only dependencies for source set 'test'. (n)
+--- unspecified (n)
+--- org.hamcrest:hamcrest:2.2 (n)
+--- org.mockito:mockito-core:4.11.0 (n)
--- org.junit.jupiter:junit-jupiter-params:5.10.0 (n)

testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.agrona:agrona:{strictly [1.19.2,2.0[; prefer 1.19.2} -> 1.19.2
+--- org.hamcrest:hamcrest:2.2
+--- org.mockito:mockito-core:4.11.0
| +--- net.bytebuddy:byte-buddy:1.12.19
| +--- net.bytebuddy:byte-buddy-agent:1.12.19
| --- org.objenesis:objenesis:3.3
+--- org.junit.jupiter:junit-jupiter-params:5.10.0
| +--- org.junit:junit-bom:5.10.0
| | +--- org.junit.jupiter:junit-jupiter:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.0 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.10.0 (c)
| | +--- org.junit.platform:junit-platform-launcher:1.10.0 (c)
| | +--- org.junit.platform:junit-platform-commons:1.10.0 (c)
| | --- org.junit.platform:junit-platform-engine:1.10.0 (c)
| --- org.junit.jupiter:junit-jupiter-api:5.10.0
| +--- org.junit:junit-bom:5.10.0 ()
| +--- org.opentest4j:opentest4j:1.3.0
| --- org.junit.platform:junit-platform-commons:1.10.0
| --- org.junit:junit-bom:5.10.0 (
)
+--- org.junit.jupiter:junit-jupiter:5.10.0
| +--- org.junit:junit-bom:5.10.0 ()
| +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (
)
| +--- org.junit.jupiter:junit-jupiter-params:5.10.0 ()
| --- org.junit.jupiter:junit-jupiter-engine:5.10.0
| +--- org.junit:junit-bom:5.10.0 (
)
| +--- org.junit.platform:junit-platform-engine:1.10.0
| | +--- org.junit:junit-bom:5.10.0 ()
| | +--- org.opentest4j:opentest4j:1.3.0
| | --- org.junit.platform:junit-platform-commons:1.10.0 (
)
| --- org.junit.jupiter:junit-jupiter-api:5.10.0 ()
--- org.junit.platform:junit-platform-launcher -> 1.10.0
+--- org.junit:junit-bom:5.10.0 (
)
--- org.junit.platform:junit-platform-engine:1.10.0 (*)

testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
No dependencies

(c) - A dependency constraint, not a dependency. The dependency affected by the constraint occurs elsewhere in the tree.
(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.

(n) - A dependency or dependency configuration that cannot be resolved.

A web-based, searchable dependency report is available by adding the --scan option.

}
}

propertyTest(JvmTestSuite) {
// We should be able to use _only_ the JQwik engine, but this issue is outstanding:
// https://github.com/gradle/gradle/issues/21299
useJUnitJupiter junitVersion

dependencies {
implementation project()
implementation("net.jqwik:jqwik:${jqwikVersion}") {
// Exclude JUnit 5 dependencies that are already provided due to useJUnitJupiter
exclude group: 'org.junit.platform', module: 'junit-platform-commons'
exclude group: 'org.junit.platform', module: 'junit-platform-engine'
}
implementation "org.json:json:${jsonVersion}"
}


targets {
all {
testTask.configure {
minHeapSize = '2g'
maxHeapSize = '2g'

javaLauncher.set(toolchainLauncher)

systemProperty 'sbe.dll', "${rootProject.projectDir}/csharp/sbe-dll/bin/Release/netstandard2.0/SBE.dll"
}
}
}
}
}
}

tasks.register('generateTestCodecs', JavaExec) {
dependsOn 'compileJava'
mainClass.set('uk.co.real_logic.sbe.SbeTool')
Expand All @@ -290,6 +345,21 @@ project(':sbe-tool') {
'src/test/resources/field-order-check-schema.xml']
}

tasks.register('generateTestDtos', JavaExec) {
dependsOn 'compileJava'
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': generatedDir,
'sbe.target.language': 'java',
'sbe.validation.stop.on.error': 'true',
'sbe.validation.xsd': validationXsdPath,
'sbe.generate.precedence.checks': 'true',
'sbe.java.precedence.checks.property.name': 'sbe.enable.test.precedence.checks',
'sbe.java.generate.dtos': 'true')
args = ['src/test/resources/example-extension-schema.xml']
}

jar {
manifest.attributes(
'Specification-Title': 'Simple Binary Encoding',
Expand Down Expand Up @@ -735,7 +805,7 @@ tasks.register('generateCSharpCodecsWithXIncludes', JavaExec) {
'sbe-samples/src/main/resources/example-extension-schema.xml']
}

tasks.register('generateCSharpCodecsTests', JavaExec) {
tasks.register('generateCSharpTestCodecs', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
Expand All @@ -754,9 +824,21 @@ tasks.register('generateCSharpCodecsTests', JavaExec) {
'sbe-benchmarks/src/main/resources/fix-message-samples.xml']
}

tasks.register('generateCSharpTestDtos', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'csharp/sbe-generated',
'sbe.target.language': 'uk.co.real_logic.sbe.generation.csharp.CSharpDtos',
Copy link
Contributor

@ethanf ethanf Oct 1, 2023

Choose a reason for hiding this comment

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

I think this is better than the approach for multiple generators in Go in #951.

For that one, we added an extra flag sbe.go.generate.generate.flyweights=true. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I struggled to choose between the two mechanisms: flag vs. generator. I opted for the generator, as it seemed less intrusive (and less likely to collide with changes in my other PR). However, at that time, I had not noticed the existing pattern for the Go generation. Using a flag avoids spinning up a new JVM and parsing the schema multiple times. Therefore, that might be a better pattern. We should be consistent in any case. I'm happy to use a flag instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For consistency, I've added a system property, sbe.csharp.generate.dtos, that enables DTO generation when using the CSharp rather than CSharpDtos target.

'sbe.xinclude.aware': 'true',
'sbe.validation.xsd': validationXsdPath)
args = ['sbe-samples/src/main/resources/example-extension-schema.xml']
}

tasks.register('generateCSharpCodecs') {
description = 'Generate csharp codecs'
dependsOn 'generateCSharpCodecsTests',
dependsOn 'generateCSharpTestCodecs',
'generateCSharpTestDtos',
'generateCSharpCodecsWithXIncludes'
}

Expand Down
1 change: 1 addition & 0 deletions config/checkstyle/suppressions.xml
Expand Up @@ -6,5 +6,6 @@
<suppress files=".*generated-src.*" checks="."/>
<suppress files=".*generated.*" checks="."/>
<suppress files="[\\/]test[\\/]" checks="MissingJavadoc.*"/>
<suppress files="[\\/]propertyTest[\\/]" checks="MissingJavadoc.*"/>
<suppress files="[\\/]sbe-benchmarks[\\/]" checks="MissingJavadoc.*"/>
</suppressions>
7 changes: 1 addition & 6 deletions csharp/sbe-dll/DirectBuffer.cs
Expand Up @@ -694,21 +694,16 @@ public int SetBytes(int index, ReadOnlySpan<byte> src)

/// <summary>
/// Writes a string into the underlying buffer, encoding using the provided <see cref="System.Text.Encoding"/>.
/// If there is not enough room in the buffer for the bytes it will throw IndexOutOfRangeException.
/// </summary>
/// <param name="encoding">encoding to use to write the bytes from the string</param>
/// <param name="src">source string</param>
/// <param name="index">index in the underlying buffer to start writing bytes</param>
/// <returns>count of bytes written</returns>
public unsafe int SetBytesFromString(Encoding encoding, string src, int index)
{
int available = _capacity - index;
int byteCount = encoding.GetByteCount(src);

if (byteCount > available)
{
ThrowHelper.ThrowIndexOutOfRangeException(_capacity);
}
CheckLimit(index + byteCount);

fixed (char* ptr = src)
{
Expand Down