<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Deep Blue Day on Medium]]></title>
        <description><![CDATA[Stories by Deep Blue Day on Medium]]></description>
        <link>https://medium.com/@deep_blue_day?source=rss-e14790d469f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qxG_3_wVqXG07yDuxrfRjQ.png</url>
            <title>Stories by Deep Blue Day on Medium</title>
            <link>https://medium.com/@deep_blue_day?source=rss-e14790d469f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 20:42:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deep_blue_day/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fixing AutoMapper runtime errors in Xamarin.Forms iOS]]></title>
            <link>https://medium.com/@deep_blue_day/fixing-automapper-runtime-errors-in-xamarin-forms-ios-13d5634c249e?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d5634c249e</guid>
            <category><![CDATA[automapper]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[xamarin]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Mon, 16 Nov 2020 16:15:01 GMT</pubDate>
            <atom:updated>2020-11-16T16:15:49.181Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Grafitti" src="https://cdn-images-1.medium.com/max/1024/1*Jh6zTr300gBtnvIv7NQO8w.jpeg" /><figcaption>Grafitti — 35mm film</figcaption></figure><p>We recently started using <a href="https://automapper.org/">AutoMapper</a> in one of our Xamarin apps to help translating objects between models/viewmodels. If you don’t know what AutoMapper is, this is their own description:</p><blockquote>AutoMapper is a simple little library built to solve a deceptively complex problem — getting rid of code that mapped one object to another.</blockquote><p>It is the sort of helper library that just makes sense, and helps you get rid of a ton of hard to maintain, error-prone manual code. Using the library itself is easy enough, and you should be well served by the available examples elsewhere.</p><p>So, we set out to use this library in our code. Everything worked nicely in debug mode while in the simulator, but the code suddenly broke when trying to run it in release mode on the device. We would get a rather generic error in AutoMapper such as the below:</p><blockquote>System.ArgumentException: Expression of type ‘System.Int32’ cannot be used for parameter of type ‘System.Object’ of method ‘System.String ToString(System.Object)’ Parameter name: arg0</blockquote><p>Reviewing the AppCenter logs, we could clearly see that the error occured when instantiating the AutoMapper configuration:</p><pre>System.Dynamic.Utils<br>ExpressionUtils.ValidateOneArgument (System.Reflection.MethodBase method, System.Linq.Expressions.ExpressionType nodeKind, System.Linq.Expressions.Expression arguments, System.Reflection.ParameterInfo pi, System.String methodParamName, System.String argumentParamName, System.Int32 index)<br>System.Linq.Expressions<br>Expression.ValidateOneArgument (System.Reflection.MethodBase method, System.Linq.Expressions.ExpressionType nodeKind, System.Linq.Expressions.Expression arg, System.Reflection.ParameterInfo pi, System.String methodParamName, System.String argumentParamName)<br>System.Linq.Expressions<br>Expression.Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0)<br>AutoMapper.Mappers<br>ConvertMapper.ConvertExpression (System.Type sourceType, System.Type destinationType)<br>AutoMapper.Mappers<br>ConvertMapper+&lt;&gt;c__DisplayClass1_1.&lt;GetConverters&gt;b__4 ()<br>System<br>Lazy`1[T].ViaFactory (System.Threading.LazyThreadSafetyMode mode)<br>System<br>Lazy`1[T].CreateValue ()<br>System<br>Lazy`1[T].get_Value ()<br>AutoMapper.Mappers<br>ConvertMapper.MapExpression (AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.ProfileMap profileMap, AutoMapper.IMemberMap memberMap, System.Linq.Expressions.Expression sourceExpression, System.Linq.Expressions.Expression destExpression, System.Linq.Expressions.Expression contextExpression)<br>AutoMapper.Execution<br>ExpressionBuilder.ObjectMapperExpression (AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.ProfileMap profileMap, AutoMapper.TypePair typePair, System.Linq.Expressions.Expression sourceParameter, System.Linq.Expressions.Expression contextParameter, AutoMapper.IMemberMap propertyMap, System.Linq.Expressions.Expression destinationParameter)<br>AutoMapper.Execution<br>ExpressionBuilder.MapExpression (AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.ProfileMap profileMap, AutoMapper.TypePair typePair, System.Linq.Expressions.Expression sourceParameter, System.Linq.Expressions.Expression contextParameter, AutoMapper.IMemberMap propertyMap, System.Linq.Expressions.Expression destinationParameter)<br>AutoMapper.Execution<br>TypeMapPlanBuilder.CreatePropertyMapFunc (AutoMapper.IMemberMap memberMap, System.Linq.Expressions.Expression destination, System.Reflection.MemberInfo destinationMember)<br>AutoMapper.Execution<br>TypeMapPlanBuilder.TryPropertyMap (AutoMapper.PropertyMap propertyMap)<br>AutoMapper.Execution<br>TypeMapPlanBuilder.CreateAssignmentFunc (System.Linq.Expressions.Expression destinationFunc)<br>AutoMapper.Execution<br>TypeMapPlanBuilder.CreateMapperLambda (System.Collections.Generic.HashSet`1[T] typeMapsPath)<br>AutoMapper<br>TypeMap.CreateMapperLambda (AutoMapper.IConfigurationProvider configurationProvider, System.Collections.Generic.HashSet`1[T] typeMapsPath)<br>AutoMapper<br>TypeMap.Seal (AutoMapper.IConfigurationProvider configurationProvider)<br>AutoMapper<br>MapperConfiguration.Seal ()<br>AutoMapper.MapperConfiguration<br>AutoMapper.MapperConfiguration..ctor (AutoMapper.Configuration.MapperConfigurationExpression configurationExpression)<br>AutoMapper.MapperConfiguration<br>AutoMapper.MapperConfiguration..ctor (System.Action`1[T] configure)</pre><p>Upon some research, we found that due to the way the iOS linker works, it strips out System.Convert logic needed by AutoMapper at runtime. More info <a href="https://stackoverflow.com/questions/51096849/xamarin-ios-linker-causing-automapper-issues">here</a>. Good news is, this is fairly easy to fix.</p><p>In your iOS project, create a file named “AutoMapperLinkerFix.xml” (any name will do), and add the below content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40dd24edaee1794fc54725bf489084d2/href">https://medium.com/media/40dd24edaee1794fc54725bf489084d2/href</a></iframe><p>Now, right click on the xml -&gt; Properties. Choose build action “Link Description”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*2puTWtnHcUmdBCvcC_q5LA.png" /></figure><p>After rebuilding and redeploying your app, the error should be gone.</p><p>Happy coding!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FoIIxlgcuQRU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DoIIxlgcuQRU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoIIxlgcuQRU%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cb142904d02c87c49f3a1e289d01a35/href">https://medium.com/media/4cb142904d02c87c49f3a1e289d01a35/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d5634c249e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XAML Compilation and a tale of SIGABRT: Ambiguous match found]]></title>
            <link>https://medium.com/@deep_blue_day/xaml-compilation-and-a-tale-of-sigabrt-ambiguous-match-found-75d3d2d478d9?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/75d3d2d478d9</guid>
            <category><![CDATA[xamarin-forms]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[xamarin]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Fri, 09 Oct 2020 17:07:59 GMT</pubDate>
            <atom:updated>2020-10-09T17:07:59.907Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIuxAHuKO3PB0uIOALa0tQ.jpeg" /><figcaption>Teufelsberg, Berlin — iPhone</figcaption></figure><p>So, in my job we are building a rather complex Xamarin app, that has grown organically over a period of around 18 months. During this period, we have needed to rethink a bit how our code is architected a few times, in order to accommodate for new (and previously unforeseen) business requirements, such as support for multiple backends and data models with the same app.</p><p>After the last code refactor, where we moved quite a few XAML files to a new cs project, we suddenly started getting crashes in a couple of views, only in release mode.</p><p>Something like the below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JV2ECuMijMJ913x0e1vy1g.png" /><figcaption>SIGABRT: Ambiguous match found thrown by RuntimeType.GetPropertyImpl</figcaption></figure><p>After a bit of scratching our heads, reviewing the Microsoft AppCenter logs, doing some googling, and finally replicating the error in the simulator while running Visual Studio, we found out something interesting in the Application Output log:</p><pre>Xamarin.Forms.Xaml.XamlParseException: Position xxx:xx. Multiple properties with name &#39;XXX.XXX.XXX.Core.Views.Templates.XXXTemplate.BackgroundColor&#39; found.</pre><p>The specified template (a reusable ContentView) actually had a “BackgroundColor” property that would hide an inherited member with the same name.</p><p>Now, here’s the catch. If the XAML is not set for compilation, it is actually compiled at run-time, where the system tries to resolve properties of XAML elements via reflection. Since our ContentView template would actually hide the base class “BackgroundColor” property, this caused an ambiguity at runtime that would cause an reflection exception that would crash the app.</p><p>What happened is (and you may have guessed it), when we moved the XAML file to a new project, we did not set the assembly-level XAML compilation option, which would have prevented this from happening.</p><p>When we added the below to Assembly.cs of the new project everything went back to normal.</p><blockquote>using Xamarin.Forms.Xaml;</blockquote><blockquote>[assembly: XamlCompilation(XamlCompilationOptions.Compile)]</blockquote><p>It is a best practice to always set XAML compilation at the assembly level. Do remember that this needs to be done for all projects in your solution that have XAML forms. For official information by Microsoft, read <a href="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xamlc">here</a>. It is also worth noticing that <a href="https://github.com/xamarin/Xamarin.Forms/issues/2632#issuecomment-390591566">this</a> github thread lead me to the answer to the problem.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FU1vGosMScjM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DU1vGosMScjM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FU1vGosMScjM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6eae784a3763dec8cbadb83f1d9bad09/href">https://medium.com/media/6eae784a3763dec8cbadb83f1d9bad09/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75d3d2d478d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create an iOS App Group for Xamarin App]]></title>
            <link>https://medium.com/@deep_blue_day/how-to-create-an-ios-app-group-for-xamarin-app-a117c172b4?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a117c172b4</guid>
            <category><![CDATA[xamarin-forms]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[xamarin]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 18:38:48 GMT</pubDate>
            <atom:updated>2020-06-03T18:38:48.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQQveYNv_wIZUIMTl2HA4g.jpeg" /><figcaption>Teruel, Spain — Sony A7III / Sony-Zeiss EF 24–70 f/4</figcaption></figure><h3>What are iOS App Groups</h3><p>According to <a href="https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_application-groups">Apple</a>:</p><blockquote>App groups allow multiple apps produced by a single development team to access shared containers and communicate using interprocess communication (IPC). Apps may belong to one or more app groups.</blockquote><p>So…when do you need to create App Groups? Probably the most common scenario is to implement Extensions, such as “Share Extension”, “Today Widget” and so on. The container app, and the extension have separate containers. See diagram below (from <a href="https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html">Apple</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*THSaF5ofVGh2I3cx4cLqCQ.png" /></figure><p>In that scenario, the App Group is the mechanism that allows the extension and the container app to have access to a shared file system and shared NSUserDefaults properties.</p><h3>Register an App Group</h3><p>Go to <a href="https://developer.apple.com/account/">apple developer</a>.</p><p>Go to Certificates, Identifiers &amp; Profiles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*45z4blOvVPzKpSP7o_T4sA.png" /></figure><p>Click on Identifiers, then choose App Groups in the dropdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzYx2o3aVLCn0pj0CJqirg.png" /></figure><p>Click on Register an App Group.</p><p>Make sure “App Groups” is selected, click “Continue”.</p><p>The app group will have an identifier, which is typically the Bundle ID with a “group.” prefix. For example, the Bundle ID “com.mycompany.myapp” would have the app group “group.com.mycompany.myapp”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8tc6QcVLWXJ6D4aa34UIQ.png" /></figure><p>Click “Continue” and “Register” in the next screen.</p><p>That’s it. Now you need to configure your app’s App ID accordingly.</p><h3>Configure App ID to enable Groups</h3><p>Go to Certificates, Identifiers &amp; Profiles.</p><p>Click on “Identifiers”, then choose “App IDs” in the dropdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*YEer3MGjyKQICeYJwL7kRg.png" /></figure><p>Check “App Groups” and click “Configure”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*hlmHA81drz8IRv7R8cVQ3Q.png" /></figure><p>Check the group you just created in the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*YHOKU59cyCV2BDpZWLrgqw.png" /></figure><p>Click “Continue”.</p><p>Click “Save”.</p><p>Repeat these steps for any Apps (or Extensions) that will be using the App Group.</p><p>If you already have provisioning profiles for these apps, they become invalid, and you will need to download and install them again.</p><h3>Configure iOS application in Xamarin</h3><h4>Edit “Entitlements.plist” to enable App Group</h4><p>Edit your “Entitlements.plist” file. Easiest way to edit this feature is by choosing “Entitlements” view instead of “Source Code”.</p><p>Check “Enable App Groups”.</p><p>Add your newly created App Group id (“group.com.mycompany.myapp” in the example above).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*luWCzjBqKpaZEWXx7-nNqQ.png" /></figure><h4>Configure Bundle Signing to use the “Entitlements.plist” file</h4><p>Right click on your iOS project, click on “Options”.</p><p>Click on iOS Bundle Signing.</p><p>On “Custom Entitlements”, choose your custom “Entitlements.plist” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*J9h8tL6o6V08TbxFKunahg.png" /></figure><p>Click OK.</p><p>Repeat these steps for any Apps (or Extensions) that will be using the App Group.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYRNJ9GbNULM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYRNJ9GbNULM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYRNJ9GbNULM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/553e8adea0960f3d253bc76a8e848370/href">https://medium.com/media/553e8adea0960f3d253bc76a8e848370/href</a></iframe><h3>References</h3><ul><li><a href="https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/provisioning/capabilities/app-groups-capabilities">App Group Capabilities in Xamarin.iOS - Xamarin</a></li><li><a href="https://medium.com/@timefrancesco/develop-and-deploy-ios8-extensions-with-xamarin-walkthrough-1b059a03e861">Develop and deploy iOS8 extensions with Xamarin — Walkthrough</a></li><li><a href="https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html">Handling Common Scenarios</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a117c172b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Open iOS Xamarin.Forms App with URL Parameters and MvvmCross Navigation]]></title>
            <link>https://medium.com/@deep_blue_day/how-to-open-ios-xamarin-forms-app-with-url-parameters-and-mvvmcross-navigation-fe2a74466492?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe2a74466492</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[xamarin]]></category>
            <category><![CDATA[xamarin-forms]]></category>
            <category><![CDATA[mvvmcross]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Wed, 29 Apr 2020 19:01:57 GMT</pubDate>
            <atom:updated>2020-04-29T19:06:33.823Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADLPgwGQRmbOdjTcZ-eD3Q.jpeg" /><figcaption>San Telmo open Air Market, Buenos Aires — April 2010</figcaption></figure><p>Recently, i had to implement user registration/validation logic in an app.</p><p>The way our team envisioned this would work is as follows:</p><ul><li>User enters email address in app and requests to create a new user.</li><li>App sends this information to a backend user registration service.</li><li>Backend service creates a token, sends validation email to the specified email address.</li><li>This email has a “special” link that when tapped should open our app, passing validation token via URL parameter.</li><li>Our app should automatically open when that “special” link is tapped, should parse the validation token specified in URL parameter, and navigate to a specific ViewModel.</li></ul><p>The above user experience is very similar to how Medium itself handles user registration.</p><p>Our app is built on top of MvvmCross MVVM framework, so we wanted the implementation to play nicely with it, avoiding hacks as much as possible. MvvmCross is a fairly powerful framework, but the <a href="https://www.mvvmcross.com/documentation/fundamentals/navigation">documentation</a> is sometimes lacking. I spent a couple of hours piecing the puzzle together to make this work, and what follows are my findings on how to implement this functionality — i do believe it is a pretty elegant solution.</p><p>Hope this helps other developers!</p><h3>Add MvxNavigation Attribute to ViewModel</h3><p>This is how MvvmCross knows that a certain ViewModel should be navigated based on a specified URL, and which parameters can be passed to it.</p><ul><li>In order for MvvmCross to know that a given ViewModel should be navigated via a specific URL path, you need to supply your routings as assembly attributes.</li><li>Multiple URLs can be added to a given ViewModel.</li><li>MvvmCross recommends putting the MvxNavigation attribute ViewModel file itself. See below.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb54ccc45b75d422a2f7b95f1054b4b1/href">https://medium.com/media/cb54ccc45b75d422a2f7b95f1054b4b1/href</a></iframe><ul><li>In the example above, the url “myapp://test/?id=1234” would navigate to the TestViewModel, passing “1234” as the id parameter.</li></ul><h4>Further Observations</h4><ul><li>The specified url is actually a regular expression, and you can use groups to match named parameters.</li><li>Make sure your regular expression is well formed, and that the URL you will supply is a match. This may sound obvious, but i did spend at least half an hour with my solution wondering why the navigation would not work as i expected when testing. You can use one of the available online regex validation tools such as <a href="http://regexstorm.net/tester">regexstorm</a>.</li><li>In my specific case, i had some Views and ViewModels outside the main shared “Core” library. In that case, adding the Navigation attribute on the ViewModel itself did not work as expected.</li><li>In order to solve that problem, I had to add the MvxNavigation attribute on the AssemblyInfo.cs of the main shared “Core” library.</li></ul><h3>Register URL Scheme in Info.plist</h3><p>This is how the App registers a URL scheme in iOS, so that when the operating system tries to open any such URL, it knows your app is the one to be executed.</p><ul><li>Browse to your iOS project and open (double click) Info.plist.</li><li>Open the “Advanced” tab.</li><li>Look for “URL Types” section.</li><li>Enter your url name and scheme.</li><li>More info by Apple <a href="https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content/defining_a_custom_url_scheme_for_your_app">here</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*o0LNlkZOb1L1u49hLiAUCQ.png" /><figcaption>URL Types in Info.plist</figcaption></figure><p>Note: Apple recommends <a href="https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content">universal links</a> instead of custom URLs as a best practice to launch our apps from the outside world, but that is outside the scope of current article. In any case, most of what is outlined here would still apply in that scenario.</p><h3>Implement HandleOpenUrl in AppDelegate</h3><p>This is the final step. Here we react to the fact that your app was launched by iOS specifying a URL, and we use IMvxNavigationService so that MvvmCross determines which ViewModel should be displayed (passing parameters as well).</p><ul><li>Browse to your iOS project and open (double click) AppDelegate.cs. If everything is set up correctly for MvvmCross, this class should inherit from MvxFormsApplicationDelegate.</li><li>Override HandleOpenUrl method.</li><li>Implement logic to process the specified url as needed and navigate using standard MvvmCross navigation (IMvxNavigationService).</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/762466272bf537031f061cc09faa7223/href">https://medium.com/media/762466272bf537031f061cc09faa7223/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgWO5AjGMbp4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgWO5AjGMbp4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgWO5AjGMbp4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/31bd6c5bec6177d8c27f9acd2d34bf5c/href">https://medium.com/media/31bd6c5bec6177d8c27f9acd2d34bf5c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe2a74466492" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Long Story Short: Performance Tuning .NET Web Applications (ASP.NET/IIS/SQL)]]></title>
            <link>https://medium.com/@deep_blue_day/long-story-short-performance-tuning-net-web-applications-asp-net-iis-sql-4f877b8b80a3?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f877b8b80a3</guid>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[performance-tuning]]></category>
            <category><![CDATA[isis]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Wed, 21 Aug 2019 02:55:41 GMT</pubDate>
            <atom:updated>2019-09-05T18:36:54.378Z</atom:updated>
            <content:encoded><![CDATA[<h3>Long Story Short: Performance Tuning .NET Web Applications (ASP.NET/IIS/SQL)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s8C9JqAQq3L9eowO1yEInQ.jpeg" /><figcaption>Valparaiso, Chile — Fujifilm X-100</figcaption></figure><h3>Introduction</h3><p>Over the years, I have had the opportunity to troubleshoot and fine-tune performance for several customers (large and small) using off-the-shelf commercial ASP.NET web applications (usually not written by me or my team).</p><p>Performance tuning projects can vary from a few days to weeks worth of work of a dedicated team, with several factors coming into play:</p><ul><li>Performance expectations.</li><li>Application complexity.</li><li>Number of components (database server, cache server, web servers, load balancers, etc).</li><li>Ability to access production servers to gather metrics, review logs, etc.</li><li>Ability to tweak or even change application behavior.</li><li>Ability to upgrade hardware or change network components / topology.</li><li>And last, but not least, customer sophistication.</li></ul><p>Irrespective of the size of the problem (and, by extension, the performance tuning project), performance tuning requires a methodical and iterative approach, which we will review at a high level.</p><h3>Performance Tuning Process</h3><h4>Understanding the problem</h4><p>The very first phase is to understand the problem so that there are no ambiguities in terms of what is possibly wrong, what are the expectations (are they realistic?) and, possibly rule out easy to fix issues.</p><p>Effective communication and making the right questions is key. If we make our job right, we will come across as knowledgeable, confident, and professional, which will help establish a trust relationship.</p><p>Possible questions to ask:</p><ul><li>What is the perceived performance problem?</li><li>When did the problem begin?</li><li>Is the problem circumscribed to a particular application area or functionality?</li><li>Is the problem perceived by all users, a subset of them?</li><li>Is there a pattern? Maybe a temporary pattern such as “every close of month” or “every day around noon” or functionality pattern such as “whenever process x is executed”.</li><li>Are there batch jobs, ETL processes, reports interacting with the same data source?</li><li>Have there been environmental changes? Software updates, new security policies, network topology changes.</li><li>Is hardware shared? Think virtualized environments, where different applications may be fighting for the same resources.</li><li>Are there other applications having performance issues as well?</li></ul><h4>Gather Evidence (Logs)</h4><p>Windows Event log, IIS logs, and other application-specific log files can provide extremely valuable contextual information. A very useful tip is to import logs into a database so you can play with data running queries with the full capabilities of the SQL language — this is a great way to find macro-level patterns, perform time-series analysis (by date, by hour, etc), or find outliers (i.e: longest-running HTTP requests or SQL queries).</p><p>In the past, i’ve used the SQL query below to import IIS W3C logs into a table in SQL server:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36e1f0155e545621800f6a99ab96e0ce/href">https://medium.com/media/36e1f0155e545621800f6a99ab96e0ce/href</a></iframe><p>dbo.IIS_W3C_LOGS table follows structure below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/faea3dc9e9d380bca8b46dc03ea51d34/href">https://medium.com/media/faea3dc9e9d380bca8b46dc03ea51d34/href</a></iframe><h4>Measure Baseline Performance</h4><p>Although having the customer perspective first-hand is extremely valuable, we should strive to find objective evidence that backs the perceived issue. It is all too-common for customers or users to have unrealistic or vague perceptions of what performance is, sometimes even confusing performance with application errors or other unrelated environmental issues (slow internet connection from mobile device, for example).</p><p>The purpose here is to have objective metrics that possibly reflect the issue as perceived by the users. As the performance tuning process moves forward, these metrics will allow the team to understand if changes are making a positive effect or not.</p><h4>Elaboration of Hypothesis</h4><p>Based on the information gathered in the previous steps, the team will come up with certain hypothesis, that will be reviewed with the customer to elaborate an action plan. We should prioritize actions that have the highest chance of making a tangible contribution to the problem.</p><p>Looking for patterns and correlations is an extremely valuable tool during this phase. For example, high CPU/Memory usage at the web server level and database server level at the same time may point to database locks.</p><p>See charts below extracted from a real-world scenario — note how IIS Server showed a clear spike in Memory Usage, while at the same time SQL Server showed a spike in CPU Load — this was later correlated to a database lock due to a particularly vicious (generated) SQL query executed in production:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*Xo273Av7PIucL2rGedI2rg.png" /><figcaption>SQL Server CPU Load</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*XpA_o0ssAIyDWGHVooQ6Ng.png" /><figcaption>IIS Memory Usage</figcaption></figure><p>Another similar real-world example below, with a different set of metrics — Also chased down to a DB Lock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*QBuwyutxMdhxXQe0HUlqfQ.png" /><figcaption>IIS Memory Usage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*sCjcqYBGnhKJoA4kcs0KIw.png" /><figcaption>SQL Server Memory Usage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*2FGp9qUdszkuaHc34t-tBg.png" /><figcaption>SQL Server Physical Disks Throughput</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*X0_FViCV4DIwENWV0QAIXA.png" /><figcaption>SQL Server Physical Disks Queue Length</figcaption></figure><h4>Make a Change</h4><p>It is very important to make one change at a time. This is the only way we can tell if a given measure is having the expected outcome. A change can be as simple as a tweak in a config file or more involved such as upgrading hardware on a SQL server, or fixing a particularly bad-performing code section or functionality.</p><h4>Measure Performance After Change</h4><p>After a change has been made, we need to test our hypotesis, and see if we have moved forward or not. We should gather the same metrics that we gathered for our baseline performance, for an equivalent period.</p><h4>Evaluate Results</h4><p>Once we have measured performance after the change, we need to evaluate key metrics we set out to improve and see if there was a positive change, while at the same time ensuring we have not made other metrics worse — remember that often times performance tuning is a balancing act. If we have reached our goals, the problem is resolved. If not, we need to go back to the Elaboration of Hypothesis phase, and repeat the process.</p><h3>Perfomance Monitor — Key Performance Metrics</h3><p>Having outlined a high-level performance tuning process, we will now review some key performance metrics you should consider for IIS, SQL Server.</p><h4>Memory \ Pages/Sec</h4><ul><li>This is the rate at which pages are read from or written to disk to resolve hard page faults. This counter is a primary indicator of the kinds of faults that cause system-wide delays.</li><li>Recommended value: Around 20.</li><li>Unhealthy if greater than 80; probably indicates not enough RAM.</li></ul><h4>Memory \ Available MBytes</h4><ul><li>This is the amount of physical memory immediately available for allocation to a process, or for system use.</li><li>Recommended value: At least 10% of physical memory. Ideally, 50% of physical memory.</li><li>SQL Server will try to consume as much memory as possible. Anything less than 10% of physical memory indicates memory pressure on the server.</li></ul><h4>Processor \ % Processor Time</h4><ul><li>This is the percentage of elapsed time the processor spends on a non-Idle thread.</li><li>Recommended value: Less than 75%. Normally, between 20% and 40%</li></ul><h4>Processor \ % Privileged Time</h4><ul><li>Indicates the time spent on Windows kernel commands (Disk I/O requests, Memory, Network).</li><li>Recommended value: As a rule of thumb, less than 30%.</li><li>If both this and Physical Disk counters are high, there might be a need for a faster disk or lower load for this server.</li></ul><h4>System \ Processor Queue Length</h4><ul><li>This is the number of threads waiting for processor time when the server’s processors are busy servicing other threads.</li><li>Recommended value: Same as number of processors or less.</li><li>A sustained or recurring queue of more threads than number of processors is a good indication of a processor bottleneck.</li></ul><h4>Physical Disk \ % Disk Time</h4><ul><li>This counter is a general mark of how busy the physical/logical disk is.</li><li>Recommended value: As low as possible. In healthy systems remains a low %, with occasional (infrequent) spikes.</li><li>If you’ve captured the perfmon for a long period (a few hours or a complete business day), and you see the %Disk Time to be greater than 80%, it’s generally indicative of a disk bottleneck, and you should take a closer look at the other counters to arrive at a logical conclusion.</li></ul><h4>Physical Disk/Logical Disk \ Avg. Disk Sec/Read &amp; Physical Disk/Logical Disk \ Avg. Disk Sec/Write</h4><ul><li>These two counters tell you how quickly your I/O subsystem is responding to requests for data from the operating system; in other words, latency.</li><li>Recommended value: An average of less than 10 ms (0.010) is good, and between 10–15 ms (0.010–0.015) is acceptable, but anything beyond 15 ms (0.015) is a cause for concern.</li></ul><h4>Memory Manager \ Target Server Memory (KB)</h4><ul><li>Indicates how much memory SQL Server “wants”.</li><li>Recommended value: The same as SQL Server: Memory Manager — Total Server Memory. Less than memory installed in the system.</li><li>If this is the same as the “SQL Server \ Memory Manager — Total Server Memory (KB)” counter, then you know SQL Server has all the memory it needs.</li><li>SQL-Server specific.</li></ul><h4>Memory Manager \ Total Server Memory (KB)</h4><ul><li>Recommended value: No less than “Memory Manager \ Target Server Memory” (KB).</li><li>If this is the same as SQL Server \ Memory Manager — Target Server Memory (KB), then SQL Server has all the memory it wants. If smaller, then SQL Server could benefit from more memory.</li><li>SQL-Server specific.</li></ul><h3>Perfomance Monitor — Best Practices</h3><ul><li>It is recommended to clear event log before beginning monitoring sessions (save to a file).</li><li>Launch “Performance Monitor”.</li><li>Unless otherwise stated, make sure you monitor “(_Total)” not a particular instance of the resource being monitored.</li><li>Make sure the duration is the amount of total time you need to plot the chart for. For example, 8 hours = 28800 seconds</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*2UjZTwCnEiPW9Lmh" /></figure><ul><li>Consider the recommended sample interval based on the total duration of your monitoring session. See table below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/0*wwqMId-IJ4OoineW" /></figure><ul><li>In web servers, it is also recommened to run “Process Explorer”. This tool will allow you to get specific information regarding w3wp.exe processes.</li><li>Utilize the below command to get the process id of your application pools:<br>“%windir%\system32\inetsrv\appcmd.exe” list wp</li></ul><h3>References</h3><p><a href="https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/7898b860-462c-4846-a3a8-1179f287ad88.mspx?mfr=true">https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/7898b860-462c-4846-a3a8-1179f287ad88.mspx?mfr=true</a></p><p><a href="https://support.microsoft.com/en-us/help/313064/how-to-monitor-web-server-performance-by-using-counter-logs-in-system-monitor-in-iis">https://support.microsoft.com/en-us/help/313064/how-to-monitor-web-server-performance-by-using-counter-logs-in-system-monitor-in-iis</a></p><p><a href="https://blog.serverdensity.com/monitor-iis/">https://blog.serverdensity.com/monitor-iis/</a></p><p><a href="http://www.sqlserverfaq.net/2011/01/31/what-perfmon-counters-should-i-monitor-and-what-each-of-them-mean/">http://www.sqlserverfaq.net/2011/01/31/what-perfmon-counters-should-i-monitor-and-what-each-of-them-mean/</a></p><p><a href="https://blogs.msdn.microsoft.com/sqljourney/2013/06/03/how-to-troubleshooting-sql-server-io-bottlenecks/">https://blogs.msdn.microsoft.com/sqljourney/2013/06/03/how-to-troubleshooting-sql-server-io-bottlenecks/</a></p><p><a href="https://blogs.technet.microsoft.com/yongrhee/2011/11/13/how-often-should-perfmon-sample/">https://blogs.technet.microsoft.com/yongrhee/2011/11/13/how-often-should-perfmon-sample/</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjQvUBf5l7Vw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjQvUBf5l7Vw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjQvUBf5l7Vw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9e48bcf19163bc5bc4ed0483cef1de9/href">https://medium.com/media/c9e48bcf19163bc5bc4ed0483cef1de9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f877b8b80a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Subdomain in Amazon Route 53]]></title>
            <link>https://medium.com/@deep_blue_day/how-to-create-a-subdomain-in-amazon-route-53-81918654f5bf?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/81918654f5bf</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Thu, 25 Apr 2019 00:30:50 GMT</pubDate>
            <atom:updated>2019-04-25T00:30:50.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Le-csucbwvr4i3TOi1b9Xw.jpeg" /><figcaption>Andes Mountain Range, Bolivia</figcaption></figure><p>This quick article assumes that you already have your parent domain hosted in Route 53, and that you want to create a subdomain for it.</p><ul><li>Log in to AWS Console.</li><li>Click Services, and search for “Route 53”.</li><li>Click on “Hosted zones”.</li><li>Click on “Create Hosted Zone”.</li><li>Fill in the hosted zone details. In “Domain Name” make sure to enter the name of the subdomain. Make sure Type is “Public Hosted Zone”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*xZ-woUEoSpmUU6J6t3QMvg.png" /></figure><ul><li>Click “Create”.</li><li>You will be redirected to the hosted zone for the subdomain.</li><li>Click on the NS record for the subdomain. Copy the values of the NS servers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fI0U7TvN6mAmMo0Zp2xRcw.png" /></figure><ul><li>Go back to “Hosted zones” and locate the hosted zone for the parent domain.</li><li>Click on “Create Record Set”. Set Type as “NS”. Paste the name servers that were copied in a previous step.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*UUDSzkvXElrADLHCYUooLA.png" /></figure><ul><li>Click “Create”.</li><li>You’re all set!</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVEAuMiKqP-4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVEAuMiKqP-4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVEAuMiKqP-4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3da940d3df167bcaba1a9013838e1e4b/href">https://medium.com/media/3da940d3df167bcaba1a9013838e1e4b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81918654f5bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Long Story Short: Async/Await Best Practices in .NET]]></title>
            <link>https://medium.com/@deep_blue_day/long-story-short-async-await-best-practices-in-net-1f39d7d84050?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f39d7d84050</guid>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[asyncawait]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Fri, 19 Apr 2019 04:26:22 GMT</pubDate>
            <atom:updated>2019-04-19T04:30:48.167Z</atom:updated>
            <content:encoded><![CDATA[<h3>Long Story Short: Async/Await Best Practices in .NET</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zywx7fcixOl4lidtC7QumA.jpeg" /><figcaption>Kabukichō (歌舞伎町), Tokyo — Ricoh GR</figcaption></figure><h3>Async/Await — Introduction</h3><p>Async/Await has been around since C# version 5.0 (2012) and has quickly become one of the pillars of modern .NET programming — any C# developer worth his/her salt should be using it to improve application performance, overall responsiveness, and code legibility.</p><p>Async/Await makes deceptively simple to implement asynchronous code, and removes the programmer from having to deal with the details of handling asynchronous code, but how many of us really know how it works underneath and what are the do’s and don’ts of this technique? There’s a lot of great information out there, but quite scattered, hence this article.</p><p>Let’s deep dive into it.</p><h4>The state machine (IAsyncStateMachine)</h4><p>The first thing to know is that, behind the scenes, every time you have a method or function with Async/Await, the compiler actually turns your method into a generated class that implements the IAsyncStateMachine interface. This class is responsible for keeping the state of your method during the life cycle of the asynchronous operation — it encapsulates all the variables of your method as fields and splits your code into sections that are executed as the state machine transitions between states so that the thread can leave the method, and when it comes back, the state is intact.</p><p>As an example, here is a very simple definition of a class with two async methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54cf1f512d398cb841d901d959b4df30/href">https://medium.com/media/54cf1f512d398cb841d901d959b4df30/href</a></iframe><p>If we examine the code generated upon build, we will see something like the below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*1jdeZpPuyFlwXnidbLRPQA.png" /></figure><p>Note that we have 2 new internal classes generated for us, one for each async method. These classes hold the state machine for each of our async methods.</p><p>Further examining the decompiled code for &lt;AsyncAwaitExample&gt;d__0, we will notice that our internal variable “myVariable” is now a class level field:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*ZQ6gmitlS-CH3rImTKSxOg.png" /></figure><p>We can also see other class-level fields used internally to maintain the state of the IAsyncStateMachine. The state machine transitions through states via the MoveNext() method, basically a big switch. Note how the continuation after each of the async calls occurs in different sections (preceded by a label).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*zi0fA9CAEMgJEUpfY1d-9A.png" /></figure><p>What this means is that the elegance of async/await comes at a price. Using async/await actually adds a bit of complexity (that you may not be aware). In server-side logic, this may not be critical, but particularly when programming mobile apps, where every CPU cycle and kb of memory counts, you should keep this in mind, as the amount of overhead can quickly add up. We’ll discuss later on this article best practices to only use Async/Await where needed.</p><p>For a fairly didactical explanation of the state machine, check this <a href="https://www.youtube.com/watch?v=My2gAv5Vrkk">youtube video</a> by the On.NET show.</p><h4>When to use Async/Await</h4><p>There are basically two scenarios where Async/Await is the right solution.</p><ul><li><strong>I/O-bound work:</strong> Your code will be waiting for something, such as data from a database, reading a file, a call to a web service. In this case you should use Async/Await, but not use the Task Parallel Library.</li><li><strong>CPU-bound work:</strong> Your code will be performing a complex computation. In this case, you should use Async/Await but spawn the work off on another thread using Task.Run. You may also consider using the <a href="https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/task-parallel-library-tpl">Task Parallel Library</a>.</li></ul><h3>Async all the way</h3><p>As you start working with async methods, you will quickly realize that the asynchronous nature of the code starts spreading up and down your hierarchy of method calls — meaning, you need to make your invoking code asynchronous as well and so on.</p><p>You may be tempted to “stop” this by blocking in your code using Task.Result or Task.Wait, converting just a small part of the application and wrapping it in a synchronous API so the rest of the application is isolated from the changes. Unfortunately, this is a recipe for creating hard to track deadlocks.</p><p>The best solution to this problem is to allow async code to grow naturally through the codebase. If you follow this solution, you’ll see async code expand to its entry point, usually an event handler or controller action. Embrace async all the way!</p><p>More information in <a href="https://msdn.microsoft.com/en-us/magazine/jj991977.aspx?f=255&amp;MSPPError=-2147217396">this article</a> by MSDN.</p><h3>If a method is declared async, make sure there is an await!</h3><p>As we already discussed, when the compiler finds an async method, it turns the method into a State Machine. If your code does not have an await in its body, the compiler will generate a warning but the state machine will be created nevertheless, adding unnecessary overhead for an operation that will actually never yield.</p><h3>Avoid…async void</h3><p>Async void is a big no-no. As a rule of thumb consider using async Task instead of async void.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16a9d60866e610b90aa0ad0591d1f2fc/href">https://medium.com/media/16a9d60866e610b90aa0ad0591d1f2fc/href</a></iframe><p>There are several reasons for this, including:</p><ul><li><strong>Exceptions thrown in an async void method can’t be caught outside of that method:</strong> When an exception is thrown out of an async Task or async Task&lt;T&gt; method, that exception is captured and placed on the Task object. With async void methods, there is no Task object, so any exceptions thrown out of an async void method will be raised directly on the SynchronizationContext that was active when the async void method started.</li></ul><p>Consider the example below. The catch block will never be reached.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f2138e58709495ef80dd74cc3687a02/href">https://medium.com/media/5f2138e58709495ef80dd74cc3687a02/href</a></iframe><p>Compare to this code where instead of async void we have an async Task. In this case, the catch is actually reached.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78632c1fdda10bf3ebf235b57b2b8b92/href">https://medium.com/media/78632c1fdda10bf3ebf235b57b2b8b92/href</a></iframe><ul><li><strong>async void methods can cause bad side effects if the caller isn’t expecting them to be async:</strong> If your asynchronous method returns nothing, use async Task (without “&lt;T&gt;” for the Task) as the return type.</li><li><strong>Async void methods are very difficult to test: </strong>Because of the differences in error handling and composing, it’s difficult to write unit tests that call async void methods. The MSTest asynchronous testing support only works for async methods returning Task or Task&lt;T&gt;.</li></ul><p>The exception to this best practice is asynchronous event handlers. Even in this case, it is recommended that you minimize the code written in the handler itself — await an async Task method that contains the actual logic.</p><p>More information in <a href="https://msdn.microsoft.com/en-us/magazine/jj991977.aspx?f=255&amp;MSPPError=-2147217396">this article</a> by MSDN.</p><h3>Consider using return Task instead of return await</h3><p>As it was already discussed, every time you declare a method as async, the compiler to create a State Machine class that actually wraps your method logic. This adds a certain amount of overhead that may add up, particularly for mobile devices, where we have stricter resource constraints.</p><p>Sometimes the method does not need to be async, but return a Task&lt;T&gt; and let the other side handle it as appropriate. If the last sentence of your code is a return await you may actually consider refactoring it so that the return type of the method is Task&lt;T&gt; (instead of async T). With this, you are avoiding the generation of the state machine, thus making your code leaner. The only time we truly want to await is when we do something with the result of the async task in the continuation of the method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b49689e804d59e94ced78fdba83dbcc8/href">https://medium.com/media/b49689e804d59e94ced78fdba83dbcc8/href</a></iframe><p>Note that if we don’t have return await, but return a Task&lt;T&gt; instead, the return happens right away, so, if the code is inside a try/catch block, the exception will not be caught. Similarly, if the code is inside a using block, it will dispose the object right away. See next best practice.</p><h3>Do not wrap return Task inside try..catch{} or using{} block</h3><p>Return Task can cause unexpected behavior used inside a try..catch block (an exception thrown by the async method will never be caught) or inside a using block because the task will be returned right away.</p><p>If you need to wrap your async code in a try..catch or using block, use return await instead.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dc14aff50addecdafc95cf4f9716cdb/href">https://medium.com/media/8dc14aff50addecdafc95cf4f9716cdb/href</a></iframe><p>More information in <a href="https://stackoverflow.com/questions/19098143/what-is-the-purpose-of-return-await-in-c">this</a> stack overflow thread.</p><h3>Avoid using .Wait() or .Result — Use GetAwaiter().GetResult() instead</h3><p>If you <em>have to block </em>waiting the completion of an Async Task, use GetAwaiter().GetResult(). Wait and Result will wrap any exceptions within an AggregateException, which complicates error handling — The advantage of GetAwaiter().GetResult() is that it returns a normal exception instead of an AggregateException.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/239223bc4745c76cfeea6242244ef5e3/href">https://medium.com/media/239223bc4745c76cfeea6242244ef5e3/href</a></iframe><p>More information in this <a href="https://blog.stephencleary.com/2014/12/a-tour-of-task-part-6-results.html">link</a>.</p><h3>If a method is async, add the Async suffix to its name</h3><p>This is the convention used in .NET to more-easily differentiate synchronous and asynchronous methods (except event handlers or web controller methods, but those should not be explicitly called by your code anyway).</p><h3>Async library methods should consider using Task.ConfigureAwait(false) to boost performance</h3><p>.NET framework has the notion of “synchronization context”, which represents a way to “get back to where you were before” — Whenever a Task is awaited, it captures current synchronization context before awaiting.</p><p>Upon Task completion, the .Post() method of synchronization context is invoked to resume where it was before. This is useful to get back to UI thread or to resume back to same ASP.NET context, etc.</p><p>When writing library code though, you rarely need to go back to the context where you were before. When Task.ConfigureAwait(false) is used, the code no longer tries to resume where it was before, instead, if possible, the code completes in the thread that completed the task, thus avoiding a context switch. This slightly boosts performance and can help avoid deadlocks as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/976ef873e1092ab6a957ecc281066c33/href">https://medium.com/media/976ef873e1092ab6a957ecc281066c33/href</a></iframe><p>This is particularly important when the library method is called a large number of times, to have better responsiveness.</p><p>As a rule of thumb use ConfigureAwait(false) for server-side processes in general. We don’t care which thread is used for the continuation, as opposed to applications where we need to come back to UI thread.</p><p>Now…In ASP.NET Core, Microsoft did away with the SynchronizationContext, so in theory, you don’t need this. But, if you are writing library code that could be potentially reused in other applications (i.e: UI App, Legacy ASP.NET, Xamarin Forms), it <a href="http://blog.stephencleary.com/2017/03/aspnetcore-synchronization-context.html">remains a best practice</a>.</p><p>For a good explanation on this concept, see <a href="https://channel9.msdn.com/Series/Three-Essential-Tips-for-Async/Async-library-methods-should-consider-using-Task-ConfigureAwait-false-">this video</a> by Channel 9.</p><h3>Reporting progress from async Tasks</h3><p>A fairly common use-case for async methods is to do work in the background, freeing up the UI thread to do other things, and maintain responsiveness. In this scenario, you may want to report progress back to the UI, so the user can follow the progress and interact with the operation.</p><p>In order to solve this common problem, .NET provides the IProgress&lt;T&gt; interface, which exposes a Report&lt;T&gt; method, which the async task invokes to report progress back to the caller. This interface is received as a parameter of the async method — the caller must provide an object that implements this interface.</p><p>.NET provides Progress&lt;T&gt;, a default implementation of IProgress&lt;T&gt;, which is actually encouraged to be used, as it handles all the low-level logic related to saving and restoring the synchronization context. Progress&lt;T&gt; also exposes an event and an Action&lt;T&gt; callback — both are called when the task reports progress.</p><p>Together, IProgress&lt;T&gt; and Progress&lt;T&gt; provide an easy way to pass progress information from a background task to the UI thread.</p><p>Note that &lt;T&gt; can be a simple value such as an int, or an object that provides contextual information about the progress, such as progress percentage, a string description of the current operation, ETA, and so on.</p><p>Do consider how often you report progress. Depending on the operation at hand, you may find that your code reports progress several times per second, which may actually cause the UI to become less responsive. In this kind of scenario, it is recommended to report progress back in coarser-grained intervals.</p><p>More information in <a href="https://devblogs.microsoft.com/dotnet/async-in-4-5-enabling-progress-and-cancellation-in-async-apis/">this article</a> by official Microsoft .NET Blog.</p><h3>Cancelling async Tasks</h3><p>Another common use-case for background tasks, is having the ability to cancel execution. .NET provides the CancellationToken class. The async method receives a CancellationToken, which is then shared by the caller code, and the async method, thus providing a mechanism to signal cancellation.</p><p>In the most common case, cancellation follows this flow:</p><ol><li>The caller creates a CancellationTokenSource object.</li><li>The caller calls a cancelable async API, and passes the CancellationToken from the CancellationTokenSource (CancellationTokenSource.Token).</li><li>The caller requests cancellation using the CancellationTokenSource object (CancellationTokenSource.Cancel()).</li><li>The task acknowledges the cancellation and cancels itself, typically using the CancellationToken.ThrowIfCancellationRequested method.</li></ol><p>Note that in order for this mechanism to work, you will need to write code to check for the cancellation being requested at regular intervals (i.e: on every iteration of your code, or at natural stopping point in the logic). Ideally, once cancellation has been requested, an async Task should cancel as quickly as possible.</p><p>You should consider using cancellation for all methods that may take a long time to complete.</p><p>More information in <a href="https://devblogs.microsoft.com/dotnet/async-in-4-5-enabling-progress-and-cancellation-in-async-apis/">this article</a> by official Microsoft .NET Blog.</p><h3>Reporting progress and cancellation — An example</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4eb91e74d0097b5518cee6eec62af9f2/href">https://medium.com/media/4eb91e74d0097b5518cee6eec62af9f2/href</a></iframe><h3>Waiting a period of time</h3><p>If you need to wait for a period of time (for example, to retry to check if a resource becomes available), make sure to use Task.Delay — never use Thread.Sleep in this scenario.</p><h3>Awaiting the completion of multiple async Tasks</h3><p>Use Task.WaitAny to wait for any task to complete. Use Task.WaitAll to wait for all tasks to complete.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fe8Uhf3gM1m0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3De8Uhf3gM1m0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fe8Uhf3gM1m0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b002bd3a9cdae3467cfbc1eb0b4655af/href">https://medium.com/media/b002bd3a9cdae3467cfbc1eb0b4655af/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f39d7d84050" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Limitations of CouchbaseLite 2.1]]></title>
            <link>https://medium.com/@deep_blue_day/limitations-of-couchbaselite-2-1-6a9d78c02cb5?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a9d78c02cb5</guid>
            <category><![CDATA[couchbase-lite]]></category>
            <category><![CDATA[couchbase]]></category>
            <category><![CDATA[couchbase-mobile]]></category>
            <category><![CDATA[nosql]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 01:58:21 GMT</pubDate>
            <atom:updated>2019-04-19T04:34:09.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZK-s52-9-witMdu-8PmRQ.jpeg" /><figcaption>Street Musician in New York — Leica X Vario</figcaption></figure><p>So, at my company, we’ve spent a respectable amount of time implementing a proof-of-concept using Couchbase Mobile for a Mobile application that should support offline capabilities and two-way data synchronization/conflict resolution. This proof-of-concept covers both the Mobile application itself as well as backend components that bridge the gap between Couchbase and other Enterprise applications.</p><p>We made a certain level of commitment to Couchbase upfront, as it seemed to check all the right boxes feature-wise, based on research done in the discovery phase of the project.</p><p>Now, when the rubber meets the road…things happen. I guess that’s the whole point of a technical proof of concept, right? I suppose we just were not expecting to find that many <em>gotchas</em> so quickly.</p><p>Here are some limitations we found — Couchbase Lite 2.1 in .NET Core:</p><ul><li>No support for LINQ. This is a bit of a bummer because LINQ allows us to implement clean, easy to understand code. In Couchbase Lite 2, querying is done using a QueryBuilder object, which is quite a bit more cumbersome and hard to read than a LINQ expression. See <a href="https://github.com/couchbase/couchbase-lite-net/wiki/LINQ-v2">here</a>.</li><li>No custom conflict resolution. This was a feature of Couchbase Lite 1.x, which was removed from Couchbase Lite 2. See <a href="https://blog.couchbase.com/document-conflicts-couchbase-mobile/">here</a>, <a href="https://docs.couchbase.com/couchbase-lite/2.1/csharp.html#handling-conflicts">here</a>, <a href="https://forums.couchbase.com/t/custom-conflict-resolution-in-couchbase-lite-2-x/19092/12">here</a> and <a href="https://forums.couchbase.com/t/synchronization-with-integer-values/19798/4">here</a>. Depending on your use case this may or may not be a big deal.</li><li>No support for geospatial queries. Although you can work around this with some algebra, I would tend to think that a database geared towards mobility should make this functionality a core feature. These days users expect to be able to see contextually-aware information based on current location. What’s even more frustrating is that this functionality was supported to an extent in Couchbase Lite 1.x. See <a href="https://forums.couchbase.com/t/are-geospatial-queries-supported-on-couchbase-lite/17082">here</a>.</li><li>No support for DateTime. The workaround is to use DateTimeOffset, so an extra conversion step is required. See <a href="https://forums.couchbase.com/t/couchbase-lite-2-0-db21-supported-types/15753">here</a>.</li><li>No Int16 support. The workaround is to use Int32.</li><li>No decimal support?</li></ul><p>Are these limitations deal breakers? You be the judge.</p><p>In our case, we are still moving forward, as the functionality as-is appears to cover the 80/20 of what we need (the complexity of sync in particular), but, will we find other, less obvious problems or limitations down the road?</p><p>Stay tuned.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FftjEcrrf7r0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DftjEcrrf7r0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FftjEcrrf7r0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/21c9a55c46c9e3fe63358d447f3dc213/href">https://medium.com/media/21c9a55c46c9e3fe63358d447f3dc213/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a9d78c02cb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to host multiple redis instances in Windows]]></title>
            <link>https://medium.com/@deep_blue_day/how-to-host-multiple-redis-instances-in-windows-5985c8f78b6f?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5985c8f78b6f</guid>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[cache]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Wed, 13 Mar 2019 18:52:13 GMT</pubDate>
            <atom:updated>2019-04-19T04:34:35.337Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to host multiple Redis instances in Windows</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZS-T0LMeJ5L2-8ftY2YNg.jpeg" /><figcaption>South Beach, Miami — Fujifilm X100</figcaption></figure><p>Ok, don’t ask why, but recently I had to configure multiple independent Redis instances in the same Windows box. Fortunately, it’s not hard to do.</p><p>Here’s the detailed procedure.</p><ul><li>In windows explorer, browse to C:\Program Files\Redis.</li><li>Copy redis.windows-service.conf to a new file. Recommended: Use port number as suffix for the file name, like “redis.windows-service_XXXX.conf”, where XXXX is the port number for the new instance.</li><li>Edit file in a text editor (run as administrator).</li><li>Change “port” parameter to a new value.</li><li>Change “logfile” parameter to a new value. Recommended: Use port number as suffix for the file name, like “Logs/redis_log_<strong>XXXX</strong>.txt”, where XXXX is the port number for the new instance.</li><li>You may need to change “syslog-ident” parameter as well.</li><li>Save file.</li><li>Open command line as administrator.</li><li>Change directory to C:\Program Files\Redis.</li><li>Run the below command line to create a new service instance. Customize the service name, display name, and conf file path to match your configuration (in bold below), where XXXX is the port number for the new instance.</li></ul><pre>sc create <strong>Redis_XXXX</strong> obj= “NT AUTHORITY\NetworkService” start= auto DisplayName= “<strong>Redis XXXX</strong>” binPath= “\”C:\Program Files\Redis\redis-server.exe\” — service-run \”C:\Program Files\Redis\redis.windows-service_<strong>XXXX</strong>.conf\”</pre><ul><li>Open services app.</li><li>You should now see a new service, with the display name used above.</li><li>Make sure the service is set to startup automatically.</li><li>Start the service. Make sure it starts without any errors.</li></ul><p>Easy peasy, right?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQ4-jOuHO-z4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQ4-jOuHO-z4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQ4-jOuHO-z4%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a443ad64dc981725d4f5744e1606bae1/href">https://medium.com/media/a443ad64dc981725d4f5744e1606bae1/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5985c8f78b6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to read Multipart MIME data from HttpResponseMessage in .NET Standard]]></title>
            <link>https://medium.com/@deep_blue_day/how-to-read-multipart-mime-data-from-httpresponsemessage-in-net-standard-9664904a7ca9?source=rss-e14790d469f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9664904a7ca9</guid>
            <category><![CDATA[nuget-package]]></category>
            <category><![CDATA[multipart]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[netstandard]]></category>
            <category><![CDATA[mime]]></category>
            <dc:creator><![CDATA[Deep Blue Day]]></dc:creator>
            <pubDate>Thu, 07 Mar 2019 19:07:24 GMT</pubDate>
            <atom:updated>2019-04-19T04:35:05.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to read Multipart MIME data from HttpResponseMessage in .NET Standard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsZ7NJIUN_yIodBCy5Juhg.jpeg" /><figcaption>35mm Expired Film — Ricoh GR</figcaption></figure><p>I am working on a .NET Standard library to act as a wrapper for a third party REST API.</p><p>Why .NET Standard? Because I want this library to be reusable across all .NET platforms (.NET Core, .NET Framework, Xamarin, etc), which means we can use the exact same code either on Mobile devices, Windows services, AWS Lambda functions, etc. More info on .NET Standard <a href="https://weblog.west-wind.com/posts/2016/nov/23/net-standard-20-making-sense-of-net-again">here</a>.</p><p>Circling back to the problem at hand. There is one particular API call that is used to bulk retrieve multiple documents in one request. This request returns any number of documents, as individual bodies in a MIME multipart response. Each enclosed body contains one requested document.</p><p>The response of this API call looks something like the below:</p><pre>--ba2576699d9e3222340bd07aa7d345d37c40210046d1a78e592efd6ef9c6<br>Content-Type: application/json</pre><pre>{\&quot;Date\&quot;:\&quot;2019-03-07T15:39:03\&quot;,\&quot;CUID\&quot;:\&quot;U000000000001\&quot;,\&quot;MUID\&quot;:\&quot;U000000000001\&quot;,\&quot;_id\&quot;:\&quot;c9b20265-86e3-4f24-917d-74081a3b5496\&quot;,\&quot;_rev\&quot;:\&quot;1-53f680ef3d2a5b488c5b5f1c091e111a\&quot;}<br>--ba2576699d9e3222340bd07aa7d345d37c40210046d1a78e592efd6ef9c6<br>Content-Type: application/json</pre><pre>{\&quot;Date\&quot;:\&quot;2019-03-06T17:36:22\&quot;,\&quot;CUID\&quot;:\&quot;UP000X0000005\&quot;,\&quot;MUID\&quot;:\&quot;UX00000001003\&quot;,\&quot;_id\&quot;:\&quot;95361bea-1111-45aa-86c9-f37540911945\&quot;,\&quot;_rev\&quot;:\&quot;1-551940e668d5c1ad3ef945a28a26b91b\&quot;}<br>--ba2576699d9e3222340bd07aa7d345d37c40210046d1a78e592efd6ef9c6--</pre><p>This is the code I used to successfully read this response, and deserialize each of the JSON documents (simplified for readability):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/232bdff798d4755babcd3d592781d9f6/href">https://medium.com/media/232bdff798d4755babcd3d592781d9f6/href</a></iframe><p>Now, here’s the catch. In order for ReadAsMultipartAsync() to be available, you will need to install NuGet package <a href="https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Client/">Microsoft.AspNet.WebApi.Client</a>.</p><p>This is a bit confusing because it seems the extensions that define ReadAsMultipartAsync were defined in System.Net.Http.Formatting package at some point, and that package was later replaced by Microsoft.AspNet.WebApi.Client. Worse, there a few clones of the old package floating around NuGet, so you may inadvertently end up using code which is no longer maintained. Watch out!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXcS8vGFvU6M%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXcS8vGFvU6M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FXcS8vGFvU6M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/42e970483695c2e889ef0cf587863311/href">https://medium.com/media/42e970483695c2e889ef0cf587863311/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9664904a7ca9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>