google / reflectable.dart

Reflectable is a Dart library that allows programmers to eliminate certain usages of dynamic reflection by specialization of reflective code to an equivalent implementation using only static techniques. The use of dynamic reflection is constrained in order to ensure that the specialized code can be generated and will have a reasonable size.
https://pub.dev/packages/reflectable
BSD 3-Clause "New" or "Revised" License
381 stars 57 forks source link

Upgrade to prepare for Dart 3; use working uris when available #310

Closed eernstg closed 1 year ago

eernstg commented 1 year ago

This PR deletes the legacy tests (they contain non-null-safe code and cannot be executed in the future). The PR also adjusts the SDK bounds in order to prepare for Dart 3.

The update revealed that one test, 'test_reflectable/test/new_instance_native_test.dart', performed a reflective invocation of the list constructor named List, which is no longer supported. The test was adjusted to call another constructor of List.

Finally, this PR changes the computation of the uri of a LibraryMirror such that it uses a package URI whenever possible. This should be helpful in the situation where there is a need to find the actual source code, as requested in https://github.com/google/reflectable.dart/issues/305.

The change in the result returned by the uri getter may seem like a breaking change, but it is hardly breaking in practice because the result returned previously was essentially meaningless (using the scheme reflectable which is not used anywhere else, and consisting mostly of a number which reflected the numbering of libraries being loaded by the analyzer during code generation).

The new behavior is tested in the updated version of 'reflect_type_test.dart'.