mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-24 03:31:04 +00: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() },
|
dependencies?.map { dependency -> dependency.toClassName() },
|
||||||
compatiblePackages?.map {
|
compatiblePackages?.map {
|
||||||
val packageName = it.property("name")
|
val packageName = it.property("name")
|
||||||
val packageVersions = (it.property("versions") as List<String>)
|
val packageVersions = (it.property("versions") as List<String>).ifEmpty { null }
|
||||||
.joinToString(", ") { version -> "\"$version\"" }
|
?.joinToString(", ") { version -> "\"$version\"" }
|
||||||
|
|
||||||
CodeBlock.of(
|
CodeBlock.of(
|
||||||
"%T(%S, setOf(%L))",
|
"%T(%S, %L)",
|
||||||
app.revanced.patcher.patch.Patch.CompatiblePackage::class,
|
app.revanced.patcher.patch.Patch.CompatiblePackage::class,
|
||||||
packageName,
|
packageName,
|
||||||
packageVersions
|
packageVersions?.let { "setOf($packageVersions)" },
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
use,
|
use,
|
||||||
|
|||||||
@@ -21,6 +21,16 @@ class TestPatchAnnotationProcessor {
|
|||||||
).loadPatch("$SAMPLE_PACKAGE.processing.ProcessablePatchGenerated").name
|
).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
|
// endregion
|
||||||
|
|
||||||
// region Dependencies
|
// 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