You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6 KiB

5 years ago
  1. //
  2. // DeprecationWarner.swift
  3. // Platform
  4. //
  5. // Created by Shai Mishali on 1/9/18.
  6. // Copyright © 2018 Krunoslav Zaher. All rights reserved.
  7. //
  8. import Foundation
  9. #if DEBUG
  10. class DeprecationWarner {
  11. private static var warned = Set<Kind>()
  12. private static var _lock = NSRecursiveLock()
  13. static func warnIfNeeded(_ kind: Kind) {
  14. _lock.lock(); defer { _lock.unlock() }
  15. guard !warned.contains(kind) else { return }
  16. warned.insert(kind)
  17. print("ℹ️ [DEPRECATED] \(kind.message)")
  18. }
  19. }
  20. extension DeprecationWarner {
  21. enum Kind {
  22. case variable
  23. case globalTestFunctionNext
  24. case globalTestFunctionError
  25. case globalTestFunctionCompleted
  26. var message: String {
  27. switch self {
  28. case .variable: return "`Variable` is planned for future deprecation. Please consider `BehaviorRelay` as a replacement. Read more at: https://git.io/vNqvx"
  29. case .globalTestFunctionNext: return "The `next()` global function is planned for future deprecation. Please use `Recorded.next()` instead."
  30. case .globalTestFunctionError: return "The `error()` global function is planned for future deprecation. Please use `Recorded.error()` instead."
  31. case .globalTestFunctionCompleted: return "The `completed()` global function is planned for future deprecation. Please use `Recorded.completed()` instead."
  32. }
  33. }
  34. }
  35. }
  36. #endif