Test failure cause by different newlines

mcnamaragio's Avatar

mcnamaragio

11 Jan, 2016 11:59 AM

I am developing a Visual Studio code fix provider based on Roslyn which changes source code to avoid a hard coded. I also have one test which is failing in appveyour but passes locally. Test fails with the following message:

Expected string to be equivalent to 

"using System.Data.Entity;\n\nnamespace ConsoleApplication1\n{\n    class TypeName\n    {\n        public void Test()\n        {\n            var model = new Model();\n            var query = model.Salesmen.Include(a => a.Orders);\n        }\n    }\n}" with a length of 238, but 

"using System.Data.Entity;\r\n\r\nnamespace ConsoleApplication1\n{\n    class TypeName\n    {\r\n        public void Test()\n        {\n            var model = new Model();\n            var query = model.Salesmen.Include(a => a.Orders);\n        }\r\n    }\n}" has a length of 242.

Is there any configuration setting on server which causes carriage returns to be generates in the resulting source code?

  1. Support Staff 1 Posted by Feodor Fitsner on 11 Jan, 2016 06:16 PM

    Feodor Fitsner's Avatar

    This might be git modifying new lines (though it must be disabled globally on build workers).

    Try adding this to your appveyor.yml:

    init:
    - git config --global core.autocrlf false
    

    Also, make sure what settings do you have on repo level.

  2. 2 Posted by mcnamaragio on 11 Jan, 2016 06:57 PM

    mcnamaragio's Avatar

    Can you clarify what you mean by settings on the repo level?

    I don't think it is related to git because carriage returns only exist in the source code that is generated at runtime by roslyn.

  3. Support Staff 3 Posted by Feodor Fitsner on 11 Jan, 2016 07:02 PM

    Feodor Fitsner's Avatar

    So, you mean Roslyn generates code differently on your local machine and build worker? I've never worked with Roslyn, but I doubt there is a server-wide setting controlling new lines.

    Can you do a public repo with few lines of code reproducing the issue?

  4. 4 Posted by mcnamaragio on 11 Jan, 2016 07:06 PM

    mcnamaragio's Avatar

    The repo is already public.

    Basically what I am doing is I give a code to roslyn and it runs a code fix provider (written by me) which fixes the code but the resulting code does not match what I expect (The resulting code has some extra carriage returns)

  5. Support Staff 5 Posted by Feodor Fitsner on 11 Jan, 2016 07:08 PM

    Feodor Fitsner's Avatar

    What's AppVeyor project URL?

  6. 6 Posted by mcnamaragio on 11 Jan, 2016 07:09 PM

    mcnamaragio's Avatar
  7. Support Staff 7 Posted by Feodor Fitsner on 11 Jan, 2016 07:20 PM

    Feodor Fitsner's Avatar

    Thanks, will take a look.

  8. Support Staff 8 Posted by Feodor Fitsner on 12 Jan, 2016 02:16 AM

    Feodor Fitsner's Avatar

    Roslyn - is it a part of .NET framework or it's something entirely installed with Nuget?

  9. Support Staff 9 Posted by Feodor Fitsner on 12 Jan, 2016 02:31 AM

    Feodor Fitsner's Avatar
  10. 10 Posted by mcnamaragio on 12 Jan, 2016 07:42 AM

    mcnamaragio's Avatar

    Thanks a lot.

  11. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac