Skip to content

Instantly share code, notes, and snippets.

View muratalalmis's full-sized avatar

Murat ALALMIŞ muratalalmis

View GitHub Profile
@muratalalmis
muratalalmis / RazorCompletionsWithRoslyn.cs
Created November 16, 2020 16:22 — forked from warrenbuckley/RazorCompletionsWithRoslyn.cs
Trying to get autocompletion on a Razor .cshtml view with Roslyn's CompletionService
[HttpPost]
public string FetchCompletions(RazorCode model)
{
var host = new System.Web.Razor.RazorEngineHost(new CSharpRazorCodeLanguage());
var templateEngine = new System.Web.Razor.RazorTemplateEngine(host);
var compiledCode = templateEngine.GenerateCode(new StringReader(model.Code));
var parsed = templateEngine.ParseTemplate(new StringReader(model.Code));
// Cannot convert from 'System.Web.Razor.Parser.SyntaxTree.Block' to 'Microsoft.CodeAnalysis.Document'
@muratalalmis
muratalalmis / TypeWrapper.cs
Created October 3, 2017 08:58 — forked from JimBobSquarePants/TypeWrapper.cs
You can do really crazy things with C#
public class TypeWrapper
{
private readonly dynamic dyn;
private readonly Dictionary<string, CallSite<Action<CallSite, object, object>>> setters
= new Dictionary<string, CallSite<Action<CallSite, object, object>>>();
private readonly Dictionary<string, CallSite<Func<CallSite, object, object>>> getters
= new Dictionary<string, CallSite<Func<CallSite, object, object>>>();
public TypeWrapper(object d)