From ba59d5e54d845749d64c6d4f93d068274abf44a1 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 5 Dec 2024 23:03:13 +0000 Subject: [PATCH 1/4] No public API records --- checkstyle.xml | 5 +++++ .../fabric/api/transfer/v1/storage/base/ResourceAmount.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/checkstyle.xml b/checkstyle.xml index daf09c3b61..e265b13f31 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -208,5 +208,10 @@ + + + + + diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/ResourceAmount.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/ResourceAmount.java index 6a6f49009a..e0b132fc34 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/ResourceAmount.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/ResourceAmount.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.transfer.v1.storage.base; +//CHECKSTYLE.OFF: MatchXpath + /** * An immutable object storing both a resource and an amount, provided for convenience. * @param The type of the stored resource. From 1a325e1cc302827a5f3aa6619842aeb52f03fc35 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 5 Dec 2024 23:05:50 +0000 Subject: [PATCH 2/4] Add note in contributing --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69ecc3559b..8b1868625d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,6 +99,8 @@ Fabric API makes strong backwards compatibility guarantees, by which contributor - If vanilla exposes optionals in return types, then returning an optional is fine. - Avoid requiring the user to cast to a subtype if possible. - Adding methods to vanilla types can be done via interface injection. +- Avoid exposing java `records` as public API + - Prefer to expose an interface that is implemented by an impl record. ### API design patterns to consider From 71c662b19efb9cc1c3e4ace6423642b7609f39cb Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 5 Dec 2024 23:31:38 +0000 Subject: [PATCH 3/4] Explain why --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b1868625d..e6937a6ad8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,7 +99,8 @@ Fabric API makes strong backwards compatibility guarantees, by which contributor - If vanilla exposes optionals in return types, then returning an optional is fine. - Avoid requiring the user to cast to a subtype if possible. - Adding methods to vanilla types can be done via interface injection. -- Avoid exposing java `records` as public API +- Avoid exposing java `records` as public API. + - Records expose more than is necessary for most APIs, which makes them difficult to evolve. - Prefer to expose an interface that is implemented by an impl record. ### API design patterns to consider From f1a7de26f31a96fc7470f8f8646ed233271908d0 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Fri, 6 Dec 2024 10:43:15 +0000 Subject: [PATCH 4/4] Fix --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6937a6ad8..706a738f10 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,7 +99,7 @@ Fabric API makes strong backwards compatibility guarantees, by which contributor - If vanilla exposes optionals in return types, then returning an optional is fine. - Avoid requiring the user to cast to a subtype if possible. - Adding methods to vanilla types can be done via interface injection. -- Avoid exposing java `records` as public API. +- Avoid exposing java `record`s as public API. - Records expose more than is necessary for most APIs, which makes them difficult to evolve. - Prefer to expose an interface that is implemented by an impl record.