不和大家卖关子,这次给大家带来的是微软粑粑前几天刚推出的新玩意:

image.png

image.png
有的小伙伴可要说了。浏览器上运行C#代码以前不就可以嘛,然后啪啪啪告诉我几个网站:C#Pad,dotnetfiddle。
重点来啦 :Tyr.Net他的功能可不只是用来在浏览器上测试代码。我这里大致的和大家讲几点功能
1.在你的网站中嵌入你的代码并进行调试
通过GitHub方式可以很方便的把你在Gist中的代码片段嵌入到当前浏览器中
比如官网的例子像这样
<h2>Fibonacci Generator</h2><p>Here is my example of a Fibonacci generator implemented in C#.</p><iframe class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="https://try.dot.net/?fromGist=df44833326fcc575e8169fccb9d41fc7"></iframe>
通过自定义的方式设置你自己的代码片段
function setCode() {
postMessageToEditor({ type: "setWorkspace", workspace: { workspaceType: "script", buffers: [{ id: "Program.cs", content: "Console.WriteLine("Hello World!");"
}]
}, bufferId: "Program.cs"
});
}function postMessageToEditor(message) { document.getElementById('example-iframe').contentWindow
.postMessage(message, "https://try.dot.net");
}

效果图
2.代码编辑器还支持主题的切换
比如我不喜欢黑色背景,使用下面代码就能切换成白色
function setDefaultTheme() {
postMessageToEditor({ type: "configureMonacoEditor", theme: "vs"
});
}function postMessageToEditor(message) { document.getElementById('example-iframe').contentWindow
.postMessage(message, "https://try.dot.net");
}

白色主题
3.几乎和VS一模一样的代码和错误提示以及代码折叠功能
如下图中代码我进行了折叠

折叠
同时上面using System.Linq;命名空间我未使用到,他也给了我智能的提示,这些都是几乎和vs一模一样的操作

image.png
作者:邵佳楠
链接:https://www.jianshu.com/p/d3cd461ca922
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1678/viewspace-2820763/ ,如需转载,请注明出处,否则将追究法律责任。