Skip to content

Instantly share code, notes, and snippets.

@mwrouse
mwrouse / Autocomplete.js
Last active March 28, 2025 04:49
Autocompletion for an object in the monaco editor
function ShowAutocompletion(obj) {
// Disable default autocompletion for javascript
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ noLib: true });
// Helper function to return the monaco completion item type of a thing
function getType(thing, isMember) {
isMember = (isMember == undefined) ? (typeof isMember == "boolean") ? isMember : false : false; // Give isMember a default value of false
switch ((typeof thing).toLowerCase()) {
case "object":
public static void Swap<T>(Expression<Func<T>> left, Expression<Func<T>> right)
{
var lvalue = left.Compile()();
Expression.Lambda<Func<T>>(Expression.Assign(left.Body, Expression.Constant(right.Compile()()))).Compile()();
Expression.Lambda<Func<T>>(Expression.Assign(right.Body, Expression.Constant(lvalue))).Compile()();
}
public class Test
{
public int X { get; set; }