This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 3e6ec4337 fix(dart): resolve fory pub.dev score issues (#3585)
3e6ec4337 is described below
commit 3e6ec433740edf05b49276a7888f91f620060d7c
Author: Shawn Yang <[email protected]>
AuthorDate: Mon Apr 20 00:25:33 2026 +0800
fix(dart): resolve fory pub.dev score issues (#3585)
## Why?
## What does this PR do?
## Related issues
## AI Contribution Checklist
- [ ] Substantial AI assistance was used in this PR: `yes` / `no`
- [ ] If `yes`, I included a completed [AI Contribution
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
in this PR description and the required `AI Usage Disclosure`.
- [ ] If `yes`, my PR description includes the required `ai_review`
summary and screenshot evidence of the final clean AI review results
from both fresh reviewers on the current PR diff or current HEAD after
the latest code changes.
## Does this PR introduce any user-facing change?
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
---
dart/packages/fory/CHANGELOG.md | 5 +
dart/packages/fory/LICENSE | 103 ------------------
dart/packages/fory/NOTICE | 5 +
.../fory/lib/src/codegen/fory_generator.dart | 121 +++++++++++----------
dart/packages/fory/pubspec.yaml | 12 +-
5 files changed, 78 insertions(+), 168 deletions(-)
diff --git a/dart/packages/fory/CHANGELOG.md b/dart/packages/fory/CHANGELOG.md
index c2fd74d72..bd2f13300 100644
--- a/dart/packages/fory/CHANGELOG.md
+++ b/dart/packages/fory/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.18.0-dev
+
+- Refresh pub.dev package metadata and documentation links.
+- Update code generation dependencies for current stable Dart tooling.
+
## 0.17.0-dev
- Dart runtime implementation around `Fory`, `Buffer`, `WriteContext`,
`ReadContext`, and `TypeResolver`.
diff --git a/dart/packages/fory/LICENSE b/dart/packages/fory/LICENSE
index 62e28df76..261eeb9e9 100644
--- a/dart/packages/fory/LICENSE
+++ b/dart/packages/fory/LICENSE
@@ -199,106 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-================================================================
-
-This product includes a number of Dependencies with separate copyright notices
-and license terms. Your use of these submodules is subject to the terms and
-conditions of the following licenses.
-
-================================================================
-
-================================================================
-Apache-2.0 licenses
-================================================================
-The following components are provided under the Apache-2.0 License. See
project link for details.
-The text of each license is the standard Apache 2.0 license.
-
-* guava (https://github.com/google/guava)
- Files:
- java/fory-core/src/main/java/org/apache/fory/util/Preconditions.java
- java/fory-core/src/main/java/org/apache/fory/reflect/TypeParameter.java
- java/fory-core/src/main/java/org/apache/fory/reflect/TypeRef.java
-
java/fory-core/src/main/java/org/apache/fory/util/concurrency/DirectExecutorService.java
-
-* spark (https://github.com/apache/spark)
- Files:
- java/fory-core/src/main/java/org/apache/fory/codegen/Code.java
- java/fory-core/src/main/java/org/apache/fory/memory/Platform.java
-
java/fory-format/src/main/java/org/apache/fory/format/vectorized/ArrowWriter.java
-
-* commons-io (https://github.com/apache/commons-io)
- Files:
-
java/fory-core/src/main/java/org/apache/fory/io/ClassLoaderObjectInputStream.java
-
-* common-lang3 (https://github.com/apache/commons-lang)
- Files:
- java/fory-core/src/main/java/org/apache/fory/util/StringUtils.java
-
-* fast-serialization (https://github.com/RuedigerMoeller/fast-serialization)
- Files:
-
benchmarks/java/src/main/java/org/apache/fory/benchmark/Identity2IdMap.java
-
-* ray (https://github.com/ray-project/ray)
- Files:
- ci/format.sh
-
-* grpc (https://github.com/grpc/grpc)
- Files:
- bazel/cython_library.bzl
-
-
-================================================================
-BSD-3-Clause licenses
-================================================================
-The following components are provided under the BSD-3-Clause License. See
project link for details.
-The text of each license is also included in licenses/LICENSE-[project].txt.
-
-* kryo (https://github.com/EsotericSoftware/kryo)
- Files:
- benchmarks/java/src/main/java/org/apache/fory/benchmark/data/Data.java
- benchmarks/java/src/main/java/org/apache/fory/benchmark/data/Image.java
- benchmarks/java/src/main/java/org/apache/fory/benchmark/data/Media.java
-
benchmarks/java/src/main/java/org/apache/fory/benchmark/data/MediaContent.java
- benchmarks/java/src/main/java/org/apache/fory/benchmark/data/Sample.java
-
benchmarks/java/src/main/java/org/apache/fory/benchmark/state/BufferType.java
-
benchmarks/java/src/main/java/org/apache/fory/benchmark/state/KryoState.java
-
java/fory-core/src/main/java/org/apache/fory/collection/ForyObjectMap.java
- java/fory-core/src/main/java/org/apache/fory/collection/IdentityMap.java
-
java/fory-core/src/main/java/org/apache/fory/collection/IdentityObjectIntMap.java
- java/fory-core/src/main/java/org/apache/fory/collection/LongMap.java
-
java/fory-core/src/main/java/org/apache/fory/collection/LongLongByteMap.java
- java/fory-core/src/main/java/org/apache/fory/collection/ObjectIntMap.java
- java/fory-core/src/main/java/org/apache/fory/type/Generics.java
- java/fory-core/src/test/java/org/apache/fory/type/GenericsTest.java
-
-================================================================
-MIT licenses
-================================================================
-The following components are provided under the MIT License. See project link
for details.
-The text of each license is also included in licenses/LICENSE-[project].txt
-
-* murmurHash3.js (https://github.com/karanlyons/murmurHash3.js)
- Files:
- javascript/packages/fory/lib/murmurHash3.ts
-
-* cython-abseil-sample (https://github.com/messense/cython-abseil-sample)
- Files:
- python/pyfory/includes/libabsl.pxd
-
-
-================================================================
-Public Domain
-================================================================
-The following components are placed in the public domain.
-The author hereby disclaims copyright to this source code.
-See project link for details.
-
-* smhasher (https://github.com/aappleby/smhasher)
- Files:
- src/fory/thirdparty/MurmurHash3.cc
- src/fory/thirdparty/MurmurHash3.h
-
-* java_util (https://github.com/yonik/java_util)
- Files:
- java/fory-core/src/main/java/org/apache/fory/util/MurmurHash3.java
diff --git a/dart/packages/fory/NOTICE b/dart/packages/fory/NOTICE
new file mode 100644
index 000000000..a4b31caf3
--- /dev/null
+++ b/dart/packages/fory/NOTICE
@@ -0,0 +1,5 @@
+Apache Fory
+Copyright 2023-2026 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/dart/packages/fory/lib/src/codegen/fory_generator.dart
b/dart/packages/fory/lib/src/codegen/fory_generator.dart
index 9ab6a63f6..eaf4c9b34 100644
--- a/dart/packages/fory/lib/src/codegen/fory_generator.dart
+++ b/dart/packages/fory/lib/src/codegen/fory_generator.dart
@@ -7,7 +7,6 @@ import 'package:build/build.dart';
import 'package:fory/fory.dart';
import 'package:source_gen/source_gen.dart';
-
class DebugGeneratedFieldTypeSpec {
const DebugGeneratedFieldTypeSpec({
required this.typeLiteral,
@@ -27,28 +26,35 @@ class DebugGeneratedFieldTypeSpec {
}
final class ForyGenerator extends Generator {
- static final TypeChecker _foryStructChecker =
- TypeChecker.fromRuntime(ForyStruct);
- static final TypeChecker _foryFieldChecker =
- TypeChecker.fromRuntime(ForyField);
- static final TypeChecker _foryUnionChecker =
- TypeChecker.fromRuntime(ForyUnion);
- static final TypeChecker _listTypeChecker =
- TypeChecker.fromRuntime(ListType);
- static final TypeChecker _mapTypeChecker =
- TypeChecker.fromRuntime(MapType);
- static final TypeChecker _refOptionChecker =
- TypeChecker.fromRuntime(RefOption);
- static final TypeChecker _nullableOptionChecker =
- TypeChecker.fromRuntime(NullableOption);
- static final TypeChecker _int32Checker = TypeChecker.fromRuntime(Int32Type);
- static final TypeChecker _int64Checker = TypeChecker.fromRuntime(Int64Type);
- static final TypeChecker _uint8Checker = TypeChecker.fromRuntime(Uint8Type);
- static final TypeChecker _uint16Checker =
TypeChecker.fromRuntime(Uint16Type);
- static final TypeChecker _uint32Checker =
TypeChecker.fromRuntime(Uint32Type);
- static final TypeChecker _uint64Checker =
TypeChecker.fromRuntime(Uint64Type);
-
- final Map<String, String> _importPrefixByLibraryIdentifier = <String,
String>{};
+ static const TypeChecker _foryStructChecker =
+ TypeChecker.typeNamed(ForyStruct, inPackage: 'fory');
+ static const TypeChecker _foryFieldChecker =
+ TypeChecker.typeNamed(ForyField, inPackage: 'fory');
+ static const TypeChecker _foryUnionChecker =
+ TypeChecker.typeNamed(ForyUnion, inPackage: 'fory');
+ static const TypeChecker _listTypeChecker =
+ TypeChecker.typeNamed(ListType, inPackage: 'fory');
+ static const TypeChecker _mapTypeChecker =
+ TypeChecker.typeNamed(MapType, inPackage: 'fory');
+ static const TypeChecker _refOptionChecker =
+ TypeChecker.typeNamed(RefOption, inPackage: 'fory');
+ static const TypeChecker _nullableOptionChecker =
+ TypeChecker.typeNamed(NullableOption, inPackage: 'fory');
+ static const TypeChecker _int32Checker =
+ TypeChecker.typeNamed(Int32Type, inPackage: 'fory');
+ static const TypeChecker _int64Checker =
+ TypeChecker.typeNamed(Int64Type, inPackage: 'fory');
+ static const TypeChecker _uint8Checker =
+ TypeChecker.typeNamed(Uint8Type, inPackage: 'fory');
+ static const TypeChecker _uint16Checker =
+ TypeChecker.typeNamed(Uint16Type, inPackage: 'fory');
+ static const TypeChecker _uint32Checker =
+ TypeChecker.typeNamed(Uint32Type, inPackage: 'fory');
+ static const TypeChecker _uint64Checker =
+ TypeChecker.typeNamed(Uint64Type, inPackage: 'fory');
+
+ final Map<String, String> _importPrefixByLibraryIdentifier =
+ <String, String>{};
@override
FutureOr<String> generate(LibraryReader library, BuildStep buildStep) {
@@ -66,8 +72,7 @@ final class ForyGenerator extends Generator {
);
final generatedApiName = '${helperBaseName}Fory';
- final enumSpecs =
- enumElements.map(_analyzeEnum).toList(growable: false);
+ final enumSpecs = enumElements.map(_analyzeEnum).toList(growable: false);
final structSpecs =
annotatedClasses.map(_analyzeStruct).toList(growable: false);
final output = StringBuffer()
@@ -98,9 +103,7 @@ final class ForyGenerator extends Generator {
final fields = element.fields
.where(
- (field) =>
- !field.isStatic &&
- !field.isSynthetic,
+ (field) => !field.isStatic && identical(field.nonSynthetic, field),
)
.where((field) => !_isSkipped(field))
.map(_analyzeField)
@@ -109,7 +112,7 @@ final class ForyGenerator extends Generator {
final sortedFields = _sortFields(fields);
final constructorPlan = _buildConstructorPlan(element, sortedFields);
return _GeneratedStructSpec(
- name: element.name,
+ name: element.displayName,
evolving: evolving,
fields: sortedFields,
constructorPlan: constructorPlan,
@@ -118,9 +121,9 @@ final class ForyGenerator extends Generator {
void _buildImportPrefixMap(LibraryReader library) {
_importPrefixByLibraryIdentifier.clear();
- for (final import in
library.element.definingCompilationUnit.libraryImports) {
+ for (final import in library.element.firstFragment.libraryImports) {
final importedLibrary = import.importedLibrary;
- final prefix = import.prefix?.element.name;
+ final prefix = import.prefix?.element.displayName;
if (importedLibrary == null || prefix == null || prefix.isEmpty) {
continue;
}
@@ -130,7 +133,7 @@ final class ForyGenerator extends Generator {
_GeneratedEnumSpec _analyzeEnum(EnumElement element) {
return _GeneratedEnumSpec(
- name: element.name,
+ name: element.displayName,
usesRawValue: _enumUsesRawValueElement(element),
);
}
@@ -154,12 +157,12 @@ final class ForyGenerator extends Generator {
final typeSpec = _analyzeTypeSpecAnnotation(field);
return _GeneratedFieldSpec(
- name: field.name,
+ name: field.displayName,
type: field.type,
displayType: _typeCodeString(field.type),
identifier: fieldId != null && fieldId >= 0
? '$fieldId'
- : _toSnakeCase(field.name),
+ : _toSnakeCase(field.displayName),
id: fieldId,
nullable: nullable,
ref: ref,
@@ -257,7 +260,7 @@ final class ForyGenerator extends Generator {
final unnamedConstructor = element.unnamedConstructor;
final hasZeroArgConstructor = unnamedConstructor != null &&
!unnamedConstructor.isFactory &&
- unnamedConstructor.parameters
+ unnamedConstructor.formalParameters
.every((parameter) => parameter.isOptional);
if (hasZeroArgConstructor && fields.every((field) => field.writable)) {
return const _ConstructorPlan.mutable();
@@ -276,12 +279,13 @@ final class ForyGenerator extends Generator {
};
final arguments = <_ConstructorArgumentSpec>[];
final constructorFieldNames = <String>{};
- for (final parameter in unnamedConstructor.parameters) {
- final field = fieldByName[parameter.name];
+ for (final parameter in unnamedConstructor.formalParameters) {
+ final parameterName = parameter.displayName;
+ final field = fieldByName[parameterName];
if (field == null) {
if (parameter.isRequiredNamed || parameter.isRequiredPositional) {
throw InvalidGenerationSourceError(
- 'Constructor parameter ${parameter.name} does not match a
serializable field.',
+ 'Constructor parameter $parameterName does not match a
serializable field.',
element: parameter,
);
}
@@ -291,7 +295,7 @@ final class ForyGenerator extends Generator {
arguments.add(
_ConstructorArgumentSpec(
fieldName: field.name,
- parameterName: parameter.name,
+ parameterName: parameterName,
named: parameter.isNamed,
),
);
@@ -313,7 +317,7 @@ final class ForyGenerator extends Generator {
if (selfRefField != null) {
throw InvalidGenerationSourceError(
'Constructor-based generated serializers cannot bind self references
early. '
- 'Use a writable zero-argument constructor for ${element.name}.',
+ 'Use a writable zero-argument constructor for ${element.displayName}.',
element: selfRefField.type.element,
);
}
@@ -768,7 +772,8 @@ final class ForyGenerator extends Generator {
" throw ArgumentError('Exactly one registration mode is required:
id, or namespace + typeName.');",
)
..writeln(' }')
- ..writeln(' if (hasNamed && (namespace == null || typeName == null))
{')
+ ..writeln(
+ ' if (hasNamed && (namespace == null || typeName == null)) {')
..writeln(
" throw ArgumentError('Both namespace and typeName are required
for named registration.');",
)
@@ -873,9 +878,6 @@ GeneratedFieldType(
)''';
}
-
-
-
String debugConversionExpressionForType(
DartType type,
DebugGeneratedFieldTypeSpec fieldType,
@@ -899,9 +901,8 @@ GeneratedFieldType(
nullable: fieldType.nullable,
ref: fieldType.ref,
dynamic: fieldType.dynamic,
- arguments: fieldType.arguments
- .map(_fromDebugFieldType)
- .toList(growable: false),
+ arguments:
+ fieldType.arguments.map(_fromDebugFieldType).toList(growable: false),
);
}
@@ -1114,7 +1115,6 @@ GeneratedFieldType(
field.fieldType.typeId == TypeIds.map;
}
-
List<_DirectGeneratedWriteReservationRun>
_directGeneratedWriteReservationRuns(
List<_GeneratedFieldSpec> fields,
@@ -1917,9 +1917,8 @@ GeneratedFieldType(
final options = _readTypeOptions(reader);
final keyObj = reader.peek('key');
final valueObj = reader.peek('value');
- final key = keyObj != null && !keyObj.isNull
- ? _readTypeSpecObj(keyObj)
- : null;
+ final key =
+ keyObj != null && !keyObj.isNull ? _readTypeSpecObj(keyObj) : null;
final value = valueObj != null && !valueObj.isNull
? _readTypeSpecObj(valueObj)
: null;
@@ -1954,7 +1953,8 @@ GeneratedFieldType(
final optionType = optionObj.type;
if (optionType != null && _refOptionChecker.isExactlyType(optionType))
{
ref = optionReader.peek('tracked')?.boolValue ?? true;
- } else if (optionType != null &&
_nullableOptionChecker.isExactlyType(optionType)) {
+ } else if (optionType != null &&
+ _nullableOptionChecker.isExactlyType(optionType)) {
nullable = optionReader.peek('value')?.boolValue ?? true;
}
}
@@ -2066,8 +2066,8 @@ GeneratedFieldType(
final method = element.getMethod('fromRawValue');
if (method == null ||
!method.isStatic ||
- method.parameters.length != 1 ||
- !method.parameters.single.type.isDartCoreInt) {
+ method.formalParameters.length != 1 ||
+ !method.formalParameters.single.type.isDartCoreInt) {
return false;
}
return method.returnType.element == element;
@@ -2168,7 +2168,7 @@ GeneratedFieldType(
return 'Object';
}
if (type is InterfaceType) {
- return type.element.name;
+ return type.element.displayName;
}
return type.getDisplayString().replaceAll('?', '');
}
@@ -2180,14 +2180,15 @@ GeneratedFieldType(
}
if (nonNullable is InterfaceType) {
final element = nonNullable.element;
- final prefix =
_importPrefixByLibraryIdentifier[element.library.identifier];
- final baseName = prefix == null ? element.name :
'$prefix.${element.name}';
+ final prefix =
+ _importPrefixByLibraryIdentifier[element.library.identifier];
+ final elementName = element.displayName;
+ final baseName = prefix == null ? elementName : '$prefix.$elementName';
if (nonNullable.typeArguments.isEmpty) {
return baseName;
}
- final typeArguments = nonNullable.typeArguments
- .map(_typeCodeString)
- .join(', ');
+ final typeArguments =
+ nonNullable.typeArguments.map(_typeCodeString).join(', ');
return '$baseName<$typeArguments>';
}
return nonNullable.getDisplayString();
diff --git a/dart/packages/fory/pubspec.yaml b/dart/packages/fory/pubspec.yaml
index 2da552530..7860a9e7f 100644
--- a/dart/packages/fory/pubspec.yaml
+++ b/dart/packages/fory/pubspec.yaml
@@ -16,9 +16,11 @@
# under the License.
name: fory
-description: Apache Fory Dart runtime
+description: Cross-language Apache Fory runtime for Dart with generated
serializers, schema evolution, and custom type support.
version: 0.18.0-dev
-repository: https://github.com/apache/fory
+homepage: https://github.com/apache/fory
+repository: https://github.com/apache/fory/tree/main/dart/packages/fory
+issue_tracker: https://github.com/apache/fory/issues
resolution: workspace
@@ -26,11 +28,11 @@ environment:
sdk: ^3.6.1
dependencies:
- analyzer: '>=6.5.0 <8.0.0'
- build: ^2.4.1
+ analyzer: ^12.1.0
+ build: ^4.0.5
build_config: ^1.1.0
meta: ^1.14.0
- source_gen: ^2.0.0
+ source_gen: ^4.2.2
dev_dependencies:
build_runner: ^2.4.13
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]