Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1036 Bump source_gen version #1038

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flutter_mobx/lib/version.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated via set_version.dart. !!!DO NOT MODIFY BY HAND!!!

/// The current version as per `pubspec.yaml`.
const version = '2.2.2';
const version = '2.3.0';
2 changes: 1 addition & 1 deletion mobx/lib/version.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated via set_version.dart. !!!DO NOT MODIFY BY HAND!!!

/// The current version as per `pubspec.yaml`.
const version = '2.4.0';
const version = '2.5.0';
4 changes: 4 additions & 0 deletions mobx_codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.7.1
- Update source_gen package to 2.0.0
- Update analyzer version to `>=6.0.0 <= 7.3.0`

## 2.7.0

- **FIX**: package upgrades, analysis issue fixes.
Expand Down
7 changes: 3 additions & 4 deletions mobx_codegen/lib/src/template/util.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:mobx_codegen/src/template/params.dart';
import 'package:mobx_codegen/src/type_names.dart';
import 'package:source_gen/source_gen.dart';
Expand All @@ -22,15 +23,13 @@ class AsyncMethodChecker {
method.returnType.isDartAsyncFuture ||
(method.isAsynchronous &&
!method.isGenerator &&
// ignore: deprecated_member_use
method.returnType.isDynamic);
method.returnType is DynamicType);

bool returnsStream(MethodElement method) =>
_checkStream.isAssignableFromType(method.returnType) ||
(method.isAsynchronous &&
method.isGenerator &&
// ignore: deprecated_member_use
method.returnType.isDynamic);
method.returnType is DynamicType);
}

TypeParamTemplate typeParamTemplate(
Expand Down
7 changes: 3 additions & 4 deletions mobx_codegen/lib/src/type_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class LibraryScopedNameFinder {
// Reverse each import's export namespace so we can map elements to their
// library-local names. Note that the definedNames include a prefix if there
// is one.
// ignore: deprecated_member_use
for (final import in library.libraryImports) {

for (final import in library.definingCompilationUnit.libraryImports) {
for (final entry in import.namespace.definedNames.entries) {
_namesByElement[entry.value] = entry.key;
}
Expand Down Expand Up @@ -80,8 +80,7 @@ class LibraryScopedNameFinder {
// If we're dealing with a typedef, we let it undergo the standard name
// lookup. Otherwise, we special case the function naming.
if (type.alias?.element is TypeAliasElement) {
// ignore: deprecated_member_use
typeElement = type.alias!.element.aliasedElement?.enclosingElement;
typeElement = type.alias!.element.aliasedElement?.enclosingElement3;
} else {
return _getFunctionTypeName(type);
}
Expand Down
2 changes: 1 addition & 1 deletion mobx_codegen/lib/version.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated via set_version.dart. !!!DO NOT MODIFY BY HAND!!!

/// The current version as per `pubspec.yaml`.
const version = '2.6.2';
const version = '2.7.1';
6 changes: 3 additions & 3 deletions mobx_codegen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mobx_codegen
description: Code generator for MobX that adds support for annotating your code with @observable, @computed, @action and also creating Store classes.
version: 2.7.0
version: 2.7.1

repository: https://github.com/mobxjs/mobx.dart
issue_tracker: https://github.com/mobxjs/mobx.dart/issues
Expand All @@ -14,13 +14,13 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
analyzer: ">=6.0.0 <7.0.0"
analyzer: ">=6.0.0 <= 7.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that the changes in type_names.dart will require analyzer 6.9.0 as a minimum. And I believe that it requires Dart 3.6

build: ^2.2.1
build_resolvers: ^2.0.6
meta: ^1.3.0
mobx: ^2.5.0
path: ^1.8.0
source_gen: ^1.2.1
source_gen: ^2.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be changed to a range constraint, otherwise the project will require Dart 3.6 as a minimum, and the usage of source_gen is compatible with v1

source_gen: ">=1.2.1 <3.0.0"


dev_dependencies:
build_runner: ^2.4.9
Expand Down
10 changes: 4 additions & 6 deletions mobx_codegen/test/util_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class MockMethod extends Mock implements MethodElement {}

class MockType extends Mock implements DartType {}

class DynamicMockType extends Mock implements DynamicType {}

MockMethod mockFutureMethod({
bool returnsDynamic = false,
bool returnsFuture = false,
bool returnsFutureOr = false,
bool isAsync = false,
bool isGenerator = false,
}) {
final returnType = MockType();
// ignore: deprecated_member_use
when(() => returnType.isDynamic).thenReturn(returnsDynamic);
final returnType = returnsDynamic ? DynamicMockType() : MockType();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is failing the static analysis when using the latest dependencies.
This static analysis bug was fixed in Dart 3.4.0 but mobx supports Dart 3.0.0 as a minimum. To keep supporting this version it can be simply changed to an if else block. Source: dart-lang/sdk#60255

  final DartType returnType;
  if (returnsDynamic) {
    returnType = DynamicMockType();
  } else {
    returnType = MockType();
  }

when(() => returnType.isDartAsyncFuture).thenReturn(returnsFuture);
when(() => returnType.isDartAsyncFutureOr).thenReturn(returnsFutureOr);

Expand All @@ -37,9 +37,7 @@ MockMethod mockStreamMethod({
bool isGenerator = false,
bool returnsDynamic = false,
}) {
final returnType = MockType();
// ignore: deprecated_member_use
when(() => returnType.isDynamic).thenReturn(returnsDynamic);
final returnType = returnsDynamic ? DynamicMockType() : MockType();

final method = MockMethod();
when(() => method.returnType).thenReturn(returnType);
Expand Down
2 changes: 1 addition & 1 deletion mobx_lint/lib/version.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated via set_version.dart. !!!DO NOT MODIFY BY HAND!!!

/// The current version as per `pubspec.yaml`.
const version = '1.0.0';
const version = '1.1.0';
Loading