The code below defines some C# code in the "source" string.
class GenHello
def main is shared
# Generate an assembly named 'hello.exe' that prints 'Hello'.
source = 'namespace N { class C { static void Main() { System.Console.WriteLine("Hello"); } } }'
provider = Microsoft.CSharp.CSharpCodeProvider()
cp = System.CodeDom.Compiler.CompilerParameters()
cp.generateExecutable = true
cp.outputAssembly = 'hello.exe'
cr = provider.compileAssemblyFromSource(cp, @[source])
if cr.errors.count
for ce in cr.errors
Console.writeLine(ce.toString)
else
Console.writeLine('OK')
The compiler yields several warnings in French which mean "the private field Cobra.Lang... is never used". The code compiled without warnings with 0.7.2.
- Code: Select all
c:\Code\Cobra\bin\CobraLang.cobra(6): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.Tracer._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(85): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CobraCore._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(794): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.Html._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(813): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.PrivateObjectViewForExceptionReport._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(911): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.SourceSite._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(996): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CobraFrame._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1097): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.FallThroughException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1120): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.DynamicOperationException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1132): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.UnknownMemberException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1148): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CannotReadPropertyException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1159): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CannotWritePropertyException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1170): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CannotSliceTypeException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1181): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CannotInTypeException._ih_invariantGuard" n"est jamais utilis‚
c:\Code\Cobra\bin\CobraLang.cobra(1192): warning: warning CS0169: Le champ priv‚ "Cobra.Lang.CannotCompareException._ih_invariantGuard" n"est jamais utilis‚
GenHello.cobra(1): warning: Le champ priv‚ "GenHello._ih_invariantGuard" n"est jamais utilis‚
If I try the new sharp'bla bla' feature, I get an error
- Code: Select all
GenHello.cobra(5): error: Cannot infer type for "source" because the type of the right hand expression is unknown.