diff --git a/rd-kt/rd-core/src/main/kotlin/com/jetbrains/rd/util/reactive/ConcurrentViewableSet.kt b/rd-kt/rd-core/src/main/kotlin/com/jetbrains/rd/util/reactive/ConcurrentViewableSet.kt index 3605ac693..4382fe94d 100644 --- a/rd-kt/rd-core/src/main/kotlin/com/jetbrains/rd/util/reactive/ConcurrentViewableSet.kt +++ b/rd-kt/rd-core/src/main/kotlin/com/jetbrains/rd/util/reactive/ConcurrentViewableSet.kt @@ -128,7 +128,7 @@ class ConcurrentViewableSet : IMutableViewableConcurrentSet { continue try { - action(definition, value) + action(newLifetime, value) } catch (e: Throwable) { Logger.root.error(e) } diff --git a/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/csharp/CSharp50Generator.kt b/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/csharp/CSharp50Generator.kt index b4a785af1..fcfe75a49 100644 --- a/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/csharp/CSharp50Generator.kt +++ b/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/csharp/CSharp50Generator.kt @@ -338,7 +338,10 @@ open class CSharp50Generator( protected fun Member.Reactive.customSerializers(containing: Declaration, leadingComma: Boolean, ignorePerClientId: Boolean = false): String { if(context != null && !ignorePerClientId) return leadingComma.condstr { ", " } + perClientIdMapValueFactory(containing) - val res = genericParams.joinToString { it.readerDelegateRef(containing, true) + ", " + it.writerDelegateRef(containing, false) } + val res = genericParams.joinToString { + val allowSpecificOpenTypeReference = false + it.readerDelegateRef(containing, allowSpecificOpenTypeReference) + ", " + it.writerDelegateRef(containing, allowSpecificOpenTypeReference) + } return (genericParams.isNotEmpty() && leadingComma).condstr { ", " } + res } diff --git a/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt b/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt index f09a4d2d2..1d9d1620b 100644 --- a/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt +++ b/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt @@ -263,7 +263,7 @@ open class Kotlin11Generator( protected fun Member.Reactive.customSerializers(scope: Declaration, ignorePerClientId: Boolean = false) : List { if (context != null && !ignorePerClientId) return listOf(context!!.longRef(scope), perClientIdMapValueFactory(scope)) - return genericParams.asList().map { it.serializerRef(scope) } + return genericParams.asList().map { it.serializerRef(scope, false) } } protected fun IDeclaration.sanitizedName(scope: IDeclaration) : String { @@ -271,14 +271,14 @@ open class Kotlin11Generator( return needQualification.condstr { namespace + "." } + name } - protected fun IType.leafSerializerRef(scope: Declaration): String? { + protected fun IType.leafSerializerRef(scope: Declaration, allowSpecificOpenTypeReference: Boolean): String? { return when (this) { is Enum -> "${sanitizedName(scope)}.marshaller" is PredefinedType -> "FrameworkMarshallers.$name" is Declaration -> this.getSetting(Intrinsic)?.marshallerObjectFqn ?: run { val name = sanitizedName(scope) - if (isAbstract) "AbstractPolymorphic($name)" else name + if (isAbstract || isOpen && !allowSpecificOpenTypeReference) "AbstractPolymorphic($name)" else name } is IArray -> if (this.isPrimitivesArray) "FrameworkMarshallers.${substitutedName(scope)}" else null @@ -286,7 +286,7 @@ open class Kotlin11Generator( } } - protected fun IType.serializerRef(scope: Declaration) : String = leafSerializerRef(scope) ?: when(this) { + protected fun IType.serializerRef(scope: Declaration, allowSpecificOpenTypeReference: Boolean) : String = leafSerializerRef(scope, allowSpecificOpenTypeReference) ?: when(this) { is InternedScalar -> "__${name}At${internKey.keyName}Serializer" else -> "__${name}Serializer" } @@ -450,7 +450,7 @@ open class Kotlin11Generator( if(decl is Toplevel) { decl.declaredTypes.forEach { if(it is Context.Generated) - +"object ${it.keyName}: ${it.contextImplementationFqn}<${it.type.substitutedName(decl)}>(\"${it.keyName}\", ${it.isHeavyKey}, ${it.type.serializerRef(decl)})" + +"object ${it.keyName}: ${it.contextImplementationFqn}<${it.type.substitutedName(decl)}>(\"${it.keyName}\", ${it.isHeavyKey}, ${it.type.serializerRef(decl, false)})" } } } @@ -580,7 +580,7 @@ open class Kotlin11Generator( } protected fun PrettyPrinter.customSerializersTrait(decl: Declaration) { - fun IType.serializerBuilder() : String = leafSerializerRef(decl)?: when (this) { + fun IType.serializerBuilder() : String = leafSerializerRef(decl, false)?: when (this) { is IArray -> itemType.serializerBuilder() + ".array()" is IImmutableList -> itemType.serializerBuilder() + ".list()" is INullable -> itemType.serializerBuilder() + ".nullable()" @@ -593,10 +593,10 @@ open class Kotlin11Generator( .filterIsInstance() .flatMap { it.genericParams.toList() } .distinct() - .filter { it.leafSerializerRef(decl) == null } + .filter { it.leafSerializerRef(decl, false) == null } allTypesForDelegation - .map { "private val ${it.serializerRef(decl)} = ${it.serializerBuilder()}" } + .map { "private val ${it.serializerRef(decl, false)} = ${it.serializerBuilder()}" } .distinct() .forEach { println(it) } } @@ -610,7 +610,7 @@ open class Kotlin11Generator( protected fun PrettyPrinter.registerSerializersTrait(decl: Toplevel, types: List) { block("override fun registerSerializersCore(serializers: ISerializers) ") { types.filter { !it.isAbstract }.filterIsInstance().println { - "serializers.register(${it.serializerRef(decl)})" + "serializers.register(${it.serializerRef(decl, true)})" } if (decl is Root) { @@ -727,7 +727,8 @@ open class Kotlin11Generator( else -> "${ctorSimpleName(decl)}(${delegatedBy.reader()})" } is Member.Reactive -> { - val params = (listOf("ctx", "buffer") + customSerializers(decl)).joinToString (", ") + val customSerializers = customSerializers(decl) + val params = (listOf("ctx", "buffer") + customSerializers).joinToString (", ") if(context != null) { "RdPerContextMap.read(${context!!.longRef(decl)}, buffer) ${this.perClientIdMapValueFactory(decl)}" } else { diff --git a/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/csharp/RecursivePolymorphicCSharpTest.kt b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/csharp/RecursivePolymorphicCSharpTest.kt new file mode 100644 index 000000000..6e8b13c37 --- /dev/null +++ b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/csharp/RecursivePolymorphicCSharpTest.kt @@ -0,0 +1,18 @@ +package com.jetbrains.rd.generator.test.cases.generator.csharp + +import com.jetbrains.rd.generator.test.cases.generator.testModels.RecursivePolymorphicModel +import com.jetbrains.rd.generator.test.cases.generator.testModels.RecursivePolymorphicModelRoot +import com.jetbrains.rd.generator.testframework.CSharpRdGenOutputTest +import com.jetbrains.rd.generator.testframework.KotlinRdGenOutputTest +import org.junit.jupiter.api.Test + +class RecursivePolymorphicCSharpTest : CSharpRdGenOutputTest() { + companion object { + const val testName = "recursivePolymorphicModelTest" + } + + override val testName = Companion.testName + + @Test + fun test1() = doTest(RecursivePolymorphicModelRoot::class.java, RecursivePolymorphicModel::class.java) +} \ No newline at end of file diff --git a/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/kotlin/RecursivePolymorphicKotlinTest.kt b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/kotlin/RecursivePolymorphicKotlinTest.kt new file mode 100644 index 000000000..a001bbdea --- /dev/null +++ b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/kotlin/RecursivePolymorphicKotlinTest.kt @@ -0,0 +1,17 @@ +package com.jetbrains.rd.generator.test.cases.generator.kotlin + +import com.jetbrains.rd.generator.test.cases.generator.testModels.RecursivePolymorphicModel +import com.jetbrains.rd.generator.test.cases.generator.testModels.RecursivePolymorphicModelRoot +import com.jetbrains.rd.generator.testframework.KotlinRdGenOutputTest +import org.junit.jupiter.api.Test + +class RecursivePolymorphicKotlinTest : KotlinRdGenOutputTest() { + companion object { + const val testName = "recursivePolymorphicModelTest" + } + + override val testName = Companion.testName + + @Test + fun test1() = doTest(RecursivePolymorphicModelRoot::class.java, RecursivePolymorphicModel::class.java) +} \ No newline at end of file diff --git a/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/testModels/RecursivePolymorphicModel.kt b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/testModels/RecursivePolymorphicModel.kt new file mode 100644 index 000000000..8fbf5d585 --- /dev/null +++ b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/testModels/RecursivePolymorphicModel.kt @@ -0,0 +1,23 @@ +package com.jetbrains.rd.generator.test.cases.generator.testModels + +import com.jetbrains.rd.generator.nova.* +import com.jetbrains.rd.generator.test.cases.generator.csharp.RecursivePolymorphicCSharpTest +import com.jetbrains.rd.generator.test.cases.generator.kotlin.RecursivePolymorphicKotlinTest +import com.jetbrains.rd.generator.testframework.CSharpRdGenOutputTest +import com.jetbrains.rd.generator.testframework.KotlinRdGenOutputTest + +object RecursivePolymorphicModelRoot : Root( + *KotlinRdGenOutputTest.generators(RecursivePolymorphicKotlinTest.testName, "org.example"), + *CSharpRdGenOutputTest.generators(RecursivePolymorphicCSharpTest.testName, "org.example") +) + +object RecursivePolymorphicModel : Ext(RecursivePolymorphicModelRoot) { + internal val BeTreeGridLine = openclass BeTreeGridLine@ { + list("children", this@BeTreeGridLine) + } + + init { + property("line", BeTreeGridLine) + property("list", immutableList(BeTreeGridLine)) + } +} \ No newline at end of file diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModel.cs b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModel.cs new file mode 100644 index 000000000..a5dee7ef8 --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModel.cs @@ -0,0 +1,256 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a RdGen v1.11. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using JetBrains.Annotations; + +using JetBrains.Core; +using JetBrains.Diagnostics; +using JetBrains.Collections; +using JetBrains.Collections.Viewable; +using JetBrains.Lifetimes; +using JetBrains.Serialization; +using JetBrains.Rd; +using JetBrains.Rd.Base; +using JetBrains.Rd.Impl; +using JetBrains.Rd.Tasks; +using JetBrains.Rd.Util; +using JetBrains.Rd.Text; + + +// ReSharper disable RedundantEmptyObjectCreationArgumentList +// ReSharper disable InconsistentNaming +// ReSharper disable RedundantOverflowCheckingContext + + +namespace org.example +{ + + + /// + ///

Generated from: RecursivePolymorphicModel.kt:14

+ ///
+ public class RecursivePolymorphicModel : RdExtBase + { + //fields + //public fields + [NotNull] public IViewableProperty Line => _Line; + [NotNull] public IViewableProperty> List => _List; + + //private fields + [NotNull] private readonly RdProperty _Line; + [NotNull] private readonly RdProperty> _List; + + //primary constructor + private RecursivePolymorphicModel( + [NotNull] RdProperty line, + [NotNull] RdProperty> list + ) + { + if (line == null) throw new ArgumentNullException("line"); + if (list == null) throw new ArgumentNullException("list"); + + _Line = line; + _List = list; + BindableChildren.Add(new KeyValuePair("line", _Line)); + BindableChildren.Add(new KeyValuePair("list", _List)); + } + //secondary constructor + private RecursivePolymorphicModel ( + ) : this ( + new RdProperty(ReadBeTreeGridLine, WriteBeTreeGridLine), + new RdProperty>(ReadBeTreeGridLineList, WriteBeTreeGridLineList) + ) {} + //deconstruct trait + //statics + + public static CtxReadDelegate ReadBeTreeGridLine = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read); + public static CtxReadDelegate> ReadBeTreeGridLineList = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read).List(); + + public static CtxWriteDelegate WriteBeTreeGridLine = Polymorphic.Write; + public static CtxWriteDelegate> WriteBeTreeGridLineList = Polymorphic.Write.List(); + + protected override long SerializationHash => 4259101978417261843L; + + protected override Action Register => RegisterDeclaredTypesSerializers; + public static void RegisterDeclaredTypesSerializers(ISerializers serializers) + { + serializers.Register(BeTreeGridLine.Read, BeTreeGridLine.Write); + serializers.Register(BeTreeGridLine_Unknown.Read, BeTreeGridLine_Unknown.Write); + + serializers.RegisterToplevelOnce(typeof(RecursivePolymorphicModelRoot), RecursivePolymorphicModelRoot.RegisterDeclaredTypesSerializers); + } + + public RecursivePolymorphicModel(Lifetime lifetime, IProtocol protocol) : this() + { + Identify(protocol.Identities, RdId.Root.Mix("RecursivePolymorphicModel")); + this.BindTopLevel(lifetime, protocol, "RecursivePolymorphicModel"); + } + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("RecursivePolymorphicModel ("); + using (printer.IndentCookie()) { + printer.Print("line = "); _Line.PrintEx(printer); printer.Println(); + printer.Print("list = "); _List.PrintEx(printer); printer.Println(); + } + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } + + + /// + ///

Generated from: RecursivePolymorphicModel.kt:15

+ ///
+ public class BeTreeGridLine : RdBindableBase + { + //fields + //public fields + [NotNull] public IViewableList Children => _Children; + + //private fields + [NotNull] protected readonly RdList _Children; + + //primary constructor + protected BeTreeGridLine( + [NotNull] RdList children + ) + { + if (children == null) throw new ArgumentNullException("children"); + + _Children = children; + BindableChildren.Add(new KeyValuePair("children", _Children)); + } + //secondary constructor + public BeTreeGridLine ( + ) : this ( + new RdList(ReadBeTreeGridLine, WriteBeTreeGridLine) + ) {} + //deconstruct trait + //statics + + public static CtxReadDelegate Read = (ctx, reader) => + { + var _id = RdId.Read(reader); + var children = RdList.Read(ctx, reader, ReadBeTreeGridLine, WriteBeTreeGridLine); + var _result = new BeTreeGridLine(children).WithId(_id); + return _result; + }; + public static CtxReadDelegate ReadBeTreeGridLine = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read); + + public static CtxWriteDelegate Write = (ctx, writer, value) => + { + value.RdId.Write(writer); + RdList.Write(ctx, writer, value._Children); + }; + public static CtxWriteDelegate WriteBeTreeGridLine = Polymorphic.Write; + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("BeTreeGridLine ("); + using (printer.IndentCookie()) { + printer.Print("children = "); _Children.PrintEx(printer); printer.Println(); + } + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } + + + public sealed class BeTreeGridLine_Unknown : BeTreeGridLine + { + //fields + //public fields + + //private fields + //primary constructor + private BeTreeGridLine_Unknown( + [NotNull] RdList children + ) : base ( + children + ) + { + } + //secondary constructor + public BeTreeGridLine_Unknown ( + ) : this ( + new RdList(ReadBeTreeGridLine, WriteBeTreeGridLine) + ) {} + //deconstruct trait + //statics + + public static new CtxReadDelegate Read = (ctx, reader) => + { + var _id = RdId.Read(reader); + var children = RdList.Read(ctx, reader, ReadBeTreeGridLine, WriteBeTreeGridLine); + var _result = new BeTreeGridLine_Unknown(children).WithId(_id); + return _result; + }; + public static new CtxReadDelegate ReadBeTreeGridLine = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read); + + public static new CtxWriteDelegate Write = (ctx, writer, value) => + { + value.RdId.Write(writer); + RdList.Write(ctx, writer, value._Children); + }; + public static new CtxWriteDelegate WriteBeTreeGridLine = Polymorphic.Write; + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("BeTreeGridLine_Unknown ("); + using (printer.IndentCookie()) { + printer.Print("children = "); _Children.PrintEx(printer); printer.Println(); + } + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModel.kt b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModel.kt new file mode 100644 index 000000000..67db67506 --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModel.kt @@ -0,0 +1,229 @@ +@file:Suppress("EXPERIMENTAL_API_USAGE","EXPERIMENTAL_UNSIGNED_LITERALS","PackageDirectoryMismatch","UnusedImport","unused","LocalVariableName","CanBeVal","PropertyName","EnumEntryName","ClassName","ObjectPropertyName","UnnecessaryVariable","SpellCheckingInspection") +package org.example + +import com.jetbrains.rd.framework.* +import com.jetbrains.rd.framework.base.* +import com.jetbrains.rd.framework.impl.* + +import com.jetbrains.rd.util.lifetime.* +import com.jetbrains.rd.util.reactive.* +import com.jetbrains.rd.util.string.* +import com.jetbrains.rd.util.* +import kotlin.time.Duration +import kotlin.reflect.KClass +import kotlin.jvm.JvmStatic + + + +/** + * #### Generated from [RecursivePolymorphicModel.kt:14] + */ +class RecursivePolymorphicModel private constructor( + private val _line: RdOptionalProperty, + private val _list: RdOptionalProperty> +) : RdExtBase() { + //companion + + companion object : ISerializersOwner { + + override fun registerSerializersCore(serializers: ISerializers) { + serializers.register(BeTreeGridLine) + serializers.register(BeTreeGridLine_Unknown) + } + + + @JvmStatic + @JvmName("internalCreateModel") + @Deprecated("Use create instead", ReplaceWith("create(lifetime, protocol)")) + internal fun createModel(lifetime: Lifetime, protocol: IProtocol): RecursivePolymorphicModel { + @Suppress("DEPRECATION") + return create(lifetime, protocol) + } + + @JvmStatic + @Deprecated("Use protocol.recursivePolymorphicModel or revise the extension scope instead", ReplaceWith("protocol.recursivePolymorphicModel")) + fun create(lifetime: Lifetime, protocol: IProtocol): RecursivePolymorphicModel { + RecursivePolymorphicModelRoot.register(protocol.serializers) + + return RecursivePolymorphicModel() + } + + private val __BeTreeGridLineListSerializer = AbstractPolymorphic(BeTreeGridLine).list() + + const val serializationHash = 4259101978417261843L + + } + override val serializersOwner: ISerializersOwner get() = RecursivePolymorphicModel + override val serializationHash: Long get() = RecursivePolymorphicModel.serializationHash + + //fields + val line: IOptProperty get() = _line + val list: IOptProperty> get() = _list + //methods + //initializer + init { + bindableChildren.add("line" to _line) + bindableChildren.add("list" to _list) + } + + //secondary constructor + private constructor( + ) : this( + RdOptionalProperty(AbstractPolymorphic(BeTreeGridLine)), + RdOptionalProperty>(__BeTreeGridLineListSerializer) + ) + + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("RecursivePolymorphicModel (") + printer.indent { + print("line = "); _line.print(printer); println() + print("list = "); _list.print(printer); println() + } + printer.print(")") + } + //deepClone + override fun deepClone(): RecursivePolymorphicModel { + return RecursivePolymorphicModel( + _line.deepClonePolymorphic(), + _list.deepClonePolymorphic() + ) + } + //contexts + //threading + override val extThreading: ExtThreadingKind get() = ExtThreadingKind.Default +} +val IProtocol.recursivePolymorphicModel get() = getOrCreateExtension(RecursivePolymorphicModel::class) { @Suppress("DEPRECATION") RecursivePolymorphicModel.create(lifetime, this) } + + + +/** + * #### Generated from [RecursivePolymorphicModel.kt:15] + */ +open class BeTreeGridLine protected constructor( + protected val _children: RdList +) : RdBindableBase() { + //companion + + companion object : IMarshaller, IAbstractDeclaration { + override val _type: KClass = BeTreeGridLine::class + + @Suppress("UNCHECKED_CAST") + override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): BeTreeGridLine { + val _id = RdId.read(buffer) + val _children = RdList.read(ctx, buffer, AbstractPolymorphic(BeTreeGridLine)) + return BeTreeGridLine(_children).withId(_id) + } + + override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: BeTreeGridLine) { + value.rdid.write(buffer) + RdList.write(ctx, buffer, value._children) + } + + + override fun readUnknownInstance(ctx: SerializationCtx, buffer: AbstractBuffer, unknownId: RdId, size: Int): BeTreeGridLine { + val objectStartPosition = buffer.position + val _id = RdId.read(buffer) + val _children = RdList.read(ctx, buffer, AbstractPolymorphic(BeTreeGridLine)) + val unknownBytes = ByteArray(objectStartPosition + size - buffer.position) + buffer.readByteArrayRaw(unknownBytes) + return BeTreeGridLine_Unknown(_children, unknownId, unknownBytes).withId(_id) + } + + } + //fields + val children: IMutableViewableList get() = _children + //methods + //initializer + init { + bindableChildren.add("children" to _children) + } + + //secondary constructor + constructor( + ) : this( + RdList(AbstractPolymorphic(BeTreeGridLine)) + ) + + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("BeTreeGridLine (") + printer.indent { + print("children = "); _children.print(printer); println() + } + printer.print(")") + } + //deepClone + override fun deepClone(): BeTreeGridLine { + return BeTreeGridLine( + _children.deepClonePolymorphic() + ) + } + //contexts + //threading +} + + +class BeTreeGridLine_Unknown ( + _children: RdList, + override val unknownId: RdId, + val unknownBytes: ByteArray +) : BeTreeGridLine ( + _children +), IUnknownInstance { + //companion + + companion object : IMarshaller { + override val _type: KClass = BeTreeGridLine_Unknown::class + + @Suppress("UNCHECKED_CAST") + override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): BeTreeGridLine_Unknown { + throw NotImplementedError("Unknown instances should not be read via serializer") + } + + override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: BeTreeGridLine_Unknown) { + value.rdid.write(buffer) + RdList.write(ctx, buffer, value._children) + buffer.writeByteArrayRaw(value.unknownBytes) + } + + + } + //fields + //methods + //initializer + //secondary constructor + constructor( + unknownId: RdId, + unknownBytes: ByteArray + ) : this( + RdList(AbstractPolymorphic(BeTreeGridLine)), + unknownId, + unknownBytes + ) + + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("BeTreeGridLine_Unknown (") + printer.indent { + print("children = "); _children.print(printer); println() + } + printer.print(")") + } + //deepClone + override fun deepClone(): BeTreeGridLine_Unknown { + return BeTreeGridLine_Unknown( + _children.deepClonePolymorphic(), + unknownId, + unknownBytes + ) + } + //contexts + //threading +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModelRoot.cs b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModelRoot.cs new file mode 100644 index 000000000..a13ad6250 --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModelRoot.cs @@ -0,0 +1,94 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a RdGen v1.11. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using JetBrains.Annotations; + +using JetBrains.Core; +using JetBrains.Diagnostics; +using JetBrains.Collections; +using JetBrains.Collections.Viewable; +using JetBrains.Lifetimes; +using JetBrains.Serialization; +using JetBrains.Rd; +using JetBrains.Rd.Base; +using JetBrains.Rd.Impl; +using JetBrains.Rd.Tasks; +using JetBrains.Rd.Util; +using JetBrains.Rd.Text; + + +// ReSharper disable RedundantEmptyObjectCreationArgumentList +// ReSharper disable InconsistentNaming +// ReSharper disable RedundantOverflowCheckingContext + + +namespace org.example +{ + + + /// + ///

Generated from: RecursivePolymorphicModel.kt:9

+ ///
+ public class RecursivePolymorphicModelRoot : RdExtBase + { + //fields + //public fields + + //private fields + //primary constructor + private RecursivePolymorphicModelRoot( + ) + { + } + //secondary constructor + //deconstruct trait + //statics + + + + protected override long SerializationHash => -6059810059586225403L; + + protected override Action Register => RegisterDeclaredTypesSerializers; + public static void RegisterDeclaredTypesSerializers(ISerializers serializers) + { + + serializers.RegisterToplevelOnce(typeof(RecursivePolymorphicModelRoot), RecursivePolymorphicModelRoot.RegisterDeclaredTypesSerializers); + serializers.RegisterToplevelOnce(typeof(RecursivePolymorphicModel), RecursivePolymorphicModel.RegisterDeclaredTypesSerializers); + } + + public RecursivePolymorphicModelRoot(Lifetime lifetime, IProtocol protocol) : this() + { + Identify(protocol.Identities, RdId.Root.Mix("RecursivePolymorphicModelRoot")); + this.BindTopLevel(lifetime, protocol, "RecursivePolymorphicModelRoot"); + } + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("RecursivePolymorphicModelRoot ("); + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModelRoot.kt b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModelRoot.kt new file mode 100644 index 000000000..ef31154cd --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/asis/RecursivePolymorphicModelRoot.kt @@ -0,0 +1,61 @@ +@file:Suppress("EXPERIMENTAL_API_USAGE","EXPERIMENTAL_UNSIGNED_LITERALS","PackageDirectoryMismatch","UnusedImport","unused","LocalVariableName","CanBeVal","PropertyName","EnumEntryName","ClassName","ObjectPropertyName","UnnecessaryVariable","SpellCheckingInspection") +package org.example + +import com.jetbrains.rd.framework.* +import com.jetbrains.rd.framework.base.* +import com.jetbrains.rd.framework.impl.* + +import com.jetbrains.rd.util.lifetime.* +import com.jetbrains.rd.util.reactive.* +import com.jetbrains.rd.util.string.* +import com.jetbrains.rd.util.* +import kotlin.time.Duration +import kotlin.reflect.KClass +import kotlin.jvm.JvmStatic + + + +/** + * #### Generated from [RecursivePolymorphicModel.kt:9] + */ +class RecursivePolymorphicModelRoot private constructor( +) : RdExtBase() { + //companion + + companion object : ISerializersOwner { + + override fun registerSerializersCore(serializers: ISerializers) { + RecursivePolymorphicModelRoot.register(serializers) + RecursivePolymorphicModel.register(serializers) + } + + + + + + const val serializationHash = -6059810059586225403L + + } + override val serializersOwner: ISerializersOwner get() = RecursivePolymorphicModelRoot + override val serializationHash: Long get() = RecursivePolymorphicModelRoot.serializationHash + + //fields + //methods + //initializer + //secondary constructor + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("RecursivePolymorphicModelRoot (") + printer.print(")") + } + //deepClone + override fun deepClone(): RecursivePolymorphicModelRoot { + return RecursivePolymorphicModelRoot( + ) + } + //contexts + //threading + override val extThreading: ExtThreadingKind get() = ExtThreadingKind.Default +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModel.cs b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModel.cs new file mode 100644 index 000000000..a5dee7ef8 --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModel.cs @@ -0,0 +1,256 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a RdGen v1.11. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using JetBrains.Annotations; + +using JetBrains.Core; +using JetBrains.Diagnostics; +using JetBrains.Collections; +using JetBrains.Collections.Viewable; +using JetBrains.Lifetimes; +using JetBrains.Serialization; +using JetBrains.Rd; +using JetBrains.Rd.Base; +using JetBrains.Rd.Impl; +using JetBrains.Rd.Tasks; +using JetBrains.Rd.Util; +using JetBrains.Rd.Text; + + +// ReSharper disable RedundantEmptyObjectCreationArgumentList +// ReSharper disable InconsistentNaming +// ReSharper disable RedundantOverflowCheckingContext + + +namespace org.example +{ + + + /// + ///

Generated from: RecursivePolymorphicModel.kt:14

+ ///
+ public class RecursivePolymorphicModel : RdExtBase + { + //fields + //public fields + [NotNull] public IViewableProperty Line => _Line; + [NotNull] public IViewableProperty> List => _List; + + //private fields + [NotNull] private readonly RdProperty _Line; + [NotNull] private readonly RdProperty> _List; + + //primary constructor + private RecursivePolymorphicModel( + [NotNull] RdProperty line, + [NotNull] RdProperty> list + ) + { + if (line == null) throw new ArgumentNullException("line"); + if (list == null) throw new ArgumentNullException("list"); + + _Line = line; + _List = list; + BindableChildren.Add(new KeyValuePair("line", _Line)); + BindableChildren.Add(new KeyValuePair("list", _List)); + } + //secondary constructor + private RecursivePolymorphicModel ( + ) : this ( + new RdProperty(ReadBeTreeGridLine, WriteBeTreeGridLine), + new RdProperty>(ReadBeTreeGridLineList, WriteBeTreeGridLineList) + ) {} + //deconstruct trait + //statics + + public static CtxReadDelegate ReadBeTreeGridLine = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read); + public static CtxReadDelegate> ReadBeTreeGridLineList = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read).List(); + + public static CtxWriteDelegate WriteBeTreeGridLine = Polymorphic.Write; + public static CtxWriteDelegate> WriteBeTreeGridLineList = Polymorphic.Write.List(); + + protected override long SerializationHash => 4259101978417261843L; + + protected override Action Register => RegisterDeclaredTypesSerializers; + public static void RegisterDeclaredTypesSerializers(ISerializers serializers) + { + serializers.Register(BeTreeGridLine.Read, BeTreeGridLine.Write); + serializers.Register(BeTreeGridLine_Unknown.Read, BeTreeGridLine_Unknown.Write); + + serializers.RegisterToplevelOnce(typeof(RecursivePolymorphicModelRoot), RecursivePolymorphicModelRoot.RegisterDeclaredTypesSerializers); + } + + public RecursivePolymorphicModel(Lifetime lifetime, IProtocol protocol) : this() + { + Identify(protocol.Identities, RdId.Root.Mix("RecursivePolymorphicModel")); + this.BindTopLevel(lifetime, protocol, "RecursivePolymorphicModel"); + } + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("RecursivePolymorphicModel ("); + using (printer.IndentCookie()) { + printer.Print("line = "); _Line.PrintEx(printer); printer.Println(); + printer.Print("list = "); _List.PrintEx(printer); printer.Println(); + } + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } + + + /// + ///

Generated from: RecursivePolymorphicModel.kt:15

+ ///
+ public class BeTreeGridLine : RdBindableBase + { + //fields + //public fields + [NotNull] public IViewableList Children => _Children; + + //private fields + [NotNull] protected readonly RdList _Children; + + //primary constructor + protected BeTreeGridLine( + [NotNull] RdList children + ) + { + if (children == null) throw new ArgumentNullException("children"); + + _Children = children; + BindableChildren.Add(new KeyValuePair("children", _Children)); + } + //secondary constructor + public BeTreeGridLine ( + ) : this ( + new RdList(ReadBeTreeGridLine, WriteBeTreeGridLine) + ) {} + //deconstruct trait + //statics + + public static CtxReadDelegate Read = (ctx, reader) => + { + var _id = RdId.Read(reader); + var children = RdList.Read(ctx, reader, ReadBeTreeGridLine, WriteBeTreeGridLine); + var _result = new BeTreeGridLine(children).WithId(_id); + return _result; + }; + public static CtxReadDelegate ReadBeTreeGridLine = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read); + + public static CtxWriteDelegate Write = (ctx, writer, value) => + { + value.RdId.Write(writer); + RdList.Write(ctx, writer, value._Children); + }; + public static CtxWriteDelegate WriteBeTreeGridLine = Polymorphic.Write; + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("BeTreeGridLine ("); + using (printer.IndentCookie()) { + printer.Print("children = "); _Children.PrintEx(printer); printer.Println(); + } + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } + + + public sealed class BeTreeGridLine_Unknown : BeTreeGridLine + { + //fields + //public fields + + //private fields + //primary constructor + private BeTreeGridLine_Unknown( + [NotNull] RdList children + ) : base ( + children + ) + { + } + //secondary constructor + public BeTreeGridLine_Unknown ( + ) : this ( + new RdList(ReadBeTreeGridLine, WriteBeTreeGridLine) + ) {} + //deconstruct trait + //statics + + public static new CtxReadDelegate Read = (ctx, reader) => + { + var _id = RdId.Read(reader); + var children = RdList.Read(ctx, reader, ReadBeTreeGridLine, WriteBeTreeGridLine); + var _result = new BeTreeGridLine_Unknown(children).WithId(_id); + return _result; + }; + public static new CtxReadDelegate ReadBeTreeGridLine = Polymorphic.ReadAbstract(BeTreeGridLine_Unknown.Read); + + public static new CtxWriteDelegate Write = (ctx, writer, value) => + { + value.RdId.Write(writer); + RdList.Write(ctx, writer, value._Children); + }; + public static new CtxWriteDelegate WriteBeTreeGridLine = Polymorphic.Write; + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("BeTreeGridLine_Unknown ("); + using (printer.IndentCookie()) { + printer.Print("children = "); _Children.PrintEx(printer); printer.Println(); + } + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModel.kt b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModel.kt new file mode 100644 index 000000000..67db67506 --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModel.kt @@ -0,0 +1,229 @@ +@file:Suppress("EXPERIMENTAL_API_USAGE","EXPERIMENTAL_UNSIGNED_LITERALS","PackageDirectoryMismatch","UnusedImport","unused","LocalVariableName","CanBeVal","PropertyName","EnumEntryName","ClassName","ObjectPropertyName","UnnecessaryVariable","SpellCheckingInspection") +package org.example + +import com.jetbrains.rd.framework.* +import com.jetbrains.rd.framework.base.* +import com.jetbrains.rd.framework.impl.* + +import com.jetbrains.rd.util.lifetime.* +import com.jetbrains.rd.util.reactive.* +import com.jetbrains.rd.util.string.* +import com.jetbrains.rd.util.* +import kotlin.time.Duration +import kotlin.reflect.KClass +import kotlin.jvm.JvmStatic + + + +/** + * #### Generated from [RecursivePolymorphicModel.kt:14] + */ +class RecursivePolymorphicModel private constructor( + private val _line: RdOptionalProperty, + private val _list: RdOptionalProperty> +) : RdExtBase() { + //companion + + companion object : ISerializersOwner { + + override fun registerSerializersCore(serializers: ISerializers) { + serializers.register(BeTreeGridLine) + serializers.register(BeTreeGridLine_Unknown) + } + + + @JvmStatic + @JvmName("internalCreateModel") + @Deprecated("Use create instead", ReplaceWith("create(lifetime, protocol)")) + internal fun createModel(lifetime: Lifetime, protocol: IProtocol): RecursivePolymorphicModel { + @Suppress("DEPRECATION") + return create(lifetime, protocol) + } + + @JvmStatic + @Deprecated("Use protocol.recursivePolymorphicModel or revise the extension scope instead", ReplaceWith("protocol.recursivePolymorphicModel")) + fun create(lifetime: Lifetime, protocol: IProtocol): RecursivePolymorphicModel { + RecursivePolymorphicModelRoot.register(protocol.serializers) + + return RecursivePolymorphicModel() + } + + private val __BeTreeGridLineListSerializer = AbstractPolymorphic(BeTreeGridLine).list() + + const val serializationHash = 4259101978417261843L + + } + override val serializersOwner: ISerializersOwner get() = RecursivePolymorphicModel + override val serializationHash: Long get() = RecursivePolymorphicModel.serializationHash + + //fields + val line: IOptProperty get() = _line + val list: IOptProperty> get() = _list + //methods + //initializer + init { + bindableChildren.add("line" to _line) + bindableChildren.add("list" to _list) + } + + //secondary constructor + private constructor( + ) : this( + RdOptionalProperty(AbstractPolymorphic(BeTreeGridLine)), + RdOptionalProperty>(__BeTreeGridLineListSerializer) + ) + + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("RecursivePolymorphicModel (") + printer.indent { + print("line = "); _line.print(printer); println() + print("list = "); _list.print(printer); println() + } + printer.print(")") + } + //deepClone + override fun deepClone(): RecursivePolymorphicModel { + return RecursivePolymorphicModel( + _line.deepClonePolymorphic(), + _list.deepClonePolymorphic() + ) + } + //contexts + //threading + override val extThreading: ExtThreadingKind get() = ExtThreadingKind.Default +} +val IProtocol.recursivePolymorphicModel get() = getOrCreateExtension(RecursivePolymorphicModel::class) { @Suppress("DEPRECATION") RecursivePolymorphicModel.create(lifetime, this) } + + + +/** + * #### Generated from [RecursivePolymorphicModel.kt:15] + */ +open class BeTreeGridLine protected constructor( + protected val _children: RdList +) : RdBindableBase() { + //companion + + companion object : IMarshaller, IAbstractDeclaration { + override val _type: KClass = BeTreeGridLine::class + + @Suppress("UNCHECKED_CAST") + override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): BeTreeGridLine { + val _id = RdId.read(buffer) + val _children = RdList.read(ctx, buffer, AbstractPolymorphic(BeTreeGridLine)) + return BeTreeGridLine(_children).withId(_id) + } + + override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: BeTreeGridLine) { + value.rdid.write(buffer) + RdList.write(ctx, buffer, value._children) + } + + + override fun readUnknownInstance(ctx: SerializationCtx, buffer: AbstractBuffer, unknownId: RdId, size: Int): BeTreeGridLine { + val objectStartPosition = buffer.position + val _id = RdId.read(buffer) + val _children = RdList.read(ctx, buffer, AbstractPolymorphic(BeTreeGridLine)) + val unknownBytes = ByteArray(objectStartPosition + size - buffer.position) + buffer.readByteArrayRaw(unknownBytes) + return BeTreeGridLine_Unknown(_children, unknownId, unknownBytes).withId(_id) + } + + } + //fields + val children: IMutableViewableList get() = _children + //methods + //initializer + init { + bindableChildren.add("children" to _children) + } + + //secondary constructor + constructor( + ) : this( + RdList(AbstractPolymorphic(BeTreeGridLine)) + ) + + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("BeTreeGridLine (") + printer.indent { + print("children = "); _children.print(printer); println() + } + printer.print(")") + } + //deepClone + override fun deepClone(): BeTreeGridLine { + return BeTreeGridLine( + _children.deepClonePolymorphic() + ) + } + //contexts + //threading +} + + +class BeTreeGridLine_Unknown ( + _children: RdList, + override val unknownId: RdId, + val unknownBytes: ByteArray +) : BeTreeGridLine ( + _children +), IUnknownInstance { + //companion + + companion object : IMarshaller { + override val _type: KClass = BeTreeGridLine_Unknown::class + + @Suppress("UNCHECKED_CAST") + override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): BeTreeGridLine_Unknown { + throw NotImplementedError("Unknown instances should not be read via serializer") + } + + override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: BeTreeGridLine_Unknown) { + value.rdid.write(buffer) + RdList.write(ctx, buffer, value._children) + buffer.writeByteArrayRaw(value.unknownBytes) + } + + + } + //fields + //methods + //initializer + //secondary constructor + constructor( + unknownId: RdId, + unknownBytes: ByteArray + ) : this( + RdList(AbstractPolymorphic(BeTreeGridLine)), + unknownId, + unknownBytes + ) + + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("BeTreeGridLine_Unknown (") + printer.indent { + print("children = "); _children.print(printer); println() + } + printer.print(")") + } + //deepClone + override fun deepClone(): BeTreeGridLine_Unknown { + return BeTreeGridLine_Unknown( + _children.deepClonePolymorphic(), + unknownId, + unknownBytes + ) + } + //contexts + //threading +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModelRoot.cs b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModelRoot.cs new file mode 100644 index 000000000..a13ad6250 --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModelRoot.cs @@ -0,0 +1,94 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a RdGen v1.11. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using JetBrains.Annotations; + +using JetBrains.Core; +using JetBrains.Diagnostics; +using JetBrains.Collections; +using JetBrains.Collections.Viewable; +using JetBrains.Lifetimes; +using JetBrains.Serialization; +using JetBrains.Rd; +using JetBrains.Rd.Base; +using JetBrains.Rd.Impl; +using JetBrains.Rd.Tasks; +using JetBrains.Rd.Util; +using JetBrains.Rd.Text; + + +// ReSharper disable RedundantEmptyObjectCreationArgumentList +// ReSharper disable InconsistentNaming +// ReSharper disable RedundantOverflowCheckingContext + + +namespace org.example +{ + + + /// + ///

Generated from: RecursivePolymorphicModel.kt:9

+ ///
+ public class RecursivePolymorphicModelRoot : RdExtBase + { + //fields + //public fields + + //private fields + //primary constructor + private RecursivePolymorphicModelRoot( + ) + { + } + //secondary constructor + //deconstruct trait + //statics + + + + protected override long SerializationHash => -6059810059586225403L; + + protected override Action Register => RegisterDeclaredTypesSerializers; + public static void RegisterDeclaredTypesSerializers(ISerializers serializers) + { + + serializers.RegisterToplevelOnce(typeof(RecursivePolymorphicModelRoot), RecursivePolymorphicModelRoot.RegisterDeclaredTypesSerializers); + serializers.RegisterToplevelOnce(typeof(RecursivePolymorphicModel), RecursivePolymorphicModel.RegisterDeclaredTypesSerializers); + } + + public RecursivePolymorphicModelRoot(Lifetime lifetime, IProtocol protocol) : this() + { + Identify(protocol.Identities, RdId.Root.Mix("RecursivePolymorphicModelRoot")); + this.BindTopLevel(lifetime, protocol, "RecursivePolymorphicModelRoot"); + } + + //constants + + //custom body + //methods + //equals trait + //hash code trait + //pretty print + public override void Print(PrettyPrinter printer) + { + printer.Println("RecursivePolymorphicModelRoot ("); + printer.Print(")"); + } + //toString + public override string ToString() + { + var printer = new SingleLinePrettyPrinter(); + Print(printer); + return printer.ToString(); + } + } +} diff --git a/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModelRoot.kt b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModelRoot.kt new file mode 100644 index 000000000..ef31154cd --- /dev/null +++ b/rd-kt/rd-gen/src/test/resources/testData/recursivePolymorphicModelTest/reversed/RecursivePolymorphicModelRoot.kt @@ -0,0 +1,61 @@ +@file:Suppress("EXPERIMENTAL_API_USAGE","EXPERIMENTAL_UNSIGNED_LITERALS","PackageDirectoryMismatch","UnusedImport","unused","LocalVariableName","CanBeVal","PropertyName","EnumEntryName","ClassName","ObjectPropertyName","UnnecessaryVariable","SpellCheckingInspection") +package org.example + +import com.jetbrains.rd.framework.* +import com.jetbrains.rd.framework.base.* +import com.jetbrains.rd.framework.impl.* + +import com.jetbrains.rd.util.lifetime.* +import com.jetbrains.rd.util.reactive.* +import com.jetbrains.rd.util.string.* +import com.jetbrains.rd.util.* +import kotlin.time.Duration +import kotlin.reflect.KClass +import kotlin.jvm.JvmStatic + + + +/** + * #### Generated from [RecursivePolymorphicModel.kt:9] + */ +class RecursivePolymorphicModelRoot private constructor( +) : RdExtBase() { + //companion + + companion object : ISerializersOwner { + + override fun registerSerializersCore(serializers: ISerializers) { + RecursivePolymorphicModelRoot.register(serializers) + RecursivePolymorphicModel.register(serializers) + } + + + + + + const val serializationHash = -6059810059586225403L + + } + override val serializersOwner: ISerializersOwner get() = RecursivePolymorphicModelRoot + override val serializationHash: Long get() = RecursivePolymorphicModelRoot.serializationHash + + //fields + //methods + //initializer + //secondary constructor + //equals trait + //hash code trait + //pretty print + override fun print(printer: PrettyPrinter) { + printer.println("RecursivePolymorphicModelRoot (") + printer.print(")") + } + //deepClone + override fun deepClone(): RecursivePolymorphicModelRoot { + return RecursivePolymorphicModelRoot( + ) + } + //contexts + //threading + override val extThreading: ExtThreadingKind get() = ExtThreadingKind.Default +} diff --git a/rd-net/Test.RdFramework/Reflection/data/Generated/RefExt.cs b/rd-net/Test.RdFramework/Reflection/data/Generated/RefExt.cs index 4266223b3..99b4ba995 100644 --- a/rd-net/Test.RdFramework/Reflection/data/Generated/RefExt.cs +++ b/rd-net/Test.RdFramework/Reflection/data/Generated/RefExt.cs @@ -68,7 +68,7 @@ [NotNull] RdProperty openModel private RefExt ( ) : this ( new RdProperty(Base.Read, Base.Write), - new RdProperty(OpenClass.Read, WriteOpenClass) + new RdProperty(ReadOpenClass, WriteOpenClass) ) {} //deconstruct trait //statics