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
public class MyClass | |
{ | |
public static LargeStruct StaticMethod(MyClass obj) | |
{ | |
// ... | |
} | |
public LargeStruct InstanceMethod() | |
{ | |
// ... |
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
public struct SomeStruct | |
{ | |
public int Value1; | |
} |
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
public unsafe class Getter | |
{ | |
private delegate*<Obj, SomeStruct> _functionPointer; | |
public Getter(string propName) | |
{ | |
var methodInfo = typeof(Obj).GetProperty(propName).GetGetMethod(); | |
_functionPointer = (delegate*<Obj, SomeStruct>)methodInfo.MethodHandle.GetFunctionPointer(); | |
} |
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; | |
namespace ManagedDotnetProfiler; | |
public class DllMain | |
{ | |
[UnmanagedCallersOnly(EntryPoint = "DllGetClassObject")] | |
public static unsafe int DllGetClassObject(Guid* rclsid, Guid* riid, IntPtr* ppv) | |
{ |
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 Microsoft.Diagnostics.Runtime; | |
using System; | |
using System.Linq; | |
namespace ExtractDynamicMethod | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ |
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.Generic; | |
using System.Linq; | |
using System.Threading; | |
using Microsoft.Diagnostics.Runtime; | |
namespace ClrmdAsyncLocal | |
{ | |
internal class Program | |
{ |
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
[MemoryDiagnoser] | |
public class EmptyEnumerator | |
{ | |
[Benchmark(Baseline = true)] public bool ArrayEmpty() => Array.Empty<string>().GetEnumerator().MoveNext(); | |
[Benchmark] public bool ArrayEmptyAsEnumerable() => ((IEnumerable<string>)Array.Empty<string>()).GetEnumerator().MoveNext(); | |
[Benchmark] public bool ArrayEmptyForEach() | |
{ | |
foreach (var _ in Array.Empty<string>()) |
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
[AsyncMethodBuilder(typeof(UiTaskMethodBuilder))] | |
public class UiTask | |
{ | |
internal TaskCompletionSource<object> Promise { get; } = new TaskCompletionSource<object>(); | |
public Task AsTask() => Promise.Task; | |
public TaskAwaiter<object> GetAwaiter() | |
{ | |
return Promise.Task.GetAwaiter(); |
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.Concurrent; | |
using System.Runtime.CompilerServices; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ThreadTasks | |
{ | |
class Program | |
{ |
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.Syntax; | |
using Microsoft.CodeAnalysis.Text; | |
namespace IsEvenSourceGenerator | |
{ | |
[Generator] |