sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
2k stars 120 forks source link

Validate the default key name and emit with Xcode runtime warning #126

Closed hank121314 closed 1 year ago

hank121314 commented 1 year ago

Summary

This PR fixes: #120

  1. Implement Xcode runtime warning in Defaults. In order to let Defaults.Key.init support @_alwaysEmitIntoClient, there is a needed to mark some functions/properties as @usableFromInline. And I also explicit the internal keyword for these functions/properties(To remind the developer not to change the access level).

  2. Validate the default key name and if it is wrong, emit with Xcode runtime warning.

Screenshot

screenshot-xcode-runtime-warning

Thanks

Thanks for your code review 😄 !

sindresorhus commented 1 year ago

In order to let Defaults.Key.init support @_alwaysEmitIntoClient,

Why does Defaults.Key.init need to support @_alwaysEmitIntoClient?

hank121314 commented 1 year ago

Why does Defaults.Key.init need to support @_alwaysEmitIntoClient?

With @_alwaysEmitIntoClient, it will let runtime warning appear at call site.

Here is the screenshot if not using @_alwaysEmitIntoClient:

screenshot-without-alwaysEmitIntoClient
sindresorhus commented 1 year ago

Nice work 👍