Skip to content

Instantly share code, notes, and snippets.

@kuhlenh
kuhlenh / .editorconfig
Last active October 4, 2021 04:56
Roslyn .NET OSS (WIP)
###############################
# Core EditorConfig Options #
###############################
root = true
# All files
[*]
indent_style = space
# Code files
@kuhlenh
kuhlenh / SpanTExample.cs
Last active November 20, 2017 16:53
Example from Span<T> in CoreCLR
ReadOnlySpan<char> valueSpan = value.AsReadOnlySpan();
if (!Int32.TryParse(valueSpan.Slice(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) ||
!Int32.TryParse(valueSpan.Slice(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) ||
!Int32.TryParse(valueSpan.Slice(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day))
{
// Couldn't convert integer, fail
return null;
}
// see entire example : https://github.com/dotnet/coreclr/blob/a16fdf04c50fd7b14b939835a040bd21084f1dc4/src/mscorlib/shared/System/Globalization/JapaneseCalendar.Win32.cs#L162-L165
@kuhlenh
kuhlenh / .editorconfig
Last active September 1, 2020 14:43
Learn how to use EditorConfig for your team
# When opening a file, EditorConfig plugins look for a file named .editorconfig in the
# directory of the opened file and in every parent directory. A search for .editorconfig
# files will stop if the root filepath is reached or an EditorConfig file with root=true
#is found. (source: http://editorconfig.org/)
# top-most EditorConfig file
root = true
# Don't use tabs for indentation for any file.
[*]
@kuhlenh
kuhlenh / .editorconfig
Created December 9, 2016 18:49
BlogEditorConfig_CodeStyleSnippet
# CSharp code style settings:
[*.cs]
csharp_style_var_for_built_in_types = true:none
@kuhlenh
kuhlenh / .editorconfig
Created December 9, 2016 18:48
BlogEditorConfig_CoreFormatting
# Code files
[*.cs,*.csx,*.vb,*.vbx]
indent_size = 4
@kuhlenh
kuhlenh / .editorconfig
Created December 9, 2016 18:47
BlogEditorConfig_Root
# top-most EditorConfig file
root = true
@kuhlenh
kuhlenh / .editorconfig
Last active December 9, 2016 18:51
Roslyn EditorConfig
# EditorConfig is awesome:
http://EditorConfig.org
# top-most EditorConfig file
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)
<Flags>
Enum MouseEventFlags
MOUSEEVENTF_ABSOLUTE = &B0000_1_0000_000000_0
MOUSEEVENTF_LEFTDOWN = &B0000_0_0000_000001_0
MOUSEEVENTF_LEFTUP = &B0000_0_0000_000010_0
MOUSEEVENTF_RIGHTDOWN = &B0000_0_0000_000100_0
MOUSEEVENTF_RIGHTUP = &B0000_0_0000_001000_0
MOUSEEVENTF_MIDDLEDOWN = &B0000_0_0000_010000_0
MOUSEEVENTF_MIDDLEUP = &B0000_0_0000_100000_0
End Enum
Async Function CalculateMonthlyTotalsAsync() As Task(Of (total As Decimal, average As Decimal, count As Integer))
using static System.Console;
static void Main(string[] args)
{
(int sum, int count) Tally(object[] values)
{
var r = (s: 0, c: 0);
foreach (var v in values)
{
switch(v)