0

I have read most, if not all, of the related questions on the site, but I don't see the same problem described, so...

I am generating some webforms code (both .aspx and .aspx.cs files), however my problem seems to be confined to the .aspx files only (the 'display' side).

When I open a file that was generated with my tool, some lines of code are combined on a single line in the VS2013 editor, and some lines of code are not.

I modified the code generator to add a System.Environment.NewLine at the end of every line to see if I could produce consistency. This was obviously the wrong action to take. It did solve the problem of some lines of code being concatenated horizontally in the editor, but other lines of code are now consistently double-spaced.

This different treatment of the line-endings appears to work differently between: (1) JavaScript code and plain text lines -- I have to insert the .NewLine at the end of every JavaScript line and every line that might contain simple text to get a separate line. (2) HTML and asp.net/html code -- if I insert a .NewLine at the end of these lines of code they will come out double-spaced.

I realize I can address this by modifying my code generator to handle the different types of code in different manners, but does anyone know why these lines of code would be handled differently to begin with? I'm just trying to learn and understand where these characteristics are coming from. Altering the Advanced Save Options doesn't seem to have any effect on this situation.

Thanks in advance!

Lynn

  • Check the generated Javascript code - what do the line endings look like? Are they \n, \n\r or even \r? – zmbq Aug 22 '15 at 18:20

1 Answers1

-1

Thanks for the consideration over the week-end. It is most appreciated.

The line of code that is introducing the System.Environment.NewLine is: SrcCode_Data.SrcCodeCode = SourceText_Data.SourceTextCode + System.Environment.NewLine;

The generated data (the contents of SrcCode_Data.SrcCodeCode above) contains: " function SetAddItemButton() {\r\n" (obviously minus the double-quotes).

I realize I should probably add one more action that is going on here that will very possibly could change things a bit...

The lines of code being generated (such as the one above for the Javascript function) are being written to a SQL Server database table/records during the generation process using sequence numbers that put the generated code into the appropriate sequence upon retrieval (by sorting these generated sequence numbers, 3 columns). When retrieved at the end of the generation process, the database records are read back in using POCO classes, and the code values are written to the appropriate .aspx and .aspx.cs source code files. My apologies for having left this out prior.

Any thoughts?

Lynn