Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warnings to generated LocalizedStringResource API #93

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ extension LocalizedStringResourceStringsTableComputedPropertySnippet: Snippet {

@AttributeListBuilder
var attributes: AttributeListSyntax {
AttributeSyntax(.identifier("iOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("macOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("tvOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("watchOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("visionOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.binaryOperator("*"), deprecated: nil, message: deprecationMessage)
}

@DeclModifierListBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ struct LocalizedStringResourceStringsTableResourceFunctionSnippet: Snippet {

@AttributeListBuilder
var attributes: AttributeListSyntax {
AttributeSyntax(.identifier("iOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("macOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("tvOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("watchOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("visionOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.binaryOperator("*"), deprecated: nil, message: deprecationMessage)
}

@DeclModifierListBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ struct LocalizedStringResourceStringsTableResourceVariableSnippet: Snippet {

@AttributeListBuilder
var attributes: AttributeListSyntax {
AttributeSyntax(.identifier("iOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("macOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("tvOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("watchOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.identifier("visionOS"), deprecated: 100000, message: deprecationMessage)
AttributeSyntax(.binaryOperator("*"), deprecated: nil, message: deprecationMessage)
}

@DeclModifierListBuilder
Expand Down
10 changes: 3 additions & 7 deletions Tests/PluginTests/PluginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import XCTest

final class PluginTests: XCTestCase {
func testPluginGeneratedSources() {
XCTAssertEqual(
String(localized: .localizable.demoBasic),
"A basic string"
)
XCTAssertEqual(
String(localizable: .demoBasic),
"A basic string"
)

XCTAssertEqual(
String(localized: .localizable.multiline(2)),
String(localized: .localizable(.multiline(2))),
"""
A string that
spans 2 lines
Expand All @@ -29,7 +25,7 @@ final class PluginTests: XCTestCase {
)

XCTAssertEqual(
String(localized: .featureOne.pluralExample(1)),
String(localized: .featureOne(.pluralExample(1))),
"1 string remaining"
)
XCTAssertEqual(
Expand All @@ -38,7 +34,7 @@ final class PluginTests: XCTestCase {
)

XCTAssertEqual(
String(localized: .featureOne.pluralExample(10)),
String(localized: .featureOne(.pluralExample(10))),
"10 strings remaining"
)
XCTAssertEqual(
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,7 @@ extension LocalizedStringResource {
/// ```
/// Continue
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Localizable.continue` instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Localizable.continue` instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Localizable.continue` instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Localizable.continue` instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Localizable.continue` instead. This property will be removed in the future.")
@available (*, deprecated, message: "Use `String.Localizable.continue` instead. This property will be removed in the future.")
internal var `continue`: LocalizedStringResource {
LocalizedStringResource(localizable: .continue)
}
Expand All @@ -284,11 +280,7 @@ extension LocalizedStringResource {
/// ```
/// Default Value
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Localizable.key` instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Localizable.key` instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Localizable.key` instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Localizable.key` instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Localizable.key` instead. This property will be removed in the future.")
@available (*, deprecated, message: "Use `String.Localizable.key` instead. This property will be removed in the future.")
internal var key: LocalizedStringResource {
LocalizedStringResource(localizable: .key)
}
Expand All @@ -298,11 +290,7 @@ extension LocalizedStringResource {
/// ```
/// Multiplatform Original
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Localizable.myDeviceVariant` instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Localizable.myDeviceVariant` instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Localizable.myDeviceVariant` instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Localizable.myDeviceVariant` instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Localizable.myDeviceVariant` instead. This property will be removed in the future.")
@available (*, deprecated, message: "Use `String.Localizable.myDeviceVariant` instead. This property will be removed in the future.")
internal var myDeviceVariant: LocalizedStringResource {
LocalizedStringResource(localizable: .myDeviceVariant)
}
Expand All @@ -312,11 +300,7 @@ extension LocalizedStringResource {
/// ```
/// I have %lld plurals
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Localizable.myPlural(_:)` instead. This method will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Localizable.myPlural(_:)` instead. This method will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Localizable.myPlural(_:)` instead. This method will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Localizable.myPlural(_:)` instead. This method will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Localizable.myPlural(_:)` instead. This method will be removed in the future.")
@available (*, deprecated, message: "Use `String.Localizable.myPlural(_:)` instead. This method will be removed in the future.")
internal func myPlural(_ arg1: Int) -> LocalizedStringResource {
LocalizedStringResource(localizable: .myPlural(arg1))
}
Expand All @@ -326,21 +310,13 @@ extension LocalizedStringResource {
/// ```
/// %lld: People liked %lld posts
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
@available (*, deprecated, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
internal func mySubstitute(_ arg1: Int, count arg2: Int) -> LocalizedStringResource {
LocalizedStringResource(localizable: .mySubstitute(arg1, count: arg2))
}
}

@available (iOS, deprecated: 100000, message: "Use the `localizable(_:)` static method instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use the `localizable(_:)` static method instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use the `localizable(_:)` static method instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use the `localizable(_:)` static method instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use the `localizable(_:)` static method instead. This property will be removed in the future.") internal static let localizable = Localizable()
@available (*, deprecated, message: "Use the `localizable(_:)` static method instead. This property will be removed in the future.") internal static let localizable = Localizable()

internal init(localizable: String.Localizable) {
self.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,13 @@ extension LocalizedStringResource {
/// - Two
/// - Three
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Multiline.multiline` instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Multiline.multiline` instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Multiline.multiline` instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Multiline.multiline` instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Multiline.multiline` instead. This property will be removed in the future.")
@available (*, deprecated, message: "Use `String.Multiline.multiline` instead. This property will be removed in the future.")
internal var multiline: LocalizedStringResource {
LocalizedStringResource(multiline: .multiline)
}
}

@available (iOS, deprecated: 100000, message: "Use the `multiline(_:)` static method instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use the `multiline(_:)` static method instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use the `multiline(_:)` static method instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use the `multiline(_:)` static method instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use the `multiline(_:)` static method instead. This property will be removed in the future.") internal static let multiline = Multiline()
@available (*, deprecated, message: "Use the `multiline(_:)` static method instead. This property will be removed in the future.") internal static let multiline = Multiline()

internal init(multiline: String.Multiline) {
self.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,7 @@ extension LocalizedStringResource {
/// ```
/// Second: %2$@ - First: %1$lld
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Positional.reorder(_:_:)` instead. This method will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Positional.reorder(_:_:)` instead. This method will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Positional.reorder(_:_:)` instead. This method will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Positional.reorder(_:_:)` instead. This method will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Positional.reorder(_:_:)` instead. This method will be removed in the future.")
@available (*, deprecated, message: "Use `String.Positional.reorder(_:_:)` instead. This method will be removed in the future.")
internal func reorder(_ arg1: Int, _ arg2: String) -> LocalizedStringResource {
LocalizedStringResource(positional: .reorder(arg1, arg2))
}
Expand All @@ -260,11 +256,7 @@ extension LocalizedStringResource {
/// ```
/// %1$lld, I repeat: %1$lld
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Positional.repeatExplicit(_:)` instead. This method will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Positional.repeatExplicit(_:)` instead. This method will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Positional.repeatExplicit(_:)` instead. This method will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Positional.repeatExplicit(_:)` instead. This method will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Positional.repeatExplicit(_:)` instead. This method will be removed in the future.")
@available (*, deprecated, message: "Use `String.Positional.repeatExplicit(_:)` instead. This method will be removed in the future.")
internal func repeatExplicit(_ arg1: Int) -> LocalizedStringResource {
LocalizedStringResource(positional: .repeatExplicit(arg1))
}
Expand All @@ -276,21 +268,13 @@ extension LocalizedStringResource {
/// ```
/// %@, are you there? %1$@?
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Positional.repeatImplicit(_:)` instead. This method will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Positional.repeatImplicit(_:)` instead. This method will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Positional.repeatImplicit(_:)` instead. This method will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Positional.repeatImplicit(_:)` instead. This method will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Positional.repeatImplicit(_:)` instead. This method will be removed in the future.")
@available (*, deprecated, message: "Use `String.Positional.repeatImplicit(_:)` instead. This method will be removed in the future.")
internal func repeatImplicit(_ arg1: String) -> LocalizedStringResource {
LocalizedStringResource(positional: .repeatImplicit(arg1))
}
}

@available (iOS, deprecated: 100000, message: "Use the `positional(_:)` static method instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use the `positional(_:)` static method instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use the `positional(_:)` static method instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use the `positional(_:)` static method instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use the `positional(_:)` static method instead. This property will be removed in the future.") internal static let positional = Positional()
@available (*, deprecated, message: "Use the `positional(_:)` static method instead. This property will be removed in the future.") internal static let positional = Positional()

internal init(positional: String.Positional) {
self.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,13 @@ extension LocalizedStringResource {
/// ```
/// My Value
/// ```
@available (iOS, deprecated: 100000, message: "Use `String.Simple.simpleKey` instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use `String.Simple.simpleKey` instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use `String.Simple.simpleKey` instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use `String.Simple.simpleKey` instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use `String.Simple.simpleKey` instead. This property will be removed in the future.")
@available (*, deprecated, message: "Use `String.Simple.simpleKey` instead. This property will be removed in the future.")
internal var simpleKey: LocalizedStringResource {
LocalizedStringResource(simple: .simpleKey)
}
}

@available (iOS, deprecated: 100000, message: "Use the `simple(_:)` static method instead. This property will be removed in the future.")
@available (macOS, deprecated: 100000, message: "Use the `simple(_:)` static method instead. This property will be removed in the future.")
@available (tvOS, deprecated: 100000, message: "Use the `simple(_:)` static method instead. This property will be removed in the future.")
@available (watchOS, deprecated: 100000, message: "Use the `simple(_:)` static method instead. This property will be removed in the future.")
@available (visionOS, deprecated: 100000, message: "Use the `simple(_:)` static method instead. This property will be removed in the future.") internal static let simple = Simple()
@available (*, deprecated, message: "Use the `simple(_:)` static method instead. This property will be removed in the future.") internal static let simple = Simple()

internal init(simple: String.Simple) {
self.init(
Expand Down
Loading