Generate an enum dynamically from file with intellisense support

*爱你&永不变心* 提交于 2019-12-07 13:16:45

问题


I heard lots about Roslyn, and I just thought is it possible to generate code dynamically from an xml file so that for the developer it will be transparent and he could enumerate the code with IntelliSense as if the code is written in the project.

I am writing a framework with a lot of customization done via config files, and would really like to use such feature if it's possible.


回答1:


What you want is what F# calls type providers and it probably is possible to do by hacking the Roslyn compiler but I think it will be a lot of work. You may want to have a look at the related question Could F# type providers be incorporated in C#. Your best bet may be to use the F# type providers in a F# project and then reference this project and its types from C# projects but I can not tell if this is viable because I am lacking F# experience.



来源:https://stackoverflow.com/questions/22960267/generate-an-enum-dynamically-from-file-with-intellisense-support

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!