问题描述
1- csharpscript.Create和CSharpCompilation.Create有什么区别?
2-如果我有一个类似此链接的类代码脚本,并且想对其进行编译,应该使用哪一个?
3-使用@namespace.addUsing
(请参阅this链接)然后在WithImports
中通过。ScriptOptions
添加这些库是否正确?
为澄清起见:
// Create a namespace: (namespace CodeGenerationSample)
var @namespace = SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName("CodeGenerationSample")).normalizeWhitespace();
// Add System using statement: (using System)
@namespace = @namespace.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System")));
然后创建像这样的this sample这样的类代码字符串,是否需要再次拥有scriptoptions
?还是仅使用代码字符串中的using system
就足够了?
var scriptOptions = ScriptOptions.Default
.WithImports("System");
var scriptObject = csharpscript.Create(scriptCode,scriptOptions);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)