Skip to content

Commit

Permalink
add @ExperimentalSerializationApi annotations everywhere possible
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfigure committed Sep 17, 2020
1 parent 8f4e02e commit 4948b8d
Show file tree
Hide file tree
Showing 37 changed files with 77 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.brudaswen.kotlinx.serialization.example

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.csv.Csv
Expand All @@ -15,6 +16,7 @@ data class Appearance(val gender: Gender?, val age: Int?, val height: Double?)
@Serializable
enum class Gender { MALE, FEMALE }

@ExperimentalSerializationApi
fun main() {
val csv = Csv(CsvConfiguration(hasHeaderRecord = true))

Expand Down
1 change: 1 addition & 0 deletions library/src/main/kotlin/kotlinx/serialization/csv/Csv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.serialization.modules.SerializersModule
* @param configuration CSV settings used during parsing/serialization.
* @param context Serialization module settings (e.g. custom serializers).
*/
@ExperimentalSerializationApi
class Csv(
internal val configuration: CsvConfiguration,
override val serializersModule: SerializersModule = EmptySerializersModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.StructureKind
Expand All @@ -10,6 +11,7 @@ import kotlinx.serialization.encoding.CompositeDecoder
*
* Supports header line such that class properties can be in different order.
*/
@ExperimentalSerializationApi
internal class ClassCsvDecoder(
csv: Csv,
reader: CsvReader,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.CompositeDecoder
Expand All @@ -9,6 +10,7 @@ import kotlinx.serialization.encoding.CompositeDecoder
*
* Expects that the first values defines the number of elements in the collection.
*/
@ExperimentalSerializationApi
internal class CollectionCsvDecoder(
csv: Csv,
reader: CsvReader,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.csv.Csv
Expand All @@ -11,6 +12,7 @@ import kotlinx.serialization.csv.Csv
* Therefore, the number of elements is determined by reading until the end of line and the size of the collection is
* not required and consequently not expected as the first value.
*/
@ExperimentalSerializationApi
internal class CollectionRecordCsvDecoder(
csv: Csv,
reader: CsvReader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlinx.serialization.modules.SerializersModule
/**
* Default CSV decoder.
*/
@ExperimentalSerializationApi
internal abstract class CsvDecoder(
protected val csv: Csv,
protected val reader: CsvReader,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.csv.Csv

Expand All @@ -9,6 +10,7 @@ import kotlinx.serialization.csv.Csv
* Expects the name of the object (either fully-qualified class name or
* [kotlinx.serialization.SerialName]).
*/
@ExperimentalSerializationApi
internal class ObjectCsvDecoder(
csv: Csv,
reader: CsvReader,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.csv.Csv
Expand All @@ -8,6 +9,7 @@ import kotlinx.serialization.descriptors.StructureKind
/**
* Decodes list of multiple CSV records/lines.
*/
@ExperimentalSerializationApi
internal class RecordListCsvDecoder(
csv: Csv,
reader: CsvReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.StructureKind
Expand All @@ -12,6 +13,7 @@ import kotlinx.serialization.encoding.CompositeDecoder
* (which is interpreted as multiple CSV records/lines). If this is the case, decoding continues in
* [RecordListCsvDecoder].
*/
@ExperimentalSerializationApi
internal class RootCsvDecoder(
csv: Csv,
reader: CsvReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.StructureKind
Expand All @@ -12,6 +13,7 @@ import kotlinx.serialization.encoding.CompositeDecoder
* Expects columns for all possible child classes. The columns for the actual type should be filled and all other
* columns are expected to contain `null` values.
*/
@ExperimentalSerializationApi
internal class SealedCsvDecoder(
csv: Csv,
reader: CsvReader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlinx.serialization.modules.SerializersModule
/**
* Default CSV encoder.
*/
@ExperimentalSerializationApi
internal abstract class CsvEncoder(
protected val csv: Csv,
protected val writer: CsvWriter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.encode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.csv.Csv

Expand All @@ -9,6 +10,7 @@ import kotlinx.serialization.csv.Csv
* Writes the name of the object (either fully-qualified class name or
* [kotlinx.serialization.SerialName]).
*/
@ExperimentalSerializationApi
internal class ObjectCsvEncoder(
csv: Csv,
writer: CsvWriter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package kotlinx.serialization.csv.encode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.encoding.CompositeEncoder

/**
* Encodes list of multiple CSV records/lines.
*/
@ExperimentalSerializationApi
internal class RecordListCsvEncoder(
csv: Csv,
writer: CsvWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.encode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.StructureKind
Expand All @@ -12,6 +13,7 @@ import kotlinx.serialization.encoding.CompositeEncoder
* (which is interpreted as multiple CSV records/lines). If this is the case, encoding continues in
* [RecordListCsvEncoder].
*/
@ExperimentalSerializationApi
internal class RootCsvEncoder(
csv: Csv,
writer: CsvWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.encode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.StructureKind
Expand All @@ -12,6 +13,7 @@ import kotlinx.serialization.encoding.CompositeEncoder
* Writes columns for all possible child classes. The columns for the actual type get filled and all other columns
* are filled with `null` values.
*/
@ExperimentalSerializationApi
internal class SealedCsvEncoder(
csv: Csv,
writer: CsvWriter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package kotlinx.serialization.csv.encode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv

/**
* Default CSV encoder that writes each value into the next column.
*/
@ExperimentalSerializationApi
internal open class SimpleCsvEncoder(
csv: Csv,
writer: CsvWriter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.CsvConfiguration
import kotlinx.serialization.csv.records.ComplexRecord
Expand All @@ -10,6 +11,7 @@ import kotlin.test.Test
/**
* Test [Csv] with different [CsvConfiguration.delimiter]s.
*/
@ExperimentalSerializationApi
class CsvDelimiterTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.list
import kotlinx.serialization.builtins.serializer
Expand All @@ -13,6 +14,7 @@ import kotlin.test.Test
/**
* Test [Csv] with simple primitive records.
*/
@ExperimentalSerializationApi
class CsvEmptyLinesTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.CsvConfiguration
import kotlinx.serialization.csv.CsvConfiguration.QuoteMode.NONE
Expand All @@ -11,6 +12,7 @@ import kotlin.test.Test
/**
* Test [Csv] with different [CsvConfiguration.escapeChar]s.
*/
@ExperimentalSerializationApi
class CsvEscapeCharTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.list
import kotlinx.serialization.csv.Csv
Expand All @@ -9,6 +10,7 @@ import kotlinx.serialization.test.assertParse
import kotlinx.serialization.test.assertStringFormAndRestored
import kotlin.test.Test

@ExperimentalSerializationApi
class CsvHasHeaderRecordTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.list
import kotlinx.serialization.builtins.serializer
Expand All @@ -10,6 +11,7 @@ import kotlinx.serialization.csv.records.IntRecord
import kotlinx.serialization.test.assertStringFormAndRestored
import kotlin.test.Test

@ExperimentalSerializationApi
class CsvHasTrailingDelimiterTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.CsvConfiguration
import kotlinx.serialization.csv.records.NullRecord
Expand All @@ -9,6 +10,7 @@ import kotlin.test.Test
/**
* Test [Csv] with different [CsvConfiguration.nullString]s.
*/
@ExperimentalSerializationApi
class CsvNullStringTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.CsvConfiguration
import kotlinx.serialization.csv.CsvConfiguration.QuoteMode.ALL
Expand All @@ -11,6 +12,7 @@ import kotlin.test.Test
/**
* Test [Csv] with different [CsvConfiguration.quoteChar]s.
*/
@ExperimentalSerializationApi
class CsvQuoteCharTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.CsvConfiguration
import kotlinx.serialization.csv.CsvConfiguration.QuoteMode.*
import kotlinx.serialization.csv.records.*
import kotlinx.serialization.test.assertStringFormAndRestored
import kotlin.test.Test

@ExperimentalSerializationApi
class CsvQuoteModeTest {

// TestString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.list
import kotlinx.serialization.csv.Csv
Expand All @@ -11,6 +12,7 @@ import kotlin.test.Test
/**
* Test [Csv] with different [CsvConfiguration.recordSeparator]s.
*/
@ExperimentalSerializationApi
class CsvRecordSeparatorTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.config

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.records.UnitRecord
import kotlinx.serialization.test.assertStringFormAndRestored
Expand All @@ -8,6 +9,7 @@ import kotlin.test.Test
/**
* Test [Csv] with [kotlin.Unit].
*/
@ExperimentalSerializationApi
class CsvUnitStringTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.serialization.csv.decode

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.records.IntStringRecord
import kotlinx.serialization.csv.records.StringRecord
Expand All @@ -9,6 +10,7 @@ import kotlin.test.Test
/**
* Test [kotlinx.serialization.csv.decode.CsvDecoder] with quoted values.
*/
@ExperimentalSerializationApi
class CsvQuotedTest {

@Test
Expand Down
Loading

0 comments on commit 4948b8d

Please sign in to comment.