{"id":527,"date":"2023-03-23T22:33:04","date_gmt":"2023-03-23T22:33:04","guid":{"rendered":"https:\/\/yer.ac\/blog\/?p=527"},"modified":"2025-08-20T13:49:17","modified_gmt":"2025-08-20T13:49:17","slug":"polymorphic-serialization-deserialziation-of-interface-implementations-in-net6","status":"publish","type":"post","link":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","title":{"rendered":"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet"},"content":{"rendered":"\n<p class=\"has-luminous-vivid-amber-color has-text-color\">I will preface this by saying <strong>this is not a good idea and was more of a &#8220;I wonder..&#8221;<\/strong>, as you lose the benefit of a descriptive model (especially in swagger), and its somewhat brittle if you add more types. Honestly it started as a &#8220;It would be nice if I could do this in this scenario..&#8221; and just went down the rabbit hole. As per most my posts here this is more my personal notes to refer to later which <em>may <\/em>help others also searching, so YMMV. There are better options using real libraries!<\/p>\n\n\n\n<p>Its not uncommon to have code which uses abstraction or inheritence in any programming language, for example a Dog, Cat and Llama all inheriting from the IAnimal interface. It&#8217;s also not uncommon to use dependency injection to determine the concrete type you wish to use for a given interface. But what if we wanted to do something a little&#8230; stupid. <\/p>\n\n\n\n<p>Taking the above example into consideration, what if we want a model to have a List\/Collection of IAnimals which can accept <em>any<\/em> derivative type within the same Web API message request?  (and not just multiple lists, but a single bound field which can accept any combination).<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why?! (and other things you can try first)<\/h2>\n\n\n\n<p>Why not?! There are a few really good resources on this topic already including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you are using .net7 or preview versions of dotnet, you may be able to use the new built in JsonDerivedType attribute as suggested <a href=\"https:\/\/stackoverflow.com\/questions\/58074304\/is-polymorphic-deserialization-possible-in-system-text-json\/74352597#74352597\">here<\/a><\/li>\n\n\n\n<li>Microsofs dotnet docs on <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/standard\/serialization\/system-text-json\/converters-how-to?pivots=dotnet-7-0#support-polymorphic-deserialization\">writing a custom json converter<\/a>, but this mostly focusses on manually specifying the object with the JsonReader and JsonWriter which means overhead for model changes.<\/li>\n\n\n\n<li>Some possibilities using libraries like JsonSubTypes <a href=\"https:\/\/github.com\/manuc66\/JsonSubTypes\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/manuc66\/JsonSubTypes<\/a> which didn&#8217;t work for me, but may for others.<\/li>\n\n\n\n<li><em>So<\/em> many SO posts on this topic, mostly around people asking why their interfaces won&#8217;t serialise, but the information is varied to say the least and oddly <em>so<\/em> many examples failed to include an example for the <em>Write<\/em>, only a read (as in, you could not Serialize).. There was a really good solution by a <em>Demetrius <\/em><a href=\"https:\/\/stackoverflow.com\/questions\/58074304\/is-polymorphic-deserialization-possible-in-system-text-json\/59785679#59785679\">here<\/a> which I got working OK for single objects but misbehaved a little for lists of mixed types.<\/li>\n<\/ul>\n\n\n\n<p>I also didn&#8217;t want to use dynamics, JObjects, reflection and such, but all of those would also be an alternative.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Onto the code<\/h2>\n\n\n\n<p>This extends the in-built <code>System.Text<\/code>.Json, rather than rely on a third party package and was all built in .net6<\/p>\n\n\n\n<p>In the example below I am specifically writing a converter which will decorate a List&lt;IAnimal&gt;, which importantly has a field we will use to allow every implementation to be identified and used as a discriminator. In this case every animal must have a type &#8211; here I use an enumeration to keep the code clean. (Note: If using an enum, you will want to have JsonStringEnumConverter as a converter in your JSON Options)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public interface IAnimal {\n   EnAnimalType Type { get; }\n}<\/code><\/pre>\n\n\n\n<p>In the <strong>Read<\/strong> override, we loop over all the objects we have been provided, and use the type discriminator to deserialise based on the parsed value. <\/p>\n\n\n\n<p>In the <strong>Write<\/strong> override, we do the same again, iterating over the items and casting them appropriately before a serialize.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n  public class <strong>MyAnimalTypeJsonTypeConverter <\/strong>: JsonConverter&lt;<strong>List&lt;IAnimal&gt;<\/strong>&gt;\n  {\n    public override <strong>List&lt;IAnimal&gt;<\/strong>\n      Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n    {\n      if (reader.TokenType != JsonTokenType.StartArray)\n        return default;\n\n      <strong>List&lt;IAnimal&gt;<\/strong> items = default;\n      foreach (JsonObject jsonObject in  JsonSerializer.Deserialize&lt;List&lt;JsonObject&gt;&gt;(ref reader, options)!)\n      {        \n        <strong>IAnimal <\/strong>item = jsonObject&#91;<strong>\"Type\"<\/strong>]?.GetValue&lt;<strong>string<\/strong>&gt;() switch\n        {\n          <strong>\"Dog\" =&gt; jsonObject.Deserialize&lt;Dog&gt;(options)!,\n          \"Cat\" =&gt; jsonObject.Deserialize&lt;Cat&gt;(options)!,<\/strong>\n          _ =&gt; null\n        };\n\n        if (item is null) continue;\n        items ??= new();\n        items.Add(item);\n      }\n\n      return items;\n    }\n\n    public override void Write(Utf8JsonWriter writer, <strong>List&lt;IAnimal&gt;<\/strong> value, JsonSerializerOptions options)\n    {\n      writer.WriteStartArray();\n      foreach (var item in value)\n      {\n        <strong>if (item.Type == EnAnimalType.Dog)\n        {\n          JsonSerializer.Serialize&lt;Dog&gt;(writer,item as Dog);\n        }\n        if (item.Type == EnAnimalType.Cat)\n        {\n          JsonSerializer.Serialize&lt;Cat&gt;(writer, item as Cat);\n        }<\/strong>\n      }\n      writer.WriteEndArray();\n    }\n  }\n<\/code><\/pre>\n\n\n\n<p>Then simply adding the attribute to my field<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;JsonConverter(typeof(<strong><strong>MyAnimalTypeJsonTypeConverter<\/strong><\/strong>))]\npublic List&lt;IAnimal&gt;? Animals{ get; set; }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Enhancements I couldn&#8217;t get working (Disallowed options, extensions&#8230;)<\/h2>\n\n\n\n<p class=\"has-small-font-size\">This code is <em>very<\/em> specific to a certain interface and I don&#8217;t like lots of similar classes, so I attempted to use C# generics to take in a <code>TMyObject<\/code> as the type (Easy) the same way the SO post linked above does, as well as enhancing the attribute to take in some form of array\/params that would be the Enum\/Type mapping. Sadly params on these JsonConverters aren&#8217;t really supported however @<strong><a href=\"https:\/\/github.com\/eiriktsarpalis\">eiriktsarpalis<\/a>&nbsp;<\/strong>on Github had a nice (and working) <a href=\"https:\/\/github.com\/dotnet\/runtime\/issues\/54187#issuecomment-871293887\">solution <\/a>to getting around the fact System.Text.Json would not accept parameters, but sadly still ended up with the issue that the params always have to be constants for attributes so I couldn&#8217;t find a &#8220;Nice&#8221; solution for decorating the field. If anybody finds a nice workaround do comment!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Closing thoughts..<\/h2>\n\n\n\n<p>As stated, this is more of a stream of consciousness for me to refer back to at a later date, but if saves you a load of frustrated googling with the right keywords then hurrah. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will preface this by saying this is not a good idea and was more of a &#8220;I wonder..&#8221;, as you lose the benefit of a descriptive model (especially in swagger), and its somewhat brittle if you add more types. Honestly it started as a &#8220;It would be nice if I could do this in &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6,44],"tags":[43],"class_list":["post-527","post","type-post","status-publish","format-standard","hentry","category-development","category-dotnet","tag-dotnet"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Polymorphic Serialization &amp; Deserialziation of Interface implementations in dotnet - yer.ac | Adventures of a developer, and other things.<\/title>\n<meta name=\"description\" content=\"Polymorphic Serialization &amp; Deserialziation of Interface &amp; abstract class implementations in .NET6\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Polymorphic Serialization &amp; Deserialziation of Interface implementations in dotnet - yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"og:description\" content=\"Polymorphic Serialization &amp; Deserialziation of Interface &amp; abstract class implementations in .NET6\" \/>\n<meta property=\"og:url\" content=\"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/\" \/>\n<meta property=\"og:site_name\" content=\"yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-23T22:33:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-20T13:49:17+00:00\" \/>\n<meta name=\"author\" content=\"yer.ac\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yer.ac\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/\"},\"author\":{\"name\":\"yer.ac\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"headline\":\"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet\",\"datePublished\":\"2023-03-23T22:33:04+00:00\",\"dateModified\":\"2025-08-20T13:49:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/\"},\"wordCount\":735,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"keywords\":[\"dotnet\"],\"articleSection\":[\"Development\",\"dotnet\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/\",\"name\":\"Polymorphic Serialization & Deserialziation of Interface implementations in dotnet - yer.ac | Adventures of a developer, and other things.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\"},\"datePublished\":\"2023-03-23T22:33:04+00:00\",\"dateModified\":\"2025-08-20T13:49:17+00:00\",\"description\":\"Polymorphic Serialization & Deserialziation of Interface & abstract class implementations in .NET6\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2023\\\/03\\\/23\\\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\",\"name\":\"yer.ac | Adventures of a developer, and other things.\",\"description\":\"Blog to keep track of things I am upto\",\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/yer.ac\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\",\"name\":\"yer.ac\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"caption\":\"yer.ac\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Polymorphic Serialization & Deserialziation of Interface implementations in dotnet - yer.ac | Adventures of a developer, and other things.","description":"Polymorphic Serialization & Deserialziation of Interface & abstract class implementations in .NET6","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","og_locale":"en_US","og_type":"article","og_title":"Polymorphic Serialization & Deserialziation of Interface implementations in dotnet - yer.ac | Adventures of a developer, and other things.","og_description":"Polymorphic Serialization & Deserialziation of Interface & abstract class implementations in .NET6","og_url":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","og_site_name":"yer.ac | Adventures of a developer, and other things.","article_published_time":"2023-03-23T22:33:04+00:00","article_modified_time":"2025-08-20T13:49:17+00:00","author":"yer.ac","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yer.ac","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/#article","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/"},"author":{"name":"yer.ac","@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"headline":"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet","datePublished":"2023-03-23T22:33:04+00:00","dateModified":"2025-08-20T13:49:17+00:00","mainEntityOfPage":{"@id":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/"},"wordCount":735,"commentCount":0,"publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"keywords":["dotnet"],"articleSection":["Development","dotnet"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","url":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","name":"Polymorphic Serialization & Deserialziation of Interface implementations in dotnet - yer.ac | Adventures of a developer, and other things.","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/#website"},"datePublished":"2023-03-23T22:33:04+00:00","dateModified":"2025-08-20T13:49:17+00:00","description":"Polymorphic Serialization & Deserialziation of Interface & abstract class implementations in .NET6","breadcrumb":{"@id":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/yer.ac\/blog\/"},{"@type":"ListItem","position":2,"name":"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet"}]},{"@type":"WebSite","@id":"https:\/\/yer.ac\/blog\/#website","url":"https:\/\/yer.ac\/blog\/","name":"yer.ac | Adventures of a developer, and other things.","description":"Blog to keep track of things I am upto","publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/yer.ac\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d","name":"yer.ac","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","caption":"yer.ac"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paP5IW-8v","jetpack-related-posts":[{"id":514,"url":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","url_meta":{"origin":527,"position":0},"title":"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)","author":"yer.ac","date":"October 6, 2021","format":false,"excerpt":"This is here mostly for my own reference for next time I need to fix this, but may be useful to someone else. Installing .NET (5, Core, etc.) via the Microsoft Supplied \"dotnet-install.ps1\"(https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-install-script) installs the frameworks fine, but then running .net core code within that windows container would sometimes yield\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/yer.ac\/blog\/category\/devops\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":303,"url":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","url_meta":{"origin":527,"position":1},"title":"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6","author":"yer.ac","date":"September 5, 2019","format":false,"excerpt":"Recently I have been trying to generate more Nuget packages for our dotnet core projects, utilizing the dotnet pack command. One issue I have been encountering is that the command was either referencing the required nuget packages, or the project reference DLLs, never both. The current problem. If you have\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":315,"url":"https:\/\/yer.ac\/blog\/2019\/10\/16\/ensuring-dotnet-test-trx-coverage-files-end-up-in-sonarqube\/","url_meta":{"origin":527,"position":2},"title":"Ensuring &#8220;dotnet test&#8221; TRX &#038; Coverage files end up in SonarQube","author":"yer.ac","date":"October 16, 2019","format":false,"excerpt":"I have written before about using SonarQube to do static analysis, but one issue I never came back to was ensuring that code coverage files generated via a build pipeline end up being picked up by the Sonar Scanner to assess code coverage. Note that the following I am actually\u2026","rel":"","context":"In &quot;DevOps&quot;","block_context":{"text":"DevOps","link":"https:\/\/yer.ac\/blog\/category\/devops\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/10\/image.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":151,"url":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-two-persisting-data-into-azure-cosmos-db\/","url_meta":{"origin":527,"position":3},"title":"Remote NLOG logging with Azure Functions (Part two) &#8211; Persisting data into Azure Cosmos DB.","author":"yer.ac","date":"May 29, 2019","format":false,"excerpt":"Last time, I got a very basic C# Azure Function hooked up to accept a request from an NLOG web service target. This time, I will be attempting to persist(insert) the incoming log information into an Azure Cosmos database container, direct from my Azure Function in VS Code. Disclaimer: This\u2026","rel":"","context":"In &quot;Azure&quot;","block_context":{"text":"Azure","link":"https:\/\/yer.ac\/blog\/category\/development\/azure\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":489,"url":"https:\/\/yer.ac\/blog\/2021\/04\/22\/using-podgrab-docker-to-backup-my-favorite-podcasts-in-this-case-on-a-qnap-nas\/","url_meta":{"origin":527,"position":4},"title":"Using PodGrab &#038; Docker to backup my favorite podcasts (In this case on a QNAP NAS)","author":"yer.ac","date":"April 22, 2021","format":false,"excerpt":"Whilst it's not a certainty that data will removed from the web, it does happen (See \/r\/datahoarder and \/r\/lostmedia). As I get all my podcasts through Spotify these days I have no control if they suddenly pull their account, or stop the show. There are also other use cases, like\u2026","rel":"","context":"In &quot;Home Networking&quot;","block_context":{"text":"Home Networking","link":"https:\/\/yer.ac\/blog\/category\/home-networking-2\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/04\/image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/04\/image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/04\/image.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/04\/image.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":69,"url":"https:\/\/yer.ac\/blog\/2019\/04\/08\/attempting-to-use-mocha-chai-to-unit-test-es6\/","url_meta":{"origin":527,"position":5},"title":"Attempting to use Mocha &#038; Chai to unit test ES6.","author":"yer.ac","date":"April 8, 2019","format":false,"excerpt":"In this post I will cover using Mocha (JS test framework) and Chai (For BDD syntax) to unit test ES6 Javascript in VS Code. I started working on a small side project, for no reason other than to play with ES6+. It's a(nother) relatively simple toast library written in as\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/04\/image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/04\/image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/04\/image.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/comments?post=527"}],"version-history":[{"count":21,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/527\/revisions"}],"predecessor-version":[{"id":595,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/527\/revisions\/595"}],"wp:attachment":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/media?parent=527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/categories?post=527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/tags?post=527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}