This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
if(args is []) { | |
args = ["--filter", "*"]; | |
}//if | |
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Debugged application */ | |
using System; | |
static class Program | |
{ | |
static void Main(string[] args) { | |
Console.WriteLine(args?.Length); // Step into Specific, Console.WriteLine here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before | |
var dictionary1 = new Dictionary<int, string> { | |
{ 1, "One" }, | |
{ 2, "Two" }, | |
}; | |
// After | |
var dictionary2 = new Dictionary<int, string> { | |
[1] = "One", | |
[2] = "Two", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main() { | |
var thing = new Thing(); | |
if(thing.A && thing == null) { | |
Console.WriteLine("thing == null"); | |
}//if | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
// ReSharper disable once CheckNamespace | |
class MultiDictionary<TKey, TValue> : Dictionary<TKey, IList<TValue>> | |
{ | |
public void Add(TKey key, params TValue[] values) { } | |
} | |
static class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
static class Program | |
{ | |
static void Main(string[] args) { | |
var lengths = args.Select(item => item.Length); | |
// "lengths" can be enumerated a few times, depending on a size of "args". | |
var xxx = args.Select(item => lengths.Select(x => x)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
static class Program | |
{ | |
static void Add(IReadOnlyCollection<object> items) { } | |
static void Add(IEnumerable<IReadOnlyCollection<object>> items) { } | |
static void Main() { | |
var list = new List<object[]>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Overload of Debug.Assert with detailMessageFormat does not supported | |
// Debug.Assert has an overload with detailMessageFormat parameter: https://msdn.microsoft.com/en-us/library/cc190597(v=vs.110).aspx. | |
// This overload does not supported by R#: | |
// * No syntax highlighting and no validation of format arguments | |
// * Code analysises does not recognize this calls (null check not works) | |
class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main() { | |
var x = DateTime.Now.Day > 10 ? 1 : new Program() ?? default(object); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Method(Entity entity) { | |
if(entity == null) { | |
throw new ArgumentNullException(nameof(entity)); | |
} else if(entity.Some.Property > 0) { | |
throw new ArgumentException(stringanize(entity.Some.Property > 0), nameof(entity)); | |
}//if | |
// "stringanize" makes a string from an expression | |
// and when we are renamed "Some" or "Property" | |
// string is updated! |
NewerOlder