Git Product home page Git Product logo

cborcoding's People

Contributors

codacy-badger avatar dabrahams avatar joskuijpers avatar somerandomiosdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cborcoding's Issues

[BUG]: `swift test` is failing on Linux

Expected Behavior

pass

Actual Behavior

Failure log is here

Steps To Reproduce

Let tests run in CI or run them on your own Linux box

Project Version

e12b478

The OS/Variant where this issue occurs.

  • iOS
  • macOS
  • tvOS
  • watchOS
  • Mac Catalyst
  • Other (Please specify in "Additional Context" section)

The version of Xcode that was used when this issue appeared.

n/a

What was the environment in which the issue appeared?

  • CBORCoding.xcodeproj
  • Package.swift
  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Other (Please specify in "Additional Context" section)

Additional Context

In CI, on Linux

Empty dictionaries of certain types throw an error when decoding

Expected Behavior

Some empty dictionaries that have been encoded with CBOREncoder throw a type mismatch error when the data is decoded again with CBORDecoder.
To me this seems like a relatively severe bug.

Actual Behavior

See provided test methods.

Steps To Reproduce

Test methods I added to CBORDecoderTests. The first one currently fails, the second one succeeds.

    /// Fails!
    func testEmptyDictionaryRoundTripUInt64Key() throws {
        let dict = [UInt64: String]()
        let data = try CBOREncoder().encode(dict)
        let dict2: [UInt64: String] = try CBORDecoder().decode(from: data)
        XCTAssertEqual(dict, dict2)
    }

    /// Succeeds
    func testEmptyDictionaryRoundTripIntKey() throws {
        let dict = [Int: String]()
        let data = try CBOREncoder().encode(dict)
        let dict2: [Int: String] = try CBORDecoder().decode(from: data)
        XCTAssertEqual(dict, dict2)
    }

Other types fail too, for example dictionaries with Int32 keys.

Project Version

6fbd643

The OS/Variant where this issue occurs.

  • iOS
  • macOS
  • tvOS
  • watchOS
  • Mac Catalyst
  • Other (Please specify in "Additional Context" section)

The version of Xcode that was used when this issue appeared.

15.0.1 (15A507)

What was the environment in which the issue appeared?

  • CBORCoding.xcodeproj
  • Package.swift
  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Other (Please specify in "Additional Context" section)

Additional Context

No response

[BUG]: workflow tests fail on main

Expected Behavior

clean run of scripts/workflowtests.sh

Actual Behavior

See attached failure log
cbor-workflowtests-log.txt

Steps To Reproduce

  1. scripts/workflowtests.sh

Project Version

e12b478

The OS/Variant where this issue occurs.

  • iOS
  • macOS
  • tvOS
  • watchOS
  • Mac Catalyst
  • Other (Please specify in "Additional Context" section)

The version of Xcode that was used when this issue appeared.

15.0.1

What was the environment in which the issue appeared?

  • CBORCoding.xcodeproj
  • Package.swift
  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Other (Please specify in "Additional Context" section)

Additional Context

No response

[BUG]: Decoding null inside an array does not work

Expected Behavior

Decoding null values to nil should work inside an array.

Actual Behavior

Cannot decode and I get the following error:

valueNotFound(Swift.Optional<Swift.Array<Swift.Int>>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "m", intValue: nil), CodingKey(stringValue: "Index 1", intValue: 1), CodingKey(stringValue: "Index 1", intValue: 1)], debugDescription: "Expected Optional<Array> but found null instead.", underlyingError: nil))

Steps To Reproduce

Here is simple sample code:

struct CBORExample: Codable, Equatable {
    var m: [[Int]?]? = nil
}

func test() {
  let obj = CBORExample(m: [[1,2], nil, [3,4]])
  do {
      let encoder = CBOREncoder()
      let encodedData = try encoder.encode(obj)    // This works fine, checked the result with cbor.me
  
      let decoder = CBORDecoder()
      let decoded: CBORExample? = try decoder.decode(CBORExample.self, from: encodedData) // This fails
      print("Decoded: \(String(describing: decoded))")
  } catch {
      print("\(error)")
  }
}

Project Version

latest

The OS/Variant where this issue occurs.

  • iOS
  • macOS
  • tvOS
  • watchOS
  • Mac Catalyst
  • Other (Please specify in "Additional Context" section)

The version of Xcode that was used when this issue appeared.

14.3.1

What was the environment in which the issue appeared?

  • CBORCoding.xcodeproj
  • Package.swift
  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Other (Please specify in "Additional Context" section)

Additional Context

No response

`xcodebuild` can't find the `Half` module when building from the command line

I'm not completely sure this is something that is the fault of this repo, but my app builds fine in Xcode itself, but my release script that automates several steps uses the xcodebuild command line and it fails with the following:

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'CBORCoding' from project 'CBORCoding')
    cd /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding
    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name CBORCoding -O -whole-module-optimization -enforce-exclusivity=checked @/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBORCoding.o.SwiftFileList -DSWIFT_PACKAGE -DXcode -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -target x86_64-apple-macos10.10 -g -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/Release -F /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/Release -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -c -num-threads 8 -output-file-map /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBORCoding-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBORCoding.swiftmodule -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/Half/Sources/CHalf/include -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/Release/include -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/DerivedSources-normal/x86_64 -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/DerivedSources/x86_64 -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/DerivedSources -Xcc -DSWIFT_PACKAGE -working-directory /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding

CompileSwift normal x86_64 (in target 'CBORCoding' from project 'CBORCoding')
    cd /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBOR+Codable.swift /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBOR+Equatable.swift /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBOR.swift /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBORDecoder.swift /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBOREncoder.swift /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBORParser.swift /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/Containers.swift -supplementary-output-file-map /var/folders/dc/pmsq9v796hzdjyj07cgn0fhw0000gn/T/supplementaryOutputs-d43348 -target x86_64-apple-macos10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/Release -F /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/Release -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -g -swift-version 5 -enforce-exclusivity=checked -O -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -working-directory -Xcc /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/Half/Sources/CHalf/include -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/Release/include -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/DerivedSources-normal/x86_64 -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/DerivedSources/x86_64 -Xcc -I/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/DerivedSources -Xcc -DSWIFT_PACKAGE -module-name CBORCoding -num-threads 8 -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBOR+Codable.o -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBOR+Equatable.o -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBOR.o -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBORDecoder.o -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBOREncoder.o -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/CBORParser.o -o /Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/build/CBORCoding.build/Release/CBORCoding.build/Objects-normal/x86_64/Containers.o
/Users/toadzky/Library/Developer/Xcode/DerivedData/File_Buddy_11-avyycioolgtstddodlblxuzxcrtc/SourcePackages/checkouts/CBORCoding/Sources/CBORCoding/CBORDecoder.swift:10:8: error: no such module 'Half'
import Half
       ^

** BUILD FAILED **


The following build commands failed:
	CompileSwift normal x86_64
	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)

I added it to my xcode project using xcode's gui for adding swift packages.

String table

Hi,

I have used this package to encode (essentially) a lis of 500 structs that have the same keys. It seems that in the binary encoding, the keys are now repeated 500 times, taking up up to 50% of the total encoding size.

Is this according to spec? Have there been considerations to have a string table?

I have not looked too deeply into the CBOR details. If it is truly like json, and you can simply embed one CBOR object into another CBOR object, then I guess a header is not possible.

Does anyone know how to build a string table with Codable? Then I can add it to a fork.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.