File tree Expand file tree Collapse file tree
src/CSScriptLib/src/CSScriptLib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -486,7 +486,6 @@ SyntaxTree createTree(string code, string path) =>
486486 {
487487 IEnumerable < Diagnostic > failures = result . Diagnostics . Where ( d => d . IsWarningAsError ||
488488 d . Severity == DiagnosticSeverity . Error ) ;
489-
490489 var message = new StringBuilder ( ) ;
491490 foreach ( Diagnostic diagnostic in failures )
492491 {
@@ -514,6 +513,18 @@ SyntaxTree createTree(string code, string path) =>
514513 message . AppendLine ( $ "{ error_location } error { diagnostic . Id } : { diagnostic . GetMessage ( ) } ") ;
515514 }
516515
516+ bool cs0518_Object = failures . Any ( x => x . Id == "CS0518" && x . GetMessage ( ) . Contains ( "'System.Object'" ) ) ;
517+ bool cs0518_Void = failures . Any ( x => x . Id == "CS0518" && x . GetMessage ( ) . Contains ( "'System.Void'" ) ) ;
518+ bool cs0012_CoreLib = failures . Any ( x => x . Id == "CS0012" && x . GetMessage ( ) . Contains ( "System.Private.CoreLib" ) ) ;
519+
520+ if ( cs0518_Object && cs0518_Void && cs0012_CoreLib && effectiveCodeKind == SourceCodeKind . Regular )
521+ {
522+ message . AppendLine ( ) ;
523+ message . AppendLine ( "This error can be caused by Roslyn compilation using SourceCodeKind being set to Regular. " +
524+ "Try to specify SourceCodeKind.Script with the RoslynEvaluator.Compile(...) or set it " +
525+ "globally with `Globals.DefaultRoslynCompilationToScript = true`" ) ;
526+ }
527+
517528 var errors = message . ToString ( ) ;
518529
519530 throw new CompilerException ( errors ) ;
You can’t perform that action at this time.
0 commit comments