nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: avro-kotlin/avro4k
Pull request #99 (2021-04-07 08:22:43)

Use UUIDSerializer as contextual in Avro.default
Current code in SerializersModule is no op:

```kotlin
 mapOf(
            UUID::class to UUIDSerializer()
         )
```

vladimirfx: This PR is depends on #88 
thake: @vladimirfx thanks for fixing :+1: 
I will merge this as soon as #98 is merged
thake: @vladimirfx can you rebase on the current master so that the CI build works?

Patch:
diff --git a/src/main/kotlin/com/github/avrokotlin/avro4k/Avro.kt b/src/main/kotlin/com/github/avrokotlin/avro4k/Avro.kt
index 810a640..6e98452 100644
--- a/src/main/kotlin/com/github/avrokotlin/avro4k/Avro.kt
+++ b/src/main/kotlin/com/github/avrokotlin/avro4k/Avro.kt
@@ -10,6 +10,7 @@ import com.github.avrokotlin.avro4k.serializer.UUIDSerializer
 import kotlinx.serialization.*
 import kotlinx.serialization.descriptors.SerialDescriptor
 import kotlinx.serialization.modules.SerializersModule
+import kotlinx.serialization.modules.contextual
 import org.apache.avro.Schema
 import org.apache.avro.file.CodecFactory
 import org.apache.avro.generic.GenericRecord
@@ -18,7 +19,6 @@ import java.nio.ByteBuffer
 import java.nio.file.Files
 import java.nio.file.Path
 import java.nio.file.Paths
-import java.util.*
 
 open class AvroInputStreamBuilder<T>(
    private val converter: (Any) -> T
@@ -125,9 +125,7 @@ class Avro(
    constructor(configuration: AvroConfiguration) : this(defaultModule, configuration)
    companion object {
       val defaultModule = SerializersModule {
-         mapOf(
-            UUID::class to UUIDSerializer()
-         )
+         contextual(UUIDSerializer())
       }
       val default = Avro(defaultModule)
 
@@ -271,4 +269,4 @@ class Avro(
       return schema(serializer.descriptor)
    }
 
-}
\ No newline at end of file
+}


Test patch:
diff --git a/src/test/kotlin/com/github/avrokotlin/avro4k/DefaultAvroTest.kt b/src/test/kotlin/com/github/avrokotlin/avro4k/DefaultAvroTest.kt
new file mode 100644
index 0000000..1dbfa31
--- /dev/null
+++ b/src/test/kotlin/com/github/avrokotlin/avro4k/DefaultAvroTest.kt
@@ -0,0 +1,20 @@
+package com.github.avrokotlin.avro4k
+
+import io.kotest.core.spec.style.FunSpec
+import io.kotest.matchers.shouldBe
+import kotlinx.serialization.Contextual
+import kotlinx.serialization.Serializable
+import java.util.UUID
+
+class DefaultAvroTest : FunSpec({
+
+    test("encoding UUID") {
+
+        @Serializable
+        data class Foo(@Contextual val a: UUID)
+
+        val uuid = UUID.randomUUID()
+        val record = Avro.default.toRecord(Foo.serializer(), Foo(uuid))
+        record.get("a").toString() shouldBe uuid.toString()
+    }
+})