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

breaking a string on many lines produce incorrect result if followed by a call #96948

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

pedrobsaila
Copy link
Contributor

Fixes #91060

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jan 13, 2024
@ghost
Copy link

ghost commented Jan 13, 2024

Tagging subscribers to this area: @dotnet/area-system-codedom
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #91060

Author: pedrobsaila
Assignees: -
Labels:

area-System.CodeDom

Milestone: -

Comment on lines +164 to +165
b.Insert(0, '(');
b.Append(')');
Copy link
Member

Choose a reason for hiding this comment

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

@pedrobsaila I am not expert here and do not understand how wrapping in a bracket would help, could you explain or is there a doc/reference I could check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The bracket forces the next function expression to be evaluated on the whole string instead of just the last substring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the easy road by doing this, I could :

  • improve it by doing a sort of lookup so i add the bracket to a splitted string only if it is used as argument to the next function expression but the code does not pass context information to the process of code generation
  • or just stop splitting strings

If you see better solutions, let me know

Copy link
Member

Choose a reason for hiding this comment

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

I see, thank you for explanation, I was expecting we just stop splitting strings, but I guess that is better for styling. I have no better suggestion, the fix LGTM.

I see @steveharter mentioned in the issue string concat using + when it shouldn't be doing that, not sure what else we could use other than +, but what he might have a better solution.

Copy link
Member

Choose a reason for hiding this comment

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

I think the bracket approach is fine.

Copy link
Member

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@steveharter steveharter merged commit 9844faa into dotnet:main Feb 14, 2024
106 of 111 checks passed
@pedrobsaila pedrobsaila deleted the 91060 branch February 14, 2024 21:44
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.CodeDom community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeDom - method invocation on a string with length in a range of 80 to 256 chars or above 1500 chars
4 participants