When we use anomymous lambda in C#, we can have to choose between passing values as parameter or using lambda capture. Second one is elegant and easy: we “just” us enclosing variables.
It is good to remember that capturing has a cost which should be understood and taken into account. For this, we can refer to : The implementation of anonymous methods in C# and its consequences – The Old New Thing.
Knowing this, we can think that C++ 11 solution is better. We have to choose wich variables are captured and if capture is a copy or a modifiable reference in capture specification block (). And, by default, there is no capture. That way, overhead it is not a hazard but a deliberate choice. Perhaps for C# 7 but with breaking changes.
Perhaps the missing auto updater I was searching: Squirrel/Squirrel.Windows. Like ClickOnce but on GitHub.
After spending some time trying to handle properly proxy authentification (407) in .Net, I’ve found how Fiddle can help us in debugging this (here).
A qote from Framework Design Guidelines Digest · dotnet/corefx Wiki with which I completely agree:
Understand Your Customer
Realize that the majority of your customers are not like you. You should design the API for your customer, not for developers working in your close working group, who unlike majority of your customers are experts in the technology you are trying to expose.
A library for csv reading and writing with every thing needed: header, fluent and auto mapping, conversion with type converter or lambda, quote and escape management, exceptional cases management (missing field, format change, comment, empty row). And I’m sure to miss some points.
A library/nuget package to simplify Win32 SendInput with smart helper methods: Windows Input Simulator.
A StringBuilder like doing native utf8 and with strict memory contraint (less allocation, less GC presure): .Net world is changing!
System.Text.Formatting · dotnet/corefxlab Wiki.
And why not sliced array to be able to prevent copy when taking substring (Proposal: Slicing #120). Now we can dream about .Net future.
In my search for a simple and elegant library for parsing command line in .Net, I found two new candidates:
First one provides a fluent API really simple to use (only one gotcha: there is two github repo owned by same person and only old one details how usage can be printed on console with the elegant SetupHelp). Already used in a production code.
Second one seems to cover more powerfull options. This library is a minimal application framework centerer around verb notion (even if a default verb can be defined). The parser is in charge of running your application through a:
where your class TheApp declare methods corresponding to each verb. Each method parameters are gathers from command line according to attributes.
You have, among other things, validation (predifined with attributes and custom with code), pre/post condition for verbs, key shortening for verb and parameters and custom types in external file using either json or xml format.
Looking at CLAP’s code, I have found an ingenious way to validate key/value parameters using SQL Expressions builtin .Net DataColumn.Expression (code is here). A DataTable is construct, a column is added for each parameter using its name and type and a single row is added to contain each value. In a small amount of line, you have expressions like “index1 > index2 AND index2 > 28”, “Name NOT LIKE ‘Test*'” or “Name NOT IN ‘Test1’,’Test2′” (parent-child relation referencing and aggregate functions are not usable but complete syntax is here).