New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C# Error function doesn’t work #598
Comments
The script engine in TE3 allows you to define types and methods without the hack. In fact, the hack won’t work at all, as Roslyn will not compile the script if there are unmatching brackets. class MyClass
{
public void SayHello()
{
Info("Hello");
}
}
var myClassInstance = new MyClass();
myClassInstance.SayHello(); There is a bug with |
oh so the behaviour is different in TE2 ? thanks for the quick update and looking forward to the fix! I'll be presenting on c# scripts in september 😁 |
Yes, it’s different. TE3 uses Roslyn, which is faster, more secure and enables the use of new C# 10 language features. This is part of the reason why we upgraded TE3 to use .NET 6. TE2 uses the old CodeDomProvider for scripting, but this is deprecated these days and only supports language features up to C# 6. |
I think I understand the reasons, but at the same time a bit sad that there will be now scripts for TE3 and scripts for TE2. And some (most probably) that will run on both. |
Yes, it was a priority for us to get TE3 to use Roslyn because of the other features it offers (better IntelliSense, etc.). But the plan is that TE2 will also use Roslyn eventually, thus ensuring that scripts work similar in both tools. |
oh, glad to hear that! |
I just read that you can also use Rosylin in TE2, right? Will the behaviour be the same then? |
just managed to set it up -- I still need the extra curly brackets but now the behaviour is much closer to TE3 |
Yep, we don't want to ship the Roslyn compiler with TE2, as that will tremendously increase the footprint, and one of the reasons why people love TE2 is that it is so lightweight. Instead, we will make sure that you can define methods and types just like you can in TE3, but if you want the new C# 10 language features, you'll have to manually configure the Roslyn compiler as you did (more information link should point here. |
Issue with |
Hello,
I watched with great interest your presentation at SQLBits 2020, particularly the part to hack the script adding methods and classes at the end. I tried adding a class at the end of the script with the extra } and { and the end but to my surprise these where not expected. I managed to get an execution by just adding the class, but then I'm getting an error when using the Error( ) function, as follows. It is odd because passing a single string should be enough isn't it? I tried passing some integer and a boolean and now I'm getting a null reference error that I always struggle with.
Object Type Message Line Column
Error There is no argument given that corresponds to the required formal parameter 'suppressHeader' of 'ScriptHost.Error(string, int, bool)' 85 29
The text was updated successfully, but these errors were encountered: