Skip to content

Instantly share code, notes, and snippets.

using System;
public class Person
{
public int Age { get; }
public string Name { get; }
public Person(int age, string name)
: this(null, new Builder { Age = age, Name = name })
{
public class Person
{
public Person(int age, string name);
public int Age { get; }
public string Name { get; }
public virtual Person With(in Builder builder);
public ref struct Builder
@CyrusNajmabadi
CyrusNajmabadi / Adding Index and Range support to existing library types (redux).md
Last active January 2, 2022 21:09
Adding Index and Range support to existing library types (redux)

Adding Index and Range support to existing library types (redux)

Summary:

Expand on the ability to implicitly support System.Index and System.Range for additional operations.

For example, the following would be allowed:

void Method(List list)
@CyrusNajmabadi
CyrusNajmabadi / CollectionLLiteralls.md
Last active October 31, 2022 16:28
Collection LLiteralls.md

Collection LLiterals

  • A modest proposal for C# or
  • The harbinger of llamageddon?

Today

  • Collections are the bread-and-butter of programming

  • LLinq started with a simple question "who works with data?"

@CyrusNajmabadi
CyrusNajmabadi / AnonymousList.md
Last active May 4, 2023 02:38
AnonymousList.md

Hey Mads! I wanted to give you a little sketch of one of the approaches we've been considering to help out in the var/natural-type space. We discussed with stephen yesterday. While not a "slam slam dunk" it def seemed to have some real upsides that made it him feel better about some things (though it also came with downsides as you'll see).

Core goals/thoughts of mine were:

  1. Perf sensitive people should not feel bad using 'var' the feature (or have to ban it).
  2. We should be able to tell people "you can trust we do a really​ good job" or, ideally, "we do the best​ job" when you use these.
  3. Limitations should be minimal. However, when present, should be sensible, acceptable, and easy to explain. Most users will feel things "just work" (However, those who like to know how the sausage is made might discover a lot of complexity to make that happen).
  4. We may be stretching our comfort zone, but hopefully the value makes that ok.
This file has been truncated, but you can view the full file.
[8/7/2024 12:22:34.966 PM] Log level is set to Trace (Includes Platform logs).
[8/7/2024 12:22:35.397 PM]
[8/7/2024 12:22:35.417 PM] Source code repository not available. Some features may not work as expected.
[8/7/2024 12:22:35.626 PM] Current list of test runtime environments: < Local Windows Environment >
[8/7/2024 12:22:37.851 PM] InternalLoadProjects Starting... [0]
[8/7/2024 12:22:38.031 PM] InternalLoadProjects Enumeration Complete in 178 ms [0]
[8/7/2024 12:22:38.371 PM] Enqueue operation 'OpenOperation', hashcode:36304837
[8/7/2024 12:22:38.379 PM] Operation left in the the queue: 1
[8/7/2024 12:22:38.379 PM] 'OpenOperation', hashcode:36304837
This file has been truncated, but you can view the full file.
Build started at 12:01 PM...
1>FastUpToDate: Ignoring up-to-date check items with Kind="ImplicitBuild" (Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost)
1>FastUpToDate: Checking configuration Debug|AnyCPU|net6.0: (Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost)
1>FastUpToDate: Build acceleration is enabled for this project via a feature flag. See "Tools | Options | Environment | Preview Features" to control this setting. See https://aka.ms/vs-build-acceleration. (Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost)
1>FastUpToDate: Comparing timestamps of inputs and outputs: (Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost)
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost)
1>FastUpToDate: D:\github\roslyn\artifacts\bin\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost\Debug\net6.0\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll (Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost)
1>FastUpToDate: