Skip to content

Releases: dart-lang/source_gen

v0.8.1

16 Apr 17:36
5b2a8a9
Compare
Choose a tag to compare
  • Cleanup logging output that duplicates headers provided by
    package:build_runner.

  • InvalidGenerationSourceError added an optional element
    parameter to support more helpful error messages.

v0.8.0

29 Mar 16:54
8bf5d08
Compare
Choose a tag to compare
  • BREAKING removed the deprecated requireLibraryDirective parameter in
    PartBuilder.

  • Revivable no longer throws a type error when attempting to revive a
    reference to a top-level function or static-class method. Now is returns a
    reference to that function or method, as expected.

v0.7.6

07 Mar 21:42
e856173
Compare
Choose a tag to compare

0.7.6

  • TypeChecker now throws an UnresolvedAnnotationException with a more
    detailed exception body (and properties useful for further debugging) instead
    of Could not resolve @null.

v0.7.5+1

15 Feb 17:56
4219ddd
Compare
Choose a tag to compare
  • LibraryBuilder and PartBuilder now have a more readable toString(),
    which is useful when emitting a warning or error in a build system. For
    example you may see Generating .g.dart: MyBuilder instead of
    Instance of LibraryBuilder in your build logs.

v0.7.4+2

31 Jan 18:05
fffde65
Compare
Choose a tag to compare
  • BUG FIX: ConstantReader.revive() now properly returns no URL fragment
    when the constant expression is resolved from a top-level or static-field.
    The documentation had said otherwise, and it was impossible to tell the
    difference between a constructor and a field. Now, fields are always in
    the form of accessor = {clazz}.{field} or {topLevelField}.

  • Fix file URIs on windows.

v0.7.4+1

22 Jan 22:42
Compare
Choose a tag to compare
  • Removed a log.finest with the output source of each generator. This allows
    a verbose option (-v) for tools like bazel or build_runner to be much more
    readable and debuggable. Files are emitted to disk for inspection in any
    case.

v0.7.4

18 Jan 22:50
5496758
Compare
Choose a tag to compare
  • Added typeNameOf, which is a safe way to get the name of a DartType,
    even when the type is a FunctionType, which has a null name in newer
    versions of the Dart analyzer.

  • Added LibraryReader.pathToUrl(Uri|String), which computes the import or
    export path necessary to reach the provided URL from the current library.
    Also added pathToAsset and pathToElement as convenience functions.

  • Expanded package:build support to allow version 0.12.0.

v0.7.0

26 Jul 15:54
Compare
Choose a tag to compare
  • Breaking changes: See the wiki
    for help upgrading.

    • Generator.generate now operates on a LibraryReader rather than being
      called for every Element within a library. Generators can iterate over
      elements using LibraryReader.allElements. GeneratorForAnnotation will
      continue to call generateForAnnotatedElement repeatedly for each element.
    • GeneratorForAnnotation passes in a ConstantReader for the annotation
      instance rather than re-creating it using mirrors.
    • GeneratorBuilder is replaced with PartBuilder and LibraryBuilder
      depending on whether the output is meant to be included in a part file.
    • Removed JsonSerializable and related classes. These are moved to
      package:json_serializable.
    • Removed lib/builder.dart. Import through source_gen.dart instead.
    • Removed OutputFormatter typedef.
  • Add LibraryReader.allElements - a utility to iterate across all Element
    instances contained in Dart library.

  • Add LibraryReader.element to get back to the LibraryElement instance.

  • Add ConstantReader.objectValue to get back to the DartObject instance.

  • Add ConstantReader.peek to read a value that returns null if not found:

// Tries to read the field "token" first, then "_token".
findTokenField(DartObject o) {
  final reader = new ConstantReader(o);
  final token = o.peek('token') ?? o.read('_token');
}
  • Add throwOnUnresolved optional parameter to TypeChecker.annotationsOf,
    TypeChecker.annotationsOfExact, TypeChecker.firstAnnotationOf, and
    TypeChecker.firstAnnotationOfExact. Setting this to false will enable you
    to check for matching annotations with incomplete type information (at your
    own risk).
  • Builder logs now log the primary inputs AssetId instead of the library,
    which is more useful for tracking down the actual files.

v0.6.1+1

18 Jul 19:02
Compare
Choose a tag to compare
  • Added spanForElement; returns a SourceSpan for an analyzer Element.
  • Logs a warning to the console when a GeneratorBuilder outputs a part file
    for a given input, but that input does not define part 'name.g.dart';.

v0.6.0

06 Jul 17:56
Compare
Choose a tag to compare
  • Breaking change: TypeChecker#annotationsOf|firstAnnotationOf now
    returns annotations that are assignable to the TypeChecker's type. As a
    result we've added #annotationsOfExact|firstAnnotationOfExact which has the
    old behavior for precise checks.

  • TypeChecker#annotations...-methods now throw a StateError if one or more
    annotations on an element are not resolvable. This is usually a sign of a
    mispelling, missing import, or missing dependency.

  • Added TypeChecker.any, which delegates to multiple other TypeChecker
    implementations when making a type check.