| Name | Description | Exceptions |
|---|---|---|
| Avoid async void | Prefer async Task methods over async void methods | Event handlers |
| Async all the way | Don't mix blocking and async code | Console main method |
| Configure context | Use ConfigureAwait(false) when you can |
Methods that require context |
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
| var ips = new[] { "95e6:a11d:a55b:43f3:8bd0:a45e:cb82:fa4b", "::1", "2041:0000:140F::875B:131B", "2041:0:140F::875B:131B" }; | |
| foreach (var ipString in ips) | |
| { | |
| var ip = IPAddress.Parse(ipString); | |
| //NOTE: MapToIPv6() is only needed when we parsed IPv4 as a source. 127.0.0.1 will become ::ffff:127.0.0.1 | |
| var bytes = ip.MapToIPv6().GetAddressBytes(); | |
| var guid = new Guid(bytes); | |
| var ipBack = new IPAddress(guid.ToByteArray()); | |
| //NOTE 2: Due to Microsoft using different byte order vs rest of the world, GUID will look different as string vs IPv6 as string. See https://stackoverflow.com/questions/9195551/why-does-guid-tobytearray-order-the-bytes-the-way-it-does |
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
| /// <summary> | |
| /// SQL metadata helper. Needed mostly because SQL SqlMetaData class is rather badly designed. | |
| /// </summary> | |
| public static class SqlMetaDataHelper | |
| { | |
| /// <summary> | |
| /// Return SqlMetaData for specific DB type. | |
| /// For variable-length fields such as VarChar length -1 is the default (maximum supported), so specify the proper length. | |
| /// </summary> | |
| public static SqlMetaData Create(string name, SqlDbType sqlDbType, int length = -1) |
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
| internal static class SqlTypeHelper | |
| { | |
| private static readonly Dictionary<Type, SqlDbType> SqlDbTypes; | |
| static SqlTypeHelper() | |
| { | |
| //https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings | |
| SqlDbTypes = new Dictionary<Type, SqlDbType> | |
| { |
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
| REM This batch file will test all of the common archive formats | |
| REM (zip, rar, 7z, gz) and .epub books (epub is just HTML inside zip container) | |
| REM using 7zip (free and open source, get it from https://www.7-zip.org) | |
| REM All bad archives are moved to "c:\BadArchives" by default, | |
| REM and the directory is created if it doesn't exist. | |
| REM Change the directory name as wanted (in two places) | |
| REM and path to 7z.exe if it isn't in the default folder. | |
| REM Password-protected files are considered to be invalid as well. | |
| MKDIR "c:\BadArchives" |
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
| # EditorConfig - http://EditorConfig.org. This file comes from Roslyn - https://github.com/dotnet/roslyn/blob/master/.editorconfig, edited | |
| # top-most EditorConfig file | |
| root = true | |
| # Use tabs for indentation. | |
| [*] | |
| indent_style = tab | |
| trim_trailing_whitespace = true | |
| end_of_line = crlf |