Skip to content

Instantly share code, notes, and snippets.

View MichalBrylka's full-sized avatar

Michał Bryłka MichalBrylka

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
namespace QuasiRandom
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace QuasiRandom
{
static class Program
{
static void Main(string[] args)
//Head+Tail for ROS<T>
static void Deconstruct<T>(this ReadOnlySpan<T> span, out T head, out ReadOnlySpan<T> tail)
{
switch (span.Length)
{
case 0:
head = default;
tail = default;
return;
case 1:
// Do not replace the array allocation with Array.Empty. We don't want to have the overhead of
// instantiating another generic type in addition to ArraySegment<T> for new type parameters.
public static ArraySegment<T> Empty { get; } = new ArraySegment<T>(new T[0]);

#Leszek

  • HTTP 2.0 + gRPC
  • Networking - benchmarks and more
  • Single image deployment
  • Native To managed transition

#Michał

using System;
namespace DotnetCommunityDemoNet5
{
abstract class Component:ICloneable
{
public int ComponentId { get; }
protected Component(int componentId) => ComponentId = componentId;
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
namespace EncUtf8
{
class Program
{
private static string _in = @"Rozdział pierwszy
@MichalBrylka
MichalBrylka / Consumer.cs
Last active September 25, 2023 17:52
Creating and using C# 9.0 records
using System;
using RecordsProducer;
var lizard1 = new Reptile(Habitat.Terrestrial) { Name = "Agama" };
var lizard2 = new Reptile(Habitat.Terrestrial) { Name = "Agama" };
//use <LangVersion>latest</LangVersion>
var lizard3 = lizard1 with { Name = "Komodo dragon", Habitat = Habitat.Terrestrial };
@MichalBrylka
MichalBrylka / Collections.cs
Created November 13, 2020 23:50
RecordSettings
using System;
namespace RecordSettings
{
/// <summary>
/// Collection parsing settings
/// </summary>
/// <remarks>For performance reasons, all delimiters and escaped characters are single chars. This makes a parsing grammar to conform LL1 rules and is very beneficial to overall parsing performance </remarks>
/// <param name="DefaultCapacity">Capacity used for creating initial collection/list/array. Use no value (null) to calculate capacity each time based on input</param>
public abstract record CollectionSettingsBase(char ListDelimiter, char NullElementMarker, char EscapingSequenceStart, char? Start, char? End, byte? DefaultCapacity) : ISettings
using System.Collections.Generic;
using NUnit.Framework;
namespace NUnit_CountBug
{
[TestFixture]
public class CountBug
{
[Test]
public void CountConstraint_ShouldWorkForInterface()