-
Code used in the live coding demo at DotNext
- https://github.com/TessenR/NotifyPropertyChangedDemo
- A simple demo with NotifyPropertyChanged generator focused on being as simple as possible. It adds a property changed event to all types implementing INotifyPropertyChanged interface and adds properties raising this event for all fields with names ending with *BackingField suffix. It covers debugging, testing and simple generator code.
- https://github.com/TessenR/BestPracticesSourceGeneratorsDemo
- A demo focused on useful approaches to source generators' problems such as decresing their work time, producing diagnostics and configuration options.
- https://github.com/TessenR/NotifyPropertyChangedDemo
-
Source generators introduction by Microsoft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using DeadlockDemo; | |
using JetBrains.Annotations; | |
var test = new MyDeadlockDemoWithLogging(); | |
Console.WriteLine("Running without deadlock..."); | |
test.MyFirstMethod(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
[Generator] | |
public class Generator : ISourceGenerator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
static class Program | |
{ | |
static void Main(string[] args) | |
{ | |
bool b = GetTricksyBool(); | |
if (b) Console.WriteLine(b.IsTrue()); | |
} |