Giter Site home page Giter Site logo

Comments (7)

NMSAzulX avatar NMSAzulX commented on June 14, 2024 1

能不能从之前编译的 domain 里获取到 compilation 相关的语法树,从而与新的代码进行合并,但是合并后编译可能需要一个新的 domain,不然可能会有冲突,不知道能不能接受一个新的 domain,原来的 domain 可能不一定能及时销毁

如果不能接受新的 domain 的话,感觉可能还是用户自己把要编译好的代码组成到一起延迟编译会比较好

增加了API, 可以返回一个格式化好的未编译的 Compilation, 也是编译用的 Compilation, 可以返回给用户.
提交记录: 62bb4ff

感觉这个需求可以考虑尝试 roslyn 的 scripting 功能,natasha 也可以考虑增加/扩展 scripting 的支持

var state = await CSharpScript.RunAsync("int x = 1;");
state = await state.ContinueWithAsync("int y = 2;");
state = await state.ContinueWithAsync("x+y");
Console.WriteLine(state.ReturnValue);

https://github.com/dotnet/roslyn/blob/main/docs/wiki/Scripting-API-Samples.md#-continue-script-execution-from-a-previous-state

这一点我感觉是轻量化的需求, 轻量化确实可以考虑一手...

from natasha.

NMSAzulX avatar NMSAzulX commented on June 14, 2024

@WeihanLi @newbe36524 @alexinea 合并程序集有什么想法吗? 是否属于应用级别的方案? 因为程序集合并是做不到的, 只能做到脚本合并, 而脚本合并是可以由开发者自行完成, 比如 csbuild1 和 csbuild2, csbuild1.combinewith(csbuild2).

public sealed partial class AssemblyCSharpBuilder 
{

    public readonly List<SyntaxTree> SyntaxTrees;
}

根据以上代码, 脚本合并只需合并两个 build 的 SyntaxTrees 即可.

from natasha.

WeihanLi avatar WeihanLi commented on June 14, 2024

能不能从之前编译的 domain 里获取到 compilation 相关的语法树,从而与新的代码进行合并,但是合并后编译可能需要一个新的 domain,不然可能会有冲突,不知道能不能接受一个新的 domain,原来的 domain 可能不一定能及时销毁

如果不能接受新的 domain 的话,感觉可能还是用户自己把要编译好的代码组成到一起延迟编译会比较好

from natasha.

DonPangPang avatar DonPangPang commented on June 14, 2024

例如一个脚本驱动的系统,启动时需要加载历史存储的脚本,当然,也可以通过系统新增脚本,然后业务由脚本完成。

目前的使用就是一个脚本会对应一个Assembly,当然,加载历史脚本时可以进行合并,但是对于新增的来说,就无法达到预期的效果。在这个系统中,由于脚本的体量可能是庞大的,通过Domain的划分可能比较笼统,所以我设想是不是可以将一些脚本追加到同一个Assembly中。

from natasha.

WeihanLi avatar WeihanLi commented on June 14, 2024

感觉这个需求可以考虑尝试 roslyn 的 scripting 功能,natasha 也可以考虑增加/扩展 scripting 的支持

var state = await CSharpScript.RunAsync("int x = 1;");
state = await state.ContinueWithAsync("int y = 2;");
state = await state.ContinueWithAsync("x+y");
Console.WriteLine(state.ReturnValue);

https://github.com/dotnet/roslyn/blob/main/docs/wiki/Scripting-API-Samples.md#-continue-script-execution-from-a-previous-state

from natasha.

NMSAzulX avatar NMSAzulX commented on June 14, 2024

例如一个脚本驱动的系统,启动时需要加载历史存储的脚本,当然,也可以通过系统新增脚本,然后业务由脚本完成。

目前的使用就是一个脚本会对应一个Assembly,当然,加载历史脚本时可以进行合并,但是对于新增的来说,就无法达到预期的效果。在这个系统中,由于脚本的体量可能是庞大的,通过Domain的划分可能比较笼统,所以我设想是不是可以将一些脚本追加到同一个Assembly中。

只能创建新的程序集. 而且目前 API 也可以做.
同一个域追加程序集可能出现问题, 同命名空间同名类可能会引发异常.

这是应用级别的需求, Natasha 无法提供底层支持.

from natasha.

DonPangPang avatar DonPangPang commented on June 14, 2024

能不能从之前编译的 domain 里获取到 compilation 相关的语法树,从而与新的代码进行合并,但是合并后编译可能需要一个新的 domain,不然可能会有冲突,不知道能不能接受一个新的 domain,原来的 domain 可能不一定能及时销毁
如果不能接受新的 domain 的话,感觉可能还是用户自己把要编译好的代码组成到一起延迟编译会比较好

增加了API, 可以返回一个格式化好的未编译的 Compilation, 也是编译用的 Compilation, 可以返回给用户. 提交记录: 62bb4ff

感觉这个需求可以考虑尝试 roslyn 的 scripting 功能,natasha 也可以考虑增加/扩展 scripting 的支持

var state = await CSharpScript.RunAsync("int x = 1;");
state = await state.ContinueWithAsync("int y = 2;");
state = await state.ContinueWithAsync("x+y");
Console.WriteLine(state.ReturnValue);

https://github.com/dotnet/roslyn/blob/main/docs/wiki/Scripting-API-Samples.md#-continue-script-execution-from-a-previous-state

这一点我感觉是轻量化的需求, 轻量化确实可以考虑一手...

我们的应用设计就是脚本驱动,一个脚本可能非常庞大,由一个类或者多个类填充,例如登录功能,我们的基座上只支持了编译、调用和校验,逻辑全在脚本里😂😂而且开发一个业务相关的脚本时可能需要频繁修改。。

from natasha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.