Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 10.1.1

* [swift] Fixes a crash when casting `NSNull` to an array.

## 10.1.0

* [objc] Adds macOS support to facilitate code sharing with existing iOS plugins.
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'ast.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '10.1.0';
const String pigeonVersion = '10.1.1';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/swift_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ import FlutterMacOS
if (listEncodedClassNames != null &&
listEncodedClassNames.contains(type.baseName)) {
indent.writeln('var $variableName: $fieldType? = nil');
indent.write('if let ${variableName}List = $value as! [Any?]? ');
indent.write('if let ${variableName}List: [Any?] = nilOrValue($value) ');
indent.addScoped('{', '}', () {
indent.writeln(
'$variableName = $fieldType.fromList(${variableName}List)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
E04641FA2A46270400661C9E /* NSNullFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E04641F92A46270400661C9E /* NSNullFieldTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -88,6 +89,7 @@
9808B6775522250A40D7D452 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
BC37C4E8AE005B445F208C02 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BF5B776B52F984FB430C15A3 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
E04641F92A46270400661C9E /* NSNullFieldTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSNullFieldTests.swift; sourceTree = "<group>"; };
EB04430DB6D43CCC08FA526B /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -126,6 +128,7 @@
33A341C6291ECDFD00D34E0F /* NullableReturnsTests.swift */,
33A341C7291ECDFD00D34E0F /* PrimitiveTests.swift */,
33A341B7291ECCA100D34E0F /* RunnerTests.swift */,
E04641F92A46270400661C9E /* NSNullFieldTests.swift */,
33A341CA291ECDFD00D34E0F /* Utils.swift */,
);
path = RunnerTests;
Expand Down Expand Up @@ -413,6 +416,7 @@
33A341D5291ECDFD00D34E0F /* AsyncHandlersTest.swift in Sources */,
33A341CE291ECDFD00D34E0F /* EnumTests.swift in Sources */,
33A341CD291ECDFD00D34E0F /* ListTests.swift in Sources */,
E04641FA2A46270400661C9E /* NSNullFieldTests.swift in Sources */,
33A341D1291ECDFD00D34E0F /* MockBinaryMessenger.swift in Sources */,
33A341CF291ECDFD00D34E0F /* NonNullFieldsTest.swift in Sources */,
33A341CB291ECDFD00D34E0F /* MultipleArityTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
@testable import test_plugin

/// Tests NSNull is correctly handled by `nilOrValue` helper, by manually setting nullable fields to NSNull.
final class NSNullFieldTests: XCTestCase {

func testNSNull_nullListToCustomStructField() throws {
let reply = NullFieldsSearchReply(
result: nil,
error: nil,
indices: nil,
request: nil,
type: nil)
var list = reply.toList()
// request field
list[3] = NSNull()
let copy = NullFieldsSearchReply.fromList(list)
XCTAssertNotNil(copy)
XCTAssertNil(copy!.request)
}

func testNSNull_nullListField() {
let reply = NullFieldsSearchReply(
result: nil,
error: nil,
indices: nil,
request: nil,
type: nil)
var list = reply.toList()
// indices field
list[2] = NSNull()
let copy = NullFieldsSearchReply.fromList(list)
XCTAssertNotNil(copy)
XCTAssertNil(copy!.indices)
}

func testNSNull_nullBasicFields() throws {
let reply = NullFieldsSearchReply(
result: nil,
error: nil,
indices: nil,
request: nil,
type: nil)
var list = reply.toList()
// result field
list[0] = NSNull()
// error field
list[1] = NSNull()
// type field
list[4] = NSNull()
let copy = NullFieldsSearchReply.fromList(list)
XCTAssertNotNil(copy)
XCTAssertNil(copy!.result)
XCTAssertNil(copy!.error)
XCTAssertNil(copy!.type)
}
}
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: pigeon
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
version: 10.1.0 # This must match the version in lib/generator_tools.dart
version: 10.1.1 # This must match the version in lib/generator_tools.dart

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down