Skip to main content

reflection_factory 2.12.1 copy "reflection_factory: ^2.12.1" to clipboard
reflection_factory: ^2.12.1 copied to clipboard

Allows Dart reflection with an easy approach, even for third-party classes, using code generation portable for all Dart platforms.

2.12.1 #

  • Generator: fix a build-time regression of 2.12.0. The inline identical(a[i], ConstructorReflection.absentArgument) ? default : a[i] as T of each omittable invoker argument made dart_style very slow on classes with large constructors (e.g. in menu_ici_api, formatting went from ~1s to 64s, and a full build from 6s to 69s). Each one is now a short call:
    invoker: (a) => Foo.named(
      a[0] as String,
      x: __argOr$<double>(a[1], 0),
    ),
    
    • ConstructorReflection.argOrDefault<T>(arg, defaultValue): the default value when arg is absentArgument, otherwise arg cast to T. The default is still written in T's context (0.0 for double x = 0).
    • __argOr$, a short alias of it, is declared in the generated file on first use.
    • Re-run dart run build_runner build: code generated by 2.12.0 keeps working.

2.12.0 #

  • Faster ClassReflection.createInstanceFromMap. Re-run dart run build_runner build to get the direct constructor calls; code generated by earlier versions keeps working, through Function.apply.

  • Generator: each ConstructorReflection gets an invoker, a closure that calls the constructor directly instead of through Function.apply:

    invoker: (a) => Foo.named(
      a[0] as String,
      x: identical(a[1], ConstructorReflection.absentArgument)
          ? 0
          : a[1] as double,
    ),
    
    • ConstructorInvoker<O>: one argument per parameter, in allParameters order, each cast to its parameter type (clean under strict-casts).
    • An omitted optional or named parameter is passed as ConstructorReflection.absentArgument, and the invoker passes the default value written in its code, in the parameter's type context. So double x = 0 gets 0.0, and List<String> l = const [] gets a List<String>. The reflected ParameterReflection.defaultValue has an int and a List<dynamic> there.
    • No invoker is generated for a constructor with a parameter typed by a type parameter (T, List<T>), which isn't in scope in generated code.
    • ConstructorReflection.invokeWith(MethodInvocation) uses the invoker when present, otherwise Function.apply.
  • createInstanceWithConstructor (used by createInstanceFromMap):

    • Calls constructors through invokeWith.
    • Without a fieldValueResolver, it calls the invoker straight from the map, skipping the MethodInvocation building. This applies to constructors without optional positional parameters, in classes without JSON name aliases. It passes the same values as before, and an error is reported as before, without calling the constructor again.
  • createInstanceFromMap: new options for maps that a caller has already resolved (e.g. DB rows in bones_api):

    • valuesResolved: values already have their fields' and parameters' types, so fieldValueResolver is ignored and constructors are called straight from the map. Nothing is converted: JSON values (an int for a double, a List<dynamic> for a List<String>, an enum name) don't fit, so use it only for values resolved by their exact types.
    • exactKeys: keys are the exact field and parameter names. fieldNameResolver is ignored, and keys matching only ignoring case (or without a leading _) aren't used.
    • JSON decoding passes a fieldValueResolver and no options, so it keeps the MethodInvocation path. It still gains the invoker.
  • createInstanceFromMap, when it falls back to an instance created without arguments plus setting fields, no longer allocates a FieldReflection per field and instance (setFor / setNullableFor on the cached fields).

  • Generator fixes. In each case the generated code didn't compile:

    • A default value that references a static member of its class by its bare name (e.g. this.limit = defaultLimit) is qualified by its class (Foo.defaultLimit), in the invoker and in the parameters' ParameterReflections.

    • A field with a function type that uses a class type parameter (e.g. T Function()? make) was emitted with T, which isn't in scope.

    • The V of FieldReflection<O, V> for a field whose type uses a class type parameter is now the type the generated code reads it as, through the raw class (type parameters as their bounds, or as the type arguments of a subclass):

      Field (in class Box<T>) Before Now
      T? value dynamic dynamic
      T? value (T extends Base) dynamic Base?
      List<T> values (T extends Base) List<dynamic> List<Base>
      T Function()? make (didn't compile) dynamic Function()?
      inherited by IntBox extends Box<int>: T? value dynamic int?
      inherited: List<T> values List<dynamic> List<int>

      The setters of those fields then receive the type they assign, so they compile under strict-casts, which they didn't for a bounded T. The types are qualified (prefixed imports) and keep their nullability (and their parameters' and return types'). A generic function type (R Function<R>()) is reflected as dynamic. A field's TypeReflection (used to decode JSON) is unchanged.

    • The supperTypes of a class whose superclass comes from a prefixed import are emitted with the prefix.

  • New benchmark/create_instance_from_map.dart, with its results in benchmark/HISTORY.md. On an Apple M5 (JIT), for a class with 8 fields:

    • Constructor path: 3110 → 450 ns/op, and 385 ns/op with valuesResolved + exactKeys.
    • fromJson: 4454 → 3035 ns/op.
    • Create + setters path: 1020 → 750 ns/op.
    • bones_api SQLite user/list: +11% ops/sec as is (regenerated), and +24–33% with the options.

2.11.0 #

  • dart_style: >=3.1.10 <3.1.11 → >=3.1.13 <3.1.14.

    • Dart 3.13.2 bundles dart_style 3.1.13 (3.13.0 and 3.13.1 bundle 3.1.10), so on current SDKs the old pin selected a formatter other than dart format's — the mismatch the pin exists to prevent (see 2.9.0).
    • The new formatter produces the same output for this package's generated code: regenerated files differ only in the embedded builder version.
  • environment.sdk: >=3.13.0 <4.0.0 → >=3.13.2 <4.0.0.

    • Keeps the pin matched to the consumer's SDK: Dart 3.13.0–3.13.1 users resolve 2.10.x, whose pin matches their bundled formatter.
    • This narrows compatibility, hence the minor bump rather than a patch.
  • analyzer: ^13.0.0 → ^14.5.0 (allowed by dart_style 3.1.13).

    • A major version of analyzer: a project that also depends on another package still constrained to analyzer 13 will keep resolving reflection_factory 2.10.x until that package moves to 14.
  • Fix: JsonDecoder.decode<Map> / decodeAsync<Map> returned nested JSON lists as lazily cast List<Map>s that threw when read.

    The values of an untyped Map were decoded with the Map TypeInfo itself, so a nested list took Map as its element type and was wrapped by List.cast<Map>(). Decoding succeeded; reading a non-Map element (an int, a String, a nested list) — or adding one — threw a TypeError far from the call that produced it. An untyped List had the same defect for its elements (List<List>).

    • A collection type without arguments (Map, List, Set, Iterable) now decodes its values/elements as dynamic. The result matches dart:convert's jsonDecode.
    • Applies to decode, decodeAsync, decodeFromBytes(Async), fromJson(Async), fromJsonMap(Async) and JsonCodec.decode*. Collections with arguments (Map<String, int>, List<User>) and entity types are unchanged.
    • Behavior changes for code that relied on the old typing:
      • Nested lists come back as List<dynamic>, not as List<Map> / List<List> views, so a cast like as List<List> on them now throws.
      • A JsonDecoder.registerTypeDecoder or jsonValueDecoderProvider keyed on Map/List is no longer called for the scalars nested under an untyped collection: they are decoded as dynamic.
  • Tests:

    • Untyped collections through every decode entry point, a non-standard decoder, JsonCodec, Set/Iterable, deep and wide nesting, and entity fields holding arbitrary JSON (new TestPayloadWithReflection).
    • New reflection_factory_json_paths_test.dart: async decoding with Future inputs/values, decoder and encoder hooks and their fallbacks, scalar parsing, callToJson, isStandard, MimeTypeResolverExtension.
    • New reflection_factory_paths_test.dart: MethodInvocation, optional positional parameters, JsonField accessors, EnumReflection, static field setters, constructor invocation errors.
    • Line coverage: reflection_factory_json.dart 86.9% → 95.9%, reflection_factory_base.dart 83.1% → 89.5%.
  • Dependencies:

    • build: ^4.0.11
    • mime: ^2.1.0
    • pub_semver: ^2.2.1
    • yaml: ^3.1.4
    • build_runner: ^2.16.2
    • build_test: ^3.5.21
    • pubspec_parse: ^1.6.0
    • data_serializer: ^1.2.3
    • test: ^1.33.0

2.10.1 #

  • Faster ClassReflection.getBestConstructorsForMap (and so createInstanceFromMap), for maps of a repeated shape — e.g. the rows of a query, decoded into entities:

    • The last lookup is memoized: a map with the same present fields, in the same order, skips the cache key and its lookup.
    • The cache key's hashCode covers the field names (unordered), not only their count, so keys with the same number of fields no longer collide.
    • _resolveFieldsNames no longer allocates closures and MapEntrys per field.

    The chosen constructors are unchanged. Measured in bones_api's db_users benchmark (SQLite): +10–15% on entity reads.

2.10.0 #

  • EnumReflection.from now accepts a String derived from Enum.toString.

    Enum.toString returns the value prefixed with the enum type name (EFoo.a), but from only resolved a bare value name (a), so the most natural way to turn an enum into a String produced something from could not read back:

    @EnableReflection()
    enum EFoo { a, b }
    
    var s = EFoo.a.toString(); // "EFoo.a"
    var e = EFoo$reflection.from(s); // was `null`, now `EFoo.a`
    

    The prefix must match the reflected enumName (case-insensitively), so a String from a different enum still resolves to null instead of silently matching by value name. Bare names keep working exactly as before, including the case-insensitive fallback, which is now shared by both forms.

2.9.1 #

  • Fixed: encoding a Uri overflowed the stack.

    Uri has no toJson and its runtime type is a private implementation (_SimpleUri, _Uri) no reflection can be registered for, so it fell through to ReflectionFactory.toJsonEncodable's last line — callToJson(object, fallback: (o) => o) — which returns the object unchanged. _JsonEncoder._valueToJson then re-processed the identical value and recursed until the stack overflowed.

    It was not deterministic across compilers, which is what made it dangerous: under the JIT the first attempt overflowed and later ones succeeded, so it read as a warm-up problem, while AOT failed every time. Code encoding a Uri could pass a full test suite and then fail permanently once compiled.

    Uri now encodes as toString(), which Uri.parse reverses, so the value round trips. Handled in both ReflectionFactory.toJsonEncodable and _JsonEncoder._objectToJson — the latter consults a supplied toEncodable before its own scalar cases, so fixing one alone leaves the other broken.

  • Also fixed the class of bug, not just this instance: _valueToJson no longer recurses when the encoder hands back the object it was given. Any type that reaches the identity fallback now degrades to toString() instead of taking the process down.

2.9.0 #

  • dart_style: >=3.1.9 <3.1.10 → >=3.1.10 <3.1.11.

    • 2.8.1 capped dart_style below 3.1.10 because the Dart SDK still bundled an older formatter, and generated code has to match the dart format of the consumer's SDK. Dart 3.13.0 bundles dart_style 3.1.10 (dart format --version), so the cap now selects the wrong formatter and reintroduces the very mismatch it was added to prevent — the two CI checks (dart format --set-exit-if-changed and a build_verify "build is up to date" test) became mutually exclusive again, this time on Dart 3.13. Hit in bones_api.
    • The bound moves with the SDK rather than being lifted: pinning to the exact formatter version the SDK ships is what keeps the two checks satisfiable.
  • environment.sdk: >=3.10.0 <4.0.0 → >=3.13.0 <4.0.0.

    • The dart_style pin is only correct for the SDK that bundles that same version. Raising the floor makes pub resolve 2.8.1 for Dart 3.10–3.12 users (whose SDKs bundle dart_style 3.1.6) instead of handing them generated code their own dart format would rewrite.
    • This narrows compatibility, hence the minor bump rather than a patch.

2.8.1 #

  • dart_style: ^3.1.9 → >=3.1.9 <3.1.10.

    • The generated *.reflection.g.dart is formatted by DartFormatter, using the dart_style resolved by pub for this package, while consumers check that code with the dart format bundled in their Dart SDK.
    • dart_style 3.1.10 changed the splitting of an argument list containing a collection literal — which is exactly the shape of the generated proxy code (onCall(this, '<method>', <String, dynamic>{...}, const __TR<...>(...))). The Dart SDK 3.12.2 still bundles dart_style 3.1.6 (dart format --version), so a package generating with 3.1.10+ ends up with generated code its own dart format wants to reformat.
    • That makes 2 common CI checks mutually exclusive for the consumer: committing the generator output fails dart format --set-exit-if-changed, and committing the formatted output fails a build_verify "the build is up to date" check, because build_runner rewrites the file back.
    • The upper bound is the lowest version that still satisfies analyzer: ^13.0.0 (3.1.9 is the first dart_style accepting analyzer 13), so this does not roll back any other dependency.
    • Not a language-version issue: the builder already resolves and passes the correct language version to DartFormatter. Verified that the divergence reproduces identically at language versions 3.7, 3.10, 3.11 and 3.12. Lift this bound once the Dart SDK bundles dart_style >= 3.1.10.
  • Tests:

    • New reflection_factory_format_test.dart, guarding the above:
      • the committed *.g.dart are left untouched by the SDK's dart format;
      • DartFormatter and the SDK's dart format agree on an argument list containing a collection literal (the generated-proxy shape). This second test is the one that actually catches the regression — the repository's own generated code does not happen to contain a diverging shape.

2.8.0 #

  • JsonEncoder:

    • Fixed removeField when combined with removeNullFields: the filters were joined with ||, so enabling both disabled both, and a field marked for removal was still emitted.
    • Fixed the encoding of a negative Duration: it was written with a minus sign on every component (-1:-30:0:0:-5), and since - is also a field separator the value decoded back positive. Now written with a single leading - (-1:30:0:0:5).
      • Note: this changes the wire format of negative Duration values. The previous format is still decoded correctly, so already persisted data is recovered. Positive values are unchanged.
  • JsonDecoder:

    • Fixed fromJsonAsync/decodeAsync for a List of entities: the collection TypeInfo was applied to each element instead of its argument, so elements were returned as raw Maps instead of entities, without any error.
    • Fixed the async Map path dropping duplicatedEntitiesAsID and resetting the entity cache in the middle of an in-progress object tree.
  • ClassReflection:

    • Fixed getBestConstructorsForMap cache key: it ignored allowOptionalOnlyConstructors, so both values of the flag shared one cache entry and the result depended on which was requested first.
    • Fixed castIterable with nullable: true: it cast to E instead of E?, making the parameter a no-op and throwing a TypeError on a collection containing null (castList and castSet were already correct).
    • Fixed castMapKeys with nullable: true: it made the values nullable instead of the keys, throwing a TypeError on a Map with a null key.
  • Reflection:

    • Fixed siblingReflectionFor throwing a TypeError instead of returning null when no sibling matched the requested type: it cast with as Reflection<T> while declaring a nullable return.
  • FunctionReflection:

    • Fixed getParameterByIndex for named parameters: the offset did not include optionalParameters, so for a function with optional positional parameters the named indexes were shifted, returning the wrong parameter and making the last one unreachable. Indexes now follow allParameters.
  • ReflectionBuilder:

    • Fixed ClassProxy generation for a method with more than one type parameter: they were written with no separator, so pair<A, B> was generated as pair<AB>.
    • Fixed operator >>> (Dart 2.14) not being in the operator blocklist: it was generated as a method name and broke the build.
    • Fixed ClassProxy with ignoreParametersTypes when the first parameter is dropped: a leading comma was emitted (compute(, int a)), breaking the build.
    • Fixed type names being generated unqualified: a type reachable only through a prefixed import (import 'other.dart' as o;) was written as Other instead of o.Other, so the generated part did not compile. Type name resolution is now aware of the input library's import prefixes.
    • Fixed record type generation: no comma was emitted between positional fields and the named group ((double{bool y})), and a record with a single positional field was missing its mandatory trailing comma ((int) instead of (int,)). Both aborted the build.
    • Fixed an infinite loop in the generated alias naming when a library declares names colliding with both an internal alias and its 0 suffix.
    • Fixed enum reflection: a static const field of the enum's own type (like static const Color def = Color.red;) was generated as an enum value in _valuesByName, shadowing the real name in EnumReflection.getName. Now only actual enum constants are generated.
  • TypeParser:

    • parseDuration: a leading - now negates the whole Duration instead of being consumed as a field separator.
  • ListSortedByUsage:

    • Exposed clampCount as @visibleForTesting.
  • Tests:

    • Added coverage for lib/src/analyzer/ (ConstantReader, TypeChecker, LibraryReader, UnresolvedAnnotationException and the url helpers), for the annotations and for the ClassProxy return helpers.
    • Total tests: 96 -> 250. Line coverage: 86.0% -> 89.1%.
  • pubspec.yaml:

    • Updated dependencies:
      • analyzer to ^13.0.0
      • build to ^4.0.6
      • dart_style to ^3.1.9
    • The previous build and dart_style lower bounds were not satisfiable with analyzer 13.x, so pub silently resolved above them.
    • SDK constraint unchanged (>=3.10.0 <4.0.0): analyzer 13.0.0 still supports ^3.9.0, but dart_style 3.1.9 (the only release compatible with analyzer 13) requires ^3.10.0.

2.7.5 #

  • Dependency updates:
    • analyzer: ^10.2.0
    • dart_style: ^3.1.6

2.7.4 #

  • JsonEntityCacheSimple:

    • Updated toString method to use null-aware spread operator for combining maps.
  • TypeParser:

    • Updated map entry parsing to use null-aware list element in Map.fromEntries.
  • pubspec.yaml:

    • Updated SDK constraint to >=3.10.0 <4.0.0.
    • Updated dependencies:
      • build to ^4.0.4
      • analyzer to ^9.0.0
      • meta to ^1.18.1
      • source_span to ^1.10.2
    • Updated dev_dependencies:
      • build_runner to ^2.11.1
      • build_test to ^3.5.7
      • lints to ^6.1.0
      • test to ^1.30.0

2.7.3 #

  • lib/src/reflection_factory_builder.dart:

    • _EnumTree<T>: Filtered enum entries to include only those marked as const when generating _valuesByName map.
  • pubspec.yaml:

    • Updated dependencies:
      • build: ^4.0.3
      • analyzer: ^8.4.1
      • dart_style: ^3.1.3
    • Updated dev_dependencies:
      • build_runner: ^2.10.4
      • build_test: ^3.5.4
      • test: ^1.29.0

2.7.2 #

  • BasicDartType: added function.

  • TypeInfo: added tFunction.

  • build_runner: ^2.10.1

  • build_test: ^3.5.1

2.7.1 #

  • Allow build_runner build --force-aot flag, removing dart:mirrors dependency.

  • TypeChecker:

    • Added TypeChecker.fromPackage:
      • Implementation _PackageTypeChecker.
    • Removed TypeChecker.fromRuntime:
      • Remove import of dart:mirrors.
      • Remove implementation _MirrorTypeChecker.
  • build: ^4.0.2

  • build_runner: ^2.10.0

  • build_test: ^3.5.0

2.7.0 #

  • sdk: '>=3.9.0 <4.0.0'

    • dart format
  • analyzer: ^8.4.0

2.6.1 #

  • build: ^4.0.1
  • build_runner: ^2.9.0
  • build_test: ^3.4.1

2.6.0 #

  • Migrate to analyzer: ^8.1.1 and build: ^3.0.2.

  • build: ^3.0.2

  • analyzer: ^8.1.1

  • dart_style: ^3.1.2

  • mime: ^2.0.0

  • collection: ^1.19.1

  • logging: ^1.3.0

  • build_runner: ^2.7.0

  • build_test: ^3.3.2

  • lints: ^6.0.0

  • Comment #dependency_validator: ^5.0.2 (incompatible with analyzer: ^8.1.1).

  • Dart CI: DART_VERSION: "latest"

  • sdk: '>=3.7.0 <4.0.0'

2.5.3 #

  • ReflectionBuilder: improve use of const for generated code.

  • dependency_validator: ^4.1.3

2.5.2 #

  • JsonCodec and JsonEncoder:

    • Added encodeToSink.
  • Dart CI:

    • DART_VERSION: "3.6.2": avoid CI issues with Dart 3.8+ and build_test.
  • build: ^2.4.2

  • meta: ^1.17.0

  • pub_semver: ^2.2.0

  • build_runner: ^2.4.15

  • test: ^1.26.3

  • coverage: ^1.15.0

2.5.1 #

  • Reflection:

    • Added getSymbol, to allow resolution of const Symbol instances.
  • MethodInvocation:

    • Added field reflection.
    • namedArguments: use reflection.getSymbol to resolve the const Symbol for the named parameters keys.
  • ReflectionBuilder:

    • _writeGeneratedCode: DartFormatter(languageVersion).
  • dart_style: ^3.0.1

2.5.0 #

  • Constructor: added fullName.

  • ClassTree._buildConstructors: use as direct constructor name as constructorAccessor, reducing generated code.

  • sdk: '>=3.6.0 <4.0.0'

  • collection: ^1.19.0

  • build_runner: ^2.4.15

  • lints: ^5.1.1

  • test: ^1.25.15

2.4.10 #

  • New InputAnalyzer and InputAnalyzerResolved:

    • Move library, compilation unit and parts resolver code.
  • ReflectionBuilder:

    • Use InputAnalyzerResolved.
    • _classProxy: Force class library dependency, and fix cache dependency issue.
    • Check for reflection annotations (AST) before skipping generation if no part directive is found.
  • ClassReflection, EnumReflection:

    • compareTo: compare enumName and className in addition to reflectionLevel.

2.4.9 #

  • ReflectionBuilder:

    • _buildSiblingsClassReflection:
      • Also activate XYZ$reflection() for imported classes with @EnableReflection.
  • _DartTypeExtension:

    • Added caches for:
      • isDartCore, isTypeWithReflection, getTypesWithReflection.
      • typeNameResolvable, typeName, hasSimpleTypeArguments, typeNameAsCode.
  • build: ^2.4.2

  • dart_style: ^2.3.8

  • yaml: ^3.1.3

  • build_runner: ^2.4.14

  • build_test: ^2.2.3

  • pubspec_parse: ^1.5.0

  • test: ^1.25.14

2.4.8 #

  • TypeParser:

    • _parserForTypeInfo: handle casting of collections.
  • sdk: '>=3.4.0 <4.0.0'

  • analyzer: ^6.11.0

  • pub_semver: ^2.1.5

  • source_span: ^1.10.1

  • build_runner: ^2.4.13

  • test: ^1.25.12

  • coverage: ^1.11.1

2.4.7 #

  • JsonDecoder:
    • _fromJsonImpl: try to parse primitives to typeInfo definition (Allow Map String keys to be parsed as int).
    • _fromJsonMapImpl: fix for when typeInfo is for a Map<K,V>.

2.4.6 #

  • TypeInfo:
    • isValidGenericType: fix for Map, MapEntry, List and Set.
    • Added toMapType, toMapEntryValueType, toMapEntryKeyType, toMapEntryType and isCastedMapEntry.

2.4.5 #

  • _TypeWrapperList, _TypeWrapperMap, _TypeWrapperSet, _TypeWrapperIterable:

    • Improve parse, handling generic types of constructed collections.
  • analyzer: ^6.8.0

  • dart_style: ^2.3.7

  • meta: ^1.16.0

  • mime: ^1.0.6

  • path: ^1.9.1

  • data_serializer: ^1.2.1

  • coverage: ^1.10.0

2.4.4 #

  • 🐛 fix(builder):

    • Use raw strings on class names.
    • ignore_for_file: added deprecated_member_use and deprecated_member_use_from_same_package.
  • Change package pubspec to pubspec_parse.

  • pubspec_parse: ^1.3.0

2.4.3 #

  • ClassReflection: optimize createInstanceWithConstructors.

2.4.2 #

  • JsonDecoder:

    • decode: optimize resolution for T/type dynamic/Object (any type).
  • JsonConverter (JsonEncoder & JsonDecoder):

    • Added isStandard.

2.4.1 #

  • JsonEntityCache:
    • Added isCachedEntityByID and cacheEntityInstantiator.
    • JsonEntityCacheSimple: implement new methods.
    • Added to interface (from JsonEntityCacheSimple): cachedEntities, allCachedEntities, instantiateAllCachedEntities, cachedEntitiesLength, cachedEntitiesInstantiatorsLength, totalCachedEntities.

2.4.0 #

  • sdk: '>=3.3.0 <4.0.0'

  • analyzer: ^6.5.0

  • meta: ^1.15.0

  • lints: ^4.0.0

  • test: ^1.25.5

  • coverage: ^1.8.0

2.3.4 #

  • Fix handling og record types with named parameters.
  • Fix type argument resolution.

2.3.3 #

  • ClassReflection:
    • Fix generation of getJsonFieldsVisibleValues for getters and setters with JsonField.hidden annotations.

2.3.2 #

  • ClassReflection:

    • Added getJsonFieldsVisibleValues
  • meta: ^1.14.0

  • build_runner: ^2.4.9

2.3.1 #

  • JsonEncoder:

    • Expose entityCache.
  • data_serializer: ^1.1.0

  • dart_style: ^2.3.6

2.3.0 #

  • New StaticFunctionReflection.

    • New StaticMethodReflection.
    • ConstructorReflection extends StaticFunctionReflection.
  • New BasicFieldReflection:

    • New StaticFieldReflection.
  • ClassReflection:

    • Added getFieldsValues.
  • meta: ^1.12.0

  • path: ^1.9.0

  • dependency_validator: ^3.2.3

2.2.8 #

  • Fix issue with parameter resolution when calling a constructor/method.

  • analyzer: ^6.4.1

  • mime: ^1.0.5

  • build_runner: ^2.4.8

  • test: ^1.25.2

2.2.7 #

  • Small fix for Duration support.

2.2.6 #

  • TypeParser: added parseDuration.

  • Json: add support to Duration.

  • coverage: ^1.7.2

  • build_test: ^2.2.2

2.2.5 #

  • TypeInfo:

    • Fix castList for nullable types.
  • lints: ^3.0.0

    • Adjust code generation for type_literal_in_constant_pattern lint.
  • dart_style: ^2.3.4

  • build_runner: ^2.4.7

2.2.4 #

  • Added basic support for Records types.

    • Added logic to handle record types and generate typedefs for record declarations.
  • Added new tests for Records and generics in test/reflection_factory_build_test.dart.

  • test: ^1.24.9

  • coverage: ^1.6.4

  • data_serializer: ^1.0.12

2.2.3 #

  • Added ClassProxy.ignoreMethods2.

2.2.2 #

  • Added @IgnoreClassProxyMethod.

2.2.1 #

  • ReflectionBuilder:

    • Generated files:
      • ignore_for_file: camel_case_types
      • ignore_for_file: camel_case_extensions
  • build: ^2.4.1

  • dart_style: ^2.3.2

  • collection: ^1.18.0

  • build_runner: ^2.4.6

  • build_test: ^2.2.0

  • data_serializer: ^1.0.10

  • test: ^1.24.6

2.2.0 #

  • LibraryReader: added allAnnotatedElements.

  • ReflectionBuilder

    • Optimize detection of annotated elements.
    • Fix typos.
  • sdk: '>=3.0.0 <4.0.0'

  • analyzer: ^6.2.0

  • lints: ^2.1.1

2.1.6 #

  • New ClassProxyDelegateListener.

2.1.5 #

  • Optimize createInstanceWithBestConstructor and createInstanceWithConstructors.

2.1.4 #

  • Added TypeParser.parserForTypeInfo.
  • Optimize TypeParser.parserFor.
  • Optimize _TypeWrapper with specialized implementations for each handled type in BasicDartType.
  • Optimize TypeInfo.parse delegating to specialized TypeWrapper.parse implementations.

2.1.3 #

  • TypeInfo:
    • Fix castCollection: redirecting Maps to castMap.
  • sdk: '>=2.19.0 <4.0.0'
  • build: ^2.4.0
  • analyzer: ^5.13.0
  • dart_style: ^2.3.1
  • meta: ^1.9.1
  • pub_semver: ^2.1.4
  • collection: ^1.17.1
  • yaml: ^3.1.2
  • source_span: ^1.10.0
  • test: ^1.24.3

2.1.2 #

  • TypeParser:
    • Small fixes parseList, parseMap and parseMapEntry.
  • TypeInfo:
    • Added callCastedArgumentA and callCastedArgumentsAB.

2.1.1 #

  • TypeInfo:
    • Added getters arguments0 and arguments1.
    • Added isCastedList, isCastedSet, isCastedIterable and isCastedMap.

2.1.0 #

  • EnumReflection (Breaking Change):
    • Now separates fields into staticFieldsNames and fieldsNames.
  • sdk: '>=2.18.0 <3.0.0'
  • collection: ^1.17.0

2.0.7 #

  • TypeInfo:
    • Fix isValidGenericType for List<T>.
    • _fromJsonImpl: pass typeInfo instead of type.
  • JsonDecoder:
    • _fromJsonListImpl: fix for List<List<T>>.

2.0.6 #

  • TypeParser.parseBool: improve detected values.
  • analyzer: ^5.10.0

2.0.5 #

  • ClassProxy:
    • Added returnValue, returnFuture and returnFutureOr.
  • Added ClassProxyCallError.
  • analyzer: ^5.8.0
  • dart_style: ^2.3.0

2.0.4 #

  • JsonEncoder:
    • Added JsonEncoder.callToJson:
      • Optimized call of toJson and avoid NoSuchMethodError.
  • TypeInfo
    • Added static isPrimitiveTypeFor
  • TypeParser:
    • Optimize isPrimitiveType and isPrimitiveValue.
  • ClassReflection:
    • Optimize withObject.
  • FieldReflection:
    • Optimize withObject.
  • ReflectionBuilder:
    • Optimize generation of getters that can use static fields:
      • Enums:
        • fieldsNames, valuesByName
      • Classes:
        • constructorsNames, fieldsNames, staticFieldsNames, methodsNames, staticMethodsNames.
    • Fix: ensure that reflected annotations are const.
  • analysis_options.yaml:
    • Added linter rules:
      • avoid_dynamic_calls
      • avoid_type_to_string
      • no_runtimeType_toString
      • discarded_futures
      • no_adjacent_strings_in_list

2.0.3 #

  • JsonEntityCacheSimple:
    • Rename length to totalCachedEntites to avoid implementation issues.

2.0.2 #

  • ClassReflection:
    • getBestConstructorsFor, createInstanceWithBestConstructor, getBestConstructorForMap, getBestConstructorsForMap:
      • Added parameter allowOptionalOnlyConstructors.
    • createInstanceFromMap:
      • Improved constructor resolution.
  • EnableReflection, ReflectionBridge:
    • Added parameter optimizeReflectionInstances = true:
      • If true all generated ClassReflection and EnumReflection will have a factory constructor and an Expando to cache reflection instances.
  • FunctionReflection:
    • methodInvocationFromMap: optimize and clean code.
  • Added annotation JsonConstructor.

2.0.1 #

  • ClassReflection.createInstanceWithBestConstructor:
    • Now throws UnresolvedParameterError instead of StateError for unresolved parameters.
  • analyzer: ^5.5.0
  • test: ^1.23.1
  • coverage: ^1.6.3

2.0.0 #

  • ClassReflection:
    • constructor:
      • removed <R> type.
    • field:
      • Ggenerated implementation declares T of FieldReflection<$class,T> statically.
    • Optimized:
      • allFields, allMethods: object instances derived from cached no-object instances.
      • construtor, staticField, field, method:
        • Caching instances.
        • Object instances derived from cached no-object instances.
  • FieldReflection:
    • Added setNullable.
  • benchmark: ^0.3.0
    • benchmark/reflection_factory_benchmark.dart
  • meta: ^1.9.0

1.2.25 #

  • Extra fix: issue when a source has a part of directive.

1.2.24 #

  • Fix issue when a source has a part of directive.

1.2.23 #

  • ReflectionBuilder
    • New sequential and buildStepTimeout.
    • Build now is sequential by default:
      • Only one BuildStep is processed at a time.
      • Avoid InconsistentAnalysisException (build issue #2689).
  • Added build.yaml options (verbose,sequential, timeout).
  • Improved logging.
  • Added ClassProxy test using libraryPath.
  • reflection_factory/build.yaml:
    • generate_for:
      • Added bin/*

1.2.22 #

  • Attempt to avoid build issue:
  • mime: ^1.0.4
  • build_test: ^2.1.6
  • test: ^1.22.2
  • coverage: ^1.6.2

1.2.21 #

  • ClassReflection:
    • Fix generated supperTypes.

1.2.20 #

  • Migrate to analyzer: ^5.4.0.
  • analyzer: ^5.4.0

1.2.19 #

  • TypeInfo:
    • Added isPrimitiveOrDynamicOrObjectType and isEntityType.
  • Fix castMapType for Map<String,dynamic>.

1.2.18 #

  • Reflection:
    • Fix castMap:
    • Added castMapKeys and castMapValues.
    • Added getters: asTypeReflection, typeInfo, listType, mapKeyType and mapValueType.
  • JsonCodec:
    • Added field mapCaster.
  • _JsonDecoder:
    • Now supports Map casting when decoding an entity field.
  • Added castMapType.
  • ReflectionBuilder:
    • Optimize and reduce generated code.
  • build: ^2.3.1
  • analyzer: ^4.7.0
  • dart_style: ^2.2.4
  • mime: ^1.0.3
  • pub_semver: ^2.1.3
  • path: ^1.8.3
  • build_runner: ^2.3.3
  • lints: ^2.0.1
  • test: ^1.22.1
  • coverage: ^1.6.1

1.2.17 #

  • FunctionReflection.parametersNamesWhere:
    • Added parameter nameResolver.
  • ClassReflection.getBestConstructorsFor:
    • Improve parameter/field JSON name alias (JsonFieldAlias) resolution.

1.2.16 #

  • ClassReflection:
    • Added fieldsWithJsonFieldHidden, fieldsWithJsonFieldVisible, hasJsonFieldHidden and hasJsonFieldVisible.
    • Added entityFields and entityFieldsNamesWhere.
    • Added getBestConstructorsFor.
    • getBestConstructorFor: using multiple contructor candidates.

1.2.15 #

  • JsonTypeDecoder: added parameter TypeInfo typeInfo.
  • JsonDecoder:
    • Added unregisterTypeDecoder
    • Allow decoding of null values with personalized JsonTypeDecoder.
  • Added ClassReflection.createInstanceWithConstructorByName.

1.2.14 #

  • FunctionReflection.methodInvocation:
    • Function parameterProvider:
      • Add parameterIndex to indicate the order of the parameter in the method.

1.2.13 #

  • Json:
    • Add parameter TypeInfo as an alternative to the parameter Type.
    • Improve collections casting.
  • TypeInfo:
    • Added constructors: TypeInfo.fromListType, TypeInfo.fromSetType, TypeInfo.fromMapType.
    • Added toListType, toSetType, toIterableType, toMapValueType and toMapKeyType.
    • Added castList, castSet, castIterable and castMap.

1.2.12 #

  • ClassReflection added field className.
  • EnumReflection added field enumName.

1.2.11 #

  • ClassProxy:
    • Optimize @ClassProxy classes resolution speed.
    • Added ClassProxy test with libraryPath parameter.
  • README.md:
    • Added part directive description.
    • Added @ClassProxy example.
  • Added tests for JsonEntityCacheSimple.

1.2.10 #

  • Small fix in TypeInfo.toString: was not passing the parameter withT to recursive calls.

1.2.9 #

  • ReflectionFactory:
    • Added getRegisterClassReflectionByName and getRegisterEnumReflectionByName.
  • JsonTypeDecoder: added parameter jsonDecoder.

1.2.8 #

  • FunctionReflection.methodInvocationFromMap and FunctionReflection.methodInvocation:
    • Better handling of unresolved parameters values. Attempts to resolve 2 times, to allow entities references through cache.
  • Reflection:
    • castList, castSet, castIterable, castMap, castCollection:
      • Added parameter nullable.

1.2.7 #

  • TypeInfo:
    • Added T generic type.
    • Added callCasted to pass the T to a Function<T>().
    • Improved internal representation og arguments.
  • ReflectionBuilder:
    • Declare reflected types using TypeInfo<T> generics.
  • Improved tests coverage.

1.2.6 #

  • Add coverage:ignore-file to generated files.
  • analyzer: ^4.6.0

1.2.5 #

  • Json:
    • toJson: fix casting bug when the resulting JSON value is null.
  • Removed unused analyzer helper code.
  • Adjusted for analyzer 4.4.0.
  • sdk: '>=2.17.0 <3.0.0'
  • analyzer: ^4.4.0

1.2.4 #

  • TypeParser and TypeInfo:
    • Add support for Uint8List.

1.2.3 #

  • JsonEntityCache:
    • Added instance id.
    • Added allowEntityFetch.
  • TypeInfo:
    • Added equalsTypeAndArguments.
  • TypeReflection:
    • Added isBigInt.
    • isNumericType renamed to isNumberType.
    • Added isNumericType (isNumericType + isBigInt).
  • Added extension TypeExtension:
    • method isPrimitiveType.
  • Added extension GenericObjectExtension:
    • isPrimitiveValue, isPrimitiveList, isPrimitiveMap.

1.2.2 #

  • ReflectionInspector:
    • Fix inspection for generated files in the subdirectory reflection.

1.2.1 #

  • Fix use of deprecated methods of package analyzer.
  • build: ^2.3.0
  • analyzer: ^4.3.0
  • pub_semver: ^2.1.1
  • yaml: ^3.1.1
  • source_span: ^1.9.1
  • build_runner: ^2.2.0
  • build_test: ^2.1.5
  • pubspec: ^2.3.0
  • data_serializer: ^1.0.7
  • dependency_validator: ^3.2.2
  • test: ^1.21.4
  • coverage: ^1.5.0

1.2.0 #

  • sdk: '>=2.15.0 <3.0.0'
  • analyzer: ^4.1.0
  • meta: ^1.8.0
  • path: ^1.8.2
  • build_runner: ^2.1.11
  • lints: ^2.0.0
  • pubspec: ^2.2.0
  • test: ^1.21.2
  • coverage: ^1.3.2

1.1.2 #

  • ClassProxy.
    • Allow type parameters in generated proxy methods.

1.1.1 #

  • TypeInfo:
    • Fix fromJson when decoding a list with a graph containing duplicated entities (referenced by ID).
    • Added support for FutureOr.
  • JsonCoder/JsonEncoder/JsonDecoder:
    • Allow override of autoResetEntityCache while encoding or decoding.
  • Improved GitHub CI: added browser tests (chrome).
  • mime: ^1.0.2
  • analyzer: ^3.4.1
  • dart_style: ^2.2.3

1.1.0 #

  • Changed possible generated reflection file path. Now it can generate:
    • Inside the directory: reflection/{{file}}.g.dart
    • Or as a sibling file {{file}}.reflection.g.dart
  • Added warning of absent part directive for the generated reflection file.

1.0.29 #

  • ClassReflection:
    • Add parameter duplicatedEntitiesAsID to JSON related methods.

1.0.28 #

  • Fix createInstanceFromMap when there's no constructor without arguments.
  • New annotation JsonFieldAlias.

1.0.27 #

  • Fix JSON DateTime parsing when encoded as an int.
  • JSON encoder/decoder can reference already encoded entities by ID through JsonEntityCache.

1.0.26 #

  • Fix ClassProxy.ignoreParametersTypes.

1.0.25 #

  • ClassProxy: added ignoreParametersTypes.

1.0.24 #

  • ClassProxy:
    • Fix proxy generation for methods that returns FutureOr.
  • ClassReflection:
    • Optimize createInstanceWithBestConstructor and getBestConstructorForMap.
  • source_span: ^1.8.2
  • path: ^1.8.1
  • collection: ^1.16.0
  • build: ^2.2.1
  • analyzer: ^3.3.1
  • dart_style: ^2.2.1

1.0.23 #

  • ClassProxy:
    • Fix target class resolution issue. Added libraryPath.
    • Added extra configuration: alwaysReturnFuture,traverseReturnTypes, ignoreMethods.
  • Improve JsonEncoder and JsonDecoder:
    • Added registerTypeToEncodable and registerTypeDecoder.

1.0.22 #

  • Added ClassProxy:
    • Allows generation of a class proxy without directly depending on the target class.

1.0.21 #

  • Improve JSON codec customization.
  • Improve createInstanceWithBestConstructor.

1.0.20 #

  • Added TypeInfo to perform type checking and handle other Type operations needed for reflection use.
  • Improved TypeReflection for Function types.
  • Fixed constructors with nullable named parameters.
  • Fixed constructors with required named parameters.
  • Fixed fields/parameters with Function typedef alias.

1.0.19 #

  • Fix small bug at createInstanceFromMap for field resolution.

1.0.18 #

  • EnumReflection: added enumName to extension.
  • Fix siblingEnumReflectionFor and siblingEnumReflectionFor.

1.0.17 #

  • JSON
    • Better JSON handling and reflection integration.
    • Encoding/decoding to/from bytes (Uint8List).
    • @JsonField: to hide a field or to force it as a json field.
  • Added support for enums: EnumReflection
  • ClassReflection:
    • Support for supper classes.
    • Added createInstanceWithNoRequiredArgsConstructor as another way to create an instance without arguments.
    • Added getBestConstructorFor, that selects the constructor capable to create an instance with provided parameters.
    • Added fromJson and fromJsonEncoded.
    • Added createInstanceWithBestConstructor and createInstanceFromMap.
    • Added declaringType.
  • Generating ClassFoo$fromJson and ClassFoo$fromJsonEncoded.
  • Optimized some operations.
  • Fixed TypeReflection for Function.
  • mime: ^1.0.1
  • base_codecs: ^1.0.1

1.0.16 #

  • ClassReflection:
    • withoutObjectInstance: now always returns the same instance.
    • Added reflectionFactoryVersion.

1.0.15 #

  • ClassReflection: added callCasted.
  • ReflectionInspector: now checks if a generated file version is the same of the reflection_factory package.

1.0.14 #

  • ClassReflection:
    • Added siblingsClassReflection and withoutObjectInstance.
    • register now triggers registration of all sibling ClassReflection.
  • Using standard Dart coverage.
  • coverage: ^1.0.3

1.0.13 #

  • Allow call to field without an object. Useful to get the field type before instantiate an object.

1.0.12 #

  • FieldReflection: added hasSetter.

1.0.11 #

  • Added support to default values of optional and named parameters.

1.0.10 #

  • Removed BUILD TIME comment in generated files to avoid unnecessary generate file modification/change.

1.0.9 #

  • Added ReflectionInspector.
  • Generated files now have the package version in the header comments.
  • toJsonEncodable: fixed handling of DateTime.
  • Improved tests.

1.0.8 #

  • Improve tests.
  • Fix issue with genetic types.

1.0.7 #

  • TypeReflection:
    • Added isOfType.
  • FunctionReflection (MethodReflection, ConstructorReflection):
    • methodInvocation(parametersProvider) now accepts a ParameterReflection, not only a String with the parameter name.

1.0.6 #

  • ClassReflection:
    • Added: fieldsWhere, staticFieldsWhere, methodsWhere, staticMethodsWhere.
  • TypeReflection:
  • Added: isPrimitiveType, isCollectionType, isMapType, isIterableType, isNumericType, isIntType, isDoubleType, isBoolType, isStringType.

1.0.5 #

  • Added support for class constructors.
  • Added TypeReflection:
    • Allows handling of Type generics/arguments.
  • Added extensions:
    • IterableTypeReflectionExtension, IterableParameterReflectionExtension, IterableFieldReflectionExtension.

1.0.4 #

  • Added ElementResolver:
  • ClassReflection:
    • Added resolvers: fieldResolver, staticFieldResolver, methodResolver, staticMethodResolver.
    • Optimized toJson to resolve faster MethodReflection of obj.toJson.
  • Changed FieldReflection to allow withObject.
  • Changed MethodReflection to allow withObject.
  • Added ReflectionFactory.toJsonEncodable.
  • Improve API Documentation.
  • Fix issue with operator overloading.

1.0.3 #

  • Annotation reflection:
    • Support for classes, fields, methods and method parameters.

1.0.2 #

  • ClassReflection:
    • Added: allMethods, allStaticMethods
  • MethodReflection:
    • Methods parameters now are defined with ParameterReflection.
    • returnType: fixed for void.
    • method: exposed, not private anymore.
    • Added:
      • equalsNormalParametersTypes, equalsOptionalParametersTypes, equalsNamedParametersTypes.
      • methodInvocation, methodInvocationFromMap.
  • MethodInvocation: class to represent an invocation.
  • Builder:
    • Now generates documentation of generated extension methods.
    • Better handling of parameters and fields with ParameterReflection.
      • Now knows if a parameter is required.
  • Improved API documentation.
  • Improved tests.
  • collection: ^1.15.0

1.0.1 #

  • @EnableReflection:
    • Added reflectionClassName, reflectionExtensionName.
  • @ReflectionBridge:
    • Added bridgeExtensionName, reflectionClassNames, reflectionExtensionNames.
  • Builder:
    • MethodReflection:
      • Added method parameters names to normal and optional parameters.
    • Optimize generated code.
    • Improved console output and verbose mode.
  • Improved tests.

1.0.0 #

  • Support for Class reflection:
    • FieldReflection
    • MethodReflection
  • Initial version.
18
likes
0
points
6.26k
downloads

Publisher

unverified uploader

Weekly Downloads

Allows Dart reflection with an easy approach, even for third-party classes, using code generation portable for all Dart platforms.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, base_codecs, build, collection, dart_style, logging, meta, mime, path, pub_semver, source_span, yaml

More

Packages that depend on reflection_factory