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

Notification

Icon
Error

'Additional Files To Include' adding Byte-order mark? (NCrunch 1.48)
SteveCooperOrg
#1 Posted : Tuesday, June 3, 2014 11:44:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/25/2013(UTC)
Posts: 7
Location: United Kingdom

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
Hi,

I'm getting a strange error using NCrunch 1.48's 'Additional files to include' configuration option. It seems that a text file is not being simply copied, but rather, somehow a Unicode BOM is being injected into the file as part of the copy. Is that feasible?

I've uploaded an example of a broken test project here; https://github.com/steve.../ncrunch-build-problem. It requires Java to run.

The odd thing here is that the tests work find in Visual Studio with the built-in testing window and the NUnit test runner, so it seems to only occur with NCrunch. And it seems somewhat intermittent, in that sometimes it builds in NCrunch, and sometimes it doesn't.

Here's the deal. I have a file, included in .csproj file like this;

Code:
	<ItemGroup>
		<Antlr4 Include="Interpreters\KPI\Measures.g4">
			<Generator>MSBuild:Compile</Generator>
			<CustomToolNamespace>MyProject.Interpreters.KPI</CustomToolNamespace>
			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
		</Antlr4>
	</ItemGroup>


This is an ANTLR grammar; ANTLR is a Java-based parser generator, so as part of the build, it kicks off a Java process which generates some C# from the '.g4' grammar file. However, by default, the '.g4' grammar file doesn't seem to get copied into NCunch's workspace automatically; I get this kind of build error;

Code:
    ..\Libraries\Antlr4.4.2.2-alpha001\build\Antlr4.targets (132)#0: cannot find or open file: C:\temp\ncrunch\4248\124\src\[...]\Interpreters\KPI\Measures.g4

So I add it as a file in 'Additional files to include'. At this point, the tool finds the file but fails with an error indicating that the *copied* version of the file now has a Byte-order mark on it -- the ANTLR tool now throws out this error;

Code:
	Interpreters\KPI\Measures.g4 (1)#0: '´' came as a complete surprise to me
	Interpreters\KPI\Measures.g4 (1)#1: '╗' came as a complete surprise to me
	Interpreters\KPI\Measures.g4 (1)#2: '┐' came as a complete surprise to me


which seems to indicate that the copied file now contains the UTF-8 BOM. The Java standard libraries are pretty ropey when dealing with BOMs, so it seems that this is what is happening here.

My reading is that NCrunch seems to be doing something other than a straight file copy with the files listed in 'Additional files to include'. Is that true?
Remco
#2 Posted : Tuesday, June 3, 2014 9:46:01 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Steve,

Thanks for sharing this issue.

v1.48 is getting quite old now. Have you tried one of the later builds to see if this solves your problem?

The build below is an early pre-release of 2.8. This build includes some fixes around file encoding preservation and it may be worth a try:

http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.8.0.4.msi
http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.8.0.4.zip
http://downloads.ncrunch.net/NCrunch_VS2008_2.8.0.4.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.8.0.4.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.8.0.4.zip
http://downloads.ncrunch.net/NCrunch_VS2012_2.8.0.4.msi
http://downloads.ncrunch.net/NCrunch_VS2012_2.8.0.4.zip
http://downloads.ncrunch.net/NCrunch_VS2013_2.8.0.4.msi
http://downloads.ncrunch.net/NCrunch_VS2013_2.8.0.4.zip

NCrunch has a history of problems when dealing with files open in the IDE that are encoding sensitive. This is because the IDE only provides the raw string data of a file when it is open, making it difficult for NCrunch to identify the correct encoding of the file when writing its contents to the workspace. You may find this problem to vary depending upon whether or not the file is open in the IDE.
1 user thanked Remco for this useful post.
SteveCooperOrg on 6/5/2014(UTC)
SteveCooperOrg
#3 Posted : Thursday, June 5, 2014 9:23:07 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/25/2013(UTC)
Posts: 7
Location: United Kingdom

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
Remco, thanks -- I'd never have thought about it being the document in the IDE being the problem, but that makes a lot of sense when I think about it.

A very preliminary test shows that closing the file and rebuilding the component seems to work correctly, so I think you've probably cracked it for me. It also means it won't be a problem for other developers who are running tests built off the ANTLR grammar, since they typically won't be editing the file, just running the tests.

This sorts my problems out. Thanks.

Steve
1 user thanked SteveCooperOrg for this useful post.
Remco on 6/5/2014(UTC)
simmdan
#4 Posted : Wednesday, October 7, 2015 4:10:19 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2012(UTC)
Posts: 13
Location: Seattle, WA

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I'm encountering this same issue with NCrunch 2.16.0.13 running under VS 2015 in a project using ANTLR4. If I have a grammar file open in the IDE (even if I haven't modified it), then my build fails apparently because the ncrunch workspace is created with a copy of the G4 file that has the wrong encoding. If I close the file in the IDE, then NCrunch rebuilds and everything is fine.

Is there anyway I can give NCrunch a hint about the encoding (either in config somewhere or in an annotation in the file or something) so that NCrunch can build properly while I have the file open? I'm doing active development on an ANTLR grammar, and it bums me out to miss the awesomeness of NCrunch automatically building and running tests in the background while I work.

Thanks!
Danny
Remco
#5 Posted : Wednesday, October 7, 2015 10:35:45 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Danny,

The problem encountered here is that Visual Studio doesn't provide any data about the actual encoding of the file you're working with. This makes it impossible for NCrunch to know exactly how to write the file into the workspace after it's been opened in the VS editor.

NCrunch does make some effort to infer the encoding by reading the underlying file and using this in combination with the data provided by VS .. but it is a 'best effort' scenario that unfortunately can never be completely reliable.

It's possible that you're working with a file in which the encoding can't be safely inferred, or the encoding is of a form that NCrunch simply doesn't recognise. If you're able to share a sample file with me (you can submit it via the contact form, I can take a look to see if there's any way we can make the encoding detection smarter - but it is hard to make promises with the limited data available.
simmdan
#6 Posted : Thursday, October 8, 2015 11:52:39 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2012(UTC)
Posts: 13
Location: Seattle, WA

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I will work on getting you a repro/sample file. In the meantime, though, it would be great if there were either some external channel which could be used to tell ncrunch the encoding of the file or even if there was just a way to tell ncrunch to not try to pick up the current in-ide version of a file but instead just to monitor the file on disk and when it changes copy that to the workspace. Right now when I change one of these files I have to save my changes and close the window in the IDE and then the build kicks off and tests run. If I could change that so that for these files only I just had to save the file but could leave it open, that would be a big step forward.

Is there any chance of there being an existing ncrunch mechanism for one of those two possibilities?
Remco
#7 Posted : Thursday, October 8, 2015 11:56:42 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
simmdan;7829 wrote:
I will work on getting you a repro/sample file. In the meantime, though, it would be great if there were either some external channel which could be used to tell ncrunch the encoding of the file or even if there was just a way to tell ncrunch to not try to pick up the current in-ide version of a file but instead just to monitor the file on disk and when it changes copy that to the workspace. Right now when I change one of these files I have to save my changes and close the window in the IDE and then the build kicks off and tests run. If I could change that so that for these files only I just had to save the file but could leave it open, that would be a big step forward.

Is there any chance of there being an existing ncrunch mechanism for one of those two possibilities?


Agreed. Such a mechanism currently doesn't exist. In theory, it could be possible for NCrunch to read a custom property from the build item to identify the encoding, for example:

<ItemGroup>
<None Include="MyFile.txt">
<NCrunchEncoding>UTF8</NCrunchEncoding>
</None>
</ItemGroup>

... But my preference would be to avoid this if possible. If you can provide me with a sample file that reproduces this, I will investigate and try to find a better option.
simmdan
#8 Posted : Friday, October 9, 2015 6:56:06 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2012(UTC)
Posts: 13
Location: Seattle, WA

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Repro solution sent via the contact form, but I can't tell for sure if it got through or not because when I click "submit request" it works for a few minutes and then displays a page that says:

Sorry!

The page you tried to access does not exist. Click here to return to the home page of NCrunch.NET.

Maybe my repro solution (5mb zipped) is too large for the contact form or something?
Remco
#9 Posted : Friday, October 9, 2015 9:18:35 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
simmdan;7837 wrote:
Repro solution sent via the contact form, but I can't tell for sure if it got through or not because when I click "submit request" it works for a few minutes and then displays a page that says:

Sorry!

The page you tried to access does not exist. Click here to return to the home page of NCrunch.NET.

Maybe my repro solution (5mb zipped) is too large for the contact form or something?


That's ... not normal. It may be related to the size, though I had thought 5mb would be OK ..

Is there any other way you can share the file with me? Can you perhaps send a dropbox link through the contact form? Sorry for the trouble.
simmdan
#10 Posted : Friday, October 9, 2015 9:23:43 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2012(UTC)
Posts: 13
Location: Seattle, WA

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Done. Thx.
Remco
#11 Posted : Friday, October 9, 2015 9:26:03 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Got it. Thanks! I'll get back to you soon.
Remco
#12 Posted : Friday, October 16, 2015 2:47:27 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
1 user thanked Remco for this useful post.
simmdan on 10/16/2015(UTC)
simmdan
#13 Posted : Friday, October 16, 2015 7:10:58 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2012(UTC)
Posts: 13
Location: Seattle, WA

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Excellent! That fixed my issue.
1 user thanked simmdan for this useful post.
Remco on 10/16/2015(UTC)
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.087 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download