From 458e9682f6eff75356c3488f4cd71a8768667b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Sun, 8 Sep 2024 04:31:02 +0200 Subject: [PATCH] feat(abg)!: replace data class perks by code generation in bindings --- .../generation/Generation.kt | 349 +++++++++++++++--- .../ActionWithAllTypesOfInputsBindingV2.kt | 244 ++++++++++-- ...onWithAllTypesOfInputsBindingV2_Untyped.kt | 147 ++++++-- .../ActionWithAllTypesOfInputsTest.kt | 1 - ...ithDeprecatedInputAndNameClashBindingV2.kt | 70 +++- .../ActionWithFancyCharsInDocsBindingV2.kt | 86 ++++- .../ActionWithInputsSharingTypeBindingV2.kt | 99 ++++- .../ActionWithNoInputsBindingV2.kt | 54 ++- .../ActionWithNoTypingsBindingV2_Untyped.kt | 68 +++- .../ActionWithOutputsBindingV2.kt | 70 +++- .../ActionWithPartlyTypingsBindingV2.kt | 83 ++++- ...ctionWithPartlyTypingsBindingV2_Untyped.kt | 72 +++- .../ActionWithSomeOptionalInputsBindingV2.kt | 134 +++++-- ...ActionWithRequiredStringInputsBindingV2.kt | 84 ++++- docs/user-guide/using-actions.md | 9 +- 15 files changed, 1298 insertions(+), 272 deletions(-) diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt index 9e3baf7b21..f2fef8e56b 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt @@ -6,6 +6,9 @@ import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.KModifier.OVERRIDE +import com.squareup.kotlinpoet.KModifier.PRIVATE +import com.squareup.kotlinpoet.KModifier.VARARG import com.squareup.kotlinpoet.MemberName import com.squareup.kotlinpoet.ParameterSpec import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy @@ -15,6 +18,7 @@ import com.squareup.kotlinpoet.TypeSpec import com.squareup.kotlinpoet.asClassName import com.squareup.kotlinpoet.asTypeName import com.squareup.kotlinpoet.buildCodeBlock +import com.squareup.kotlinpoet.joinToCode import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.MetadataRevision import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource @@ -24,6 +28,7 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.domain.prettyPr import io.github.typesafegithub.workflows.actionbindinggenerator.domain.subName import io.github.typesafegithub.workflows.actionbindinggenerator.generation.Properties.CUSTOM_INPUTS import io.github.typesafegithub.workflows.actionbindinggenerator.generation.Properties.CUSTOM_VERSION +import io.github.typesafegithub.workflows.actionbindinggenerator.generation.Types.nullableAny import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Input import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Metadata import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.fetchMetadata @@ -39,6 +44,8 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.utils.toCamelCa import io.github.typesafegithub.workflows.actionbindinggenerator.utils.toKotlinPackageName import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion.V1 +import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion.V2 +import java.util.Objects public data class ActionBinding( val kotlinCode: String, @@ -50,6 +57,7 @@ public data class ActionBinding( private object Types { val mapStringString = Map::class.asTypeName().parameterizedBy(String::class.asTypeName(), String::class.asTypeName()) + val nullableAny = Any::class.asTypeName().copy(nullable = true) val nullableString = String::class.asTypeName().copy(nullable = true) val mapToList = MemberName("kotlin.collections", "toList") val listToArray = MemberName("kotlin.collections", "toTypedArray") @@ -136,69 +144,97 @@ private fun generateActionBindingSourceCode( untypedClass: Boolean = false, replaceWith: CodeBlock? = null, ): String { + val packageName = "io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}" val fileSpec = FileSpec - .builder( - "io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}", - className, - ).addFileComment( + .builder(packageName, className) + .addFileComment( """ This file was generated using action-binding-generator. Don't change it by hand, otherwise your changes will be overwritten with the next binding code regeneration. See https://github.com/typesafegithub/github-workflows-kt for more info. """.trimIndent(), - ).addType(generateActionClass(metadata, coords, bindingVersion, inputTypings, className, untypedClass, replaceWith)) - .addSuppressAnnotation(metadata) - .indent(" ") + ).addType( + generateActionClass( + metadata, + coords, + bindingVersion, + inputTypings, + packageName, + className, + untypedClass, + replaceWith, + ), + ).addSuppressAnnotation( + bindingVersion = bindingVersion, + classIsDeprecated = replaceWith != null, + metadata = metadata, + ).indent(" ") .build() return buildString { fileSpec.writeTo(this) } } -private fun FileSpec.Builder.addSuppressAnnotation(metadata: Metadata) = - apply { - val isDeprecatedInputUsed = metadata.inputs.values.any { it.deprecationMessage.isNullOrBlank().not() } - - addAnnotation( - AnnotationSpec - .builder(Suppress::class.asClassName()) - .addMember(CodeBlock.of("%S", "DataClassPrivateConstructor")) - .addMember(CodeBlock.of("%S", "UNUSED_PARAMETER")) - .apply { - if (isDeprecatedInputUsed) { - addMember(CodeBlock.of("%S", "DEPRECATION")) - } - }.build(), - ) +private fun FileSpec.Builder.addSuppressAnnotation( + bindingVersion: BindingVersion, + classIsDeprecated: Boolean, + metadata: Metadata, +): FileSpec.Builder { + val suppress = AnnotationSpec.builder(Suppress::class.asClassName()) + if (bindingVersion <= V1) { + suppress.addMember(CodeBlock.of("%S", "DataClassPrivateConstructor")) + } + suppress.addMember(CodeBlock.of("%S", "UNUSED_PARAMETER")) + val isDeprecatedInputUsed = metadata.inputs.values.any { it.deprecationMessage.isNullOrBlank().not() } + if (bindingVersion.isDeprecated || ((bindingVersion >= V2) && classIsDeprecated) || isDeprecatedInputUsed) { + suppress.addMember(CodeBlock.of("%S", "DEPRECATION")) } + addAnnotation(suppress.build()) + return this +} private fun generateActionClass( metadata: Metadata, coords: ActionCoords, bindingVersion: BindingVersion, inputTypings: Map, + packageName: String, className: String, untypedClass: Boolean, replaceWith: CodeBlock?, -): TypeSpec = - TypeSpec +): TypeSpec { + val commonConstructorParameters = + metadata.buildCommonConstructorParameters(inputTypings, coords, className, untypedClass) + return TypeSpec .classBuilder(className) - .addModifiers(KModifier.DATA) + .addDataModifier(bindingVersion) .addKdocIfNotEmpty(actionKdoc(metadata, coords, untypedClass)) .deprecateBindingVersion(bindingVersion) .replaceWith(bindingVersion, replaceWith) - .addClassConstructorAnnotation() + .addClassConstructorAnnotation(bindingVersion) .inheritsFromRegularAction(coords, metadata, className) - .primaryConstructor(metadata.primaryConstructor(inputTypings, coords, className, untypedClass)) + .primaryConstructor(buildPrimaryConstructor(bindingVersion, commonConstructorParameters)) .properties(metadata, coords, inputTypings, className, untypedClass) .addInitializerBlock(metadata, bindingVersion, coords, inputTypings, untypedClass) - .addFunction(metadata.secondaryConstructor(inputTypings, coords, className, untypedClass)) + .addSecondaryConstructor(bindingVersion, metadata, inputTypings, commonConstructorParameters, untypedClass) .addFunction(metadata.buildToYamlArgumentsFunction(inputTypings, untypedClass)) + .addEqualsFunction(bindingVersion, className, commonConstructorParameters) + .addHashCodeFunction(bindingVersion, commonConstructorParameters) + .addToStringFunction(bindingVersion, className, commonConstructorParameters) + .addCopyFunction(bindingVersion, packageName, className, commonConstructorParameters) .addCustomTypes(inputTypings, coords, className) .addOutputClassIfNecessary(metadata) .addBuildOutputObjectFunctionIfNecessary(metadata) .build() +} + +private fun TypeSpec.Builder.addDataModifier(bindingVersion: BindingVersion): TypeSpec.Builder { + if (bindingVersion <= V1) { + addModifiers(KModifier.DATA) + } + return this +} private fun TypeSpec.Builder.addCustomTypes( typings: Map, @@ -312,7 +348,7 @@ private fun TypeSpec.Builder.addBuildOutputObjectFunctionIfNecessary(metadata: M FunSpec .builder("buildOutputObject") .returns(if (metadata.outputs.isEmpty()) OutputsBase else ClassName("", "Outputs")) - .addModifiers(KModifier.OVERRIDE) + .addModifiers(OVERRIDE) .addParameter("stepId", String::class) .addCode(CodeBlock.of("return Outputs(stepId)")) .build(), @@ -338,7 +374,7 @@ private fun Metadata.buildToYamlArgumentsFunction( untypedClass: Boolean, ) = FunSpec .builder("toYamlArguments") - .addModifiers(KModifier.OVERRIDE) + .addModifiers(OVERRIDE) .returns(LinkedHashMap::class.parameterizedBy(String::class, String::class)) .addAnnotation( AnnotationSpec @@ -408,12 +444,14 @@ private fun TypeSpec.Builder.replaceWith( return this } -private fun TypeSpec.Builder.addClassConstructorAnnotation(): TypeSpec.Builder { - addAnnotation( - AnnotationSpec - .builder(ExposedCopyVisibility::class.asClassName()) - .build(), - ) +private fun TypeSpec.Builder.addClassConstructorAnnotation(bindingVersion: BindingVersion): TypeSpec.Builder { + if (bindingVersion <= V1) { + addAnnotation( + AnnotationSpec + .builder(ExposedCopyVisibility::class.asClassName()) + .build(), + ) + } return this } @@ -442,22 +480,42 @@ private fun TypeSpec.Builder.inheritsFromRegularAction( .addSuperclassConstructorParameter("_customVersion ?: %S", coords.version) } -private fun Metadata.primaryConstructor( +private fun buildPrimaryConstructor( + bindingVersion: BindingVersion, + commonConstructorParameters: Iterable, +): FunSpec { + val constructor = FunSpec.constructorBuilder() + if (bindingVersion <= V1) { + constructor.addModifiers(PRIVATE) + } + if (bindingVersion >= V2) { + constructor + .addParameter( + ParameterSpec + .builder("pleaseUseNamedArguments", Unit::class) + .addModifiers(VARARG) + .build(), + ) + } + return constructor.addParameters(commonConstructorParameters).build() +} + +private fun TypeSpec.Builder.addSecondaryConstructor( + bindingVersion: BindingVersion, + metadata: Metadata, inputTypings: Map, - coords: ActionCoords, - className: String, + commonConstructorParameters: Iterable, untypedClass: Boolean, -): FunSpec = - FunSpec - .constructorBuilder() - .addModifiers(KModifier.PRIVATE) - .addParameters(buildCommonConstructorParameters(inputTypings, coords, className, untypedClass)) - .build() +): TypeSpec.Builder { + if (bindingVersion <= V1) { + addFunction(metadata.buildSecondaryConstructor(inputTypings, commonConstructorParameters, untypedClass)) + } + return this +} -private fun Metadata.secondaryConstructor( +private fun Metadata.buildSecondaryConstructor( inputTypings: Map, - coords: ActionCoords, - className: String, + commonConstructorParameters: Iterable, untypedClass: Boolean, ): FunSpec = FunSpec @@ -465,9 +523,9 @@ private fun Metadata.secondaryConstructor( .addParameter( ParameterSpec .builder("pleaseUseNamedArguments", Unit::class) - .addModifiers(KModifier.VARARG) + .addModifiers(VARARG) .build(), - ).addParameters(buildCommonConstructorParameters(inputTypings, coords, className, untypedClass)) + ).addParameters(commonConstructorParameters) .callThisConstructor( inputs .keys @@ -544,6 +602,197 @@ private fun Metadata.buildCommonConstructorParameters( ).build(), ) +private fun TypeSpec.Builder.addEqualsFunction( + bindingVersion: BindingVersion, + className: String, + commonConstructorParameters: Iterable, +): TypeSpec.Builder { + if (bindingVersion >= V2) { + addFunction(buildEqualsFunction(className, commonConstructorParameters)) + } + return this +} + +private fun buildEqualsFunction( + className: String, + commonConstructorParameters: Iterable, +) = FunSpec + .builder("equals") + .addModifiers(OVERRIDE) + .addParameter(ParameterSpec.builder("other", nullableAny).build()) + .returns(Boolean::class) + .addCode( + buildCodeBlock { + addStatement("if (this === other) return true") + addStatement("if (javaClass != other?.javaClass) return false") + addStatement("other as %N", className) + + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return true") + 1 -> addStatement("return %1N == other.%1N", propertyNames.first()) + else -> { + add("return %1N == other.%1N &&\n", propertyNames.first()) + add( + propertyNames.drop(1).joinToCode( + separator = " &&\n", + ) { + buildCodeBlock { + indent() + add("%1N == other.%1N", it) + unindent() + } + }, + ) + } + } + }, + ).build() + +private fun TypeSpec.Builder.addHashCodeFunction( + bindingVersion: BindingVersion, + commonConstructorParameters: Iterable, +) = apply { + if (bindingVersion >= V2) { + addFunction(buildHashCodeFunction(commonConstructorParameters)) + } +} + +private fun buildHashCodeFunction(commonConstructorParameters: Iterable) = + FunSpec + .builder("hashCode") + .addModifiers(OVERRIDE) + .returns(Int::class) + .addCode( + buildCodeBlock { + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return 0") + 1 -> addStatement("return %T.hash(%N)", Objects::class, propertyNames.first()) + else -> { + add("return %T.hash(\n", Objects::class) + add( + propertyNames.joinToCode( + separator = ",\n", + suffix = ",\n)", + ) { + buildCodeBlock { + indent() + add("%N", it) + unindent() + } + }, + ) + } + } + }, + ).build() + +private fun TypeSpec.Builder.addToStringFunction( + bindingVersion: BindingVersion, + className: String, + commonConstructorParameters: Iterable, +): TypeSpec.Builder { + if (bindingVersion >= V2) { + addFunction(buildToStringFunction(className, commonConstructorParameters)) + } + return this +} + +private fun buildToStringFunction( + className: String, + commonConstructorParameters: Iterable, +) = FunSpec + .builder("toString") + .addModifiers(OVERRIDE) + .returns(String::class) + .addCode( + buildCodeBlock { + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return %S", "$className()") + + 1 -> + addStatement( + "return %P", + CodeBlock.of("%1L(%2L=$%2N)", className, propertyNames.first()), + ) + + else -> { + beginControlFlow("return buildString") + addStatement("append(%S)", "$className(") + propertyNames.dropLast(1).forEach { + addStatement( + "append(%P)", + CodeBlock.of("%1L=$%1N", it), + ) + addStatement("append(%S)", ", ") + } + addStatement( + "append(%P)", + CodeBlock.of("%1L=$%1N", propertyNames.last()), + ) + addStatement("append(%S)", ")") + endControlFlow() + } + } + }, + ).build() + +private fun TypeSpec.Builder.addCopyFunction( + bindingVersion: BindingVersion, + packageName: String, + className: String, + commonConstructorParameters: Iterable, +): TypeSpec.Builder { + if (bindingVersion >= V2) { + addFunction(buildCopyFunction(packageName, className, commonConstructorParameters)) + } + return this +} + +private fun buildCopyFunction( + packageName: String, + className: String, + commonConstructorParameters: Iterable, +) = FunSpec + .builder("copy") + .returns(ClassName(packageName, className)) + .addParameter( + ParameterSpec + .builder("pleaseUseNamedArguments", Unit::class) + .addModifiers(VARARG) + .build(), + ).addParameters( + commonConstructorParameters + .map { it.toBuilder().defaultValue("this.%N", it.name).build() }, + ).addCode( + buildCodeBlock { + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return %N()", className) + + 1 -> addStatement("return %1N(%2N = %2N)", className, propertyNames.first()) + + else -> { + add("return %1N(\n", className) + add( + propertyNames.joinToCode( + separator = "", + suffix = ")", + ) { + buildCodeBlock { + indent() + add("%1N = %1N,\n", it) + unindent() + } + }, + ) + } + } + }, + ).build() + private fun ParameterSpec.Builder.defaultValueIfNullable( input: Input, untypedClass: Boolean, diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt index a56caad041..24ccb2a36b 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt @@ -1,18 +1,16 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any import kotlin.Boolean -import kotlin.ExposedCopyVisibility import kotlin.Float import kotlin.Int import kotlin.String @@ -57,8 +55,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithAllTypesOfInputsBindingV2 private constructor( +public class ActionWithAllTypesOfInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Short description */ @@ -243,36 +241,6 @@ public data class ActionWithAllTypesOfInputsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - bazGoo: Boolean? = null, - bazGoo_Untyped: String? = null, - binKin: Boolean? = null, - binKin_Untyped: String? = null, - intPint: Int? = null, - intPint_Untyped: String? = null, - floPint: Float? = null, - floPint_Untyped: String? = null, - finBin: ActionWithAllTypesOfInputsBindingV2.Bin? = null, - finBin_Untyped: String? = null, - gooZen: ActionWithAllTypesOfInputsBindingV2.Zen? = null, - gooZen_Untyped: String? = null, - bahEnum: ActionWithAllTypesOfInputsBindingV2.BahEnum? = null, - bahEnum_Untyped: String? = null, - listStrings: List? = null, - listStrings_Untyped: String? = null, - listInts: List? = null, - listInts_Untyped: String? = null, - listEnums: List? = null, - listEnums_Untyped: String? = null, - listIntSpecial: List? = null, - listIntSpecial_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = bazGoo_Untyped, binKin = binKin, binKin_Untyped = binKin_Untyped, intPint = intPint, intPint_Untyped = intPint_Untyped, floPint = floPint, floPint_Untyped = floPint_Untyped, finBin = finBin, finBin_Untyped = finBin_Untyped, gooZen = gooZen, gooZen_Untyped = gooZen_Untyped, bahEnum = bahEnum, bahEnum_Untyped = bahEnum_Untyped, listStrings = listStrings, listStrings_Untyped = listStrings_Untyped, listInts = listInts, listInts_Untyped = listInts_Untyped, listEnums = listEnums, listEnums_Untyped = listEnums_Untyped, listIntSpecial = listIntSpecial, listIntSpecial_Untyped = listIntSpecial_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -304,6 +272,208 @@ public data class ActionWithAllTypesOfInputsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithAllTypesOfInputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + bazGoo == other.bazGoo && + bazGoo_Untyped == other.bazGoo_Untyped && + binKin == other.binKin && + binKin_Untyped == other.binKin_Untyped && + intPint == other.intPint && + intPint_Untyped == other.intPint_Untyped && + floPint == other.floPint && + floPint_Untyped == other.floPint_Untyped && + finBin == other.finBin && + finBin_Untyped == other.finBin_Untyped && + gooZen == other.gooZen && + gooZen_Untyped == other.gooZen_Untyped && + bahEnum == other.bahEnum && + bahEnum_Untyped == other.bahEnum_Untyped && + listStrings == other.listStrings && + listStrings_Untyped == other.listStrings_Untyped && + listInts == other.listInts && + listInts_Untyped == other.listInts_Untyped && + listEnums == other.listEnums && + listEnums_Untyped == other.listEnums_Untyped && + listIntSpecial == other.listIntSpecial && + listIntSpecial_Untyped == other.listIntSpecial_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + bazGoo, + bazGoo_Untyped, + binKin, + binKin_Untyped, + intPint, + intPint_Untyped, + floPint, + floPint_Untyped, + finBin, + finBin_Untyped, + gooZen, + gooZen_Untyped, + bahEnum, + bahEnum_Untyped, + listStrings, + listStrings_Untyped, + listInts, + listInts_Untyped, + listEnums, + listEnums_Untyped, + listIntSpecial, + listIntSpecial_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithAllTypesOfInputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo=$bazGoo""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""binKin=$binKin""") + append(", ") + append("""binKin_Untyped=$binKin_Untyped""") + append(", ") + append("""intPint=$intPint""") + append(", ") + append("""intPint_Untyped=$intPint_Untyped""") + append(", ") + append("""floPint=$floPint""") + append(", ") + append("""floPint_Untyped=$floPint_Untyped""") + append(", ") + append("""finBin=$finBin""") + append(", ") + append("""finBin_Untyped=$finBin_Untyped""") + append(", ") + append("""gooZen=$gooZen""") + append(", ") + append("""gooZen_Untyped=$gooZen_Untyped""") + append(", ") + append("""bahEnum=$bahEnum""") + append(", ") + append("""bahEnum_Untyped=$bahEnum_Untyped""") + append(", ") + append("""listStrings=$listStrings""") + append(", ") + append("""listStrings_Untyped=$listStrings_Untyped""") + append(", ") + append("""listInts=$listInts""") + append(", ") + append("""listInts_Untyped=$listInts_Untyped""") + append(", ") + append("""listEnums=$listEnums""") + append(", ") + append("""listEnums_Untyped=$listEnums_Untyped""") + append(", ") + append("""listIntSpecial=$listIntSpecial""") + append(", ") + append("""listIntSpecial_Untyped=$listIntSpecial_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Short description + * @param fooBar_Untyped <required> Short description + * @param bazGoo <required> First boolean input! + * @param bazGoo_Untyped <required> First boolean input! + * @param binKin Boolean and nullable + * @param binKin_Untyped Boolean and nullable + * @param intPint <required> Integer + * @param intPint_Untyped <required> Integer + * @param floPint <required> Float + * @param floPint_Untyped <required> Float + * @param finBin <required> Enumeration + * @param finBin_Untyped <required> Enumeration + * @param gooZen <required> Integer with special value + * @param gooZen_Untyped <required> Integer with special value + * @param bahEnum <required> Enum with custom naming + * @param bahEnum_Untyped <required> Enum with custom naming + * @param listStrings List of strings + * @param listStrings_Untyped List of strings + * @param listInts List of integers + * @param listInts_Untyped List of integers + * @param listEnums List of enums + * @param listEnums_Untyped List of enums + * @param listIntSpecial List of integer with special values + * @param listIntSpecial_Untyped List of integer with special values + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + bazGoo: Boolean? = this.bazGoo, + bazGoo_Untyped: String? = this.bazGoo_Untyped, + binKin: Boolean? = this.binKin, + binKin_Untyped: String? = this.binKin_Untyped, + intPint: Int? = this.intPint, + intPint_Untyped: String? = this.intPint_Untyped, + floPint: Float? = this.floPint, + floPint_Untyped: String? = this.floPint_Untyped, + finBin: ActionWithAllTypesOfInputsBindingV2.Bin? = this.finBin, + finBin_Untyped: String? = this.finBin_Untyped, + gooZen: ActionWithAllTypesOfInputsBindingV2.Zen? = this.gooZen, + gooZen_Untyped: String? = this.gooZen_Untyped, + bahEnum: ActionWithAllTypesOfInputsBindingV2.BahEnum? = this.bahEnum, + bahEnum_Untyped: String? = this.bahEnum_Untyped, + listStrings: List? = this.listStrings, + listStrings_Untyped: String? = this.listStrings_Untyped, + listInts: List? = this.listInts, + listInts_Untyped: String? = this.listInts_Untyped, + listEnums: List? = this.listEnums, + listEnums_Untyped: String? = this.listEnums_Untyped, + listIntSpecial: List? = this.listIntSpecial, + listIntSpecial_Untyped: String? = this.listIntSpecial_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithAllTypesOfInputsBindingV2 = ActionWithAllTypesOfInputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + bazGoo = bazGoo, + bazGoo_Untyped = bazGoo_Untyped, + binKin = binKin, + binKin_Untyped = binKin_Untyped, + intPint = intPint, + intPint_Untyped = intPint_Untyped, + floPint = floPint, + floPint_Untyped = floPint_Untyped, + finBin = finBin, + finBin_Untyped = finBin_Untyped, + gooZen = gooZen, + gooZen_Untyped = gooZen_Untyped, + bahEnum = bahEnum, + bahEnum_Untyped = bahEnum_Untyped, + listStrings = listStrings, + listStrings_Untyped = listStrings_Untyped, + listInts = listInts, + listInts_Untyped = listInts_Untyped, + listEnums = listEnums, + listEnums_Untyped = listEnums_Untyped, + listIntSpecial = listIntSpecial, + listIntSpecial_Untyped = listIntSpecial_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) public sealed class Bin( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt index 596d9c327a..14fe86848f 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt @@ -2,8 +2,8 @@ // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. @file:Suppress( - "DataClassPrivateConstructor", "UNUSED_PARAMETER", + "DEPRECATION", ) package io.github.typesafegithub.workflows.actions.johnsmith @@ -11,8 +11,11 @@ package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Deprecated -import kotlin.ExposedCopyVisibility +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -66,8 +69,8 @@ import kotlin.collections.toTypedArray "Use the typed class instead", ReplaceWith("ActionWithAllTypesOfInputsBindingV2"), ) -@ExposedCopyVisibility -public data class ActionWithAllTypesOfInputsBindingV2_Untyped private constructor( +public class ActionWithAllTypesOfInputsBindingV2_Untyped( + vararg pleaseUseNamedArguments: Unit, /** * Short description */ @@ -136,24 +139,6 @@ public data class ActionWithAllTypesOfInputsBindingV2_Untyped private constructo } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar_Untyped: String, - bazGoo_Untyped: String, - binKin_Untyped: String? = null, - intPint_Untyped: String, - floPint_Untyped: String, - finBin_Untyped: String, - gooZen_Untyped: String, - bahEnum_Untyped: String, - listStrings_Untyped: String? = null, - listInts_Untyped: String? = null, - listEnums_Untyped: String? = null, - listIntSpecial_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar_Untyped = fooBar_Untyped, bazGoo_Untyped = bazGoo_Untyped, binKin_Untyped = binKin_Untyped, intPint_Untyped = intPint_Untyped, floPint_Untyped = floPint_Untyped, finBin_Untyped = finBin_Untyped, gooZen_Untyped = gooZen_Untyped, bahEnum_Untyped = bahEnum_Untyped, listStrings_Untyped = listStrings_Untyped, listInts_Untyped = listInts_Untyped, listEnums_Untyped = listEnums_Untyped, listIntSpecial_Untyped = listIntSpecial_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -173,6 +158,124 @@ public data class ActionWithAllTypesOfInputsBindingV2_Untyped private constructo ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithAllTypesOfInputsBindingV2_Untyped + return fooBar_Untyped == other.fooBar_Untyped && + bazGoo_Untyped == other.bazGoo_Untyped && + binKin_Untyped == other.binKin_Untyped && + intPint_Untyped == other.intPint_Untyped && + floPint_Untyped == other.floPint_Untyped && + finBin_Untyped == other.finBin_Untyped && + gooZen_Untyped == other.gooZen_Untyped && + bahEnum_Untyped == other.bahEnum_Untyped && + listStrings_Untyped == other.listStrings_Untyped && + listInts_Untyped == other.listInts_Untyped && + listEnums_Untyped == other.listEnums_Untyped && + listIntSpecial_Untyped == other.listIntSpecial_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar_Untyped, + bazGoo_Untyped, + binKin_Untyped, + intPint_Untyped, + floPint_Untyped, + finBin_Untyped, + gooZen_Untyped, + bahEnum_Untyped, + listStrings_Untyped, + listInts_Untyped, + listEnums_Untyped, + listIntSpecial_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithAllTypesOfInputsBindingV2_Untyped(") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""binKin_Untyped=$binKin_Untyped""") + append(", ") + append("""intPint_Untyped=$intPint_Untyped""") + append(", ") + append("""floPint_Untyped=$floPint_Untyped""") + append(", ") + append("""finBin_Untyped=$finBin_Untyped""") + append(", ") + append("""gooZen_Untyped=$gooZen_Untyped""") + append(", ") + append("""bahEnum_Untyped=$bahEnum_Untyped""") + append(", ") + append("""listStrings_Untyped=$listStrings_Untyped""") + append(", ") + append("""listInts_Untyped=$listInts_Untyped""") + append(", ") + append("""listEnums_Untyped=$listEnums_Untyped""") + append(", ") + append("""listIntSpecial_Untyped=$listIntSpecial_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar_Untyped Short description + * @param bazGoo_Untyped First boolean input! + * @param binKin_Untyped Boolean and nullable + * @param intPint_Untyped Integer + * @param floPint_Untyped Float + * @param finBin_Untyped Enumeration + * @param gooZen_Untyped Integer with special value + * @param bahEnum_Untyped Enum with custom naming + * @param listStrings_Untyped List of strings + * @param listInts_Untyped List of integers + * @param listEnums_Untyped List of enums + * @param listIntSpecial_Untyped List of integer with special values + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar_Untyped: String = this.fooBar_Untyped, + bazGoo_Untyped: String = this.bazGoo_Untyped, + binKin_Untyped: String? = this.binKin_Untyped, + intPint_Untyped: String = this.intPint_Untyped, + floPint_Untyped: String = this.floPint_Untyped, + finBin_Untyped: String = this.finBin_Untyped, + gooZen_Untyped: String = this.gooZen_Untyped, + bahEnum_Untyped: String = this.bahEnum_Untyped, + listStrings_Untyped: String? = this.listStrings_Untyped, + listInts_Untyped: String? = this.listInts_Untyped, + listEnums_Untyped: String? = this.listEnums_Untyped, + listIntSpecial_Untyped: String? = this.listIntSpecial_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithAllTypesOfInputsBindingV2_Untyped = ActionWithAllTypesOfInputsBindingV2_Untyped( + fooBar_Untyped = fooBar_Untyped, + bazGoo_Untyped = bazGoo_Untyped, + binKin_Untyped = binKin_Untyped, + intPint_Untyped = intPint_Untyped, + floPint_Untyped = floPint_Untyped, + finBin_Untyped = finBin_Untyped, + gooZen_Untyped = gooZen_Untyped, + bahEnum_Untyped = bahEnum_Untyped, + listStrings_Untyped = listStrings_Untyped, + listInts_Untyped = listInts_Untyped, + listEnums_Untyped = listEnums_Untyped, + listIntSpecial_Untyped = listIntSpecial_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) public class Outputs( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt index 508421d597..bd02aaf418 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt @@ -226,7 +226,6 @@ class ActionWithAllTypesOfInputsTest : DescribeSpec({ V2 -> { // when action as ActionWithAllTypesOfInputsBindingV2 - @Suppress("DATA_CLASS_INVISIBLE_COPY_USAGE_WARNING") val actionWithOneChange = action.copy(fooBar = "another") // then diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt index 2c14723448..e561ad601d 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -31,8 +31,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithDeprecatedInputAndNameClashBindingV2 private constructor( +public class ActionWithDeprecatedInputAndNameClashBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Foo bar - new */ @@ -67,14 +67,6 @@ public data class ActionWithDeprecatedInputAndNameClashBindingV2 private constru } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -84,5 +76,53 @@ public data class ActionWithDeprecatedInputAndNameClashBindingV2 private constru ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithDeprecatedInputAndNameClashBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithDeprecatedInputAndNameClashBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Foo bar - new + * @param fooBar_Untyped <required> Foo bar - new + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithDeprecatedInputAndNameClashBindingV2 = ActionWithDeprecatedInputAndNameClashBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt index 55329df926..4f29e80088 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -33,8 +33,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithFancyCharsInDocsBindingV2 private constructor( +public class ActionWithFancyCharsInDocsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * This is a /* test */ */ @@ -78,16 +78,6 @@ public data class ActionWithFancyCharsInDocsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - nestedKotlinComments: String? = null, - nestedKotlinComments_Untyped: String? = null, - percent: String? = null, - percent_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(nestedKotlinComments = nestedKotlinComments, nestedKotlinComments_Untyped = nestedKotlinComments_Untyped, percent = percent, percent_Untyped = percent_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -99,5 +89,67 @@ public data class ActionWithFancyCharsInDocsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithFancyCharsInDocsBindingV2 + return nestedKotlinComments == other.nestedKotlinComments && + nestedKotlinComments_Untyped == other.nestedKotlinComments_Untyped && + percent == other.percent && + percent_Untyped == other.percent_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + nestedKotlinComments, + nestedKotlinComments_Untyped, + percent, + percent_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithFancyCharsInDocsBindingV2(") + append("""nestedKotlinComments=$nestedKotlinComments""") + append(", ") + append("""nestedKotlinComments_Untyped=$nestedKotlinComments_Untyped""") + append(", ") + append("""percent=$percent""") + append(", ") + append("""percent_Untyped=$percent_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param nestedKotlinComments This is a /* test */ + * @param nestedKotlinComments_Untyped This is a /* test */ + * @param percent For example "100%" + * @param percent_Untyped For example "100%" + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + nestedKotlinComments: String? = this.nestedKotlinComments, + nestedKotlinComments_Untyped: String? = this.nestedKotlinComments_Untyped, + percent: String? = this.percent, + percent_Untyped: String? = this.percent_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithFancyCharsInDocsBindingV2 = ActionWithFancyCharsInDocsBindingV2( + nestedKotlinComments = nestedKotlinComments, + nestedKotlinComments_Untyped = nestedKotlinComments_Untyped, + percent = percent, + percent_Untyped = percent_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt index 026e146b24..f5929da094 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt @@ -1,17 +1,16 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Int import kotlin.String import kotlin.Suppress @@ -34,8 +33,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithInputsSharingTypeBindingV2 private constructor( +public class ActionWithInputsSharingTypeBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> */ @@ -91,18 +90,6 @@ public data class ActionWithInputsSharingTypeBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooOne: ActionWithInputsSharingTypeBindingV2.Foo? = null, - fooOne_Untyped: String? = null, - fooTwo: ActionWithInputsSharingTypeBindingV2.Foo? = null, - fooTwo_Untyped: String? = null, - fooThree: ActionWithInputsSharingTypeBindingV2.Foo? = null, - fooThree_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooOne = fooOne, fooOne_Untyped = fooOne_Untyped, fooTwo = fooTwo, fooTwo_Untyped = fooTwo_Untyped, fooThree = fooThree, fooThree_Untyped = fooThree_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -116,6 +103,80 @@ public data class ActionWithInputsSharingTypeBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithInputsSharingTypeBindingV2 + return fooOne == other.fooOne && + fooOne_Untyped == other.fooOne_Untyped && + fooTwo == other.fooTwo && + fooTwo_Untyped == other.fooTwo_Untyped && + fooThree == other.fooThree && + fooThree_Untyped == other.fooThree_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooOne, + fooOne_Untyped, + fooTwo, + fooTwo_Untyped, + fooThree, + fooThree_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithInputsSharingTypeBindingV2(") + append("""fooOne=$fooOne""") + append(", ") + append("""fooOne_Untyped=$fooOne_Untyped""") + append(", ") + append("""fooTwo=$fooTwo""") + append(", ") + append("""fooTwo_Untyped=$fooTwo_Untyped""") + append(", ") + append("""fooThree=$fooThree""") + append(", ") + append("""fooThree_Untyped=$fooThree_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooOne <required> + * @param fooOne_Untyped <required> + * @param fooTwo <required> + * @param fooTwo_Untyped <required> + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooOne: ActionWithInputsSharingTypeBindingV2.Foo? = this.fooOne, + fooOne_Untyped: String? = this.fooOne_Untyped, + fooTwo: ActionWithInputsSharingTypeBindingV2.Foo? = this.fooTwo, + fooTwo_Untyped: String? = this.fooTwo_Untyped, + fooThree: ActionWithInputsSharingTypeBindingV2.Foo? = this.fooThree, + fooThree_Untyped: String? = this.fooThree_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithInputsSharingTypeBindingV2 = ActionWithInputsSharingTypeBindingV2( + fooOne = fooOne, + fooOne_Untyped = fooOne_Untyped, + fooTwo = fooTwo, + fooTwo_Untyped = fooTwo_Untyped, + fooThree = fooThree, + fooThree_Untyped = fooThree_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) public sealed class Foo( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt index b20f199d0c..8a11ad1ee7 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -27,8 +27,8 @@ import kotlin.collections.Map * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithNoInputsBindingV2 private constructor( +public class ActionWithNoInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * Type-unsafe map where you can put any inputs that are not yet supported by the binding */ @@ -49,14 +49,42 @@ public data class ActionWithNoInputsBindingV2 private constructor( } - public constructor( - vararg pleaseUseNamedArguments: Unit, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(_customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = LinkedHashMap(_customInputs) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithNoInputsBindingV2 + return _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithNoInputsBindingV2(") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithNoInputsBindingV2 = ActionWithNoInputsBindingV2( + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt index 97db7e9c94..1216138f53 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -49,8 +49,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithNoTypingsBindingV2_Untyped private constructor( +public class ActionWithNoTypingsBindingV2_Untyped( + vararg pleaseUseNamedArguments: Unit, public val foo_Untyped: String, public val bar_Untyped: String? = null, /** @@ -73,14 +73,6 @@ public data class ActionWithNoTypingsBindingV2_Untyped private constructor( } - public constructor( - vararg pleaseUseNamedArguments: Unit, - foo_Untyped: String, - bar_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(foo_Untyped = foo_Untyped, bar_Untyped = bar_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -90,5 +82,51 @@ public data class ActionWithNoTypingsBindingV2_Untyped private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithNoTypingsBindingV2_Untyped + return foo_Untyped == other.foo_Untyped && + bar_Untyped == other.bar_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + foo_Untyped, + bar_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithNoTypingsBindingV2_Untyped(") + append("""foo_Untyped=$foo_Untyped""") + append(", ") + append("""bar_Untyped=$bar_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + foo_Untyped: String = this.foo_Untyped, + bar_Untyped: String? = this.bar_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithNoTypingsBindingV2_Untyped = ActionWithNoTypingsBindingV2_Untyped( + foo_Untyped = foo_Untyped, + bar_Untyped = bar_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt index 41d06e17f7..10a0161761 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -31,8 +31,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithOutputsBindingV2 private constructor( +public class ActionWithOutputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Short description */ @@ -67,14 +67,6 @@ public data class ActionWithOutputsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -84,6 +76,54 @@ public data class ActionWithOutputsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithOutputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithOutputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Short description + * @param fooBar_Untyped <required> Short description + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithOutputsBindingV2 = ActionWithOutputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) public class Outputs( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt index 317a813b5a..6d43427ff6 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt @@ -1,17 +1,16 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Int import kotlin.String import kotlin.Suppress @@ -32,8 +31,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithPartlyTypingsBindingV2 private constructor( +public class ActionWithPartlyTypingsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> */ @@ -70,16 +69,6 @@ public data class ActionWithPartlyTypingsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - foo: Int? = null, - foo_Untyped: String? = null, - bar_Untyped: String? = null, - baz_Untyped: String, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(foo = foo, foo_Untyped = foo_Untyped, bar_Untyped = bar_Untyped, baz_Untyped = baz_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -91,5 +80,65 @@ public data class ActionWithPartlyTypingsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithPartlyTypingsBindingV2 + return foo == other.foo && + foo_Untyped == other.foo_Untyped && + bar_Untyped == other.bar_Untyped && + baz_Untyped == other.baz_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + foo, + foo_Untyped, + bar_Untyped, + baz_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithPartlyTypingsBindingV2(") + append("""foo=$foo""") + append(", ") + append("""foo_Untyped=$foo_Untyped""") + append(", ") + append("""bar_Untyped=$bar_Untyped""") + append(", ") + append("""baz_Untyped=$baz_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param foo <required> + * @param foo_Untyped <required> + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + foo: Int? = this.foo, + foo_Untyped: String? = this.foo_Untyped, + bar_Untyped: String? = this.bar_Untyped, + baz_Untyped: String = this.baz_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithPartlyTypingsBindingV2 = ActionWithPartlyTypingsBindingV2( + foo = foo, + foo_Untyped = foo_Untyped, + bar_Untyped = bar_Untyped, + baz_Untyped = baz_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt index 8d2d2d786c..d812b6dade 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt @@ -2,8 +2,8 @@ // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. @file:Suppress( - "DataClassPrivateConstructor", "UNUSED_PARAMETER", + "DEPRECATION", ) package io.github.typesafegithub.workflows.actions.johnsmith @@ -11,8 +11,11 @@ package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Deprecated -import kotlin.ExposedCopyVisibility +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -54,8 +57,8 @@ import kotlin.collections.toTypedArray "Use the typed class instead", ReplaceWith("ActionWithPartlyTypingsBindingV2"), ) -@ExposedCopyVisibility -public data class ActionWithPartlyTypingsBindingV2_Untyped private constructor( +public class ActionWithPartlyTypingsBindingV2_Untyped( + vararg pleaseUseNamedArguments: Unit, public val foo_Untyped: String, public val bar_Untyped: String? = null, public val baz_Untyped: String, @@ -79,15 +82,6 @@ public data class ActionWithPartlyTypingsBindingV2_Untyped private constructor( } - public constructor( - vararg pleaseUseNamedArguments: Unit, - foo_Untyped: String, - bar_Untyped: String? = null, - baz_Untyped: String, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(foo_Untyped = foo_Untyped, bar_Untyped = bar_Untyped, baz_Untyped = baz_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -98,5 +92,57 @@ public data class ActionWithPartlyTypingsBindingV2_Untyped private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithPartlyTypingsBindingV2_Untyped + return foo_Untyped == other.foo_Untyped && + bar_Untyped == other.bar_Untyped && + baz_Untyped == other.baz_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + foo_Untyped, + bar_Untyped, + baz_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithPartlyTypingsBindingV2_Untyped(") + append("""foo_Untyped=$foo_Untyped""") + append(", ") + append("""bar_Untyped=$bar_Untyped""") + append(", ") + append("""baz_Untyped=$baz_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + foo_Untyped: String = this.foo_Untyped, + bar_Untyped: String? = this.bar_Untyped, + baz_Untyped: String = this.baz_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithPartlyTypingsBindingV2_Untyped = ActionWithPartlyTypingsBindingV2_Untyped( + foo_Untyped = foo_Untyped, + bar_Untyped = bar_Untyped, + baz_Untyped = baz_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt index 1ae94320d1..2471d8a424 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -39,8 +39,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithSomeOptionalInputsBindingV2 private constructor( +public class ActionWithSomeOptionalInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * Required is default, default is set */ @@ -123,22 +123,6 @@ public data class ActionWithSomeOptionalInputsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - bazGoo: String? = null, - bazGoo_Untyped: String? = null, - zooDar: String? = null, - zooDar_Untyped: String? = null, - cooPoo: String? = null, - cooPoo_Untyped: String? = null, - `package`: String? = null, - package_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = bazGoo_Untyped, zooDar = zooDar, zooDar_Untyped = zooDar_Untyped, cooPoo = cooPoo, cooPoo_Untyped = cooPoo_Untyped, `package` = `package`, package_Untyped = package_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -156,5 +140,109 @@ public data class ActionWithSomeOptionalInputsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithSomeOptionalInputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + bazGoo == other.bazGoo && + bazGoo_Untyped == other.bazGoo_Untyped && + zooDar == other.zooDar && + zooDar_Untyped == other.zooDar_Untyped && + cooPoo == other.cooPoo && + cooPoo_Untyped == other.cooPoo_Untyped && + `package` == other.`package` && + package_Untyped == other.package_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + bazGoo, + bazGoo_Untyped, + zooDar, + zooDar_Untyped, + cooPoo, + cooPoo_Untyped, + `package`, + package_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithSomeOptionalInputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo=$bazGoo""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""zooDar=$zooDar""") + append(", ") + append("""zooDar_Untyped=$zooDar_Untyped""") + append(", ") + append("""cooPoo=$cooPoo""") + append(", ") + append("""cooPoo_Untyped=$cooPoo_Untyped""") + append(", ") + append("""package=$`package`""") + append(", ") + append("""package_Untyped=$package_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar Required is default, default is set + * @param fooBar_Untyped Required is default, default is set + * @param bazGoo Required is default, default is null + * @param bazGoo_Untyped Required is default, default is null + * @param zooDar Required is false, default is set + * @param zooDar_Untyped Required is false, default is set + * @param cooPoo Required is false, default is default + * @param cooPoo_Untyped Required is false, default is default + * @param package <required> Required is true, default is default + * @param package_Untyped <required> Required is true, default is default + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + bazGoo: String? = this.bazGoo, + bazGoo_Untyped: String? = this.bazGoo_Untyped, + zooDar: String? = this.zooDar, + zooDar_Untyped: String? = this.zooDar_Untyped, + cooPoo: String? = this.cooPoo, + cooPoo_Untyped: String? = this.cooPoo_Untyped, + `package`: String? = this.`package`, + package_Untyped: String? = this.package_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithSomeOptionalInputsBindingV2 = ActionWithSomeOptionalInputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + bazGoo = bazGoo, + bazGoo_Untyped = bazGoo_Untyped, + zooDar = zooDar, + zooDar_Untyped = zooDar_Untyped, + cooPoo = cooPoo, + cooPoo_Untyped = cooPoo_Untyped, + `package` = `package`, + package_Untyped = package_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt index efbb2c7e5a..12da37beeb 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt @@ -2,7 +2,6 @@ // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. @file:Suppress( - "DataClassPrivateConstructor", "UNUSED_PARAMETER", "DEPRECATION", ) @@ -12,8 +11,11 @@ package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Deprecated -import kotlin.ExposedCopyVisibility +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -38,8 +40,8 @@ import kotlin.collections.toTypedArray * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class SimpleActionWithRequiredStringInputsBindingV2 private constructor( +public class SimpleActionWithRequiredStringInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Short description */ @@ -93,16 +95,6 @@ public data class SimpleActionWithRequiredStringInputsBindingV2 private construc } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - bazGoo: String? = null, - bazGoo_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = bazGoo_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -114,5 +106,69 @@ public data class SimpleActionWithRequiredStringInputsBindingV2 private construc ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as SimpleActionWithRequiredStringInputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + bazGoo == other.bazGoo && + bazGoo_Untyped == other.bazGoo_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + bazGoo, + bazGoo_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("SimpleActionWithRequiredStringInputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo=$bazGoo""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Short description + * @param fooBar_Untyped <required> Short description + * @param bazGoo <required> Just another input + * with multiline description + * @param bazGoo_Untyped <required> Just another input + * with multiline description + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + bazGoo: String? = this.bazGoo, + bazGoo_Untyped: String? = this.bazGoo_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): SimpleActionWithRequiredStringInputsBindingV2 = SimpleActionWithRequiredStringInputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + bazGoo = bazGoo, + bazGoo_Untyped = bazGoo_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/docs/user-guide/using-actions.md b/docs/user-guide/using-actions.md index d90246f29c..a81976ed37 100644 --- a/docs/user-guide/using-actions.md +++ b/docs/user-guide/using-actions.md @@ -119,7 +119,14 @@ anyway as defined above. `https://bindings.krzeminski.it/v2` -: TBD +: - Binding classes are no `data` classes anymore. + - The `equals` method will work like before. + - The `hashCode` method will work like before. + - The `toString` method will work like before. + - Destructuring assignments are not possible anymore as this will likely break silently or during + compilation when action owners add new inputs in between existing ones. + - The `copy` method will work like before, just that now usage of named arguments is enforced + to ensure source compatibility when action owners add new inputs in between existing ones. `https://bindings.krzeminski.it` / `https://bindings.krzeminski.it/v1`