-
Notifications
You must be signed in to change notification settings - Fork 238
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
Add new method CSScript.CodeDomEvaluator.ReferenceAssembliesByName(list<string) #267
Comments
Well, I can understand what you are trying to solve and will consider converting the signature to the "params" version. It is because I am trying to keep the API as lean as possible. And "params" will completely address your issue. Saying that, I would prefer users to extend the engine interface as much as possible instead of modifying it. Thus this simple extension in your code will completely address your issue even without waiting the the next release: static class CSScriptExtensions
{
public static IEvaluator ReferenceAssemblyByNames(this IEvaluator evaluator, string[] assemblyNames)
=> assemblyNames.ToList().ForEach(asm => evaluator.ReferenceAssemblyByName(asm));
} |
A small modification to the code below was required
internal static class CSScriptExtensions
{
internal static IEvaluator ReferenceAssemblyByNames(this IEvaluator evaluator, List<string> assemblyNames)
{
foreach(var assemblyName in assemblyNames)
{
evaluator.ReferenceAssemblyByName(assemblyName);
}
return evaluator;
}
}
Hint the code below did not return a IEvaluator
Tom
|
Correct. 👍 Though the signature can be improved even further: static class CSScriptExtensions
{
public static IEvaluator ReferenceAssemblyByNames(this IEvaluator evaluator, IEnumerable<string> assemblyNames)
{
foreach(var assemblyName in assemblyNames)
evaluator.ReferenceAssemblyByName(assemblyName);
return evaluator;
}
} |
Done. Will be available in the very next release. |
A follow-up for people interested in this new feature... The v4.3 release notes reference this enhancement request: The actual implementation is a change to the signature of this method |
Request:
Enable loading referenced assemblies from a list of strings (assy names) instead of explicit individual ReferenceAssemblyByName(string) for each assy,
Current State:
We must add a ReferenceAssemblyByName line for the number of referenced assys that we want to be able to load.
Scenario:
We are executing scripts written by a separate team that may have 0..N referenced assys. This would make our code that wraps the CSScript library support this use case.
The text was updated successfully, but these errors were encountered: