Is it possible to retrieve compilation warning?

95 views
Skip to first unread message

stef

unread,
Nov 14, 2013, 10:45:07 AM11/14/13
to cs-s...@googlegroups.com
I generate some VB.NET file, which is compiled using CSSCript.
Everything happens programmatically (ie CSScript is used as a library).

Sometimes, the VB.NET that is generated contains warnings such as:
warning BC42322: Runtime errors might occur when converting 'String' to 'System.Collections.Generic.IEnumerable(Of UserDataLayer.IPeak)'

And indeed, the code compiles well but has runtime error!
I would like to avoid running code with such warning.
I thought that
CSScript.GlobalSettings.HideCompilerWarnings = false;
would solve my issue, but it does not.

Would it be possible that CSSCript library returns the warnings when compiling the VB.NET piece of code so that we avoid execution?

Oleg Shilo

unread,
Nov 14, 2013, 8:21:10 PM11/14/13
to cs-s...@googlegroups.com
HideCompilerWarnings is used only to hide the warnings from the compiler output. What you need is to treat the warnings (all or some of them) as errors.

You can do this with the C#/VB compiler options:

CSScript.LoadWithConfig("script.cs"nulltrueCSScript.GlobalSettings, "/warnaserror+");
Or from the code:

//css_co /warnaserror+;
using System;
using System.Diagnostics;
using System.Windows.Forms;
 
class Script   
{ 
   ...
Keep in mind that if you execute standalone scripts (not hosted) the global default CS-Script settings for the DefaultArgiuments has an explicit warnings suppression, which may not be what you want Though it is not your case as you are using hosting CS-Script engine.
Inline image 1


Regards,
Oleg

On Fri, Nov 15, 2013 at 2:45 AM, stef <stephan...@gmail.com> wrote:
I generate some VB.NET file, which is compiled using CSSCript.
Everything happens programmatically (ie CSScript is used as a library).

Sometimes, the VB.NET that is generated contains warnings such as:
warning BC42322: Runtime errors might occur when converting 'String' to 'System.Collections.Generic.IEnumerable(Of UserDataLayer.IPeak)'

And indeed, the code compiles well but has runtime error!
I would like to avoid running code with such warning.
I thought that
CSScript.GlobalSettings.= false;

would solve my issue, but it does not.

Would it be possible that CSSCript library returns the warnings when compiling the VB.NET piece of code so that we avoid execution?

--
You received this message because you are subscribed to the Google Groups "CS-Script" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs-script+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

image.png

stephan...@gmail.com

unread,
Nov 15, 2013, 3:54:35 AM11/15/13
to cs-s...@googlegroups.com, osh...@gmail.com
Hi Oleg,

Thanks, it works!

Strangely, there is no overload of "CSScript.LoadWithConfig" where you could pass your code in a string like "CSScript.LoadCode" does.
Anyway, I just flushed my code (which is actually not in a file as I said, but in a string) in a temp file, just as CScript library does itself for CSript.LoadCode.

Regards,
Stéphane
Reply all
Reply to author
Forward
0 new messages