This file contains hidden or 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.Numerics; | |
//var interfaces = GetAllIntegerInterfaces(); | |
var interfaces = GetAllFloatInterfaces(); | |
WriteMermaidGraph( | |
from i in interfaces | |
from b in GetUniqueBaseInterfaces(i) | |
select (i.Name, b.Name)); |
This file contains hidden or 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
// https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md で | |
// Merged into 17.3p2 になってるやつ。 | |
using System.Diagnostics.CodeAnalysis; | |
// DIM for Static Members | |
interface IA | |
{ | |
// static abstract 自体これまで「RequiresPreviewFeatures」だったのであんまり「新機能」感はないけども。 | |
// 17.3p5 から、static virtual も書けるように。 |
This file contains hidden or 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.CodeAnalysis.CSharp; | |
using Microsoft.CodeAnalysis.CSharp.Scripting; | |
using Microsoft.CodeAnalysis.Scripting; | |
using System.Text; | |
var template = """ | |
class MyClass | |
{ | |
`* | |
var properties = new[] { |
This file contains hidden or 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
#nullable disable | |
#pragma warning disable IDE0004, IDE0049, IDE0052, IDE0055, IDE0060, CS1998, CS0626 | |
using System.Runtime.CompilerServices; | |
using static System.Runtime.CompilerServices.Unsafe; | |
class A | |
{ | |
Delegate _x; | |
public object X |
This file contains hidden or 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 BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System.Runtime.CompilerServices; | |
BenchmarkRunner.Run<AsBenchmark>(); | |
class Util | |
{ | |
public static long M1<T>(T x) | |
{ |
This file contains hidden or 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
// 【!! 終了のお知らせ】 | |
// のはずなんだけど、 VS 17.3p1 ではまだ消えてなかった。 | |
m(null); | |
static void m(string s!!) { } |
This file contains hidden or 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.Runtime.CompilerServices; | |
var r = new R(); | |
// (.NET 7 で緩和予定だけど、今は) ref struct を型引数にできない。 | |
//ref int r = ref Unsafe.As<R, int>(ref r); // CS0306 エラー | |
unsafe | |
{ | |
// As<int, int> で関数ポインターを取っておいて、 |
This file contains hidden or 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
var it = typeof(IDisposable); | |
var t = typeof(S); | |
var map = t.GetInterfaceMap(typeof(IDisposable)); | |
ulong guard1 = 0x8_0000_0009; | |
var s = new S { X = 1, Y = 2, Z = 3, W = 4 }; | |
ulong guard2 = 0x6_0000_0007; | |
{ |
This file contains hidden or 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 BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
BenchmarkRunner.Run<SpanBenchmark>(); | |
[MemoryDiagnoser] | |
public class SpanBenchmark | |
{ | |
private const int N = 1000; |
This file contains hidden or 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.Text; | |
using System.Text.Encodings.Web; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
var original = new A(123, "あいう abc \b/\r\n\t\"\\\'🐈"); | |
var opt = new JsonSerializerOptions | |
{ | |
//Encoder = new NoEscapingEncoder(), |