Skip to content

Instantly share code, notes, and snippets.

@thomaslevesque
thomaslevesque / TestNullable.cs
Created June 5, 2020 12:01
Repro for CS8762 false positive
using System.Diagnostics.CodeAnalysis;
namespace TestNullable
{
class Test
{
static bool TrySomething1(string s, [NotNullWhen(false)] out string? failReason)
{
// warning CS8762: Parameter 'failReason' must have a non-null value when exiting with 'false'.
return s.Length % 2 == 0
@thomaslevesque
thomaslevesque / NaturalSortStringComparer.cs
Created September 14, 2022 01:45
Natural sort string comparer
using System;
using System.Collections.Generic;
/// <summary>
/// String comparer that takes numbers into account.
/// e.g. "Episode 9" will be considered less than "Episode 10", even though it would be greater based on strictly
/// alphabetical order.
/// </summary>
public class NaturalSortStringComparer : IComparer<string>
{
@thomaslevesque
thomaslevesque / .gitignore
Last active November 3, 2022 07:56
Tests in same project
bin/
obj/
.vs/
.idea/
.vscode/
*.user