Skip to content

Commit

Permalink
Release 0.18.1
Browse files Browse the repository at this point in the history
  • Loading branch information
drewhamilton committed Dec 14, 2024
1 parent 55ce748 commit 8cdf7fd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 17 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 0.18.1
_2024-12-13

Add ability to skip individual properties with `@Poko.Skip`. These properties will be omitted from
all generated functions. This feature is experimental and requires opt-in via `@SkipSupport`.

Replace `@ArrayContentBased` with `@Poko.ReadArrayContent`. Add a deprecated `typealias` for the
former to aid migration.

Add support for use optional property-level features with custom Poko annotation. Nested annotations
with the same name as the optional feature, such as `@MyData.ReadArrayContent` and
`@MyData.Skip`, will be respected.

Fix issue with FIR checkers. K2-enabled IDEs should now highlight Poko errors and warnings in
consumer source code.

## 0.18.0
_2024-12-2_

Expand Down
48 changes: 32 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,52 @@ generate that function but will still generate the non-overridden functions. Usi
is not recommended, and if they are used, it is recommended to override `equals` and `hashCode`
manually.

### Annotation
By default, the `dev.drewhamilton.poko.Poko` annotation is used to mark classes for Poko generation.
If you prefer, you can create a different annotation and supply it to the Gradle plugin.

```groovy
apply plugin: "dev.drewhamilton.poko"
poko {
pokoAnnotation.set "com/example/MyData"
}
```

Nested annotations mentioned below can optionally be added with the same name to the base annotation
and used for their respective features. For example, `@MyData.ReadArrayContent` will cause the
annotated property's contents to be used in the Poko-generated functions.

### Arrays
By default, Poko does nothing to inspect the contents of array properties. [This aligns with the
behavior of data classes](https://blog.jetbrains.com/kotlin/2015/09/feedback-request-limitations-on-data-classes/#Appendix.Comparingarrays).

Poko consumers can change this behavior on a per-property basis with the `@ArrayContentBased`
Poko consumers can change this behavior on a per-property basis with the `@Poko.ReadArrayContent`
annotation. On properties of a typed array type, this annotation will generate a `contentDeepEquals`
check. On properties of a primitive array type, this annotation will generate a `contentEquals`
check. And on properties of type `Any` or of a generic type, this annotation will generate a `when`
statement that disambiguates the many array types at runtime and uses the appropriate
`contentDeepEquals` or `contentEquals` check. In all cases, the corresponding content-based
`hashCode` and `toString` are generated for the property as well.

Using arrays as properties in data types is still not generally recommended: arrays are mutable, and
Using arrays as properties in data types is not generally recommended: arrays are mutable, and
mutating data can affect the results of `equals` and `hashCode` over time, which is generally
unexpected. For this reason, `@ArrayContentBased` should only be used in very performance-sensitive
APIs.
unexpected. For this reason, `@Poko.ReadArrayContent` should only be used in very
performance-sensitive APIs.

### Annotation
By default, the `dev.drewhamilton.poko.Poko` annotation is used to mark classes for Poko generation.
If you prefer, you can create a different annotation and supply it to the Gradle plugin.
### Skipping properties

```groovy
apply plugin: "dev.drewhamilton.poko"
poko {
pokoAnnotation.set "com/example/MyDataAnnotation"
}
```
It is sometimes useful to omit some properties from consideration when generating the Poko
functions. This can be done with the experimental `@Poko.Skip` annotation. Properties with this
annotation will be excluded from all three generated functions. For example:

Note that this only affects the primary marker annotation. Supplemental annotations such as
`@ArrayContentBased` do not support customization.
```kotlin
@Poko class Data(
val id: String,
@Poko.Skip val callback: () -> Unit,
) : CircuitUiState

Data("a", { println("a") }) == Data("a", { println("not a") }) // yields `true`
```

### Download

Expand All @@ -71,7 +87,7 @@ exclusively compatible with specific versions of Poko.

| Kotlin version | Poko version |
|-----------------|--------------|
| 2.1.0 | 0.18.0 |
| 2.1.0 | 0.18.1 |
| 2.0.0 – 2.0.21 | 0.17.2 |
| 1.9.0 – 1.9.24 | 0.15.3 |
| 1.8.20 – 1.8.22 | 0.13.1 |
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kotlin.code.style=official
kotlin.js.stdlib.dom.api.included=false

PUBLISH_GROUP=dev.drewhamilton.poko
PUBLISH_VERSION=0.19.0-SNAPSHOT
PUBLISH_VERSION=0.18.1

# Uncomment to enable snapshot dependencies:
#snapshots_repository=https://oss.sonatype.org/content/repositories/snapshots
Expand Down

0 comments on commit 8cdf7fd

Please sign in to comment.