Skip to content

Instantly share code, notes, and snippets.

View TessenR's full-sized avatar

Andrey Dyatlov TessenR

View GitHub Profile
TessenR / Spoiler.cs
Created January 14, 2021 19:54
Spiler alert
// compile with C# 8
class C
void M()
// in C# 8 you'll get a warning here but neither T? nor [AllowNull] will be allowed
void M<T>(T t = default) { } // CS8601
TessenR / Code.cs
Last active December 21, 2020 16:49
Generator adding logging to locks
using System;
using System.Threading;
using System.Threading.Tasks;
using DeadlockDemo;
using JetBrains.Annotations;
var test = new MyDeadlockDemoWithLogging();
Console.WriteLine("Running without deadlock...");
TessenR /
Last active August 30, 2023 21:34
Source generators in action links
TessenR / ChainedGenerators.cs
Last active August 26, 2020 05:19
Chained source generators where subsequent generators aware of the previous generators' changes
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using Microsoft.CodeAnalysis;
TessenR / Generator.cs
Created August 26, 2020 00:46
Iterative source generator reusing types from previous iterations
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
public class Generator : ISourceGenerator
using System;
using System.Runtime.InteropServices;
static class Program
static void Main(string[] args)
bool b = GetTricksyBool();
if (b) Console.WriteLine(b.IsTrue());