ufcpp-live / UfcppLiveAgenda

@ufcpp live streaming agenda
MIT License
24 stars 2 forks source link

.NET 8 Preview 7 & Visual Studio 17.8 Preview 1 #76

Closed ufcpp closed 9 months ago

ufcpp commented 11 months ago

17.7 も GA したし振り返る?

C# /.NET 関連:

ufcpp commented 11 months ago

API diff の見た目がえぐい

image

(改行してないせい。実際の差分は , IUtf8SpanParsable<byte> だけ。)

ufcpp commented 11 months ago

DegreesToRadians

ufcpp-live commented 10 months ago
using System.Globalization;
using System.Numerics;

Console.WriteLine(parse<int>("123"u8));
Console.WriteLine(parse<byte>("123"u8));

// string と bool はこのインターフェイスも、
// string の方の ISpanFormattable/Parsable も実装してない
Console.WriteLine(parse<string>("123"u8));
Console.WriteLine(parse<bool>("true"u8));

// Complex の書式わかんねぇ
Console.WriteLine(parse<Complex>("123 256"u8));

static T parse<T>(ReadOnlySpan<byte> s)
    where T : IUtf8SpanParsable<T>
    => T.Parse(s, CultureInfo.InvariantCulture);
ufcpp-live commented 10 months ago
// 現状、new string[3] になっちゃう。
// GA までには、InlineArray 化する予定。
Span<string> a = ["", "a", "abc"]; // stackalloc 化無理
ufcpp-live commented 10 months ago
ImmutableArray<string> s = [""]; // F12 で ImmutableArray.Create に飛べてほしい

List<int> list;
_ = list[1]; // それでいうと、インデクサーも F12 で飛べてほしい。
ufcpp-live commented 10 months ago
static void X1(IEnumerable<int>? a)
{
    // ここ、target-type が IEnumerable なので、 [] は Empty 最適化かかる予定
    foreach (var x in a ?? [])
    {
        Console.WriteLine(x);
    }
}

static void X2(List<int>? a)
{
    // こっちで同じことやると、Empty 最適化かからない可能性大なのでは…
    foreach (var x in a ?? [])
    {
        Console.WriteLine(x);
    }
}

List.Empty 必要?

ufcpp-live commented 10 months ago

Case Preserving 置換、コピペからの整形で便利かも。

image

ufcpp-live commented 10 months ago
static async ValueTask MAsync()
{
    {
        Span<int> x; // これダメ。
        M1(stackalloc int[1]); // これは行けるのに。
    }

    await Task.Delay(1);
}

static IEnumerable<object> MIterator()
{
    Span<int> x = default; // これ、平気。
    M1(x);

    yield return null;

    // イテレーターの場合は yield をまたいだ瞬間にエラー。
    //foreach (var item in x) { }
}

static void M1(Span<int> x) { }