Visitar URL original
[animations] Adds opaque argument to OpenContainer by HelloChunWei · Pull Request #179 · flutter/packages · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[Pigeon] Added an error message if a valid datatype used directly as …
…a return type or argument (#185)
  • Loading branch information
gaaclarke authored Jul 31, 2020
commit b17bacc4f687e35288c0a529751402cbbcd4fa72
2 changes: 2 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.1.3

* Added error message if supported datatypes are used as arguments or return
types directly, without an enclosing class.
* Added support for List and Map datatypes in Java and Objective-C targets.

## 0.1.2+1
Expand Down
15 changes: 15 additions & 0 deletions packages/pigeon/lib/pigeon_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@ options:
}
}
}
for (Api api in root.apis) {
for (Method method in api.methods) {
if (_validTypes.contains(method.argType)) {
result.add(Error(
message:
'Unsupported argument type: "${method.argType}" in API: "${api.name}" method: "${method.name}'));
}
if (_validTypes.contains(method.returnType)) {
result.add(Error(
message:
'Unsupported return type: "${method.returnType}" in API: "${api.name}" method: "${method.name}'));
}
}
}

return result;
}

Expand Down
22 changes: 22 additions & 0 deletions packages/pigeon/test/pigeon_lib_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ abstract class NestorApi {
Nestor getit();
}

@HostApi()
abstract class InvalidArgTypeApi {
void doit(bool value);
}

@HostApi()
abstract class InvalidReturnTypeApi {
bool doit();
}

void main() {
test('parse args - input', () {
final PigeonOptions opts =
Expand Down Expand Up @@ -215,4 +225,16 @@ void main() {
expect(classNames.contains('Nestor'), true);
expect(classNames.contains('OnlyVisibleFromNesting'), true);
});

test('invalid datatype for argument', () {
final Pigeon pigeon = Pigeon.setup();
final ParseResults results = pigeon.parse(<Type>[InvalidArgTypeApi]);
expect(results.errors.length, 1);
});

test('invalid datatype for argument', () {
final Pigeon pigeon = Pigeon.setup();
final ParseResults results = pigeon.parse(<Type>[InvalidReturnTypeApi]);
expect(results.errors.length, 1);
});
}