From 8d8198f90587d3066a6957b710b7610e50f49cde Mon Sep 17 00:00:00 2001 From: Nguyen Date: Sun, 21 Jun 2020 12:04:34 +0200 Subject: [PATCH] Fix #47: mixin compile-time error (#48) Additionally, * Update examples in documentation * Update to_string_helper and to_string_helper_generator to version 1.1.1 --- example_with_generator/pubspec.yaml | 4 ++-- example_without_generator/pubspec.yaml | 2 +- generator/CHANGELOG.md | 3 +++ generator/lib/src/to_string_generator.dart | 2 +- generator/pubspec.yaml | 4 ++-- to_string_helper/CHANGELOG.md | 3 +++ to_string_helper/README.md | 10 +++++----- to_string_helper/example/example.md | 17 ++++++++++++++--- to_string_helper/pubspec.yaml | 2 +- 9 files changed, 32 insertions(+), 15 deletions(-) diff --git a/example_with_generator/pubspec.yaml b/example_with_generator/pubspec.yaml index 36f70ff..33f5116 100644 --- a/example_with_generator/pubspec.yaml +++ b/example_with_generator/pubspec.yaml @@ -5,13 +5,13 @@ environment: sdk: ">=2.0.0 <3.0.0" dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 dev_dependencies: test: ^1.0.0 build_runner: ^1.0.0 - to_string_helper_generator: ^1.0.0 + to_string_helper_generator: ^1.1.0 #dependency_overrides: # to_string_helper: diff --git a/example_without_generator/pubspec.yaml b/example_without_generator/pubspec.yaml index 81f8e2d..0aaa0ba 100644 --- a/example_without_generator/pubspec.yaml +++ b/example_without_generator/pubspec.yaml @@ -5,7 +5,7 @@ environment: sdk: ">=2.0.0 <3.0.0" dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 dev_dependencies: test: ^1.0.0 diff --git a/generator/CHANGELOG.md b/generator/CHANGELOG.md index 421c9d2..6e8cca5 100644 --- a/generator/CHANGELOG.md +++ b/generator/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.1.1 +* Fix #47: mixin compile-time error + # 1.1.0 * Generate code for annotation `@ToStringMixin`. diff --git a/generator/lib/src/to_string_generator.dart b/generator/lib/src/to_string_generator.dart index 0a30d66..cd8d49e 100644 --- a/generator/lib/src/to_string_generator.dart +++ b/generator/lib/src/to_string_generator.dart @@ -102,7 +102,7 @@ class ToStringGenerator extends GeneratorForAnnotation { sb ..writeln('@override') ..writeln('String toString() {') - ..writeln('return $methodName(this);') + ..writeln('return $methodName(this as $classname);') ..writeln('}'); // close mixin diff --git a/generator/pubspec.yaml b/generator/pubspec.yaml index b597a6b..f1711ff 100644 --- a/generator/pubspec.yaml +++ b/generator/pubspec.yaml @@ -1,5 +1,5 @@ name: to_string_helper_generator -version: 1.1.0 +version: 1.1.1 description: > Generate code for package to_string_helper. This package is not needed if you want to use to_string_helper without code generation. @@ -10,7 +10,7 @@ environment: sdk: ">=2.0.0 <3.0.0" dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 analyzer: ^0.39.7 build: ^1.0.0 source_gen: ^0.9.5 diff --git a/to_string_helper/CHANGELOG.md b/to_string_helper/CHANGELOG.md index bd81cc8..682a246 100644 --- a/to_string_helper/CHANGELOG.md +++ b/to_string_helper/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.1.1 +* Update examples in documentation + # 1.1.0 * Added annotation `@ToStringMixin`. diff --git a/to_string_helper/README.md b/to_string_helper/README.md index 09e0757..5fd6e1b 100644 --- a/to_string_helper/README.md +++ b/to_string_helper/README.md @@ -11,7 +11,7 @@ Otherwise, you only need this package. 1. Add dependency to your `pubspec.yaml` ```yaml dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 ``` 2. Configure your class ```dart @@ -40,10 +40,10 @@ Otherwise, you only need this package. 1. Add dependencies to your `pubspec.yaml` ```yaml dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 dev_dependencies: build_runner: ^1.0.0 - to_string_helper_generator: ^1.0.0 + to_string_helper_generator: ^1.1.0 ``` 2. Configure your class * With mixin @@ -67,8 +67,8 @@ Otherwise, you only need this package. class Bike {/*...*/} ``` 3. Generate code (see [build_runner](https://pub.dev/packages/build_runner)) - * `pub run build_runner build`: run a single build and exit. - * `pub run build_runner watch`: continuously run builds as you edit files. + * `pub run build_runner build` or `flutter packages run build_runner build`: run a single build and exit. + * `pub run build_runner watch` or `flutter packages run build_runner watch`: continuously run builds as you edit files. 4. Use the generated code to produce output of `toString` * With mixin ```dart diff --git a/to_string_helper/example/example.md b/to_string_helper/example/example.md index 5e03624..46fa965 100644 --- a/to_string_helper/example/example.md +++ b/to_string_helper/example/example.md @@ -2,7 +2,7 @@ * `pubspec.yaml` ```yaml dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 ``` * `bike.dart` @@ -22,17 +22,21 @@ } } ``` +* Output + ``` + Bike{wheels=2, false} + ``` # Simple example (with code generator) * Require package [to_string_helper_generator](https://pub.dev/packages/to_string_helper_generator) * `pubspec.yaml` ```yaml dependencies: - to_string_helper: ^1.0.0 + to_string_helper: ^1.1.0 dev_dependencies: build_runner: ^1.0.0 - to_string_helper_generator: ^1.0.0 + to_string_helper_generator: ^1.1.0 ``` * `bike.dart` with mixin ```dart @@ -69,3 +73,10 @@ } } ``` +* Generate code (see [build_runner](https://pub.dev/packages/build_runner)) + * `pub run build_runner build` or `flutter packages run build_runner build`: run a single build and exit. + * `pub run build_runner watch` or `flutter packages run build_runner watch`: continuously run builds as you edit files. +* Output + ``` + Bike{hasEngine=false} + ``` diff --git a/to_string_helper/pubspec.yaml b/to_string_helper/pubspec.yaml index 2001c85..f6d3faf 100644 --- a/to_string_helper/pubspec.yaml +++ b/to_string_helper/pubspec.yaml @@ -1,5 +1,5 @@ name: to_string_helper -version: 1.1.0 +version: 1.1.1 description: Flexibly configure output of toString method (with or without code generation) (with or without mixin). homepage: https://github.com/zenonine/to_string_helper repository: https://github.com/zenonine/to_string_helper/tree/master/to_string_helper