I hereby claim:
- I am atsvetkov on github.
- I am atsvetkov (https://keybase.io/atsvetkov) on keybase.
- I have a public key whose fingerprint is ED30 494E 8268 E48A F3CE 7394 F7FB 7DE3 7BC9 07AA
To claim this, I am signing this object:
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BenchmarkRunner.Run<GuardBenchmark>(); | |
} | |
} | |
[MemoryDiagnoser] | |
public class GuardBenchmark |
void Foo(SomeReferenceType input) | |
{ | |
Guard.NotNull(input, nameof(input)); | |
// do something useful | |
} |
public static void NotNull<T>(T value, string name) where T: class | |
{ | |
if (value == null) | |
{ | |
throw new ArgumentNullException(name); | |
} | |
} |
void Foo(SomeReferenceType input) | |
{ | |
Guard.NotNull(() => input); | |
// do something useful | |
} |
public static class Guard | |
{ | |
public static void NotNull<T>(Expression<Func<T>> expression) where T : class | |
{ | |
var value = /* somehow compile the expression and invoke the delegate to produce a value */; | |
if (value == null) | |
{ | |
throw new ArgumentNullException(GetParameterName(expression)); | |
} | |
} |
void Foo(SomeReferenceType input) | |
{ | |
Guard.NotNull(input); | |
// do something useful | |
} |
public static class Guard | |
{ | |
public static void NotNull(object value) | |
{ | |
if (value == null) | |
{ | |
throw new ArgumentNullException(/* how to get original argument name here??? */); | |
} | |
} | |
} |
void Foo(SomeReferenceType input) | |
{ | |
if (input == null) | |
{ | |
throw new ArgumentNullException("input"); | |
} | |
// if we made it here, input can be safely dereferenced and used | |
} |
I hereby claim:
To claim this, I am signing this object:
static void Main(string[] args) | |
{ | |
var connectionString = ConfigurationManager.ConnectionStrings["Database"].ConnectionString; | |
// creates the database if not yet exists | |
EnsureDatabase.For.SqlDatabase(connectionString); | |
var upgrader = DeployChanges.To.SqlDatabase(connectionString) | |
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()) | |
.LogToConsole() |