mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-06-13 05:37:38 +02:00
fix: Do not set CompatiblePackage.versions
if @CompatiblePackage.versions
is empty
This commit is contained in:
@ -81,14 +81,14 @@ class PatchProcessor(
|
||||
dependencies?.map { dependency -> dependency.toClassName() },
|
||||
compatiblePackages?.map {
|
||||
val packageName = it.property("name")
|
||||
val packageVersions = (it.property("versions") as List<String>)
|
||||
.joinToString(", ") { version -> "\"$version\"" }
|
||||
val packageVersions = (it.property("versions") as List<String>).ifEmpty { null }
|
||||
?.joinToString(", ") { version -> "\"$version\"" }
|
||||
|
||||
CodeBlock.of(
|
||||
"%T(%S, setOf(%L))",
|
||||
"%T(%S, %L)",
|
||||
app.revanced.patcher.patch.Patch.CompatiblePackage::class,
|
||||
packageName,
|
||||
packageVersions
|
||||
packageVersions?.let { "setOf($packageVersions)" },
|
||||
)
|
||||
},
|
||||
use,
|
||||
|
@ -21,6 +21,16 @@ class TestPatchAnnotationProcessor {
|
||||
).loadPatch("$SAMPLE_PACKAGE.processing.ProcessablePatchGenerated").name
|
||||
)
|
||||
|
||||
@Test
|
||||
fun generateNullProperties() = compile(
|
||||
getSourceFile(
|
||||
"null", "NullPropertiesPatch"
|
||||
)
|
||||
).loadPatch("$SAMPLE_PACKAGE.null.NullPropertiesPatchGenerated").let {
|
||||
assertNull(it.description) // Because no description was provided.
|
||||
assertNull(it.compatiblePackages!!.first().versions) // Because no versions were provided.
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Dependencies
|
||||
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.patcher.patch.annotation.processor.samples.`null`
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
|
||||
@Patch(
|
||||
"Patch with null properties",
|
||||
compatiblePackages = [CompatiblePackage("com.google.android.youtube")],
|
||||
)
|
||||
object NullPropertiesPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext) {}
|
||||
}
|
Reference in New Issue
Block a user