This file contains hidden or 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
public class C | |
{ | |
RedisValue ToRedisValue(object obj) | |
{ | |
return obj switch | |
{ | |
null => Null, | |
RedisValue v => v, | |
string v => (RedisValue)v, | |
int v => v, |
This file contains hidden or 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
IEnumerable<string> GenerateFizzBuzzList() | |
{ | |
var fizzes = Cycle("", "", "Fizz"); | |
var buzzes = Cycle("", "", "", "", "Buzz"); | |
var words = fizzes.Zip(buzzes, (f, b) => f + b); | |
var numbers = Range(1, 100); | |
return numbers.Zip(words, (n, w) => w == "" ? n.ToString() : w); | |
} |
This file contains hidden or 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; | |
namespace FizzBuzz | |
{ | |
static class Program | |
{ | |
static void Main() | |
{ | |
for (var i = 1; i <= 100; i++) | |
{ |
This file contains hidden or 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
public Bar DoSomething(Foo uncheckedFoo) => | |
uncheckedFoo is Foo foo | |
? DoSomething2(foo) | |
: throw new ArgumentNullException(nameof(uncheckedFoo)); | |
private Bar DoSomething2(Foo foo) => // foo is definitely set here |
This file contains hidden or 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
public void F<T>() | |
{ | |
switch (typeof(T)) | |
{ | |
case Type t when t == typeof(Foo): break; | |
case Type t when t == typeof(Bar): break; | |
} | |
} |
This file contains hidden or 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
if condition_1: | |
statement_1() | |
else if condition_2: | |
statement_2() | |
else if condition_3: | |
statement_3() | |
else: | |
statement_9() |
This file contains hidden or 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
<div class="comment"> | |
<div class="comment-author">David Arno</div> | |
<div class="comment-content"> | |
In your summary, you state "The main disadvantage of using the internal access modifier is that you can't easily unit test such a class". | |
Your entire post builds a complex, messy workaround to this through marking active methods as obsolete and having to wrap tests in "ignore warning" | |
pragmas. Yet the whole article misses the elephant in the room: internal classes are implementation details; they should not be unit tested directly. | |
Implementation details change, leading to brittle tests that need rewriting as those details change. Unit tests should test public APIs. If internal code | |
cannot be reached via a public API, then delete it as it has no purpose. | |
</div> | |
<div class="comment-date">2015-08-22 12:15 UTC</div> |
This file contains hidden or 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; | |
using System.IO; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using System.Xml; | |
using System.Xml.Linq; | |
namespace GithubWikiDoc | |
{ |
This file contains hidden or 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
public class Cat | |
{ | |
public string Name { get; set; } | |
public string Color { get; set; } | |
public Cat() | |
{ | |
Cat("Unamed", "gray"); | |
} |
This file contains hidden or 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
DoSomethingCodeA(); | |
try | |
{ | |
var exceptionsToBeIgnored = false; | |
foreach (var x in SomeExpression) | |
{ | |
exceptionsToBeIgnored = true; | |
DoSomethingCodeB(); | |
exceptionsToBeIgnored = false; | |
} |
NewerOlder