Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Build appears to fail due to Japanese in c# strings
Joakim
#1 Posted : Monday, April 4, 2016 10:08:28 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/4/2016(UTC)
Posts: 4
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I am working with a few projects that has Japanese hard-coded strings,
this seems to trip the building process which ncrunch is doing.
Mind you that if I were to save a file that has the problem it can build every once in a while only to revert back to being unable to build again.
Currently using the trial version but am considering buying the product if I can get this to work smoothly.

The project builds correctly if you do a regular visual studio build and runs perfectly,
but the build ncrunch dues produces the following errors:

Error messages in Japanese ( English ):
定数の 新しい行です。 ( constant " " is new line )
構文エラーです。',' が必要です。 ( syntactic error. "," is needed. )
) が必要です。 ( ")" is needed )
Remco
#2 Posted : Monday, April 4, 2016 11:47:24 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

This is very odd. Are you saying that the build error messages themselves are in Japanese?

Something worth checking is the encoding of the source file inside the NCrunch workspace. When NCrunch builds your project, it makes copies of all the source files and places them inside an isolated workspace, where the project can then be built. There is some complexity in identifying the correct encoding of the files, as when they are open in the IDE, it is difficult for NCrunch to know how they are actually encoded (since the text just gets pulled out of the IDE's memory, rather than read from file).

If you right-click on the failed build, then choose Advanced->Browse to workspace, you should be able to inspect the workspace NCrunch has built for the project. It's worth finding the source file giving the error inside this workspace and examining it in an editor that can detect its encoding. Compare the encoding with the original file back in your foreground solution. Are they the same?
Joakim
#3 Posted : Tuesday, April 5, 2016 1:54:13 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/4/2016(UTC)
Posts: 4
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Remco;8524 wrote:
Hi, thanks for sharing this issue.

This is very odd. Are you saying that the build error messages themselves are in Japanese?

Something worth checking is the encoding of the source file inside the NCrunch workspace. When NCrunch builds your project, it makes copies of all the source files and places them inside an isolated workspace, where the project can then be built. There is some complexity in identifying the correct encoding of the files, as when they are open in the IDE, it is difficult for NCrunch to know how they are actually encoded (since the text just gets pulled out of the IDE's memory, rather than read from file).

If you right-click on the failed build, then choose Advanced->Browse to workspace, you should be able to inspect the workspace NCrunch has built for the project. It's worth finding the source file giving the error inside this workspace and examining it in an editor that can detect its encoding. Compare the encoding with the original file back in your foreground solution. Are they the same?


I looked at the file and even though it is saved in UTF8 it seems to have borked some characters and removed regular quotation marks breaking the code.

An example is: "サポート 太郎" changes into "サポ��EチE太郁E which breaks the the string since the last quotation mark is now gone.
(I hope you can see the characters and not just boxes)
Remco
#4 Posted : Tuesday, April 5, 2016 1:56:50 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Is there any chance you can whittle this down to a small code sample (a project that builds) and submit it through the contact form on this site? If I can get a clean sample to reproduce the problem, I stand a good chance of being able to implement a fix.
Joakim
#5 Posted : Wednesday, April 6, 2016 12:40:45 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/4/2016(UTC)
Posts: 4
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I tried to copy the code and try recreating the error in a smaller project, however it seems as if I can't recreate it myself.

Edit:
I tested a few more things and noticed that the projects that fails to build will build as long as the files affected in each project is open in visual studio.
Close any of the affected files and the project that the file belongs to fails to build.
Remco
#6 Posted : Wednesday, April 6, 2016 3:31:28 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Joakim;8530 wrote:

Edit:
I tested a few more things and noticed that the projects that fails to build will build as long as the files affected in each project is open in visual studio.
Close any of the affected files and the project that the file belongs to fails to build.


This makes sense. When the file isn't open in VS, NCrunch can just straight copy the file from disk in whatever encoding it happens to be.

When the file is open in VS, NCrunch needs to obtain the file content from VS itself rather than the file. In this situation, there is no information available about the encoding of the text in the file. To work around this, NCrunch tries to auto-detect the encoding by reading the file on disk, then writing the data from VS into the workspace using the detected encoding. There is no way this can ever be 100%, but it catches almost every case. You've managed to find a situation where the encoding for some reason isn't being detected correctly or the text provided by VS isn't encoded the way it should be. In either case, I'll need to get a sample that can reproduce the problem so that I can recreate it and assess our options.

One way you may be able to limit the impact of the problem is by moving the Japanese text into a separate source file, away from the rest of your code. In this way, you can leave the file closed while you work so NCrunch doesn't need to try and obtain its data from VS.
Joakim
#7 Posted : Wednesday, April 6, 2016 4:49:13 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/4/2016(UTC)
Posts: 4
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I see!

I'll try and create a sample project that reproduces this!
Can't do it right now but I'll do it as soon as possible.

Edit:

Just in case anyone is interested I managed to reproduce the issue and sent the project to NCrunch.
How to reproduce:
Have one solution with three different projects in it.
1) main project like a console app.
2) test project to store the test class.
3) a class library that contains a class which has Japanese in it.

Now as long as the class in the class library is not open in VS NCrunch will no longer be able to build the class library due to corrupt files.
1 user thanked Joakim for this useful post.
Remco on 4/6/2016(UTC)
Remco
#8 Posted : Thursday, April 7, 2016 1:18:46 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for sharing the sample code. I've managed to reproduce the problem. It didn't fail for me in the same way as you've described, but it still failed badly enough for me to figure out what was happening :)

NCrunch is failing to correctly detect the encoding of BOM-less UTF8 source files that are open in the IDE. It's working fine for resource files, just not source files.

To work around the problem, make sure that any UTF8 source files containing non-ASCII text always have a BOM header. There are a number of tools that let you set the encoding of a source file (I use Notepad++).

A fix for this will be out in the next version of NCrunch.
1 user thanked Remco for this useful post.
Joakim on 4/7/2016(UTC)
Remco
#9 Posted : Friday, April 22, 2016 3:22:47 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
A fix for this issue is now available in v2.21, released today - http://www.ncrunch.net/download
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.058 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download