Skip to content

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

Merged
steveharter merged 2 commits into
dotnet:mainfrom
pedrobsaila:91060
Feb 14, 2024
Merged

steveharter merged 2 commits into
dotnet:mainfrom
pedrobsaila:91060

Conversation

@pedrobsaila

Copy link
Copy Markdown
Contributor

Fixes #91060

@ghost ghost added area-System.CodeDom community-contribution Indicates that the PR has been added by a community member labels Jan 13, 2024
@ghost

ghost commented Jan 13, 2024

Copy link
Copy Markdown

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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.

@buyaa-n
buyaa-n requested a review from steveharter January 20, 2024 01:27

@buyaa-n buyaa-n left a comment

Copy link
Copy Markdown
Contributor

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
@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