Do not automatically convert `\n` to Swift 4 multiline strings?

Description

See the attached file (I don't have an Obj-C source but you can probably get the idea it was using `\n` characters).
Statements like this look a bit wierd, although are perfectly correct.

Let's add a configurable option (i.e. ConversionOptions.ConvertNewlinesToMultilineStrings) to
switch on/off automatic conversion of strings containing`\n` to Swift 4 multiline strings.
Default to `false`.

Environment

None

Activity

Show:
Alex Petuschak
February 13, 2018, 6:59 AM

Customer's comment:

Also, there is a bug where NSStrings @"\n\t" messes up the conversion as the tool removes the \n and adds """ pair since it thinks it is a multi-line text.

Alex Petuschak
February 19, 2018, 6:53 PM
Edited

+Related report:

In the translation of Line 13 of the ObjC (NSArray<NSString *> *lines = [input componentsSeparatedByString:@"\n"]), the Swift output seems to separate by 2 blank lines rather than one single newline. This is repeated on Line 33 of the ObjC.

See http://swiftify.me/013cu3

Alex Petuschak
March 5, 2018, 9:21 AM
Edited

+Another report:
http://swiftify.me/9ysk7b

Similarly to the above, there is an extra blank line in the Swift translation of "\n".

+Created a MethodWithStringPassedAsErrorParameterShouldNotThrow() test.
Need to fix it and address TODO/NOTE comments that I have added.

Alex Petuschak
March 21, 2018, 2:40 PM
Edited

Released an update, and now I see the following when running unit tests in Release configuration:
http://take.ms/5Simj

This needs to be addressed ASAP since it breaks running Live unit tests on our build server.

Note: it's not a must to maintain unit tests for different values of ConversionOptions.
We presumably keep a minimum number of options, and so far we've been presenting the "best" default options to users.
Feel free to either exclude unit tests for non-default settings, or ignore them in Release configuration only.

P.S. Another alternative: just include "offending" unit tests into `#if false` block and comment accordingly.

Alex Petuschak
April 5, 2018, 10:27 AM

Since I have ignored the above mentioned unit tests in the Release configuration to fix running unit tests on Live, closing this out.

Assignee

Ivan Kochurkin

Reporter

Alex Petuschak

Labels

Git Branch Name

None

GitHub Issue

None

Components

Fix versions

Priority

High
Configure