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

Fix for 20662. Linebreaks in HasData() in migration #20699

Merged
merged 1 commit into from
Apr 22, 2020

Conversation

lajones
Copy link
Contributor

@lajones lajones commented Apr 21, 2020

Fixes #20662

Generating the verbatim string literal syntax in the migration HasData() and snapshot BuildModel() code where the input data had line breaks in it caused problems because the code generators would add an additional indent at the newline and hence unintentionally add spaces to the string literal.

Now we generate "\r" and "\n" in non-verbatim strings instead.

@lajones lajones requested a review from bricelam April 21, 2020 00:24
@lajones lajones self-assigned this Apr 21, 2020
? "@\"" + value.Replace("\"", "\"\"") + "\""
: "\"" + value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
// do not use @"" syntax as in Migrations this can get indented at a newline and so add spaces to the literal
"\"" + value.Replace(@"\", @"\\").Replace("\"", "\\\"").Replace("\n", @"\n").Replace("\r", @"\r") + "\"";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file an issue to use verbatim strings where it makes sense? (I always wanted us to generate @"...(localdb)\MSSQLLocalDB..." in OnConfiguring)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised #20723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seeding data via HasData that contains new lines includes undesired tabs when a migration is generated
2 participants