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

[release/8.0-preview7] Share SourceWriter between JSON & config binding generators #89196

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jul 19, 2023

Backport of #89150 to release/8.0-preview7

/cc @layomia

Customer Impact

Fixes an issue with the configuration binding generator where it parses multiline source strings to be formatted into C# source code. It wasn't parsing new lines correctly, leading to a compilation error in both when building the repo for development in some build configurations, and also in user applications. The issues were reported by @tannergooding and multiple community members. Fixing this would unblock these important scenarios.

The source is written with an internal custom type called SourceWriter. The configuration & JSON generators use separate but similar implementations. The JSON implementation handles line endings correctly; so the fix here is the move the JSON copy into a common location to be used by both generators, and delete the config binding copy.

There are no changes to the JSON implementation; it calls the writer APIs in the exact same way. The config implementation had to make a non-trivial diff w.r.t. lines of code changed, but those were mostly to change the names of the methods called to match the writer type.

Testing

The config binder generator has all unit tests still passing, and there's no diff to the baseline formatting tests except for a few new lines added to match the formatting of the strings in source code. This is because the JSON source writer correctly includes the new lines specified by the input source string, into the resulting formatted code. The new lines are included for better readability.

Unit test cases were added for the SourceWriter method that was causing the build errors. It ensures that it can handle various line endings correctly, for both consistent and mixed line-ending inputs.

Risk

The JSON generator didn't change, so risk is low. The config binding generator has no test regressions, and the added SourceWriter tests should help minimize the risk here.

@carlossanlop carlossanlop added the Servicing-consider Issue for next servicing release review label Jul 19, 2023
@ericstj ericstj added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jul 19, 2023
@ericstj
Copy link
Member

ericstj commented Jul 19, 2023

Merged as this was passing modulo one unrelated test issue. (linked)

@carlossanlop carlossanlop deleted the backport/pr-89150-to-release/8.0-preview7 branch July 19, 2023 20:18
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants